ogstools.mesh.create.boundary_set module#

class ogstools.mesh.create.boundary_set.BoundarySet[source]#

Bases: ABC

Abstract base class representing a collection of boundaries with constraints.

A BoundarySet is composed of multiple boundaries linked with constraints: - Free of gaps and overlaps. - Distinguished by markers to identify different boundaries. - Adherence to rules of piecewise linear complex (PLC).

abstractmethod bounds()[source]#
Return type:

list

abstractmethod filenames()[source]#
Return type:

list[Path]

class ogstools.mesh.create.boundary_set.LayerSet[source]#

Bases: BoundarySet

Collection of geological layers stacked to represent subsurface arrangements.

In a geological information system, multiple layers can be stacked vertically to represent the subsurface arrangement. This class provides methods to manage and work with layered geological data.

Initializes a LayerSet. It checks if the list of provided layers are given in a top to bottom order. In neighboring layers, layers share the same surface (upper bottom == low top).

__init__(layers)[source]#

Initializes a LayerSet. It checks if the list of provided layers are given in a top to bottom order. In neighboring layers, layers share the same surface (upper bottom == low top).

bounds()[source]#
Return type:

list

filenames()[source]#
Return type:

list[Path]

classmethod from_pandas(df)[source]#

Create a LayerSet from a Pandas DataFrame.

Return type:

LayerSet

create_raster(resolution, margin=0.0)[source]#

Create raster representations for the LayerSet.

This method generates raster files at a specified resolution for each layer’s top and bottom boundaries and returns paths to the raster files.

Parameters:
  • resolution (float) – The resolution for raster creation.

  • margin (float) – ratio by which to shrink the raster boundary (0.01 == 1%)

Return type:

tuple[Path, Path]

create_rasters(resolution)[source]#

For each surface a (temporary) raster file with given resolution is created.

Parameters:

resolution (float) – The resolution for raster creation.

Return type:

list[Path]

refine(factor)[source]#

Refine the LayerSet by increasing the number of subdivisions.

This function refines the LayerSet by increasing the number of subdivisions in each layer. The factor parameter determines the degree of refinement.

Parameters:
  • layerset – The original LayerSet to be refined.

  • factor (int) – The refinement factor for the number of subdivisions.

Return type:

LayerSet

Returns:

A new LayerSet with increased subdivisions for each layer.

to_region_prism(resolution, margin=0.0)[source]#

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

This function takes a LayerSet and converts it into a 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:
  • resolution (float) – The desired resolution in [meter] for meshing. It must greater than 0.

  • margin (float) – ratio by which to shrink the raster boundary (0.01 == 1%)

Return type:

RegionSet

Returns:

A RegionSet 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 = layer_set.to_region_prism(resolution)

to_region_simplified(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:
  • xy_resolution (float) – The desired spatial resolution of the mesh in the XY plane.

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

Return type:

RegionSet

Returns:

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 = layer_set.to_region_simplified(xy_resolution, rank)

to_region_tetrahedron(resolution, margin=0.0)[source]#

Convert a layered geological structure to a tetrahedral meshed region.

This function converts a layered geological structure represented by a LayerSet into a tetrahedral meshed region using the specified resolution.

Parameters:
  • resolution (int) – The desired resolution for meshing.

  • margin (float) – ratio by which to shrink the raster boundary (0.01 == 1%)

Return type:

RegionSet

Returns:

A RegionSet object containing the tetrahedral meshed representation of the geological structure.

raises:

ValueError: If an error occurs during the meshing process.

notes:
  • The resolution parameter determines the desired spatial resolution of the mesh.

  • The function utilizes tetrahedral meshing using Tetgen software to create the meshed representation.

  • The resulting mesh is tetrahedral, and material IDs are assigned to mesh cells based on the geological layers.

example:

layer_set = LayerSet(…) resolution = 1 # Example resolution for meshing region_set = layer_set.to_region_tetrahedron(resolution)

to_region_voxel(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:

resolution (list) – A list of [x_resolution, y_resolution, z_resolution] for voxelization.

Return type:

RegionSet

Returns:

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 = layer_set.to_region_voxel(resolution)