![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
A base class for creating and managing mesh data structures. More...
#include <mesh_base.hpp>
Public Types | |
| enum | Entity { VtxEnty = 0 , FacetEnty = SelfDim - 1 , CellEnty = SelfDim } |
| Enumerates the different types of mesh entities based on their dimension. More... | |
| using | index_t = IndexType |
| using | float_t = FloatType |
| using | SelfPoint = Point<FloatType, SelfDim> |
| Map for cell-to-cell connectivity (the dual graph). | |
| using | DualMap = datastructure::CrsMap<IndexType, IndexType> |
| Map from cells to the facets that form their boundary. | |
| using | CellToFacetMap = datastructure::CrsMap<IndexType, IndexType> |
| Map from cells to the vertices that define them. | |
| using | CellToVtxMap = datastructure::CrsMap<IndexType, IndexType> |
| An uncompressed (temporary) version of the CellToVtxMap. | |
| using | CellToVtxMapUncompressed = datastructure::CrsMapUncompressed<IndexType> |
| Map from facets to the cells they separate. | |
| using | FacetToCellMap |
| Map from facets to the vertices that define them. | |
| using | FacetToVtxMap |
| Map from vertices to the cells they belong to. | |
| using | VtxToCellMap = datastructure::CrsMap<IndexType, IndexType> |
| Represents an edge as a pair of vertex indices. | |
| using | EdgeVtxs = std::array<IndexType, 2> |
| Map from an edge to its two vertices. | |
| using | EdgeToVtxMap = std::vector<EdgeVtxs> |
| Map from cells to their edges. | |
| using | CellToEdgeMap = datastructure::CrsMap<IndexType, IndexType> |
| Map from edges to adjacent cells. | |
| using | EdgeToCellMap = datastructure::CrsMap<IndexType, IndexType> |
Public Member Functions | |
| std::vector< SelfPoint > & | getVertexes () |
| Gets a modifiable reference to the vector of vertices. | |
| const std::vector< SelfPoint > & | getVertexes () const |
| Gets a constant reference to the vector of vertices. | |
| DualMap & | getDualMap () |
| Gets a modifiable reference to the dual graph (cell-to-cell connections). | |
| const DualMap & | getDualMap () const |
| Gets a constant reference to the dual graph (cell-to-cell connections). | |
| CellToFacetMap & | getCellToFacetMap () |
| Gets a modifiable reference to the cell-to-facet map. | |
| const CellToFacetMap & | getCellToFacetMap () const |
| Gets a constant reference to the cell-to-facet map. | |
| CellToVtxMap & | getCellToVtxMap () |
| Gets a modifiable reference to the cell-to-vertex map. | |
| const CellToVtxMap & | getCellToVtxMap () const |
| Gets a constant reference to the cell-to-vertex map. | |
| FacetToCellMap & | getFacetToCellMap () |
| Gets a modifiable reference to the facet-to-cell map. | |
| const FacetToCellMap & | getFacetToCellMap () const |
| Gets a constant reference to the facet-to-cell map. | |
| FacetToVtxMap & | getFacetToVtxMap () |
| Gets a modifiable reference to the facet-to-vertex map. | |
| const FacetToVtxMap & | getFacetToVtxMap () const |
| Gets a constant reference to the facet-to-vertex map. | |
| VtxToCellMap & | getVtxToCellMap () |
| Gets a modifiable reference to the vertex-to-cell map. | |
| const VtxToCellMap & | getVtxToCellMap () const |
| Gets a constant reference to the vertex-to-cell map. | |
| const auto & | getDualGlobalMap () const |
| const auto & | getCellToFacetGlobalMap () const |
| const auto & | getCellToVtxGlobalMap () const |
| const auto & | getFacetToCellGlobalMap () const |
| const auto & | getFacetToVtxGlobalMap () const |
| const auto & | getVtxToCellGlobalMap () const |
| auto & | getMeshTags () |
| Gets a modifiable reference to the mesh tags. | |
| const auto & | getMeshTags () const |
| Gets a constant reference to the mesh tags. | |
| auto & | getMetadata () |
| Gets a modifiable reference to the mesh metadata. | |
| const auto & | getMetadata () const |
| Gets a constant reference to the mesh metadata. | |
| IndexType | numCells () const |
| Returns the total number of cells in the mesh. | |
| void | buildInternalMaps () |
| Builds all the secondary connectivity maps from the primary ones. | |
| constexpr IndexType | nEntity (std::size_t dim) const |
| Returns the total number of entities of a given dimension. | |
| constexpr IndexType | nLocEntity (std::size_t dim) const |
| Returns the number of locally owned entities of a given dimension. | |
| template<std::size_t dim> | |
| constexpr auto & | getEntityToCellMap () const |
| Gets the map from a given entity dimension to cells. | |
| template<std::size_t dim> | |
| constexpr auto & | getEntityToCellGlobalMap () const |
| Gets the global map from a given entity dimension to cells. | |
| constexpr IndexType | nOwnedCells () const |
| Returns the number of locally owned cells. | |
| template<class Archive> | |
| void | serialize (Archive &ar, const unsigned int) |
| Serializes the mesh data. | |
Static Public Member Functions | |
| static constexpr bool | parallel () |
| Indicates if the mesh is configured for parallel computation. | |
Static Public Attributes | |
| static constexpr IndexType | outer_dim = OuterDim |
| The dimension of the embedding space. | |
| static constexpr IndexType | self_dim = SelfDim |
| The dimension of the mesh itself. | |
| static constexpr IndexType | vtx_per_face = self_dim <= 2 ? self_dim : -1 |
| True if the mesh is a surface in a higher-dimensional space (e.g., a 2D surface in 3D space). | |
| static constexpr bool | is_manifold = !(outer_dim == self_dim) |
| A special value used to represent an undefined or invalid index. | |
| static constexpr IndexType | UNDEF = static_cast<IndexType>(-1) |
Protected Member Functions | |
| const auto & | self () const |
| Helper to get a constant reference to the Derived class instance. | |
| auto & | self () |
| Helper to get a reference to the Derived class instance. | |
| datastructure::CrsMap< index_t, index_t > | invertCellAgglomeration (const std::vector< index_t > &old_to_new_cell) const |
| Creates a map from new (agglomerated) cell IDs to old (fine) cell IDs. | |
| std::vector< index_t > | buildNewToOldFacetAgglomerationAndCellToFacet (const auto &new_to_old_cell, Derived &agg_mesh) const |
| Builds the facet mapping and cell-to-facet map for an agglomerated mesh. | |
| auto | buildFacetToCellAndFacetToVtxAgglomeration (const std::vector< index_t > &new_to_old_facet, const std::vector< index_t > &old_to_new_cell, Derived &agg_mesh) const |
| Builds the facet-to-cell and facet-to-vertex maps for an agglomerated mesh. | |
| void | buildCellToVtxAgglomeration (const auto &new_to_old_cell, const auto &old_to_new_vtx, Derived &agg_mesh) const |
| Builds the cell-to-vertex map for an agglomerated mesh. | |
| Derived | agglomerateBase (const std::vector< index_t > &old_to_new_cell, bool check_connected=true) const |
| Creates a new, coarser mesh by grouping cells together. | |
| void | agglomerateCheckConnected (const datastructure::CrsMap< IndexType, IndexType > &new_to_old_cell) const |
| Checks if each new agglomerated cell consists of connected old cells. | |
| void | buildVtxToCell () |
| Builds the vertex-to-cell connectivity map. | |
| void | buildCellToFacet () |
| Builds the cell-to-facet connectivity map. | |
| void | buildDualGraph () |
| Builds the dual graph (cell-to-cell adjacency). | |
Protected Attributes | |
| std::vector< SelfPoint > | m_vertexes |
| < A list of all vertex coordinates. | |
| DualMap | m_dual_graph |
| Maps each cell to the list of its boundary facets. | |
| CellToFacetMap | m_cell_to_facet |
| Maps each cell to the list of its vertices. | |
| CellToVtxMap | m_cell_to_vtx |
| Maps each facet to its borders. | |
| FacetToCellMap | m_facet_to_cell |
| Maps each facet to its vertices. | |
| FacetToVtxMap | m_facet_to_vtx |
| Maps each vertex to the list of cells it belongs to. | |
| VtxToCellMap | m_vtx_to_cell |
| Stores all tags associated with the mesh. | |
| MeshTag< SelfDim, IndexType > | m_mesh_tags |
| Stores global metadata for the mesh. | |
| Metadata< FloatType, IndexType > | m_metadata |
Friends | |
| bool | operator== (const MeshBase &lhs, const MeshBase &rhs) |
| Checks if two meshes are identical. | |
A base class for creating and managing mesh data structures.
This class provides the fundamental storage and connectivity information for a mesh, such as vertices, cells, and faces. It uses a common programming pattern called CRTP (Curiously Recurring Template Pattern), which allows it to be extended by a Derived class with more specific features.
It defines the relationships between different mesh parts (e.g., which vertices form a cell, which cells are neighbors).
| FloatType | The data type for floating-point numbers (e.g., float or double). |
| IndexType | The data type for indices (e.g., int or std::size_t). |
| OuterDim | The dimension of the space the mesh lives in (e.g., 3 for a surface in 3D space). |
| SelfDim | The dimension of the mesh itself (e.g., 2 for a 2D mesh, 3 for a 3D mesh). |
| Derived | The actual mesh class that inherits from this base (CRTP). |
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::CellToEdgeMap = datastructure::CrsMap<IndexType, IndexType> |
Map from edges to adjacent cells.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::CellToFacetMap = datastructure::CrsMap<IndexType, IndexType> |
Map from cells to the vertices that define them.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::CellToVtxMap = datastructure::CrsMap<IndexType, IndexType> |
An uncompressed (temporary) version of the CellToVtxMap.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::CellToVtxMapUncompressed = datastructure::CrsMapUncompressed<IndexType> |
Map from facets to the cells they separate.
If this is not a manyfold a facet separates exactly two cells (unless on the boundary of the mesh). If it is a manifold there is no limit (e.g. a graph junction of many edges)
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::DualMap = datastructure::CrsMap<IndexType, IndexType> |
Map from cells to the facets that form their boundary.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::EdgeToCellMap = datastructure::CrsMap<IndexType, IndexType> |
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::EdgeToVtxMap = std::vector<EdgeVtxs> |
Map from cells to their edges.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::EdgeVtxs = std::array<IndexType, 2> |
Map from an edge to its two vertices.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::FacetToCellMap |
Map from facets to the vertices that define them.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::FacetToVtxMap |
Map from vertices to the cells they belong to.
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::float_t = FloatType |
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::index_t = IndexType |
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::SelfPoint = Point<FloatType, SelfDim> |
Map for cell-to-cell connectivity (the dual graph).
| using vulpes::geometry::MeshBase< FloatType, IndexType, OuterDim, SelfDim, Derived >::VtxToCellMap = datastructure::CrsMap<IndexType, IndexType> |
Represents an edge as a pair of vertex indices.
| enum vulpes::geometry::MeshBase::Entity |
|
protected |
Creates a new, coarser mesh by grouping cells together.
This process, called agglomeration, is used to create a simplified version of the mesh, for example in multigrid solvers.
| old_to_new_cell | A vector mapping each old cell to a new, larger cell ID. |
| check_connected | If true, verifies that each new cell is formed by a connected group of old cells. |
|
protected |
Checks if each new agglomerated cell consists of connected old cells.
It performs a search (DFS) within each group of old cells to ensure they form a single, contiguous block. It will exit with an error if a disconnected group is found.
| new_to_old_cell | A map from new cell IDs to the old cell IDs they contain. |
|
protected |
Builds the cell-to-facet connectivity map.
|
protected |
Builds the cell-to-vertex map for an agglomerated mesh.
| new_to_old_cell | A map from new cell IDs to the old cell IDs they contain. | |
| old_to_new_vtx | A map from old vertex IDs to new vertex IDs. | |
| [in,out] | agg_mesh | The new, agglomerated mesh being built. |
|
protected |
Builds the dual graph (cell-to-cell adjacency).
Two cells are considered neighbors if they share a common facet.
|
protected |
Builds the facet-to-cell and facet-to-vertex maps for an agglomerated mesh.
| new_to_old_facet | A map from new facet IDs to old facet IDs. | |
| old_to_new_cell | A map from old cell IDs to new cell IDs. | |
| [in,out] | agg_mesh | The new, agglomerated mesh being built. |
|
inline |
Builds all the secondary connectivity maps from the primary ones.
This is a convenience function that calls the individual build methods for creating maps like VtxToCell, CellToFacet, and the DualGraph.
|
protected |
Builds the facet mapping and cell-to-facet map for an agglomerated mesh.
This function identifies the boundary facets of the new, larger cells.
| new_to_old_cell | A map from new cell IDs to the old cell IDs they contain. | |
| [in,out] | agg_mesh | The new, agglomerated mesh being built. |
|
protected |
Builds the vertex-to-cell connectivity map.
|
inline |
|
inline |
Gets a modifiable reference to the cell-to-facet map.
|
inline |
Gets a constant reference to the cell-to-facet map.
|
inline |
|
inline |
Gets a modifiable reference to the cell-to-vertex map.
|
inline |
Gets a constant reference to the cell-to-vertex map.
|
inline |
|
inline |
Gets a modifiable reference to the dual graph (cell-to-cell connections).
|
inline |
Gets a constant reference to the dual graph (cell-to-cell connections).
|
inlineconstexpr |
Gets the global map from a given entity dimension to cells.
Similar to getEntityToCellMap, but for the entire (global) mesh. This call is forwarded to the Derived class.
| dim | The dimension of the entity. |
|
inlineconstexpr |
Gets the map from a given entity dimension to cells.
For example, getEntityToCellMap<0>() would return the vertex-to-cell map. This call is forwarded to the Derived class.
| dim | The dimension of the entity. |
|
inline |
|
inline |
Gets a modifiable reference to the facet-to-cell map.
|
inline |
Gets a constant reference to the facet-to-cell map.
|
inline |
|
inline |
Gets a modifiable reference to the facet-to-vertex map.
|
inline |
Gets a constant reference to the facet-to-vertex map.
|
inline |
Gets a modifiable reference to the mesh tags.
|
inline |
Gets a constant reference to the mesh tags.
|
inline |
Gets a modifiable reference to the mesh metadata.
|
inline |
Gets a constant reference to the mesh metadata.
|
inline |
Gets a modifiable reference to the vector of vertices.
|
inline |
Gets a constant reference to the vector of vertices.
|
inline |
|
inline |
Gets a modifiable reference to the vertex-to-cell map.
|
inline |
Gets a constant reference to the vertex-to-cell map.
|
protected |
Creates a map from new (agglomerated) cell IDs to old (fine) cell IDs.
| old_to_new_cell | A vector where the index is the old cell ID and the value is the new cell ID. |
|
inlineconstexpr |
Returns the total number of entities of a given dimension.
This call is forwarded to the Derived class.
| dim | The dimension of the entity (e.g., 0 for vertices, self_dim for cells). |
|
inlineconstexpr |
Returns the number of locally owned entities of a given dimension.
This is mainly for parallel computing. This call is forwarded to the Derived class.
| dim | The dimension of the entity. |
|
inlineconstexpr |
Returns the number of locally owned cells.
|
inline |
Returns the total number of cells in the mesh.
It also includes assertions to ensure the mesh data is consistent.
|
inlinestaticconstexpr |
Indicates if the mesh is configured for parallel computation.
|
inlineprotected |
Helper to get a reference to the Derived class instance.
|
inlineprotected |
Helper to get a constant reference to the Derived class instance.
|
inline |
Serializes the mesh data.
This function is used to save or send the mesh's state. It's designed to work with a serialization library like Boost.Serialization.
| ar | The archive object to write to or read from. |
|
friend |
Checks if two meshes are identical.
| lhs | The left-hand side mesh. |
| rhs | The right-hand side mesh. |
|
staticconstexpr |
A special value used to represent an undefined or invalid index.
|
protected |
Maps each cell to the list of its vertices.
|
protected |
Maps each facet to its borders.
If this is not a manifold the cells are always two if the facet is internal and one if on the boundary, in this case one of the two entries is UNDEF. The cell in the first position in the one where the vertices of the facet in m_facet_to_vtx follow the "correct" orientation (CCW in 2D/outer pointing following the right-hand rule in 3D), the second one instead must be the contrary.
|
protected |
Maps each cell to the list of its boundary facets.
|
protected |
Maps each facet to its vertices.
In 1D, facets are the same as vertices.
|
protected |
Maps each vertex to the list of cells it belongs to.
|
protected |
Stores global metadata for the mesh.
|
protected |
|
protected |
< A list of all vertex coordinates.
The dual graph, storing neighbors for each cell. Two cells are neighbors if they share a facet.
|
protected |
Stores all tags associated with the mesh.
|
staticconstexpr |
The dimension of the embedding space.
|
staticconstexpr |
The dimension of the mesh itself.
The number of vertices per face. Set to -1 for 3D meshes where faces can have variable vertices.
|
inlinestaticconstexpr |
|
staticconstexpr |
True if the mesh is a surface in a higher-dimensional space (e.g., a 2D surface in 3D space).