Mondaic

salvus.mesh.data_structures.mesh_block.mesh_block

salvus.mesh.data_structures.mesh_block.mesh_block salvus mesh data_structures mesh_block mesh_block

Salvus’ mesh block class.

Classes

MeshBlock

class MeshBlock(builtins.object):
    def __init__(
        self,
        x: npt.NDArray,
        y: npt.NDArray,
        z: npt.NDArray | None = None,
        mask: npt.NDArray | None = None,
        elemental_fields: dict[str, npt.NDArray] | None = None,
    ): ...

A dataclass representing a simple mesh building block.

Works in 2 and 3 dimensions.

Parameters
  • x npt.NDArray — The coordinates of the points in the x dimension.
  • y npt.NDArray — The coordinates of the points in the y dimension.
  • z npt.NDArray | None — The coordinates of the points in the z dimension. Only for 3-D.
  • mask npt.NDArray | None — An optional point-wise mask.
  • elemental_fields dict[str, npt.NDArray] | None — Any elemental fields to attach to the mesh block.
Attributes
element_count_x int

Number of elements in the x dimension.

element_count_y int

Number of elements in the y dimension.

element_count_z int

Number of elements in the z dimension.

ndim int

Dimensionality of the mesh block.

number_of_elements int

Number of elements, with the mask applied.

number_of_points int

Number of points in the mesh block.

points npt.NDArray

Get the points of the mesh block as a (n_point, n_dim) array.

Methods
apply_element_wise_mask()
def apply_element_wise_mask(
    self, masking_function: collections.abc.Callable | npt.NDArray
) -> None: ...

Apply an element wise mask to each element.

Parameters
  • masking_function collections.abc.Callable | npt.NDArray — A callback function that will be evaluated for each elements centroid, alternatively directly a numpy array containing the result of said function.
Returns None
attach_field()
def attach_field(self, name: str, field: npt.NDArray) -> None: ...

Attach elemental fields to the mesh block.

Parameters
  • name str — The name of the field.
  • field npt.NDArray — The values of the field. Must be an array of length mesh_block.number_of_elements.
Returns None
get_connectivity()
def get_connectivity(self) -> npt.NDArray: ...

Compute the connectivity of the mesh block.

Returns npt.NDArray
get_element_centroid()
def get_element_centroid(self) -> tuple[npt.NDArray, ...]: ...

Get the coordinates of the element centroids.

Returns tuple[npt.NDArray, ...]
get_unstructured_mesh()
def get_unstructured_mesh(self) -> UnstructuredMesh: ...

Convert the mesh block to a Salvus mesh object.

Returns UnstructuredMesh