Mondaic
This API reference is not for the latest stable Salvus version.

salvus.mesh.data_structures.distributed_mesh.distributed_mesh

The distributed mesh data structure.

Classes

DistributedMesh

class 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.

Parameters
  • comm int — The MPI communicator.
  • embedding Mesh — The embedding mesh.
  • mesh Mesh — The local mesh on this rank.
  • global_element_map list[npt.NDArray] — A list mapping from rank to the global element IDs owned by that rank.
  • dmplex bindings.DMPlex | None — The distributed DMPlex object.
Attributes
all_nodal_fields set[str]

All nodal fields across all blocks.

global_element_ids_rank npt.NDArray

The global element ids of the elements on this rank.

global_variables dict[str, allowed_global_types]

The global variables.

model_order int

The model order.

nodal_fields_per_block dict[int, set[str]]

The nodal fields per block.

number_of_dimensions int

The number of spatial dimensions.

number_of_elements int

The total number of elements.

side_sets tuple[SideSet, ...]

The side sets.

Methods
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.

Parameters
  • element_selection_function collections.abc.Callable — Function that takes the global element indices returns the indices to keep.
  • mesh Mesh | None — The mesh to reduce from. Can be None on ranks that have no elements selected by the element selection function.
  • reduction_operations_per_field dict[str, str] — Dictionary mapping field names to reduction operations. Reduction operations can be “sum”, “min”, “max”, or “replace”.
  • timer Timer | None — Execution timer.
  • log_to_logger bool — Whether to log timing to the logger.
  • reentrant_timer bool — Whether the timer is reentrant.
  • artifacts ArtifactsFromToMesh | None — Optional cached intermediates from a prior to_mesh_with_artifacts() call on the same distributed mesh and selection. When given, the element selection call, discretize_blocks, and get_aperture_sfs are skipped.
Returns None
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.

Parameters
  • element_selection_function collections.abc.Callable — Function that takes the global element indices returns the indices to keep.
  • timer Timer | None — Execution timer.
  • log_to_logger bool — Whether to log timing to the logger.
  • reentrant_timer bool — Whether the timer is reentrant.
Returns Mesh | None — The assembled Mesh.
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.

Parameters
  • element_selection_function collections.abc.Callable — Function that takes the global element indices and returns the indices to keep.
  • timer Timer | None — Execution timer.
  • log_to_logger bool — Whether to log timing to the logger.
  • reentrant_timer bool — Whether the timer is reentrant.
  • cached_block_dms list[tuple[bindings.DMPlex, bindings.DMPlex]] | None — Optional pre-computed per-block DMPlex objects from a previous call. If given, the Discretize blocks step is skipped.
Returns tuple[Mesh | None, ArtifactsFromToMesh] — A tuple (mesh, artifacts). mesh is None if no elements were selected on this rank.