24#ifndef VULPES_GEOMETRY_MESH_MESH_3D_HPP_
25#define VULPES_GEOMETRY_MESH_MESH_3D_HPP_
35#include <unordered_map>
42#include <vtkCellArray.h>
43#include <vtkCellData.h>
44#include <vtkFloatArray.h>
47#include <vtkPointData.h>
49#include <vtkPolyData.h>
50#include <vtkPolyDataReader.h>
51#include <vtkPolygon.h>
52#include <vtkPolyhedron.h>
53#include <vtkSmartPointer.h>
55#include <vtkUnstructuredGrid.h>
56#include <vtkXMLUnstructuredGridReader.h>
57#include <vtkXMLUnstructuredGridWriter.h>
76template <
typename FloatType,
typename IndexType>
82 Mesh3D<FloatType, IndexType>> {
126 const Eigen::Vector<FloatType, 2> z_range,
140 const std::vector<SelfPoint>& vertexes,
144 this->
m_cell_to_vtx = cell_vertices.template compress<IndexType>();
162 const std::vector<SelfPoint>& vertexes,
166 :
Mesh3D(vertexes, cell_vertices, cells_face_vtxs) {
176 template <
class Archive>
192 return (
static_cast<const BaseType&
>(lhs) ==
193 static_cast<const BaseType&
>(rhs)) &&
255 constexpr IndexType
nEntity(std::size_t dim)
const {
258 }
else if (dim == 1) {
260 }
else if (dim == 2) {
262 }
else if (dim == 3) {
266 throw std::invalid_argument(
"invalid entity dimension");
277 template <std::
size_t dim>
279 if constexpr (dim == 0) {
281 }
else if constexpr (dim == 1) {
283 }
else if constexpr (dim == 2) {
286 static_assert(dim * 0);
300 PROFILE(agg_mesh.buildEdgeMaps());
370template <
typename FloatType,
typename IndexType>
372 const std::string& filename,
373 bool check_vtxs_unique =
false,
374 bool add_tags =
true);
393template <
typename FloatType,
typename IndexType>
398 bool tetra_elements =
false);
403 const std::string&,
bool,
bool);
405 const std::string&,
bool,
bool);
407 const std::string&,
bool,
bool);
409 const std::string&,
bool,
bool);
IndexType size() const
Get the number of rows in the CRS map.
Definition crs_map.hpp:331
A class for a 2D mesh, inheriting from MeshBase.
Definition mesh_2d.hpp:94
Represents a 3D mesh.
Definition mesh_3d.hpp:82
std::vector< EdgeVtxs > EdgeToVtxMap
Map from cells to their edges.
Definition mesh_base.hpp:418
datastructure::CrsMap< IndexType, IndexType > CellToEdgeMap
Map from edges to adjacent cells.
Definition mesh_base.hpp:420
Point< FloatType, 3 > SelfPoint
Alias for a 3D point with coordinates of type FloatType.
Definition mesh_3d.hpp:87
void buildFacetToCellAndFacetToVertex(const CellsFaceVtxsUncompressed &cells_face_vtxs)
Builds the facet-to-cell and facet-to-vertex maps.
Definition mesh_3d.cpp:65
EdgeToVtxMap & getEdgeToVtxMap()
Gets a mutable reference to the edge-to-vertex map.
Definition mesh_3d.hpp:203
const EdgeToCellMap & getEdgeToCellMap() const
Gets a constant reference to the edge-to-cell map.
Definition mesh_3d.hpp:230
datastructure::CrsMapUncompressed< IndexType > CellToVtxMapUncompressed
Map from facets to the cells they separate.
Definition mesh_base.hpp:401
void serialize(Archive &ar, const unsigned int)
Serializes the mesh data for saving or transferring.
Definition mesh_3d.hpp:177
static Mesh3D extrude(const Mesh2D< FloatType, IndexType > &mesh_2d, const Eigen::Vector< FloatType, 2 > z_range, IndexType n_elems)
Creates a 3D mesh by extruding a 2D mesh.
Definition mesh_3d.cpp:181
const CellToEdgeMap & getCellToEdgeMap() const
Gets a constant reference to the cell-to-edge map.
Definition mesh_3d.hpp:219
EdgeToCellMap & getEdgeToCellMap()
Gets a mutable reference to the edge-to-cell map.
Definition mesh_3d.hpp:225
const auto & getCellToEdgeGlobalMap() const
Gets a constant reference to the global cell-to-edge map.
Definition mesh_3d.hpp:241
const auto & getEdgeToVtxGlobalMap() const
Gets a constant reference to the global edge-to-vertex map.
Definition mesh_3d.hpp:236
friend bool operator==(const Mesh3D &lhs, const Mesh3D &rhs)
Compares two Mesh3D objects for equality.
Definition mesh_3d.hpp:191
const auto & getEdgeToCellGlobalMap() const
Gets a constant reference to the global edge-to-cell map.
Definition mesh_3d.hpp:246
Mesh3D agglomerate(const std::vector< IndexType > &old_to_new_cell) const
Creates a new mesh by agglomerating (merging) cells of the current mesh.
Definition mesh_3d.hpp:298
datastructure::CrsMap< IndexType, IndexType > EdgeToCellMap
Definition mesh_base.hpp:422
CellToEdgeMap & getCellToEdgeMap()
Gets a mutable reference to the cell-to-edge map.
Definition mesh_3d.hpp:214
Mesh3D(const std::vector< SelfPoint > &vertexes, const CellToVtxMapUncompressed &cell_vertices, const CellsFaceVtxsUncompressed &cells_face_vtxs, const MeshTag< 3, IndexType > &mesh_tags)
Constructor for creating a 3D mesh with tags.
Definition mesh_3d.hpp:161
const EdgeToVtxMap & getEdgeToVtxMap() const
Gets a constant reference to the edge-to-vertex map.
Definition mesh_3d.hpp:208
constexpr IndexType nEntity(std::size_t dim) const
Returns the number of entities of a specific dimension in the mesh.
Definition mesh_3d.hpp:255
EdgeToCellMap m_edge_to_cell
A map from edges to the cells that contain them.
Definition mesh_3d.hpp:345
std::vector< std::vector< IndexType > > CellsFaceVtxsUncompressed
A vector of vectors, where each inner vector holds the vertex indices for the faces of a cell.
Definition mesh_3d.hpp:104
void buildEdgeMaps()
Builds the edge-related maps.
Definition mesh_3d.cpp:116
MeshBase< FloatType, IndexType, 3, 3, Mesh3D< FloatType, IndexType > > BaseType
Alias for the base class, MeshBase.
Definition mesh_3d.hpp:91
constexpr auto & getEntityToCellMap() const
Returns the entity-to-cell map for a given dimension.
Definition mesh_3d.hpp:278
Mesh3D()=default
Default constructor. Creates an empty 3D mesh.
Mesh3D(const std::vector< SelfPoint > &vertexes, const CellToVtxMapUncompressed &cell_vertices, const CellsFaceVtxsUncompressed &cells_face_vtxs)
Constructor for creating a 3D mesh from a list of vertices, cell-to-vertex connectivity,...
Definition mesh_3d.hpp:139
CellToEdgeMap m_cell_to_edge
A map from cells to their edges.
Definition mesh_3d.hpp:341
EdgeToVtxMap m_edge_to_vtx
A map from edges to their constituent vertices.
Definition mesh_3d.hpp:334
A base class for creating and managing mesh data structures.
Definition mesh_base.hpp:370
FacetToCellMap & getFacetToCellMap()
Definition mesh_base.hpp:464
Mesh3D< FloatType, IndexType > agglomerateBase(const std::vector< index_t > &old_to_new_cell, bool check_connected=true) const
CellToFacetMap m_cell_to_facet
Definition mesh_base.hpp:733
datastructure::CrsMap< IndexType, IndexType > CellToVtxMap
Definition mesh_base.hpp:399
VtxToCellMap & getVtxToCellMap()
Definition mesh_base.hpp:474
MeshTag< SelfDim, IndexType > m_mesh_tags
Definition mesh_base.hpp:749
std::vector< SelfPoint > m_vertexes
Definition mesh_base.hpp:728
datastructure::CrsMap< IndexType, IndexType > EdgeToCellMap
Definition mesh_base.hpp:422
DualMap & getDualMap()
Definition mesh_base.hpp:448
datastructure::CrsMap< IndexType, IndexType > CellToEdgeMap
Definition mesh_base.hpp:420
std::vector< SelfPoint > & getVertexes()
Definition mesh_base.hpp:442
std::vector< EdgeVtxs > EdgeToVtxMap
Definition mesh_base.hpp:418
CellToVtxMap m_cell_to_vtx
Definition mesh_base.hpp:735
void buildInternalMaps()
Definition mesh_base.hpp:514
datastructure::CrsMapUncompressed< IndexType > CellToVtxMapUncompressed
Definition mesh_base.hpp:401
std::array< IndexType, 2 > EdgeVtxs
Definition mesh_base.hpp:416
Definition mesh_3d.cpp:281
Definition abs_agg_model.cpp:40
Eigen::Matrix< DataType, Dim, 1, Eigen::ColMajor > Point
Definition traits.hpp:34
Definition cell_manager.hpp:38
#define PROFILE(func)
Time a single execution of func under the label #func using Profiler::start()/stop().
Definition profiler.hpp:44
A structure to store tags for different parts of a mesh.
Definition mesh_base.hpp:333