Rodin::Geometry::MeshBase class

Abstract base class for all mesh implementations.

MeshBase provides the common interface for all mesh types in Rodin, defining fundamental operations such as:

  • Point inclusion testing
  • Basic mesh properties (dimension, vertex count, etc.)
  • Polytope access through iterators
  • Mesh I/O operations
  • Connectivity queries

Inheritance Hierarchy

All concrete mesh implementations derive from this base class:

Thread Safety

MeshBase and derived classes are not thread-safe during construction. Once finalized, read-only operations are thread-safe.

Derived classes

template<>
class Mesh<Context::Local>
Represents the subdivision of some domain into faces of (possibly) different geometries.

Constructors, destructors, conversion operators

~MeshBase() defaulted virtual
Virtual destructor.

Public functions

auto operator==(const MeshBase& other) const -> bool constexpr
Equality comparison (pointer equality).
auto operator!=(const MeshBase& other) const -> bool constexpr
Inequality comparison.
auto inclusion(const Point& p) const -> Optional<Point> virtual
Tests point inclusion in the mesh.
auto isEmpty() const -> bool
Checks if mesh is empty.
auto isSurface() const -> bool
Checks if mesh is a surface mesh.
auto getVertexCount() const -> size_t
Gets the number of vertices.
auto getFaceCount() const -> size_t
Gets the number of faces.
auto getCellCount() const -> size_t
Gets the number of cells.
auto getFaceAttribute(Index index) const -> Attribute
Gets face attribute.
auto getCellAttribute(Index index) const -> Attribute
Gets cell attribute.
auto scale(Real c) -> MeshBase& pure virtual
Scales mesh coordinates by a factor.
auto load(const boost::filesystem::path& filename, IO::FileFormat fmt = IO::FileFormat::MFEM) -> MeshBase& pure virtual
Loads mesh from file.
void save(const boost::filesystem::path& filename, IO::FileFormat fmt = IO::FileFormat::MFEM) const pure virtual
Saves mesh to file.
void flush() pure virtual
Flushes cached mesh data.
auto isSubMesh() const -> bool pure virtual
Checks if this mesh is a submesh.
auto isInterface(Index faceIdx) const -> bool pure virtual
Checks if a face is an interface between regions.
auto isBoundary(Index faceIdx) const -> bool pure virtual
Checks if a face is on the mesh boundary.
auto asSubMesh() -> SubMeshBase& pure virtual
Casts to SubMeshBase interface (mutable).
auto asSubMesh() const -> const SubMeshBase& pure virtual
Casts to SubMeshBase interface (const).
auto getDimension() const -> size_t pure virtual
Gets the topological dimension.
auto getSpaceDimension() const -> size_t pure virtual
Gets the ambient space dimension.
auto getVolume() const -> Real pure virtual
Gets the total mesh volume.
auto getVolume(Attribute attr) const -> Real pure virtual
Gets volume of cells with specified attribute.
auto getVolume(const FlatSet<Attribute>& attr) const -> Real pure virtual
Gets volume of cells with attributes in set.
auto getPerimeter() const -> Real pure virtual
Gets the total mesh perimeter.
auto getPerimeter(Attribute attr) const -> Real pure virtual
Gets perimeter of cells with specified attribute.
auto getPerimeter(const FlatSet<Attribute>& attr) const -> Real pure virtual
Gets perimeter of cells with attributes in set.
auto getArea() const -> Real pure virtual
Gets total area.
auto getArea(Attribute attr) const -> Real pure virtual
Gets area of elements with specified attribute.
auto getArea(const FlatSet<Attribute>& attr) const -> Real pure virtual
Gets area of elements with attributes in set.
auto getMeasure(size_t d) const -> Real pure virtual
Gets measure of polytopes of given dimension.
auto getMeasure(size_t d, Attribute attr) const -> Real pure virtual
Gets measure of polytopes with attribute.
auto getMeasure(size_t d, const FlatSet<Attribute>& attr) const -> Real pure virtual
Gets measure of polytopes with attributes in set.
auto getBoundary() const -> FaceIterator pure virtual
Gets iterator over boundary faces.
auto getInterface() const -> FaceIterator pure virtual
Gets iterator over interface faces.
auto getPolytopeCount(size_t dimension) const -> size_t pure virtual
Gets count of polytopes of given dimension.
auto getPolytopeCount(Polytope::Type g) const -> size_t pure virtual
Gets count of polytopes of given geometry type.
auto getCell() const -> CellIterator pure virtual
Gets iterator over all cells.
auto getFace() const -> FaceIterator pure virtual
Gets iterator over all faces.
auto getVertex() const -> VertexIterator pure virtual
Gets iterator over all vertices.
auto getPolytope(size_t dimension) const -> PolytopeIterator pure virtual
Gets iterator over polytopes of given dimension.
auto getCell(Index idx) const -> CellIterator pure virtual
Gets iterator to specific cell.
auto getFace(Index idx) const -> FaceIterator pure virtual
Gets iterator to specific face.
auto getVertex(Index idx) const -> VertexIterator pure virtual
Gets iterator to specific vertex.
auto getPolytope(size_t dimension, Index idx) const -> PolytopeIterator pure virtual
Gets iterator to specific polytope.
auto getPolytopeTransformation(size_t dimension, Index idx) const -> const PolytopeTransformation& pure virtual
Gets polytope transformation.
auto getGeometry(size_t dimension, Index idx) const -> Polytope::Type pure virtual
Gets geometry type of a polytope.
auto getAttribute(size_t dimension, Index index) const -> Attribute pure virtual
Gets attribute of a polytope.
auto setAttribute(const std::pair<size_t, Index>& p, Attribute attr) -> MeshBase& pure virtual
Sets attribute of a polytope.
auto getConnectivity() -> ConnectivityBase& pure virtual
Gets reference to mesh connectivity.
auto getConnectivity() const -> const ConnectivityBase& pure virtual
Gets a constant reference to the mesh connectivity.
auto getVertexCoordinates(Index idx) const -> Eigen::Map<const Math::SpatialPoint> pure virtual
Gets the space coordinates of the vertex at the given index.
auto setVertexCoordinates(Index idx, Real s, size_t i) -> MeshBase& pure virtual
Sets the space coordinate of the vertex at the given index for the given coordinate index.
auto setVertexCoordinates(Index idx, const Math::SpatialPoint& coords) -> MeshBase& pure virtual
Sets the space coordinate of the vertex at the given index for the given coordinate index.
auto getContext() const -> const Context::Base& pure virtual
Gets the execution context of the mesh.

