salvus.mesh.data_structures.distributed_mesh.distributed_mesh
salvus.mesh.data_structures.distributed_mesh.distributed_mesh salvus mesh data_structures distributed_mesh distributed_mesh The distributed mesh data structure.
Classes
DistributedMesh
DistributedMeshclass DistributedMesh(builtins.object):
def __init__(
self,
comm: int,
embedding: Mesh,
mesh: Mesh,
global_element_map: list[npt.NDArray],
dmplex: bindings.DMPlex | None,
) -> None: ...A mesh distribtuted across multiple MPI ranks.
commint — The MPI communicator.embeddingMesh — The embedding mesh.meshMesh — The local mesh on this rank.global_element_maplist[npt.NDArray] — A list mapping from rank to the global element IDs owned by that rank.dmplexbindings.DMPlex | None — The distributed DMPlex object.
all_nodal_fields set[str]
all_nodal_fields set[str]All nodal fields across all blocks.
global_element_ids_rank npt.NDArray
global_element_ids_rank npt.NDArrayThe global element ids of the elements on this rank.
global_variables dict[str, allowed_global_types]
global_variables dict[str, allowed_global_types]The global variables.
model_order int
model_order intAlias of shape_order.
nodal_fields_per_block dict[int, set[str]]
nodal_fields_per_block dict[int, set[str]]The nodal fields per block.
number_of_dimensions int
number_of_dimensions intThe number of spatial dimensions.
number_of_elements int
number_of_elements intThe total number of elements.
shape_order int
shape_order intThis mesh’s own geometric/shape order.
Same quantity as Mesh.model_order, NOT the simulation’s solution
order. The name to use for consistency across mesh formats.
side_sets tuple[SideSet, ...]
side_sets tuple[SideSet, ...]The side sets.
from_h5()
from_h5()def from_h5(path: str | pathlib.Path, comm: int) -> DistributedMesh: ...Read a distributed mesh from a directory.
This is a collective operation that must be called on all ranks of the reading communicator. Reading is only supported when the reading communicator has the same size as the communicator the mesh was written with.
pathstr | pathlib.Path — The directory containing the distributed mesh.commint — The MPI communicator to read into.
reduce_from_mesh()
reduce_from_mesh()def reduce_from_mesh(
self,
element_selection_function: collections.abc.Callable,
mesh: Mesh | None,
reduction_operations_per_field: dict[str, str],
timer: Timer | None = None,
log_to_logger: bool = False,
reentrant_timer: bool = False,
artifacts: ArtifactsFromToMesh | None = None,
) -> None: ...Reduce a mesh into the distributed mesh.
This function needs to be called on all ranks of a distributed mesh’s communicator. Each rank usually will define its own element selection function.
element_selection_functioncollections.abc.Callable — Function that takes the global element indices returns the indices to keep.meshMesh | None — The mesh to reduce from. Can be None on ranks that have no elements selected by the element selection function.reduction_operations_per_fielddict[str, str] — Dictionary mapping field names to reduction operations. Reduction operations can be “sum”, “min”, “max”, or “replace”.timerTimer | None =None— Execution timer.log_to_loggerbool =False— Whether to log timing to the logger.reentrant_timerbool =False— Whether the timer is reentrant.artifactsArtifactsFromToMesh | None =None— Optional cached intermediates from a priorto_mesh_with_artifacts()call on the same distributed mesh and selection. When given, the element selection call,discretize_blocks, andget_aperture_sfsare skipped.
to_mesh()
to_mesh()def to_mesh(
self,
element_selection_function: collections.abc.Callable,
timer: Timer | None = None,
log_to_logger: bool = False,
reentrant_timer: bool = False,
) -> Mesh | None: ...Convert to a regular Mesh by selecting elements.
It will gather the selected elements from all ranks.
This function needs to be called on all ranks of a distributed mesh’s communicator. Each rank usually will define its own element selection function.
element_selection_functioncollections.abc.Callable — Function that takes the global element indices returns the indices to keep.timerTimer | None =None— Execution timer.log_to_loggerbool =False— Whether to log timing to the logger.reentrant_timerbool =False— Whether the timer is reentrant.
to_mesh_with_artifacts()
to_mesh_with_artifacts()def to_mesh_with_artifacts(
self,
element_selection_function: collections.abc.Callable,
timer: Timer | None = None,
log_to_logger: bool = False,
reentrant_timer: bool = False,
cached_block_dms: (
list[tuple[bindings.DMPlex, bindings.DMPlex]] | None
) = None,
) -> tuple[Mesh | None, ArtifactsFromToMesh]: ...Like to_mesh but also returns cacheable intermediates.
The returned ArtifactsFromToMesh can be passed back to
reduce_from_mesh() (via its artifacts argument) on the same
distributed mesh and selection to skip redundant work.
This function needs to be called on all ranks of a distributed mesh’s communicator. Each rank usually will define its own element selection function.
element_selection_functioncollections.abc.Callable — Function that takes the global element indices and returns the indices to keep.timerTimer | None =None— Execution timer.log_to_loggerbool =False— Whether to log timing to the logger.reentrant_timerbool =False— Whether the timer is reentrant.cached_block_dmslist[tuple[bindings.DMPlex, bindings.DMPlex]] | None =None— Optional pre-computed per-block DMPlex objects from a previous call. If given, theDiscretize blocksstep is skipped.
(mesh, artifacts). mesh is None if no elements were selected on this rank.write_h5()
write_h5()def write_h5(self, path: str | pathlib.Path) -> None: ...Write the distributed mesh to a directory.
This is a collective operation that must be called on all ranks of
the distributed mesh’s communicator. The target directory must not
yet exist and is created by rank 0. Each rank writes its local mesh,
while rank 0 additionally writes the embedding, the global element
map, and a small metadata file. The dmplex attribute is not written
but reconstructed when reading.
pathstr | pathlib.Path — The target directory. Must not already exist.