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()
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.
identifierstr — Group level name.array_namestr — Part name of the array.arraynpt.NDArray — The actual array.
list_shared_memory_blocks()
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.
random_name()
random_name()def random_name() -> str: ...Convenience function generating a per-process unique and short name.
shared_memory_block_exists()
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.
namestr — The name of the shared memory block.
Classes
SharedMemoryUnstructuredMeshStore
SharedMemoryUnstructuredMeshStoreclass 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.
identifierstr — 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_dictdict[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_ownerbool — Identify the owning process. If this is True, the shared memory will be freed in the object’s destructor.
from_identifier()
from_identifier()def from_identifier(identifier: str, readonly: bool = True) -> typing.Self: ...Get a shared memory unstructured mesh object from an identifier.
identifierstr — The identifier.readonlybool — Return a readonly version.
from_unstructured_mesh()
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.
identifierstr — Globally unique identifier of the mesh.mUnstructuredMesh — The unstructured mesh.
close()
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.
to_unstructured_mesh()
to_unstructured_mesh()def to_unstructured_mesh(self) -> UnstructuredMesh: ...Get an unstructured mesh object from the shared structure.