salvus.mesh.data_structures.mesh_block.mesh_block
Salvus’ mesh block class.
Classes
MeshBlock
MeshBlockclass MeshBlock(builtins.object):
def __init__(
self,
x: numpy.ndarray,
y: numpy.ndarray,
z: Optional[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]] = None,
mask: Optional[
numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]
] = None,
elemental_fields: Optional[
Dict[str, numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]]
] = None,
): ...A dataclass representing a simple mesh building block.
Works in 2 and 3 dimensions.
Parameters
xnumpy.ndarray — The coordinates of the points in the x dimension.ynumpy.ndarray — The coordinates of the points in the y dimension.zOptional[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]] — The coordinates of the points in the z dimension. Only for 3-D.maskOptional[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]] — An optional point-wise mask.elemental_fieldsOptional[Dict[str, numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]]] — Any elemental fields to attach to the mesh block.
Attributes
element_count_x int
element_count_x intNumber of elements in the x dimension.
element_count_y int
element_count_y intNumber of elements in the y dimension.
element_count_z int
element_count_z intNumber of elements in the z dimension.
ndim int
ndim intDimensionality of the mesh block.
number_of_elements int
number_of_elements intNumber of elements, with the mask applied.
number_of_points int
number_of_points intNumber of points in the mesh block.
points numpy.ndarray
points numpy.ndarrayGet the points of the mesh block as a (n_point, n_dim) array.
Methods
apply_element_wise_mask()
apply_element_wise_mask()def apply_element_wise_mask(
self,
masking_function: Union[
Callable, numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]
],
) -> None: ...Apply an element wise mask to each element.
Parameters
masking_functionUnion[Callable, numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]]] — 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()
attach_field()def attach_field(self, name: str, field: numpy.ndarray) -> None: ...Attach elemental fields to the mesh block.
Parameters
namestr — The name of the field.fieldnumpy.ndarray — The values of the field. Must be an array of lengthmesh_block.number_of_elements.
Returns None
get_connectivity()
get_connectivity()def get_connectivity(self) -> numpy.ndarray: ...Compute the connectivity of the mesh block.
Returns numpy.ndarray
get_element_centroid()
get_element_centroid()def get_element_centroid(
self,
) -> Tuple[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]], ...]: ...Get the coordinates of the element centroids.
Returns Tuple[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]], ...]
get_unstructured_mesh()
get_unstructured_mesh()def get_unstructured_mesh(
self,
) -> (
salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh
): ...Convert the mesh block to a Salvus mesh object.
Returns salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh