MMG Parameters Reference¶
import pyvista as pv
import mmgpy # noqa: F401 -- registers reader/writer + .mmg accessor
mesh = pv.read("input.mesh")
Complete reference for the keyword arguments accepted by dataset.mmg.remesh(...) (and its variants remesh_optimize, remesh_uniform, remesh_levelset, move). Each call returns a fresh PyVista dataset; the input is not mutated.
Size Parameters¶
hmin¶
Minimum edge length.
| Property | Value |
|---|---|
| Type | float |
| Default | Auto-computed |
| Range | > 0 |
Edges shorter than hmin will be collapsed or lengthened.
hmax¶
Maximum edge length.
| Property | Value |
|---|---|
| Type | float |
| Default | Auto-computed |
| Range | > hmin |
Edges longer than hmax will be split.
hsiz¶
Uniform target edge size.
| Property | Value |
|---|---|
| Type | float |
| Default | None |
| Range | > 0 |
When set, overrides hmin and hmax with uniform sizing.
hgrad¶
Gradation parameter controlling size transition.
| Property | Value |
|---|---|
| Type | float |
| Default | 1.3 |
| Range | >= 1.0 |
hgrad=1.0: No size variation allowedhgrad=1.3: Default, allows 30% size change between adjacent edgeshgrad=2.0: Large size variations allowed
Geometric Parameters¶
hausd¶
Hausdorff distance, maximum distance between input and output geometry.
| Property | Value |
|---|---|
| Type | float |
| Default | 0.01 * bounding box diagonal |
| Range | > 0 |
Smaller values produce a closer geometric approximation at the cost of more elements.
ar¶
Ridge detection angle (degrees).
| Property | Value |
|---|---|
| Type | float |
| Default | 45.0 |
| Range | 0 - 180 |
- Edges with dihedral angle greater than
arare treated as ridges and preserved during remeshing. ar=180disables ridge detection.
Control Flags¶
optim¶
Enable optimization mode (no topology changes).
| Property | Value |
|---|---|
| Type | int |
| Default | 0 |
| Values | 0 (off), 1 (on) |
When enabled, only moves vertices to improve quality.
noinsert¶
Disable vertex insertion.
| Property | Value |
|---|---|
| Type | int |
| Default | 0 |
| Values | 0 (off), 1 (on) |
Prevents adding new vertices during remeshing.
noswap¶
Disable edge/face swapping.
Prevents topology changes via edge/face swaps.
nomove¶
Disable vertex movement.
Keeps vertices at their original positions.
nosurf¶
Preserve surface vertices.
Prevents modification of surface mesh vertices.
Output Control¶
verbose¶
Verbosity level.
| Property | Value |
|---|---|
| Type | int |
| Default | 1 |
| Range | -1 to 10 |
silent = mesh.mmg.remesh(verbose=-1) # Silent
errors = mesh.mmg.remesh(verbose=0) # Errors only
info = mesh.mmg.remesh(verbose=1) # Standard info
debug = mesh.mmg.remesh(verbose=5) # Debug output
Common Combinations¶
Quality optimization only¶
Or use the convenience method:
Uniform remeshing¶
Or use the convenience method:
High-quality surface approximation¶
remeshed = mesh.mmg.remesh(
hmax=0.1,
hausd=0.0001, # Tight geometric tolerance
hgrad=1.1, # Smooth size transition
)
Preserve sharp features¶
Fast coarse remeshing¶
Volume interior only¶
Parameter Interactions¶
| Parameters | Effect |
|---|---|
optim=1, noinsert=1 |
Quality optimization only |
hmin=hmax |
Near-uniform sizing |
hausd small + hmax large |
More elements on surface |
ar=180 |
No ridge preservation |
hgrad=1.0 |
No size gradation |
Best Practices¶
- Start with defaults, MMG auto-computes reasonable values.
- Set
hmaxfirst, it is the most important parameter. - Add
hausdfor surfaces, it controls geometric fidelity. - Tune
hgrad, lower values give smoother transitions. - Use
verbose=-1for batch processing. - Validate results with
dataset.mmg.validate(detailed=True)after remeshing.