Mondaic

salvus.mesh.algorithms.unstructured_mesh.parallel_utils

salvus.mesh.algorithms.unstructured_mesh.parallel_utils salvus mesh algorithms unstructured_mesh parallel_utils

Store and retrieve UnstructuredMesh objects to and from shared memory objects.

Functions

array_to_shared_memory()

def array_to_shared_memory(
    identifier: str, array_name: str, array: npt.NDArray
) -> _SharedMemoryArray: ...

Convert a numpy array to a shared memory block.

Returns the name of the shared memory block as well as the shared memory object.

Parameters
  • identifier str — Group level name.
  • array_name str — Part name of the array.
  • array npt.NDArray — The actual array.
Returns _SharedMemoryArray

list_shared_memory_blocks()

def list_shared_memory_blocks() -> list[str]: ...

List the shared memory blocks available on this machine that are managed by Salvus.

Returns list[str]

random_name()

def random_name() -> str: ...

Convenience function generating a per-process unique and short name.

Returns str

shared_memory_block_exists()

def shared_memory_block_exists(name: str) -> bool: ...

Return True if the given shared memory block exists on the current machine.

Parameters
  • name str — The name of the shared memory block.
Returns bool

Classes

SharedMemoryUnstructuredMeshStore

class SharedMemoryUnstructuredMeshStore(builtins.object):
    def __init__(
        self,
        identifier: str,
        array_dict: dict[str, _SharedMemoryArray],
        is_owner: bool,
    ) -> None: ...

A shared memory representation for Salvus unstructured meshes.

It will be kept alive as long as the process that created it is alive and has not garbage collected said object.

Parameters
  • identifier str — A globally unique identifier of the shared memory unstructured mesh object. Only one object of a given name can exist at any point in time.
  • array_dict dict[str, _SharedMemoryArray] — An UnstructuredMesh object is made up of several individual array and dictionaries. This object keeps track of all these object and their shared memory representations.
  • is_owner bool — Identify the owning process. If this is True, the shared memory will be freed in the object’s destructor.
Methods
from_identifier()
def from_identifier(identifier: str, readonly: bool = True) -> typing.Self: ...

Get a shared memory unstructured mesh object from an identifier.

Parameters
  • identifier str — The identifier.
  • readonly bool — Return a readonly version.
Returns typing.Self
from_unstructured_mesh()
def from_unstructured_mesh(
    identifier: str, m: UnstructuredMesh
) -> typing.Self: ...

Create a shared memory unstructured mesh object from an unstructured mesh.

This will create one copy but once done multiple processes can access the same memory.

Parameters
  • identifier str — Globally unique identifier of the mesh.
  • m UnstructuredMesh — The unstructured mesh.
Returns typing.Self
close()
def close(self) -> None: ...

Close the object and free the underlying shared memory object if the current process is the owner of the memory.

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

Get an unstructured mesh object from the shared structure.

Returns UnstructuredMesh