Version:

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()

Convert a numpy array to a shared memory block.
Returns the name of the shared memory block as well as the shared memory object.
SIGNATURE
def array_to_shared_memory(
    identifier: str, array_name: str, array: npt.NDArray
) -> _SharedMemoryArray: ...
ARGUMENTS
Required
identifier
Type:str
Description:
Group level name.
Required
array_name
Type:str
Description:
Part name of the array.
Required
array
Type:npt.NDArray
Description:
The actual array.
RETURNS
Return type: _SharedMemoryArray

list_shared_memory_blocks()

List the shared memory blocks available on this machine that are managed by Salvus.
SIGNATURE
def list_shared_memory_blocks() -> list[str]: ...
RETURNS
Return type: list[str]

random_name()

Convenience function generating a per-process unique and short name.
SIGNATURE
def random_name() -> str: ...
RETURNS
Return type: str

shared_memory_block_exists()

Return True if the given shared memory block exists on the current machine.
SIGNATURE
def shared_memory_block_exists(name: str) -> bool: ...
ARGUMENTS
Required
name
Type:str
Description:
The name of the shared memory block.
RETURNS
Return type: bool

Classes

SharedMemoryUnstructuredMeshStore

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.
SIGNATURE
class SharedMemoryUnstructuredMeshStore(builtins.object):
    def __init__(
        self,
        identifier: str,
        array_dict: dict[str, _SharedMemoryArray],
        is_owner: bool,
    ) -> None: ...
ARGUMENTS
Required
identifier
Type:str
Description:
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.
Required
array_dict
Type:dict[str, _SharedMemoryArray]
Description:
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.
Required
is_owner
Type:bool
Description:
Identify the owning process. If this is True, the shared memory will be freed in the object's destructor.

Class Methods

SharedMemoryUnstructuredMeshStore.from_identifier()
Get a shared memory unstructured mesh object from an identifier.
SIGNATURE
def from_identifier(identifier: str, readonly: bool = True) -> typing.Self: ...
ARGUMENTS
Required
identifier
Type:str
Description:
The identifier.
Optional
readonly
Type:bool
Default value:True
Description:
Return a readonly version.
SharedMemoryUnstructuredMeshStore.from_unstructured_mesh()
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.
SIGNATURE
def from_unstructured_mesh(
    identifier: str, m: UnstructuredMesh
) -> typing.Self: ...
ARGUMENTS
Required
identifier
Type:str
Description:
Globally unique identifier of the mesh.
Required
m
Type:UnstructuredMesh
Description:
The unstructured mesh.

Methods

SharedMemoryUnstructuredMeshStore.close()
Close the object and free the underlying shared memory object if the current process is the owner of the memory.
SIGNATURE
def close(self) -> None: ...
SharedMemoryUnstructuredMeshStore.to_unstructured_mesh()
Get an unstructured mesh object from the shared structure.
SIGNATURE
def to_unstructured_mesh(self) -> UnstructuredMesh: ...
PAGE CONTENTS