Meshes
Comprehensive guide to working with meshes in Rodin.
Introduction
A mesh is the fundamental data structure in finite element analysis. It represents the discretization of a computational domain into simple geometric shapes called polytopes (triangles, tetrahedra, etc.).
In Rodin, the Mesh class is the central object of the Geometry module. It stores:
- Vertex coordinates: the physical positions of mesh nodes
- Cell connectivity: which vertices form each cell (triangle, tet, etc.)
- Topological incidence: computed on demand via Connectivity (e.g., which cells share an edge, which edges lie on the boundary)
- Attributes: integer labels on cells and boundary faces, used to distinguish subdomains and boundary segments
The mesh supports both structured generation (via UniformGrid and Box factory methods) and unstructured meshes loaded from files in MFEM, MEDIT, or HDF5 format.
Factory Methods
| Method | Description |
|---|---|
Mesh::UniformGrid(type, shape) | Generate a uniform grid filling the unit hypercube . The type specifies the cell shape (Triangle, Tetrahedron, etc.) and shape gives the number of subdivisions per axis. |
Mesh::Box(type, shape) | Generate a surface mesh (boundary of the unit box). The type specifies the face shape (Segment for 2D boundary, Triangle for 3D boundary), and the resulting mesh has topological dimension one less than the ambient space. |
Mesh::Build() | Programmatic construction via the Builder pattern. |
Key Concepts
Domain Partition
Mathematically, a mesh partitions a domain :
where each is a polytope (e.g., triangle, tetrahedron).
Dimensions
A mesh has two important dimensions:
- Topological dimension (
getDimension()): The dimension of the highest dimensional polytopes (e.g., 2 for triangular meshes, 3 for tetrahedral) - Space dimension (
getSpaceDimension()): The dimension of the ambient space in which the mesh is embedded
Example: A 2D surface embedded in 3D space has topological dimension 2 and space dimension 3.
Mesh Entities
Meshes consist of entities of different dimensions:
| Dimension | Name | Examples |
|---|---|---|
| 0 | Vertices | Points |
| 1 | Edges | Line segments |
| 2 | Faces (2D) or Cells (2D meshes) | Triangles, Quadrilaterals |
| 3 | Cells (3D meshes) | Tetrahedra, Hexahedra |
Basic Usage
Here's a simple example creating and querying a mesh:
#include <Rodin/Geometry.h> using namespace Rodin; using namespace Rodin::Geometry; int main() { // Create a 2D triangular mesh Mesh mesh; mesh = mesh.UniformGrid(Polytope::Type::Triangle, {16, 16}); // Query mesh properties std::cout << "Dimension: " << mesh.getDimension() << std::endl; std::cout << "Vertices: " << mesh.getVertexCount() << std::endl; std::cout << "Cells: " << mesh.getCellCount() << std::endl; std::cout << "Volume: " << mesh.getVolume() << std::endl; return 0; }
Detailed Topics
For detailed information on specific aspects of working with meshes, see:
- Mesh Creation - Creating meshes from files or programmatically
- Mesh Connectivity - Understanding connectivity relations
- Mesh Iteration - Iterating over mesh entities
- Geometric Queries - Geometric queries and measurements
- Mesh Input/Output - Input/output operations
- Advanced Utilities - Advanced utilities and transformations
See Also
- Mesh class reference
- Polytopes guide
- Connectivity guide
- MPI distributed computing — distributed meshes using
Mesh<Context::MPI>, partitioning, and reconciliation - Examples