ogstools.meshlib.region package#

ogstools.meshlib.region.to_region_prism(layer_set, resolution)[source]#

Convert a layered geological structure into a RegionSet using prism meshing.

This function takes a boundary_set.LayerSet and converts it into a region.RegionSet object using prism or tetrahedral meshing technique. The function will use prism elements for meshing if possible; otherwise, it will use tetrahedral elements.

Parameters:

layer_set (LayerSet): A boundary_set.LayerSet. resolution (float): The desired resolution in [meter] for meshing. It must greater than 0.

Returns:

RegionSet: A boundary_set.LayerSet object containing the meshed representation of the geological structure.

Raises:

ValueError: If an error occurs during the meshing process.

Example:

layer_set = LayerSet(…) resolution = 0.1 region_set = to_region_prism(layer_set, resolution)

Return type:

RegionSet

ogstools.meshlib.region.to_region_simplified(layer_set, xy_resolution, rank)[source]#

Convert a layered geological structure to a simplified meshed region.

This function converts a layered geological structure represented by a LayerSet into a simplified meshed region using the specified xy_resolution and rank.

Parameters:
  • (LayerSet) (layer_set) – A LayerSet object representing the layered geological structure.

  • (float) (xy_resolution) – The desired spatial resolution of the mesh in the XY plane.

  • (int) (rank) – The rank of the mesh (2 for 2D, 3 for 3D).

Return type:

RegionSet

Returns:

RegionSet: A RegionSet object containing the simplified meshed representation of the geological structure.

Raises:

AssertionError: If the length of the bounds retrieved from the layer_set is not 6.

Example:

layer_set = LayerSet(…) xy_resolution = 0.1 # Example resolution in XY plane rank = 2 # Mesh will be 2D region_set = to_region_simplified(layer_set, xy_resolution, rank)

ogstools.meshlib.region.to_region_tetraeder(layer_set, resolution)[source]#
Return type:

RegionSet

ogstools.meshlib.region.to_region_voxel(layer_set, resolution)[source]#

Convert a layered geological structure to a voxelized mesh.

This function converts a layered geological structure represented by a LayerSet into a voxelized mesh using the specified resolution.

Parameters:

layer_set (LayerSet): A LayerSet object representing the layered geological structure. resolution (list): A list of [x_resolution, y_resolution, z_resolution] for voxelization.

Returns:

Mesh: A Mesh object containing the voxelized mesh representation of the geological structure.

Raises:

ValueError: If an error occurs during the voxelization process.

Example:

layer_set = LayerSet(…) resolution = [0.1, 0.1, 0.1] # Example voxelization resolutions in x, y, and z dimensions voxel_mesh = to_region_voxel(layer_set, resolution)

Return type:

RegionSet

class ogstools.meshlib.region.RegionSet[source]#

Bases: object

A class representing a set of regions composed of subsets, each identified by MaterialID.

The RegionSet class represents a collection of regions, where each region is composed of subsets. Each subset within a region is uniquely identified by “MaterialID”.

__init__(input)[source]#
box_boundaries()[source]#

Retrieve the boundaries of the mesh in local coordinate system (u, v, w).

This function extracts the boundaries of the mesh along the u, v, and w directions of the local coordinate system. The u-axis corresponds to the x-coordinate, the v-axis corresponds to the y-coordinate, and the w-axis corresponds to the z-coordinate.

Returns:

tuple: A tuple (u_min, u_max, v_min, v_max, w_min, w_max) representing the boundaries of the mesh in the local coordinate system.

Notes:
Example:

mesh = … u_min, u_max, v_min, v_max, w_min, w_max = mesh.box_boundaries()

Return type:

tuple[UnstructuredGrid, …]

ogstools.meshlib.region.to_boundary(surface_mesh, filter_condition)[source]#

Extract cells from a surface mesh that meet a filter condition for normals.

This function takes a surface mesh represented by a pv.PolyData object and extracts cells that match a specified filter condition based on the normals of the mesh.

Parameters:
  • surface_mesh (PolyData) – The input surface mesh.

  • filter_condition (Callable[[ndarray], ndarray]) – A callable filter condition that takes an array of normals as input and returns an array indicating whether the condition is met.

Return type:

UnstructuredGrid

Returns:

pv.UnstructuredGrid: A mesh containing only the cells that meet the filter condition.

Example:

surface_mesh = … specific_cells = to_boundary(surface_mesh, lambda normals: [n[2] > 0.5 for n in normals])

Submodules#