PyMeshIt: An open-source geological solid modeling and tetrahedral meshing engine integrated in PZero
Abstract. Volumetric mesh generation from surface-based geological models is a fundamental preprocessing step for numerical simulation of subsurface processes including fluid flow, heat transport, and deformation, with applications spanning geothermal energy, groundwater modeling and management, underground facility design, slope stability and hazard modeling, carbon sequestration and hydrocarbon reservoirs. To convert a surface-based geomodel into a volumetric mesh, build a watertight Piecewise Linear Complex (PLC) of the geological model as input to boundary-conforming meshing kernels to guarantee geometry-consistent tetrahedralization. Discretization remains challenging because geological models contain internal intersecting discontinuities, concave boundaries, folded or overturned surfaces, and geological attributes such as stratigraphic and structural identifiers and boundary condition tags that must be preserved during the meshing stage.
We present PyMeshIt, an open-source Python implementation and extension of the C++ MeshIt meshing engine (Cacace and Blöcher 2015), developed to generate watertight PLCs and tetrahedral meshes for complex geological models. PyMeshIt is developed to be used either as a standalone meshing software or as a modeling engine integrated into the open-source PZero geological modeling framework, a platform for 3D structural interpretation and modeling (Bistacchi et al. 2021). The internal architecture of PyMeshIt splits the meshing process into several sequential stages: geometric preprocessing, hull construction, primary surface generation and interpolation, intersection resolution into a consistent PLC, and a final constrained tetrahedralization.
A central technical contribution in PyMeshIt is the preservation and recovery of facet identity through the Python- TetGen interface, enabling exact extraction of fault and boundary triangle sets from the final volumetric mesh that can be input to the later numerical simulation stages (e.g., to be used to impose boundary conditions). To define boundary objects, PyMeshIt combines adaptive alpha-shape extraction for concave but projection-compatible surfaces, a 3D angular gap method for raw folded point clouds where projection-based hull algorithms fail, and a mesh-connectivity- based boundary extraction for pre-triangulated surfaces and already triangulated surfaces imported from PZero, with respect to MeshIt. We tested PyMeshIt on multiple synthetic benchmarks and five real case studies, reporting element counts and mesh quality metrics, and compared the outcomes against the original C++ implementation of MeshIt. Results demonstrate that PyMeshIt extends the original MeshIt workflow from faulted reservoir geometries to more complex folded geological models while maintaining controllable per-surface resolution, PLC consistency, and simulation-ready geological attribution. We additionally discuss the main limitations of the current implementation when dealing with very tight folds in the raw point-cloud pathway, where k-nearest-neighbour graphs used for Isomap may create cross-limb shortcuts; for such cases, pre-triangulated PZero surfaces with topology-derived boundaries currently provide a more robust alternative.