ogstools.meshlib.meshes module#
- class ogstools.meshlib.meshes.Meshes[source]#
Bases:
object
OGS input mesh. Refers to prj - file section <meshes>
- Initialize a Meshes object.
- param meshes:
List of Mesh objects (pyvista UnstructuredGrid) The first mesh is the domain mesh. All following meshes represent subdomains, and their points must align with points on the domain mesh. If needed, the domain mesh itself can also be added again as a subdomain.
- returns:
A Meshes object
- __init__(meshes)[source]#
- Initialize a Meshes object.
- param meshes:
List of Mesh objects (pyvista UnstructuredGrid) The first mesh is the domain mesh. All following meshes represent subdomains, and their points must align with points on the domain mesh. If needed, the domain mesh itself can also be added again as a subdomain.
- returns:
A Meshes object
- classmethod from_gmsh(filename, dim=0, reindex=True, log=True, meshname='domain')[source]#
Generates pyvista unstructured grids from a gmsh mesh (.msh).
Extracts domain-, boundary- and physical group-submeshes.
- Parameters:
filename (Path) – Gmsh mesh file (.msh) as input data
dim (int | list[int]) – Spatial dimension (1, 2 or 3), trying automatic detection, if not given. If multiple dimensions are provided, all elements of these dimensions are embedded in the resulting domain mesh.
reindex (bool) – Physical groups / regions / Material IDs to be renumbered consecutively beginning with zero.
log (bool) – If False, silence log messages
meshname (str) – The name of the domain mesh and used as a prefix for subdomain meshes.
- Returns:
A dictionary of names and corresponding meshes
- Return type:
- classmethod from_mesh(mesh, threshold_angle=15.0, domain_name='domain')[source]#
Extract 1D boundaries of a 2D mesh.
- Parameters:
mesh (UnstructuredGrid) – The 2D domain
threshold_angle (float | None) – If None, the boundary will be split by the assumption of vertical lateral boundaries. Otherwise it represents the angle (in degrees) between neighbouring elements which - if exceeded - determines the corners of the boundary mesh.
domain_name (str) – The name of the domain mesh.
- Returns:
A Meshes object.
- Return type:
- values()[source]#
Get all Mesh objects (pyvista.UnstructuredGrid).
- Returns:
All Mesh objects
- Return type:
ValuesView[Mesh]
- items()[source]#
Get all meshnames-Mesh pairs.
Each item is a tuple of (name, Mesh)
- Returns:
All (name, Mesh) pairs
- Return type:
ItemsView[str, Mesh]
- pop(key)[source]#
Remove a mesh by name and return it.
This removes the mesh from the internal dictionary.
- Parameters:
key (str) – The name of the mesh to remove
- Returns:
The Mesh object that was removed
- Return type:
- domain()[source]#
Get the domain mesh.
By convention, the domain mesh is the first mesh in the dictionary of meshes when the Meshes object was constructed. The domain mesh is expected to be constant. e.g. Do not: myobject.domain = pv.Sphere()
- Returns:
The domain mesh
- Return type:
- domain_name()[source]#
Get the name of the domain mesh.
By convention, the domain mesh is the first mesh in the dictionary of meshes when the Meshes object was constructed.
- Returns:
The name of the domain mesh
- Return type:
str
- subdomains()[source]#
Get the subdomain meshes.
By convention, all meshes except the first one are considered subdomains. This returns a list of those subdomain meshes.
- Returns:
A dictionary of {name: Mesh} for all subdomains
- Return type:
dict[str, Mesh]
- save(meshes_path=None, overwrite=False)[source]#
Save all meshes.
This function will perform identifySubdomains, if not yet been done.
- Parameters:
meshes_path (Path | None) – Optional path to the directory where meshes should be saved. If None, a temporary directory will be used.
overwrite (bool) – If True, existing mesh files will be overwritten. If False, an error is raised if any file already exists.
- Returns:
A list of Paths pointing to the saved mesh files
- Return type:
list[Path]