Function documentation

bool Rodin::Geometry::MeshBase::operator==(const MeshBase& other) const constexpr

Equality comparison (pointer equality).

Parameters
other in Mesh to compare with
Returns True if this is the same mesh object

bool Rodin::Geometry::MeshBase::operator!=(const MeshBase& other) const constexpr

Inequality comparison.

Parameters
other in Mesh to compare with
Returns True if not the same mesh object

Optional<Point> Rodin::Geometry::MeshBase::inclusion(const Point& p) const virtual

Tests point inclusion in the mesh.

Parameters
in Point to test
Returns Optional point if included in mesh

Determines whether a point lies within the mesh domain and returns its representation if so.

bool Rodin::Geometry::MeshBase::isEmpty() const

Checks if mesh is empty.

Returns True if mesh has no vertices

An empty mesh is defined as a mesh with no vertices.

bool Rodin::Geometry::MeshBase::isSurface() const

Checks if mesh is a surface mesh.

Returns True if mesh has codimension 1

A mesh is considered a surface mesh if its codimension is 1, meaning the difference between space dimension and topological dimension equals 1.

Examples:

  • 2D mesh embedded in 3D space (triangulated surface)
  • 1D mesh embedded in 2D space (curve)

size_t Rodin::Geometry::MeshBase::getVertexCount() const

Gets the number of vertices.

Returns Vertex count

size_t Rodin::Geometry::MeshBase::getFaceCount() const

Gets the number of faces.

Returns Face count (codimension-1 polytopes)

size_t Rodin::Geometry::MeshBase::getCellCount() const

Gets the number of cells.

Returns Cell count (maximal dimension polytopes)

Attribute Rodin::Geometry::MeshBase::getFaceAttribute(Index index) const

Gets face attribute.

Parameters
index in Face index
Returns Attribute value

Attribute Rodin::Geometry::MeshBase::getCellAttribute(Index index) const

Gets cell attribute.

Parameters
index in Cell index
Returns Attribute value

MeshBase& Rodin::Geometry::MeshBase::scale(Real c) pure virtual

Scales mesh coordinates by a factor.

Parameters
in Scaling factor
Returns Reference to this mesh

Multiplies all vertex coordinates by $ c $ .

MeshBase& Rodin::Geometry::MeshBase::load(const boost::filesystem::path& filename, IO::FileFormat fmt = IO::FileFormat::MFEM) pure virtual

Loads mesh from file.

Parameters
filename in Path to mesh file
fmt in File format (MFEM, GMSH, etc.)
Returns Reference to this mesh

void Rodin::Geometry::MeshBase::save(const boost::filesystem::path& filename, IO::FileFormat fmt = IO::FileFormat::MFEM) const pure virtual

