Commit 45453ece by JasonPries

### Nightly Commit

```Work on HomogeneousForcing for Poisson-like equations
Started implementation of Magnetostatic solver```
parent 3f264747
 ... ... @@ -6,34 +6,35 @@ #include "Eigen" #include "FiniteElementMesh.h" #include "Region.h" #include "Physics.h" class Condition { public: virtual ~Condition() {}; virtual Eigen::VectorXd operator()(double const t) const = 0; }; template class HomogeneousForcing { class HomogeneousForcing : public Condition { }; template class HomogeneousForcing<2, ElementOrder, QuadratureOrder> { class HomogeneousForcing<2, ElementOrder, QuadratureOrder> : public Condition { public: HomogeneousForcing(Physics<2, ElementOrder, QuadratureOrder> &op, std::vector r, std::function f) : Operator{op}, Regions{r}, Function{f} { auto const& dom = op.domain(); auto const& tris = dom.triangles(); Indicator.resize(tris.size()); HomogeneousForcing(Physics<2, ElementOrder, QuadratureOrder> &op, std::vector reg, std::function f) : Operator{op}, Regions{reg}, Function{f} { Indicator.resize(op.domain().triangles().size()); // TODO: num_elements (once quadrilateral elements added) Indicator.setZero(); for(size_t i = 0;i!=r.size();++i){ auto const& t = dom.region(r[i]).triangles(); for(size_t j = 0;j!=t.size();++j){ Indicator(tris[t[j]].id()) = 1.0; for (size_t const &i : reg) { for (size_t const &j : op.domain().region(i).triangles()) { Indicator(j) = 1.0; } } } }; auto const &indicator() const { return Indicator; }; Eigen::VectorXd operator()(double const t) const { Eigen::VectorXd operator()(double const t) const override { Eigen::VectorXd output = (Operator.basis()[0] * (Operator.weights()(0) * Indicator)); // TODO: ?SparseVector? for (size_t i = 1; i != TriangleQuadratureRule::size; ++i) { output += (Operator.basis()[i] * (Operator.weights()(i) * Indicator)); ... ... @@ -43,14 +44,16 @@ public: return output; }; auto const &indicator() const { return Indicator; }; protected: Physics<2, ElementOrder, QuadratureOrder> &Operator; std::vector Regions; Eigen::VectorXd Indicator; // TODO: ?Make Indicator part of the Region class instead? ElementIndicator, NodeIndicator? std::function Function; Eigen::VectorXd Indicator; // TODO: ?Make Indicator part of the Region class instead? ElementIndicator, NodeIndicator? }; #endif //OERSTED_CONDITION_H
 #ifndef OERSTED_FINITEELEMENTMESH_H #define OERSTED_FINITEELEMENTMESH_H #include #include #include "MatrixGroup.h" ... ... @@ -8,25 +9,25 @@ #include "Triangle.h" #include "Region.h" template template class FiniteElementMesh {}; template class FiniteElementMesh<2,P> { template class FiniteElementMesh<2,Order> { public: FiniteElementMesh() {}; FiniteElementMesh(std::vector nodes, std::vector> tris, std::vector> regs) : Nodes(nodes), Triangles(tris), Regions(regs) {}; FiniteElementMesh(std::vector nodes, std::vector> tris, std::vector> r) : Nodes(nodes), Triangles(tris), Regions(r) {}; std::vector const &nodes() const { return Nodes; }; std::vector> const &triangles() const { return Triangles; }; std::vector> const &triangles() const { return Triangles; }; std::vector> const ®ions() const { return Regions; }; XY const &node(size_t i) const { return Nodes[i]; }; Triangle

const &triangle(size_t i) const { return Triangles[i]; }; Triangle const &triangle(size_t i) const { return Triangles[i]; }; Region<2> const ®ion(size_t i) const { return Regions[i]; }; ... ... @@ -43,7 +44,7 @@ public: template SparseMatrixGroup::size> basis() const { SparseMatrixGroup::size> mat(Nodes.size(), Triangles.size(), Triangle

::NumNodes); SparseMatrixGroup::size> mat(Nodes.size(), Triangles.size(), Triangle::NumNodes); for (size_t i = 0; i != Triangles.size(); ++i) { Triangles[i].basis(mat, Nodes); ... ... @@ -54,7 +55,7 @@ public: template DerivativeMatrixGroup::size> derivative() const { DerivativeMatrixGroup::size> df(Nodes.size(), Triangles.size(), Triangle

::NumNodes); DerivativeMatrixGroup::size> df(Nodes.size(), Triangles.size(), Triangle::NumNodes); for (size_t i = 0; i!= Triangles.size();++i) { Triangles[i].derivative(df, Nodes); ... ... @@ -65,8 +66,9 @@ public: protected: std::vector Nodes; std::vector> Triangles; std::vector> Regions; std::vector> Triangles; std::vector> Regions; // Contains vector of size_t referencing Triangles (and later Quadrilaterals) }; #endif //OERSTED_FINITEELEMENTMESH_H

 ... ... @@ -27,13 +27,12 @@ enum class Variable { Psi = 26 + 23 }; template class Physics { public: static constexpr size_t QuadraturePoints = TriangleQuadratureRule::size; /* /* TODO: template class PhysicsData : public PhysicsInterface {...}; virtual Eigen::VectorXd init_residual() = 0; virtual Eigen::SparseMatrix init_jacobian() = 0; virtual void residual(Eigen::SparseMatrix &J, Eigen::VectorXd &r) = 0; ... ... @@ -76,13 +75,6 @@ public: using Physics<2, ElementOrder, QuadratureOrder>::weights; using Physics<2, ElementOrder, QuadratureOrder>::basis; /* Magnetostatic(FiniteElementMesh<2, ElementOrder> &d) : Domain{d}, ElementWeights{d.triangles().size()}, Derivatives{d.nodes().size(), d.triangles().size(), Triangle::NumNodes}, Basis{d.nodes().size(), d.triangles().size(), Triangle::NumNodes} {}; */ Magnetostatic(FiniteElementMesh<2, ElementOrder> &d) : Physics<2, ElementOrder, QuadratureOrder>{d} {}; Eigen::VectorXd init_residual() { return Eigen::VectorXd(Domain.nodes().size()); }; ... ...
 ... ... @@ -2,18 +2,20 @@ #define OERSTED_REGION_H #include #include template class Region {}; class Region { }; template<> class Region<2> { public: Region(std::vector tris) : Triangles(tris) {}; Region(std::vector tris) : Triangles{tris} {}; size_t const &triangle(size_t i) const { return Triangles[i]; }; std::vector const &triangles() const { return Triangles; }; std::vector const& triangles() const { return Triangles; }; size_t const &triangle(size_t i) const { return Triangles[i]; }; protected: std::vector Triangles; ... ...
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