BoundaryCondition.h 2.6 KB
 JasonPries committed Jan 17, 2017 1 2 3 4 5 6 7 8 9 10 11 12 13 ``````#ifndef OERSTED_BOUNDARYCONDITION_H #define OERSTED_BOUNDARYCONDITION_H #include #include #include #include #include "MatrixGroup.h" #include "QuadratureRule.h" #include "FiniteElementMesh.h" `````` JasonPries committed Jan 26, 2017 14 15 16 ``````// TODO: DiscreteBoundaryCondition versus ContinuousBoundaryCondition? Somehow need to apply to top level model and have that be translated to the discrete model // TODO: Boundary conditions should represent simple containers that know how to perform actions on matrices, parsing of boundaries to extract nodes should take place at a higher level `````` JasonPries committed Jan 17, 2017 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ``````class BoundaryCondition { public: virtual ~BoundaryCondition(){}; virtual void apply(std::vector> &triplets) const = 0; virtual void reduce(std::set> &index) const = 0; }; template class ZeroDirichlet : public BoundaryCondition{}; template class ZeroDirichlet<2,ElementOrder,QuadratureOrder> : public BoundaryCondition { public: `````` JasonPries committed Jan 26, 2017 31 `````` ZeroDirichlet(std::vector nodes) : Nodes{nodes} {}; `````` JasonPries committed Jan 17, 2017 32 33 34 35 36 37 38 39 40 41 42 43 `````` void apply(std::vector> &triplets) const override {}; void reduce(std::set> &index) const override { for (size_t i = 0; i != Nodes.size(); ++i) { index.insert(Nodes[i]); } }; protected: std::vector Nodes; }; `````` JasonPries committed Jan 26, 2017 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 `````` template class PeriodicBoundaryCondition : public BoundaryCondition{}; template class PeriodicBoundaryCondition<2,ElementOrder,QuadratureOrder> : public BoundaryCondition { public: PeriodicBoundaryCondition(std::vector first_nodes, std::vector second_nodes, bool antiperiodic) : FirstNodes{first_nodes}, SecondNodes{second_nodes}, Antiperiodic{antiperiodic} {}; void apply(std::vector> &triplets) const override { double sign{1.0 - 2.0 * Antiperiodic}; // TODO: /* for(size_t i = 0;i!=FirstNodes.size();++i){ triplets[FirstNodes[i]].row() = SecondNodes[i]; triplest[FirstNodes[i]].value() = sign; } */ } void reduce(std::set> &index) const override { for (size_t i = 0; i != SecondNodes.size(); ++i) { index.insert(SecondNodes[i]); } } protected: std::vector FirstNodes; std::vector SecondNodes; bool Antiperiodic; }; `````` JasonPries committed Jan 17, 2017 80 ``#endif //OERSTED_BOUNDARYCONDITION_H``