salvus.mesh.data_structures.common
salvus.mesh.data_structures.common salvus mesh data_structures common Common operations on data structures for Salvus Mesh.
Functions
distinguish_mesh_path()
distinguish_mesh_path()def distinguish_mesh_path(
filename: pathlib.Path | str,
) -> type[ChunkedMesh | UnstructuredMesh | Mesh]: ...Distinguish between mesh types based on file contents.
Useful when a path is given and the mesh type is unknown.
filenamepathlib.Path | str — Path to the mesh file or directory (in the case of a ChunkedMesh).
is_mesh_file()
is_mesh_file()def is_mesh_file(filename: pathlib.Path | str) -> bool: ...Check if a file is a valid Salvus Mesh file.
filenamepathlib.Path | str — Path to the mesh file.
is_unstructured_mesh_file()
is_unstructured_mesh_file()def is_unstructured_mesh_file(filename: pathlib.Path | str) -> bool: ...Check if a file is a valid Salvus UnstructuredMesh file.
filenamepathlib.Path | str — Path to the mesh file.
read_dim_from_h5()
read_dim_from_h5()def read_dim_from_h5(filename: pathlib.Path | str) -> int: ...Read the spatial dimension of a mesh from an HDF5 file.
filenamepathlib.Path | str — Path to the HDF5 file.
visco_params_in_file()
visco_params_in_file()def visco_params_in_file(filename: pathlib.Path | str) -> bool: ...Check if a mesh file contains visco material parameters.
filenamepathlib.Path | str — Path to the mesh file.
Classes
MeshBlockLike
MeshBlockLikeclass MeshBlockLike(typing.Protocol):
def __init__(self):
...Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]):
def meth(self) -> T:
...MeshLike
MeshLikeclass MeshLike(typing.Protocol):
def __init__(self):
...Protocol for operations on block-based meshes.
Mesh and ChunkedMesh implement this protocol.
to_mesh()
to_mesh()def to_mesh(self) -> Mesh: ...Convert to a block-based Mesh.
to_unstructured_mesh()
to_unstructured_mesh()def to_unstructured_mesh(self) -> UnstructuredMesh: ...Convert to an UnstructuredMesh.