Saves mesh to file.

Parameters
filename in Path to output file
fmt in File format

void Rodin::Geometry::MeshBase::flush() pure virtual

Flushes cached mesh data.

Clears any internally cached derived data (e.g., cached Jacobians).

bool Rodin::Geometry::MeshBase::isSubMesh() const pure virtual

Checks if this mesh is a submesh.

Returns True if this is a SubMesh instance

A Mesh which is also a SubMesh may be casted down to access SubMesh-specific functionality:

if (mesh.isSubMesh())
{
  auto& submesh = static_cast<SubMesh<Context::Local>&>(mesh);
  const auto& parent = submesh.getParent();
}

bool Rodin::Geometry::MeshBase::isInterface(Index faceIdx) const pure virtual

Checks if a face is an interface between regions.

Parameters
faceIdx in Face index
Returns True if face connects cells with different attributes

bool Rodin::Geometry::MeshBase::isBoundary(Index faceIdx) const pure virtual

Checks if a face is on the mesh boundary.

Parameters
faceIdx in Face index
Returns True if face belongs to only one cell

SubMeshBase& Rodin::Geometry::MeshBase::asSubMesh() pure virtual

Casts to SubMeshBase interface (mutable).

Returns Reference to SubMeshBase interface
Exceptions
Exception if mesh is not a submesh

const SubMeshBase& Rodin::Geometry::MeshBase::asSubMesh() const pure virtual

Casts to SubMeshBase interface (const).

Returns Const reference to SubMeshBase interface
Exceptions
Exception if mesh is not a submesh

size_t Rodin::Geometry::MeshBase::getDimension() const pure virtual

Gets the topological dimension.

Returns Mesh dimension $ D $ (highest polytope dimension)

size_t Rodin::Geometry::MeshBase::getSpaceDimension() const pure virtual

Gets the ambient space dimension.

Returns Space dimension in which mesh is embedded

For example, a 2D triangulated surface in 3D space has:

Real Rodin::Geometry::MeshBase::getVolume() const pure virtual

Gets the total mesh volume.

Returns Sum of all cell volumes

Real Rodin::Geometry::MeshBase::getVolume(Attribute attr) const pure virtual

Gets volume of cells with specified attribute.

Parameters
attr in Attribute value
Returns Sum of volumes of cells with attribute attr

Real Rodin::Geometry::MeshBase::getVolume(const FlatSet<Attribute>& attr) const pure virtual

Gets volume of cells with attributes in set.

Parameters
attr in Set of attribute values
Returns Sum of volumes

Real Rodin::Geometry::MeshBase::getPerimeter() const pure virtual

Gets the total mesh perimeter.

Returns Sum of all cell perimeters

Real Rodin::Geometry::MeshBase::getPerimeter(Attribute attr) const pure virtual

Gets perimeter of cells with specified attribute.

Parameters
attr in Attribute value
Returns Sum of perimeters

Real Rodin::Geometry::MeshBase::getPerimeter(const FlatSet<Attribute>& attr) const pure virtual

Gets perimeter of cells with attributes in set.

Parameters
attr in Set of attribute values
Returns Sum of perimeters

Real Rodin::Geometry::MeshBase::getArea() const pure virtual

Gets total area.

Returns Sum of all element areas

Real Rodin::Geometry::MeshBase::getArea(Attribute attr) const pure virtual

Gets area of elements with specified attribute.

Parameters
attr in Attribute value
Returns Sum of areas

Real Rodin::Geometry::MeshBase::getArea(const FlatSet<Attribute>& attr) const pure virtual

Gets area of elements with attributes in set.

Parameters
attr in Set of attribute values
Returns Sum of areas

Real Rodin::Geometry::MeshBase::getMeasure(size_t d) const pure virtual

Gets measure of polytopes of given dimension.

Parameters
in Polytope dimension
Returns Total measure

Real Rodin::Geometry::MeshBase::getMeasure(size_t d, Attribute attr) const pure virtual

Gets measure of polytopes with attribute.

Parameters
in Polytope dimension
attr in Attribute value
Returns Total measure

Real Rodin::Geometry::MeshBase::getMeasure(size_t d, const FlatSet<Attribute>& attr) const pure virtual

Gets measure of polytopes with attributes in set.

Parameters
in Polytope dimension
attr in Set of attribute values
Returns Total measure

FaceIterator Rodin::Geometry::MeshBase::getBoundary() const pure virtual

Gets iterator over boundary faces.

Returns FaceIterator for boundary faces

FaceIterator Rodin::Geometry::MeshBase::getInterface() const pure virtual

