ogstools.mesh.create.boundary module#

class ogstools.mesh.create.boundary.Boundary[source]#

Bases: ABC

Abstract base class representing a boundary within a mesh.

A boundary refers to the set of edges or faces that defines the delineation between the interior region and exterior regions of a mesh. In a 2D mesh, it is formed by a closed collection of line segments (1D). In a 3D mesh, it is formed by a closed collection of faces (2D).

abstractmethod dim()[source]#

Get the dimension of the boundary.

Return type:

int

Returns:

The dimension of the boundary. For example, the dimension of a boundary of a cube (3D) is 2.

class ogstools.mesh.create.boundary.Layer[source]#

Bases: Boundary

Layer(top: ogstools.mesh.create.boundary_subset.Surface, bottom: ogstools.mesh.create.boundary_subset.Surface, material_id: int = 0, num_subdivisions: int = 0)

top: Surface#
bottom: Surface#
material_id: int = 0#
num_subdivisions: int = 0#

Class representing a geological layer with top and bottom surfaces.

A geological layer is a distinct unit of rock or sediment that has unique properties and characteristics, associated by the material_id. It is often bounded by two surfaces: the top surface and the bottom surface. These surfaces delineate the spatial extent of the layer in the GIS system.

create_raster(resolution)[source]#

Create raster representations for the layer.

For each surface, including intermediate surfaces (num_of_subdivisions > 0), this method generates .asc files.

Parameters:

resolution (float) – The resolution for raster creation.

Return type:

list[Path]

Returns:

A list of filenames to .asc raster files.

dim()[source]#

Get the dimension of the boundary.

Return type:

int

Returns:

The dimension of the boundary. For example, the dimension of a boundary of a cube (3D) is 2.

to_simplified_mesh(resolution, rank, bounds)[source]#

Convert a geological layer to a simplified mesh.

This function converts a geological layer into a simplified mesh using the specified resolution, rank, and bounding bounds.

Parameters:
  • resolution (float) – The desired spatial resolution of the mesh in units of the geological structure. Be cautious with very high resolutions, as they may lead to distorted or incomplete meshes, making them unsuitable for further analysis.

  • rank (int) – The rank of the mesh (2 for 2D, 3 for 3D). The mesh dimensionality must be consistent with the provided bounds.

  • bounds (list[float]) – A list of bounding values [min_x, max_x, min_y, max_y] for 2D mesh or [min_x, max_x, min_y, max_y, min_z, max_z] for 3D mesh. The bounds define the region of the geological structure that will be meshed.

Return type:

UnstructuredGrid

Returns:

A simplified unstructured grid mesh representing the layer.

raises:

Exception: If the specified rank is not 2 or 3, indicating an invalid mesh dimensionality.

example:

layer = … resolution = 1.5 # Example resolution in geological units rank = 2 # Mesh will be 2D bounds = [0, 10, 0, 10] # Bounding box [min_x, max_x, min_y, max_y] mesh = layer.to_simplified_mesh(layer, resolution, rank, bounds)

__init__(top, bottom, material_id=0, num_subdivisions=0)#
class ogstools.mesh.create.boundary.LocationFrame[source]#

Bases: object

LocationFrame(xmin: float, xmax: float, ymin: float, ymax: float)

xmin: float#
xmax: float#
ymin: float#
ymax: float#
as_gml(filename)[source]#

Generate GML representation of the location frame.

Parameters:

filename (Path) – The filename to save the GML representation to.

Return type:

None

Returns:

None

__init__(xmin, xmax, ymin, ymax)#
class ogstools.mesh.create.boundary.Raster[source]#

Bases: object

Class representing a raster representation of a location frame.

This class provides methods to create and save a raster representation based on a specified location frame and resolution.

frame: LocationFrame#
resolution: float#
__init__(frame, resolution)#
as_vtu(outfilevtu)[source]#

Create and save a raster representation as a VTK unstructured grid.

Parameters:

outfilevtu (Path) – The path to save the VTK unstructured grid.

Return type:

Path

Returns:

The path to the saved VTK unstructured grid representation.