meshlib#
Overview#
ogstools.mesh is a collection of utilities built around PyVista
UnstructuredGrid objects — so the entire PyVista
ecosystem (visualization, slicing, probing, format export) works out of the box. ogstools.mesh
adds only what PyVista doesn’t know about: OGS data conventions, validation, integration point
data, and layer-based mesh creation.
For creating meshes from scratch, ogstools.gmsh_tools wraps the
Gmsh Python API and exposes it with
OGS-ready defaults (material IDs, boundary groups).
API references: ogstools.mesh package · ogstools.gmsh_tools package
What makes an OGS mesh special#
An OGS mesh is presented as pv.UnstructuredGrid that carries several OGS-specific data arrays:
Name |
Location |
dtype |
Purpose |
|---|---|---|---|
|
|
|
Labels every element with a material zone; used by OGS to apply material parameters and boundary conditions |
|
|
|
On boundary/sub-meshes: links back to the element in the parent bulk mesh |
|
|
|
On boundary/sub-meshes: links back to the node in the parent bulk mesh |
integration point arrays |
|
|
Stress, strain, or other constitutive quantities at Gauss points inside each element |
|
|
JSON bytes |
Describes each IP array: integration order and number of components |
Creating meshes#
Simple geometries — ogstools.gmsh_tools#
rect() and cuboid() wrap the Gmsh Python API
to produce structured or unstructured 2D/3D meshes with MaterialIDs per layer and named boundary
physical groups ("top", "bottom", "left", "right") ready for OGS boundary conditions.
remesh_with_triangles() converts an existing quad mesh to triangles.
Layered geological domains — ogstools.mesh.create#
Surface → Layer → LayerSet → .to_region_prism() / .to_region_voxel() /
.to_region_tetrahedron(). Surfaces can be PyVista meshes or VTU
files. MaterialIDs are propagated automatically from each Surface.
API: ogstools.mesh.create package ·
ogstools.mesh.create.boundary_set module (LayerSet) ·
ogstools.mesh.create.boundary module (Layer) ·
ogstools.mesh.create.boundary_subset module (Surface, Gaussian2D)
Reading, validating, and saving#
read wraps pv.read()
and returns a pv.UnstructuredGrid. save additionally strips NaN arrays and syncs
IntegrationPointMetaData. validate calls the OGS
checkMesh tool; node_reordering
fixes element node ordering for OGS6 compliance.
API: ogstools.mesh.file_io module · ogstools.mesh.utils module
Integration point data#
After a simulation, material constitutive quantities (stress and strain tensors, damage variables,
…) are stored at Gauss integration points — one value per integration point per element, not per
node. OGS encodes this in mesh.field_data as flat arrays plus a JSON metadata block
(IntegrationPointMetaData) that records the integration order and component count for each array.
IPdata provides dict-like access to these arrays. to_ip_mesh() and to_ip_point_cloud()
build visualizable meshes by tessellating each element around its integration points, making the
data explorable in PyVista or ParaView.
API: ogstools.mesh.ip_data module (IPdata, ip_metadata) ·
ogstools.mesh.ip_mesh module (to_ip_mesh, to_ip_point_cloud, ip_data_threshold)
Mesh comparison and geometric utilities#
difference(base, subtract)— subtracts data arrays between two meshes element-by-element; resamples automatically when topologies differ.depth(mesh, top_mesh)— interpolates and returns a depth-below-surface scalar from a reference surface mesh.from_simulator(simulation, ...)— extracts a live mesh from a running OGS co-simulation via the OGS Python bindings.
API: ogstools.mesh.differences module · ogstools.mesh.geo module · ogstools.mesh.cosim module