ogstools.meshlib package#

class ogstools.meshlib.Surface[source]#

Bases: object

A surface is a sub group of a polygon mesh (2D). A surface is not closed and therefore does not represent a volume. (Geological) layers (stratigraphic units) can be defined by an upper and lower surface. By convention, properties (material_id and resolution ), actually associated to the stratigraphic unit layer, are given together with the lower boundary (class Surface) of a stratigraphic unit (class Layer).

Initialize a surface mesh. Either from pyvista or from a file.

property material_id: int#
__init__(input, material_id)[source]#

Initialize a surface mesh. Either from pyvista or from a file.

Parameters:
  • input (Path | DataSet) –

  • material_id (int) –

create_raster_file(resolution)[source]#

Creates a raster file specific to resolution. If outfile is not specified, the extension is replaced by .asc

:returns the path and filename of the created file (.asc)

Parameters:

resolution (float) –

Return type:

Path

class ogstools.meshlib.Layer[source]#

Bases: Boundary

Layer(top: ogstools.meshlib.boundary_subset.Surface, bottom: ogstools.meshlib.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.

Args:

resolution (float): The resolution for raster creation.

Returns:

list[Path]: A list of filenames to .asc raster files.

Parameters:

resolution (float) –

Return type:

list[Path]

dim()[source]#

Get the dimension of the boundary.

Returns:

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

__init__(top, bottom, material_id=0, num_subdivisions=0)#
Parameters:
  • top (Surface) –

  • bottom (Surface) –

  • material_id (int) –

  • num_subdivisions (int) –

Return type:

None

class ogstools.meshlib.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)#
Parameters:
Return type:

None

as_vtu(outfilevtu)[source]#

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

Args:

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

Returns:

Path: The path to the saved VTK unstructured grid representation.

Parameters:

outfilevtu (Path) –

Return type:

Path

class ogstools.meshlib.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.

Args:

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

Returns:

None

Parameters:

filename (Path) –

__init__(xmin, xmax, ymin, ymax)#
Parameters:
  • xmin (float) –

  • xmax (float) –

  • ymin (float) –

  • ymax (float) –

Return type:

None

class ogstools.meshlib.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).

abstract dim()[source]#

Get the dimension of the boundary.

Returns:

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

class ogstools.meshlib.MeshSeries[source]#

Bases: object

A wrapper around pyvista and meshio for reading of pvd and xdmf timeseries.

Will be replaced by own module in ogstools with similar interface.

__init__(filepath)[source]#
Parameters:

filepath (str | Path) –

Return type:

None

read(timestep, lazy_eval=True)[source]#

Lazy read function.

Parameters:
  • timestep (int) –

  • lazy_eval (bool) –

Return type:

UnstructuredGrid

clear()[source]#
Return type:

None

property timesteps: range#

Return the timesteps of the timeseries data.

property timevalues: list[float]#

Return the timevalues of the timeseries data.

closest_timestep(timevalue)[source]#

Return the corresponding timestep from a timevalue.

Parameters:

timevalue (float) –

Return type:

int

closest_timevalue(timevalue)[source]#

Return the closest timevalue to a timevalue.

Parameters:

timevalue (float) –

Return type:

float

read_closest(timevalue)[source]#

Return the closest timestep in the data for a given timevalue.

Parameters:

timevalue (float) –

Return type:

UnstructuredGrid

read_interp(timevalue, lazy_eval=True)[source]#

Return the temporal interpolated mesh for a given timevalue.

Parameters:
  • timevalue (float) –

  • lazy_eval (bool) –

Return type:

UnstructuredGrid

class ogstools.meshlib.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).

Parameters:

layers (list[Layer]) –

bounds()[source]#
filenames()[source]#
classmethod from_pandas(df)[source]#

Create a LayerSet from a Pandas DataFrame.

Parameters:

df (DataFrame) –

create_raster(resolution)[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.

create_rasters(resolution)[source]#

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

Parameters:

resolution (int) –

Return type:

list[Path]

ogstools.meshlib.rect(lengths=1.0, n_edge_cells=1, structured_grid=True, order=1, out_name=Path('unit_square.msh'))[source]#
Parameters:
  • lengths (float | list[float]) –

  • n_edge_cells (int | list[int]) –

  • structured_grid (bool) –

  • order (int) –

  • out_name (Path) –

ogstools.meshlib.cuboid(lengths=1.0, n_edge_cells=1, structured_grid=True, order=1, out_name=Path('unit_cube.msh'))[source]#
Parameters:
  • lengths (float | list[float]) –

  • n_edge_cells (int | list[int]) –

  • structured_grid (bool) –

  • order (int) –

  • out_name (Path) –

Subpackages#

Submodules#