[Feature]: Should mesh conversion include pre-checks or automatic repair for tetrahedralization?
What feature or enhancement are you proposing?
The current tetrahedralization function in genesis/utils/mesh.py directly passes the mesh to tetgen without any prior validity check:
def tetrahedralize_mesh(mesh, tet_cfg):
# Importing pyvista and tetgen are very slow and not used very often. Let's delay import.
import pyvista as pv
import tetgen
pv_obj = pv.PolyData(
mesh.vertices, np.concatenate([np.full((mesh.faces.shape[0], 1), mesh.faces.shape[1]), mesh.faces], axis=1)
)
tet = tetgen.TetGen(pv_obj)
# Build and apply the switches string directly, since
# the Python wrapper sometimes ignores certain kwargs
# (e.g. maxvolume). See: https://github.com/pyvista/tetgen/issues/24
switches = make_tetgen_switches(tet_cfg)
verts, elems = tet.tetrahedralize(switches=switches)
# visualize_tet(tet, pv_obj, show_surface=False, plot_cell_qual=False)
return verts, elems
Motivation
While investigating issue #1093, I found that the provided test.obj file was not watertight (had 3270 boundary edges) and consisted of many disconnected components. This caused the tetrahedralization to fail silently or with unclear error messages. This raises an important question: Should Genesis perform automatic mesh validity checks (or even repairs) before attempting FEM/MPM simulation setup?
Potential Benefit
Improved usability
What is the expected outcome of the implementation work?
- Users will receive clear, actionable error messages
Additional information
No response
This raises an important question: Should Genesis perform automatic mesh validity checks (or even repairs) before attempting FEM/MPM simulation setup?
We already do in some context. See convex decomposition. But it is very minimalistic. It should be at least able to properly diagnose the issue, if we cannot solve it.