FiniteElementMesh.cpp 2.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include "FiniteElementMesh.h"

template<> FiniteElementMesh<2,1>::FiniteElementMesh(Mesh &m) {
    // std::vector<XY> nodes
    // std::vector<Triangle<Order>> tris
    // std::vector<std::shared_ptr<Region<2>>> r
    // std::vector<std::shared_ptr<Boundary<2>>> b

    Nodes.reserve(m.size_points()); // TODO: This will be larger when Order > 1
    for (size_t i = 0; i!= m.size_points(); ++i) {
        Nodes.emplace_back(m.point(i));
    }

    /* TODO: Changes to rotational motion implementation
        Initially, perform a straightforward conversion as currently implemented
        Define a new Boundary type called (called something like SlidingBoundary)
            SlidingBoundary holds a reference to the two boundaries and ensures the correct mapping
        In FiniteElementMesh, add a method called make_sliding(...) or something similar
            This method will implement a procedure which duplicates the nodes on the boundary and renumbers the nodes in the appropriate elements
        Then, the SlidingInterface boundary condition holds a pointer to the SlidingBoundary instead of two Boundary objects

        Perhaps a similar approach can be taken for implementing periodic boundary conditions (e.g. MappedBoundary holds two (or several arrays of) boundaries and enforces the proper invariant)
            e.g. make_mapped(...)
        Then PeriodicBoundaryCondition holds a pointer to the MappedBoundary instead of two Boundary objects

        TODO: To make these easier to implement from the user side, Boundary should hold a shared_ptr to the defining curve (from the Mesh object)
            Then selection can be implemented by passing the shared_ptr that the user has (similar to how the Mesh operations work)
     */

30 31 32 33 34
    /*
    Boundaries.reserve(m.size_constraints());
    for (size_t i = 0; i!= m.size_constraints(); ++i) {
        Boundaries.push_back(std::make_shared<Boundary<2>>());
    }
35
    */
36

37 38 39 40 41 42 43 44 45 46 47 48
    Regions.reserve(m.size_contours());
    for (size_t i = 0; i != m.size_contours(); ++i) {
        Regions.push_back(std::make_shared<Region<2>>()); // TODO: Assign material properties here
    }

    Triangles.reserve(m.size_triangles());
    for (size_t i = 0; i != m.size_triangles(); ++i) {
        auto &dt = m.triangle(i);
        Regions[dt.contour()]->push_back(i);
        Triangles.emplace_back(i, m.nodes_from_triangle(dt));
    }
};