LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
mesh.h
1
9#ifndef INCG62731052ee4a4a2d9f256c2caac43835
10#define INCG62731052ee4a4a2d9f256c2caac43835
11
12#include <lf/mesh/mesh.h>
13#include <spdlog/logger.h>
14
15#include "lf/base/base.h"
16#include "lf/mesh/utils/print_info.h"
17#include "point.h"
18#include "quad.h"
19#include "segment.h"
20#include "triangle.h"
21
22namespace lf::mesh::hybrid2d {
23
28const unsigned int idx_nil = lf::base::kIdxNil;
29
30class MeshFactory;
31
35class Mesh : public mesh::Mesh {
36 public:
37 [[nodiscard]] unsigned DimMesh() const override { return 2; }
38 [[nodiscard]] unsigned DimWorld() const override { return dim_world_; }
39
40 [[nodiscard]] std::span<const Entity* const> Entities(
41 unsigned codim) const override;
42 [[nodiscard]] size_type NumEntities(unsigned codim) const override;
43 [[nodiscard]] size_type NumEntities(
44 lf::base::RefEl ref_el_type) const override;
45 [[nodiscard]] size_type Index(const Entity& e) const override;
46 [[nodiscard]] const mesh::Entity* EntityByIndex(
47 dim_t codim, glb_idx_t index) const override;
48 [[nodiscard]] bool Contains(const mesh::Entity& e) const override;
49
50 private:
53 std::vector<hybrid2d::Point> points_;
55 std::vector<hybrid2d::Segment> segments_;
57 std::vector<hybrid2d::Triangle> trias_;
59 std::vector<hybrid2d::Quadrilateral> quads_;
60
67 std::array<std::vector<const mesh::Entity*>, 3> entity_pointers_;
68
70 using GeometryPtr = std::unique_ptr<geometry::Geometry>;
71 using NodeCoordList = std::vector<GeometryPtr>;
72 using EdgeList =
73 std::vector<std::pair<std::array<size_type, 2>, GeometryPtr>>;
74 using CellList =
75 std::vector<std::pair<std::array<size_type, 4>, GeometryPtr>>;
76
128 Mesh(dim_t dim_world, NodeCoordList nodes, EdgeList edges, CellList cells,
129 bool check_completeness);
130
131 friend class MeshFactory;
132
133 public:
135 static std::shared_ptr<spdlog::logger>& Logger() {
136 static auto logger = base::InitLogger("lf::mesh::hybrid2d::Mesh::Logger");
137 return logger;
138 }
139};
140
141} // namespace lf::mesh::hybrid2d
142
143#endif // INCG62731052ee4a4a2d9f256c2caac43835
Represents a reference element with all its properties.
Definition ref_el.h:109
Interface class representing a topological entity in a cellular complex
Definition entity.h:42
Abstract interface for objects representing a single mesh.
lf::base::dim_t dim_t
Mesh()=default
Implements mesh::MeshFactory interface and can be used to construct a hybrid mesh with dimMesh=2.
Basis 2D mesh type compliant with abstract mesh interface.
Definition mesh.h:35
std::vector< std::pair< std::array< size_type, 4 >, GeometryPtr > > CellList
Definition mesh.h:74
std::vector< hybrid2d::Point > points_
array of 0-dimensional entity object of co-dimension 2
Definition mesh.h:53
std::unique_ptr< geometry::Geometry > GeometryPtr
Data types for passing information about mesh intities.
Definition mesh.h:70
size_type NumEntities(unsigned codim) const override
The number of Entities that have the given codimension.
Definition mesh.cc:49
std::vector< std::pair< std::array< size_type, 2 >, GeometryPtr > > EdgeList
Definition mesh.h:72
std::vector< hybrid2d::Segment > segments_
array of 1-dimensional entity object of co-dimension 1
Definition mesh.h:55
unsigned DimMesh() const override
The dimension of the manifold described by the mesh, or equivalently the maximum dimension of the ref...
Definition mesh.h:37
std::vector< hybrid2d::Triangle > trias_
array of triangular cell objects, oo-dimension 0
Definition mesh.h:57
const mesh::Entity * EntityByIndex(dim_t codim, glb_idx_t index) const override
Method for accessing an entity through its index.
Definition mesh.cc:106
std::vector< GeometryPtr > NodeCoordList
Definition mesh.h:71
std::array< std::vector< const mesh::Entity * >, 3 > entity_pointers_
Auxliary array of cell (co-dim ==0 entities) pointers.
Definition mesh.h:67
unsigned DimWorld() const override
The dimension of the Euclidean space in which the mesh is embedded.
Definition mesh.h:38
size_type Index(const Entity &e) const override
Acess to the index of a mesh entity of any co-dimension.
Definition mesh.cc:84
std::span< const Entity *const > Entities(unsigned codim) const override
All entities of a given codimension.
Definition mesh.cc:20
bool Contains(const mesh::Entity &e) const override
Check if the given entity is a part of this mesh.
Definition mesh.cc:113
static std::shared_ptr< spdlog::logger > & Logger()
logger, used by methods of Mesh to log additional information.
Definition mesh.h:135
std::vector< hybrid2d::Quadrilateral > quads_
array of quadrilateral cell objects, oo-dimension 0
Definition mesh.h:59
const unsigned int kIdxNil
Index flagged as invalid.
Definition types.h:36
unsigned int size_type
general type for variables related to size of arrays
Definition types.h:20
unsigned int sub_idx_t
type for local indices of sub-entities
Definition types.h:28
unsigned int dim_t
type for dimensions and co-dimensions and numbers derived from them
Definition types.h:32
unsigned int glb_idx_t
type for global index of mesh entities (nodes, edges, cells)
Definition types.h:24
std::shared_ptr< spdlog::logger > InitLogger(const std::string &name)
Create a spdlog logger, register it in the spdlog registry and initialize it with LehrFEM++ specific ...
An alternative implementation of a hybrid2d mesh manager that uses Pointers to store sub-entity relat...
Definition hybrid2d.h:11
const unsigned int idx_nil
Definition mesh.h:28
lf::base::dim_t dim_t
Definition mesh.h:25
lf::base::glb_idx_t glb_idx_t
Definition mesh.h:27
lf::base::size_type size_type
Definition mesh.h:24
lf::base::sub_idx_t sub_idx_t
Definition mesh.h:26