Mondaic

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()

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.

Parameters
  • filename pathlib.Path | str — Path to the mesh file or directory (in the case of a ChunkedMesh).
Returns type[ChunkedMesh | UnstructuredMesh | Mesh] — The class type corresponding to the mesh type.

is_mesh_file()

def is_mesh_file(filename: pathlib.Path | str) -> bool: ...

Check if a file is a valid Salvus Mesh file.

Parameters
  • filename pathlib.Path | str — Path to the mesh file.
Returns bool — True if the file is a valid Mesh file, False otherwise.

is_unstructured_mesh_file()

def is_unstructured_mesh_file(filename: pathlib.Path | str) -> bool: ...

Check if a file is a valid Salvus UnstructuredMesh file.

Parameters
  • filename pathlib.Path | str — Path to the mesh file.
Returns bool — True if the file is a valid UnstructuredMesh file, False otherwise.

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.

Parameters
  • filename pathlib.Path | str — Path to the HDF5 file.
Returns int — The spatial dimension of the mesh.

visco_params_in_file()

def visco_params_in_file(filename: pathlib.Path | str) -> bool: ...

Check if a mesh file contains visco material parameters.

Parameters
  • filename pathlib.Path | str — Path to the mesh file.
Returns bool — True if the file contains visco material parameters, False otherwise.

Classes

MeshBlockLike

class 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

class MeshLike(typing.Protocol):
    def __init__(self):
        ...

Protocol for operations on block-based meshes.

Mesh and ChunkedMesh implement this protocol.

Methods
to_mesh()
def to_mesh(self) -> Mesh: ...

Convert to a block-based Mesh.

Returns Mesh
to_unstructured_mesh()
def to_unstructured_mesh(self) -> UnstructuredMesh: ...

Convert to an UnstructuredMesh.

Returns UnstructuredMesh