General concepts » 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 $ \Omega $ 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

MethodDescription
Mesh::UniformGrid(type, shape)Generate a uniform grid filling the unit hypercube $ [0, N_1{-}1] \times \cdots $ . 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 $ \mathcal{T}_h $ partitions a domain $ \Omega $ :

\[ \Omega = \bigcup_{K \in \mathcal{T}_h} K \]

where each $ K $ 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:

DimensionNameExamples
0VerticesPoints
1EdgesLine segments
2Faces (2D) or Cells (2D meshes)Triangles, Quadrilaterals
3Cells (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:

See Also