Skip to content
This API reference is not for the latest stable Salvus version.

salvus.mesh.data_structures.chunked_mesh.chunked_mesh

Module implemented a mesh object split across multiple files.

Classes

ChunkedMesh

class ChunkedMesh(builtins.object):
    def __init__(
        self,
        root_folder: pathlib.Path,
        _embedding: pathlib.Path,
        _chunks: list[pathlib.Path],
        _global_element_mapping_filename: pathlib.Path,
        _meta_contents_cache: dict | None = None,
    ) -> None: ...

A mesh split across multiple files.

All file paths are relative to the root folder.

Parameters
  • root_folder pathlib.Path — The root folder containing the chunked mesh.
  • _embedding pathlib.Path — The file containing the embedding mesh.
  • _chunks list[pathlib.Path] — The files containing the mesh chunks.
  • _global_element_mapping_filename pathlib.Path — The file containing the global element mapping.
  • _meta_contents_cache dict | None = None — Cache for the meta contents.
Attributes
blocks list[ChunkedMeshBlock]

The blocks of the chunked mesh.

chunk_filenames list[pathlib.Path]

The paths to the chunk mesh files.

embedding_filename pathlib.Path

The path to the embedding mesh file.

global_element_map_filename pathlib.Path

The path to the global element map file.

global_variables dict[str, typing.Any]

The global variables of the chunked mesh.

is_fluid list[bool]

Whether the chunked mesh contains fluid materials.

The list contains a boolean for each block.

Returns: True if the chunked mesh contains fluid materials, False otherwise.

is_visco list[bool]

Whether the chunked mesh contains visco materials.

The list contains a boolean for each block.

Returns: True if the chunked mesh contains visco materials, False otherwise.

linear_solids list[mesh_linear_solids.LinearSolidsOnMesh | None]

Get the linear solids per block.

model_order int

The model order of the chunked mesh.

nodal_fields_per_block dict[int, set[str]]

The nodal fields per block of the chunked mesh.

number_of_blocks int

The number of blocks in the chunked mesh.

number_of_dimensions int

The number of spatial dimensions of the chunked mesh.

number_of_elements int

The total number of elements in the chunked mesh.

number_of_elements_per_block dict[int, int]

The total number of elements in the blocks of the chunked mesh.

number_of_nodes_per_element int

The number of nodes per element of the chunked mesh.

number_of_points_per_element_and_direction int

Number of GLL points per element and spatial direction.

Also known as the shape mapping order.

Methods
from_files()
def from_files(
    embedding: pathlib.Path, chunks: list[pathlib.Path]
) -> ChunkedMesh: ...

Create a chunked mesh from an embedding files + a list of chunk files.

They must all be in the same folder, and there must be no other files in that folder.

This functions will add new meta-data files to the folder so this can only be called once. After this function has been called, the parent folder of the passed files can be loaded as a chunked mesh with ChunkedMesh.from_folder().

Parameters
  • embedding pathlib.Path — The file containing the embedding mesh.
  • chunks list[pathlib.Path] — The files containing the mesh chunks.
Returns ChunkedMesh — The loaded chunked mesh.
from_folder()
def from_folder(folder: pathlib.Path | str) -> ChunkedMesh: ...

Load a chunked mesh from a folder.

Parameters
  • folder pathlib.Path | str — The folder containing the chunked mesh.
Returns ChunkedMesh — The loaded chunked mesh.
compute_file_size()
def compute_file_size(self) -> int: ...

Compute the total file size of the chunked mesh.

Returns int — The total file size in bytes.
move()
def move(self, target_folder: pathlib.Path) -> None: ...

Move the chunked mesh to a new folder.

If will modify the object in-place to point to the new location.

Parameters
  • target_folder pathlib.Path — The folder to move the chunked mesh to.
Returns None — Nothing.
sum_gradients()
def sum_gradients(
    self,
    gradients: list[tuple[pathlib.Path, collections.abc.Callable]],
    output_folder: pathlib.Path,
) -> ChunkedMesh: ...

Sum gradients stored on the chunked mesh and write to disk.

This function will sum all gradients passed to it and return a new chunked mesh with the same geometry and same chunking as this object. It will sum all gradients for each chunk, elements that are not part of any gradient will be flooded with zeros.

Parameters
  • gradients list[tuple[pathlib.Path, collections.abc.Callable]] — A list of all gradients to sum. Each entry is a tuple with the path to the gradient file and a function that takes the embedding and return the global elements ids for the current gradient file.
  • output_folder pathlib.Path — The folder to store the summed gradients in.
Returns ChunkedMesh — A new chunked mesh containing the sum of all passed gradients.
to_mesh()
def to_mesh(
    self, element_selection_function: collections.abc.Callable | None
) -> Mesh: ...

Assemble the chunked mesh into a single unstructured mesh.

Parameters
  • element_selection_function collections.abc.Callable | None — Callable that takes the embedding mesh and returns the global element IDs to include in the assembled mesh. If None, all elements from the embedding will be included.
Returns Mesh — The assembled unstructured mesh.
to_unstructured_mesh()
def to_unstructured_mesh(
    self, element_selection_function: collections.abc.Callable | None
) -> UnstructuredMesh: ...

Assemble the chunked mesh into a single mesh.

Parameters
  • element_selection_function collections.abc.Callable | None — Callable that takes the embedding mesh and returns the global element IDs to include in the assembled mesh. If None, all elements from the embedding will be included.
Returns UnstructuredMesh — The assembled mesh.

ChunkedMeshBlock

class ChunkedMeshBlock(builtins.object):
    def __init__(self) -> None: ...

A block in a chunked mesh.

Currently not implemented.