Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
PolyhedralMesh.h
Go to the documentation of this file.
1/* This file is part of MoDELib, distributed under GNU GPL v2. */
2#ifndef model_PolyhedralMesh_H_
3#define model_PolyhedralMesh_H_
4#include <Polyhedron.h>
5#include <tuple>
6#include <array>
7#include <algorithm>
8#include <stdexcept>
9#include <utility>
10namespace model
11{
12 template <int dim> class SimplicialMesh;
13 template <int dim, typename Sequence> struct PolyhedralFactories;
14 template <int dim, size_t... orders> struct PolyhedralFactories<dim, std::index_sequence<orders...>>
15 {
16 using Type = std::tuple<PolyhedronFactory<dim, int(orders)>...>;
17 };
18 template <int dim> class PolyhedralMesh
19 {
20 static_assert(dim >= 1);
22 template <int order>
23 void buildBoundary(const std::shared_ptr<Polyhedron<dim, order>> &cell,
24 const std::vector<std::vector<size_t>> &simplices,
25 const std::map<size_t, Eigen::Matrix<double, dim, 1>> &positions);
26 template <int order> void validateLevel() const;
27 template <int order> void attachSimplex(const Simplex<dim, order> *simplex);
28 void buildPerimeter(const std::shared_ptr<Polyhedron<dim, 2>> &cell);
29 void orientMeshFaces();
30
31 public:
32 using Vector = Eigen::Matrix<double, dim, 1>;
33 struct FaceInput
34 {
35 size_t id;
36 std::vector<size_t> regions;
37 std::vector<std::array<size_t, dim>> simplices;
38 };
40 {
41 std::apply([this](auto &...factory) { ((factory.owner = this), ...); }, factories);
42 }
43 PolyhedralMesh(const PolyhedralMesh &) = delete;
45 PolyhedralMesh(const std::map<size_t, Vector> &positions, const std::vector<FaceInput> &faces);
46 template <int order> const PolyhedronFactory<dim, order> &factory() const
47 {
48 return std::get<order>(factories);
49 }
50 std::shared_ptr<Polyhedron<dim, dim>> getRegion(size_t id)
51 {
52 return std::get<dim>(factories).get(id);
53 }
54 std::shared_ptr<Polyhedron<dim, dim - 1>> createFace(const Simplex<dim, dim - 1> *simplex);
55 const Polyhedron<dim, dim> &region(size_t id) const;
56 const Polyhedron<dim, dim - 1> &face(size_t id) const;
57 void buildTopology();
58 void validate() const;
59 };
60} // namespace model
62#endif
const Polyhedron< dim, dim - 1 > & face(size_t id) const
PolyhedralMesh(const PolyhedralMesh &)=delete
std::shared_ptr< Polyhedron< dim, dim - 1 > > createFace(const Simplex< dim, dim - 1 > *simplex)
PolyhedralMesh & operator=(const PolyhedralMesh &)=delete
const PolyhedronFactory< dim, order > & factory() const
Eigen::Matrix< double, dim, 1 > Vector
const Polyhedron< dim, dim > & region(size_t id) const
std::shared_ptr< Polyhedron< dim, dim > > getRegion(size_t id)
std::tuple< PolyhedronFactory< dim, int(orders)>... > Type
std::vector< std::array< size_t, dim > > simplices
std::vector< size_t > regions