salvus.mesh.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] = None,
mask: Optional[numpy.ndarray] = None,
elemental_fields: Optional[Dict[str, numpy.ndarray]] = None,
):
...A dataclass representing a simple mesh building block.
Works in 2 and 3 dimensions.
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] — The coordinates of the points in the z dimension. Only for 3-D.maskOptional[numpy.ndarray] — An optional point-wise mask.elemental_fieldsOptional[Dict[str, numpy.ndarray]] — Any elemental fields to attach to the mesh block.
ndim int
ndim intDimensionality of the mesh block.
nelem_x int
nelem_x intNumber of elements in the x dimension.
nelem_y int
nelem_y intNumber of elements in the y dimension.
nelem_z int
nelem_z intNumber of elements in the z dimension.
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.
add_mask()
add_mask()def add_mask(self, criterion: Union[Callable, numpy.ndarray]) -> None:
...Add a mask to the mesh block according to the criterion evaluated at the element centroids.
Any elemental fields will be remapped as required.
criterionUnion[Callable, numpy.ndarray] — Either: - callback function with the signature criterion(x, y) which returns an array of bool, True for those elements that should be masked out, or - a numpy array of bool of the same size asself.mask, which will be logically or’d onto self.mask.
attach_field()
attach_field()def attach_field(self, name: str, field: numpy.ndarray) -> None:
...Attach elemental fields to the mesh block.
namestr — The name of the field.fieldnumpy.ndarray — The values of the field. Must be an array of lengthmesh_block.number_of_elements.
get_connectivity()
get_connectivity()def get_connectivity(self) -> numpy.ndarray:
...Compute the connectivity of the mesh block.
get_element_centroid()
get_element_centroid()def get_element_centroid(self) -> Tuple[numpy.ndarray, ...]:
...Get the coordinates of the element centroids.
get_unstructured_mesh()
get_unstructured_mesh()def get_unstructured_mesh(
self,
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Convert the mesh block to a Salvus mesh object.
plot()
plot()def plot(
self, figure: Optional[matplotlib.figure.Figure] = None, show: bool = False
) -> Optional[matplotlib.figure.Figure]:
...Plots the mesh block in 2 and 3 dimensions.
figureOptional[matplotlib.figure.Figure] — figureshowbool — Show the plot.