ogstools.mesh package#

ogstools.mesh.depth(mesh, top_mesh, vertical_axis=None)[source]#

Returns the depth values of the mesh.

Computes the distance between each point of mesh and top_mesh along the vertical_axis. Uses linear interpolation to interpolate in between points of top_mesh.

Parameters:
  • mesh (UnstructuredGrid) – Mesh at the points of which the depth is computed.

  • top_mesh (UnstructuredGrid) – The mesh which defines the vertical boundary.

  • vertical_axis (int | Literal['x', 'y', 'z'] | None) – If not given: For 3D, the z-axes is used. For 2D, the last axis of the plane wherein the mesh is lying is used (i.e. y if the mesh is in the xy-plane; z if it is in the xz-plane).

Return type:

ndarray

ogstools.mesh.difference(base_mesh, subtract_mesh, variable=None)[source]#

Compute the difference of variables between two meshes.

Parameters:
  • base_mesh (UnstructuredGrid) – The mesh to subtract from.

  • subtract_mesh (UnstructuredGrid) – The mesh whose data is to be subtracted.

  • variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.

Returns:

A new mesh containing the difference of variable or of all datasets between both meshes.

Return type:

UnstructuredGrid

ogstools.mesh.difference_matrix(meshes_1, meshes_2=None, variable=None)[source]#

Compute the difference between all combinations of two meshes from one or two arrays based on a specified variable.

Parameters:
  • meshes_1 (ndarray[tuple[int, ...], dtype[UnstructuredGrid]]) – The first list/array of meshes to be subtracted from.

  • meshes_2 (ndarray[tuple[int, ...], dtype[UnstructuredGrid]] | None) – The second list/array of meshes, it is subtracted from the first list/array of meshes - meshes_1 (optional).

  • variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.

Returns:

An array of meshes containing the differences of variable or all datasets between meshes_1 and meshes_2 for all possible combinations.

Return type:

ndarray

ogstools.mesh.difference_pairwise(meshes_1, meshes_2, variable=None)[source]#

Compute pairwise difference between meshes from two lists/arrays (they have to be of the same length).

Parameters:
  • meshes_1 (ndarray[tuple[int, ...], dtype[UnstructuredGrid]]) – The first list/array of meshes to be subtracted from.

  • meshes_2 (ndarray[tuple[int, ...], dtype[UnstructuredGrid]]) – The second list/array of meshes whose data is subtracted from the first list/array of meshes - meshes_1.

  • variable (Variable | str | None) – The variable of interest. If not given, all point and cell_data will be processed raw.

Returns:

An array of meshes containing the differences of variable or all datasets between meshes_1 and meshes_2.

Return type:

ndarray

ogstools.mesh.from_simulator(simulation, name, node_properties=None, cell_properties=None, field_properties=None)[source]#

Constructs a pyvista mesh from a running simulation. It always contains points (geometry) and cells (topology) and optionally the given node-based or cell-based properties Properties must be added afterwards

param simulator:

Initialized and not finalized simulator object

param name:

Name of the submesh (e.g. domain, left, … )

param node_properties:

Given properties will be added to the mesh None or [] -> no properties will be added

param cell_properties:

Given properties will be added to the mesh None or [] -> no properties will be added

returns:

A Mesh (Pyvista Unstructured Grid) object

Return type:

UnstructuredGrid

ogstools.mesh.ip_data_threshold(mesh, value, scalars='MaterialIDs', invert=False)[source]#

Filters integration point data to match the threshold criterion.

Similar to pyvista’s threshold filter, but only acting on the field data and returning the modified field data dict.

Parameters:
  • mesh (UnstructuredGrid) – original mesh, needs to contain MaterialIDs and IntegratioPointMetaData.

  • value (int | Sequence[int]) – Single value or (min, max) to be used for the threshold. If a sequence, then length must be 2. If single value, it is used as the lower bound and selecting everything above.

  • scalars (str) – Name of data to threshold on.

  • invert (bool) – Invert the threshold results

Return type:

dict[str, ndarray]

ogstools.mesh.ip_metadata(mesh)[source]#

return the IntegrationPointMetaData in the mesh’s field_data as a dict.

Return type:

list[dict[str, Any]]

ogstools.mesh.read(filename)[source]#

Read a single mesh from a filepath.

Return type:

UnstructuredGrid

ogstools.mesh.save(filename, mesh, **kwargs)[source]#

Save mesh to file.

Supported are all file formats pyvista supports. In case you want to save as a vtu-file and the given mesh is not a pv.UnstructuredGrid it is cast to one prior to saving.

Parameters:
  • filename (Path | str) – Filename to save the mesh to

  • mesh (DataSet) – pyvista mesh

ogstools.mesh.to_ip_mesh(mesh)[source]#

Create a mesh with cells centered around integration points.

Return type:

UnstructuredGrid

ogstools.mesh.to_ip_point_cloud(mesh)[source]#

Convert integration point data to a pyvista point cloud.

Return type:

UnstructuredGrid

Subpackages#

Submodules#