Gets iterator over interface faces.

Returns FaceIterator for interface faces

size_t Rodin::Geometry::MeshBase::getPolytopeCount(size_t dimension) const pure virtual

Gets count of polytopes of given dimension.

Parameters
dimension in Polytope dimension
Returns Number of polytopes

size_t Rodin::Geometry::MeshBase::getPolytopeCount(Polytope::Type g) const pure virtual

Gets count of polytopes of given geometry type.

Parameters
in Polytope geometry type
Returns Number of polytopes

CellIterator Rodin::Geometry::MeshBase::getCell() const pure virtual

Gets iterator over all cells.

Returns CellIterator

FaceIterator Rodin::Geometry::MeshBase::getFace() const pure virtual

Gets iterator over all faces.

Returns FaceIterator

VertexIterator Rodin::Geometry::MeshBase::getVertex() const pure virtual

Gets iterator over all vertices.

Returns VertexIterator

PolytopeIterator Rodin::Geometry::MeshBase::getPolytope(size_t dimension) const pure virtual

Gets iterator over polytopes of given dimension.

Parameters
dimension in Polytope dimension
Returns PolytopeIterator

CellIterator Rodin::Geometry::MeshBase::getCell(Index idx) const pure virtual

Gets iterator to specific cell.

Parameters
idx in Cell index
Returns CellIterator positioned at cell

FaceIterator Rodin::Geometry::MeshBase::getFace(Index idx) const pure virtual

Gets iterator to specific face.

Parameters
idx in Face index
Returns FaceIterator positioned at face

VertexIterator Rodin::Geometry::MeshBase::getVertex(Index idx) const pure virtual

Gets iterator to specific vertex.

Parameters
idx in Vertex index
Returns VertexIterator positioned at vertex

PolytopeIterator Rodin::Geometry::MeshBase::getPolytope(size_t dimension, Index idx) const pure virtual

Gets iterator to specific polytope.

Parameters
dimension in Polytope dimension
idx in Polytope index
Returns PolytopeIterator positioned at polytope

const PolytopeTransformation& Rodin::Geometry::MeshBase::getPolytopeTransformation(size_t dimension, Index idx) const pure virtual

Gets polytope transformation.

Parameters
dimension in Polytope dimension
idx in Polytope index
Returns Reference to transformation $ x: K \rightarrow \tau $

Polytope::Type Rodin::Geometry::MeshBase::getGeometry(size_t dimension, Index idx) const pure virtual

Gets geometry type of a polytope.

Parameters
dimension in Polytope dimension
idx in Polytope index
Returns Geometry type

Attribute Rodin::Geometry::MeshBase::getAttribute(size_t dimension, Index index) const pure virtual

Gets attribute of a polytope.

Parameters
dimension in Polytope dimension
index in Polytope index
Returns Attribute value

MeshBase& Rodin::Geometry::MeshBase::setAttribute(const std::pair<size_t, Index>& p, Attribute attr) pure virtual

Sets attribute of a polytope.

Parameters
in Pair of (dimension, index)
attr in New attribute value
Returns Reference to this mesh

ConnectivityBase& Rodin::Geometry::MeshBase::getConnectivity() pure virtual

Gets reference to mesh connectivity.

Returns Const reference to Connectivity object

Eigen::Map<const Math::SpatialPoint> Rodin::Geometry::MeshBase::getVertexCoordinates(Index idx) const pure virtual

Gets the space coordinates of the vertex at the given index.

Parameters
idx in Vertex index

MeshBase& Rodin::Geometry::MeshBase::setVertexCoordinates(Index idx, Real s, size_t i) pure virtual

Sets the space coordinate of the vertex at the given index for the given coordinate index.

Parameters
idx in Vertex index
in New coordinate
in Coordinate index

For example, the following code sets the coordinates of the 0-vertex to $ (0, 5, 10) $ in a mesh embedded in three dimensional space.

Mesh mesh;
// Add vertices...
mesh.setVertexCoordinates(0, 0.0, 0);
mesh.setVertexCoordinates(0, 5.0, 1);
mesh.setVertexCoordinates(0, 10.0, 2);

MeshBase& Rodin::Geometry::MeshBase::setVertexCoordinates(Index idx, const Math::SpatialPoint& coords) pure virtual

Sets the space coordinate of the vertex at the given index for the given coordinate index.

Parameters
idx in Vertex index
coords in New coordinates

const Context::Base& Rodin::Geometry::MeshBase::getContext() const pure virtual

Gets the execution context of the mesh.

Returns Reference to the context object

The context determines whether the mesh is local, distributed, or uses another execution model.