Commit b270e42c authored by Pries, Jason's avatar Pries, Jason
Browse files

Implement += operator for time and SlidingInterface

parent cc6dd272
......@@ -30,6 +30,6 @@
</Objective-C-extensions>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>
\ No newline at end of file
......@@ -179,7 +179,20 @@ public:
}
}
SlidingInterface &operator+=(const size_t &m) {
std::rotate(Second.begin(), Second.begin() + m, Second.end());
if (Antiperiodic) {
std::rotate(Value.begin(), Value.begin() + m, Value.end());
auto v_iter = Value.rbegin();
for (size_t i = 0; i != m; ++i) {
*(v_iter) = -*(v_iter);
++v_iter;
}
}
}
// TODO: SlidingInterface& operator--() {...};
// TODO: SlidingInterface& operator-=() {...};
void apply(Eigen::SparseMatrix<double> &bc_matrix) const override {
std::vector<Eigen::Triplet<double>> triplets;
......
......@@ -40,12 +40,14 @@ enum class FieldVariable {
class PhysicsInterface {
public:
double time() { return Time; };
double time() const { return Time; };
double &time() { return Time; };
void time(double t) { Time = t; };
protected:
double Time;
double Time{0.0};
std::vector<std::shared_ptr<Forcing>> ForcingCondtions;
std::vector<std::shared_ptr<BoundaryCondition>> BoundaryConditions;
......@@ -261,7 +263,8 @@ public:
return pbc;
}
auto add_periodic_boundary(std::vector<std::shared_ptr<DiscreteBoundary<2>>> b0, std::vector<std::shared_ptr<DiscreteBoundary<2>>> b1, std::vector<bool> orientation, bool antiperiodic) {
auto add_periodic_boundary(std::vector<std::shared_ptr<DiscreteBoundary<2>>> b0, std::vector<std::shared_ptr<DiscreteBoundary<2>>> b1, std::vector<bool> orientation,
bool antiperiodic) {
auto pbc = std::make_shared<PeriodicBoundaryCondition<2, ElementOrder, QuadratureOrder>>(b0, b1, orientation, antiperiodic);
BoundaryConditions.push_back(pbc);
return pbc;
......@@ -306,7 +309,7 @@ public:
for (auto i = reduction_index.rbegin(); i != reduction_index.rend(); ++i) {
triplets.erase(triplets.begin() + *i);
for (auto j = triplets.begin() + *i; j != triplets.end(); ++j){
for (auto j = triplets.begin() + *i; j != triplets.end(); ++j) {
*j = Eigen::Triplet<double>(j->row() - 1, j->col(), j->value()); // TODO: Could be more efficient
}
}
......
......@@ -1142,7 +1142,6 @@ public:
TEST_F(Salient_Pole_Synchrel, Test) {
Magnetostatic<2, 1, 1, FieldVariable::A> msph{fem};
msph.time(0.0);
// Set material properties
//MaterialProperties electrical_steel = MaterialProperties(std::make_shared<LinearIsotropicMagneticMaterial>(1000.0));
......@@ -1167,7 +1166,6 @@ TEST_F(Salient_Pole_Synchrel, Test) {
msph.assemble();
// Solve
std::cout << "//TODO: msph.time() += N * dt, *position += N (see below)" << std::endl;
auto solution = msph.initialize();
for (size_t iter = 0; iter != position->size() / 32; ++iter) {
msph.solve(solution);
......@@ -1184,11 +1182,9 @@ TEST_F(Salient_Pole_Synchrel, Test) {
fem.write_vector(Bx, By, SAVE_DIR, std::string("salient_pole_synchrel_B_") + std::to_string(iter));
// Increment Position
// TODO: msph.time() += N * dt, *position += N
for (size_t i = 0; i != 32; ++i) {
++*position;
msph.time(msph.time() + dt);
}
*position += 32;
msph.time() += 32 * dt;
msph.assemble();
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment