Using an MMG mesh in Rodin
Share the geometry interface and manage remeshing lifetimes.
Mesh interfaces
MMG::Mesh derives from Geometry::Mesh<Context::Local>. It can therefore be supplied to local finite element spaces and variational problems through the geometry interface. Its additional metadata records MMG corners, ridges and required entities.
Initialize from generated geometry
Assignment from a plain geometry mesh copies its topology and coordinates and clears MMG-specific metadata. Apply feature labels after that assignment.
constexpr size_t nodes = 8; MMG::Mesh mesh; mesh = Mesh().UniformGrid(Polytope::Type::Triangle, {nodes, nodes}); mesh.scale(1.0 / (nodes - 1)); mesh.getConnectivity().compute(1, 2); mesh.setCorner(0); mesh.setCorner(nodes - 1); mesh.setCorner(nodes * (nodes - 1)); mesh.setCorner(nodes * nodes - 1); mesh.setRequiredVertex(0);
Scope spaces around remeshing
A finite element space borrows its mesh and determines degrees of freedom from the current topology. The adaptation example constructs a nodal size field on that mesh and passes it to MMG.
P1 vh(mesh); MMG::RealGridFunction sizeMap(vh); sizeMap = [](const Point& point) { return 0.05 + 0.15 * point.x(); }; MMG::Adapt().setHMin(0.04).setHMax(0.21).adapt(mesh, sizeMap);
After the call, the old size field's topology-dependent representation is no longer used. The program leaves its scope before continuing. Construct fresh spaces, trial/test functions and problems for the new mesh; transfer fields through a specified interpolation or projection procedure when their state is needed for the next solve.
Keep the feature representation
MEDIT I/O stores the MMG metadata used by the wrapper. Passing the object through a plain geometry interface provides the operations supported by that interface. Select an MMG-aware representation when the corner, ridge and required-entity sets must be retained.