Wiki

Clone wiki

mshr / FAQ

Mshr FAQ

Preserve surface during meshing

To do this, use the Tetgen backend and set parameters["preserve_surface"] = True.

#!python
from mshr import *

# Load surface from file
geometry = Surface3D("filename.off")
domain = CSGCGALDomain3D(geometry)

generator = TetgenMeshGenerator3D(domain)
generator.parameters["preserve_surface"] = True
generator.parameters["mesh_resolution"] = 10

mesh = generator.generate()

Note that while this is also possible with CSG geometries the triangulation of the of the surface will typically not be of good quality.

Setting parameters["mesh_resolution"] will affect the max cell volume requested from Tetgen and may result in badly shaped tetrahedrons since the surface can not be refined.

Updated