salvus.mesh.algorithms.distributed_mesh.convert
salvus.mesh.algorithms.distributed_mesh.convert salvus mesh algorithms distributed_mesh convert Convert an MPI distributed mesh to a regular Mesh on a single rank.
Functions
to_mesh()
to_mesh()def to_mesh(
distributed_mesh: DistributedMesh,
element_selection_function: collections.abc.Callable,
timer: Timer | None = None,
log_to_logger: bool = True,
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.
distributed_meshDistributedMesh — The distributed mesh to convert.element_selection_functioncollections.abc.Callable — Function that takes the global element indices returns the indices to keep.timerTimer | None — Execution timer.log_to_loggerbool — Whether to log timing to the logger.reentrant_timerbool — Whether the timer is reentrant.
to_mesh_with_artifacts()
to_mesh_with_artifacts()def to_mesh_with_artifacts(
distributed_mesh: DistributedMesh,
element_selection_function: collections.abc.Callable,
timer: Timer | None = None,
log_to_logger: bool = True,
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 the cacheable intermediate values.
Always uses the DMPlex-based code path. The returned ArtifactsFromToMesh
can be passed to from_mesh() (via its artifacts argument) to skip
the corresponding work on a subsequent reduction call for the same
distributed mesh and selection.
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.
distributed_meshDistributedMesh — The distributed mesh to convert.element_selection_functioncollections.abc.Callable — Function that takes the global element indices and returns the indices to keep.timerTimer | None — Execution timer.log_to_loggerbool — Whether to log timing to the logger.reentrant_timerbool — Whether the timer is reentrant.cached_block_dmslist[tuple[bindings.DMPlex, bindings.DMPlex]] | None — Optional pre-computed per-block DMPlex objects. If given, theDiscretize blocksstep is skipped.
(mesh, artifacts). mesh is None if no elements were selected on this rank.Classes
ArtifactsFromToMesh
ArtifactsFromToMeshclass ArtifactsFromToMesh(builtins.object):
def __init__(
self,
selected_element_ids: npt.NDArray,
block_dms: list[tuple[bindings.DMPlex, bindings.DMPlex]],
sf_sec: list[bindings.PetscStarForest],
sf_ap: list[bindings.PetscStarForest],
) -> None: ...Cacheable intermediate values produced by to_mesh_with_artifacts.
These can be reused by a subsequent from_mesh() call (via its
artifacts argument) on the same distributed mesh and element
selection to skip recomputing the element selection, the per-block
DMPlex objects, and the nodal aperture star forests.
selected_element_idsnpt.NDArray — The pre-filtered Salvus global element IDs for the local rank (the result of the element selection function intersected with the IDs known to this rank).block_dmslist[tuple[bindings.DMPlex, bindings.DMPlex]] — The per-block DMPlex objects produced bydmplex.discretize_blocks. Selection-independent and may be reused across calls with different element selections.sf_seclist[bindings.PetscStarForest] — Per-block nodal section star forests for this selection.sf_aplist[bindings.PetscStarForest] — Per-block nodal aperture star forests for this selection.