Version:

salvus.mesh.algorithms.unstructured_mesh.basic

salvus.mesh.algorithms.unstructured_mesh.basic salvus mesh algorithms unstructured_mesh basic
Basic operations.

Functions

add_two_meshes()

Add two meshes together.
Only fields that exist in both meshes, will be in the combined mesh, others will be discarded.
SIGNATURE
def add_two_meshes(
    mesh_a: UnstructuredMesh,
    mesh_b: UnstructuredMesh,
    make_unique_points: bool = True,
) -> UnstructuredMesh: ...
ARGUMENTS
Required
mesh_a
Type:UnstructuredMesh
Description:
First mesh.
Required
mesh_b
Type:UnstructuredMesh
Description:
Second mesh.
Optional
make_unique_points
Type:bool
Default value:True
Description:
If True, duplicate points in both meshes will be discarded. This should be True in most cases, only set this to False for performance reasons if you know what you are doing.
RETURNS
Return type: UnstructuredMesh

apply_element_mask()

Apply an element mask to the mesh returning a new mesh object.
Only retains elements that are set to True in the mask.
SIGNATURE
def apply_element_mask(
    mesh: UnstructuredMesh,
    mask: npt.NDArray,
    return_node_map: bool = False,
    side_sets: str | list[str] | None = None,
) -> UnstructuredMesh | tuple[UnstructuredMesh, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
mask
Type:npt.NDArray
Description:
The mask as boolean array.
Optional
return_node_map
Type:bool
Default value:False
Description:
Return a node map together with the new mesh object, to be used to map nodal fields to the set of nodes that are retained in the mesh.
Optional
side_sets
Type:str | list[str] | None
Default value:None
Description:
list of side set names to which the mask should be directly connected. All elements not connected to the side sets are retained. Can be used to avoid cavities in the mask.
RETURNS
Return type: UnstructuredMesh | tuple[UnstructuredMesh, npt.NDArray]

assert_meshes_are_compatible()

Asserts that two meshes are compatible.
Compatibility is defined as having the same dimensionality, scale, and shape order.
Will raise a descriptive AssertionError if that is not the case.
SIGNATURE
def assert_meshes_are_compatible(
    mesh_a: UnstructuredMesh, mesh_b: UnstructuredMesh
) -> None: ...
ARGUMENTS
Required
mesh_a
Type:UnstructuredMesh
Description:
The first mesh.
Required
mesh_b
Type:UnstructuredMesh
Description:
The second mesh.

get_element_centroid()

For each element, compute its centroid.
SIGNATURE
def get_element_centroid(
    mesh: UnstructuredMesh, spherical: bool = False
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
spherical
Type:bool
Default value:False
Description:
Assume a spherical mesh to perform a spherical computation.
RETURNS
Return type: npt.NDArray

get_element_centroid_radius()

Get the radius of the centroid of each element for spherical meshes.
Compute the centroids of all elements on the fly from the nodes of the mesh. Useful to determine which domain in a layered medium an element belongs to or to compute elemental properties from the model. This function computes the spherical radius directly and is hence more memory efficient than UnstructuredMesh.get_element_centroid()
SIGNATURE
def get_element_centroid_radius(mesh: UnstructuredMesh) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
RETURNS
Return type: npt.NDArray

get_element_nodes()

Get the nodes for each element in the mesh.
Get duplicated nodes, i.e. an array with shape (nelem, nodes_per_element, ndim) containing the node locations for all elements for all nodes. This can be significant in terms of memory requirements.
SIGNATURE
def get_element_nodes(
    mesh: UnstructuredMesh,
    mask: tuple | npt.NDArray = (slice(None, None, None),),
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
mask
Type:tuple | npt.NDArray
Default value:(slice(None, None, None),)
Description:
An optional mask to apply to the connectivity before returning the points.
RETURNS
Return type: npt.NDArray

get_mass_matrix()

Compute the mass matrix of a mesh.
This function computes the mass matrix of a mesh using the GLL quadrature points and weights. The mass matrix is computed as the integral of the product of the shape functions over the element volume.
SIGNATURE
def get_mass_matrix(mesh: UnstructuredMesh) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh for which to compute the mass matrix.
RETURNS
Return type: npt.NDArray
The mass matrix of the mesh as a 2D numpy array of shape (n_elem, n_nodes_per_element).

get_valence()

Get the valence of each node in the mesh ordered per element.
SIGNATURE
def get_valence(mesh: UnstructuredMesh) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
RETURNS
Return type: npt.NDArray
The valence of each node in the mesh.

jacobian_at_nodes()

Compute the Jacobian at each element and each node.
SIGNATURE
def jacobian_at_nodes(mesh: UnstructuredMesh) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
RETURNS
Return type: npt.NDArray
The Jacobian: [n_elm, n_node, n_dim, n_dim].

meshes_are_equal()

Compare two meshes for equality.
SIGNATURE
def meshes_are_equal(
    mesh_a: UnstructuredMesh,
    mesh_b: typing.Any,
    raise_with_error_if_not_equal: bool = False,
) -> bool: ...
ARGUMENTS
Required
mesh_a
Type:UnstructuredMesh
Description:
Mesh a.
Required
mesh_b
Type:typing.Any
Description:
The other mesh.
Optional
raise_with_error_if_not_equal
Type:bool
Default value:False
Description:
Raise in case both are not equal.
RETURNS
Return type: bool

rotate_coordinates()

Rotate the mesh coordinates in-place using Z-Y-Z extrinsic Euler angles.
This function rotates the mesh node coordinates around the origin by applying three right-handed, global-axis-fixed rotations in the following sequence:
1. Rotate around the global Z-axis by `euler_angles[0]` degrees.
2. Rotate around the global Y-axis by `euler_angles[1]` degrees.
3. Rotate around the global Z-axis by `euler_angles[2]` degrees.
SIGNATURE
def rotate_coordinates(
    mesh: UnstructuredMesh, euler_angles: npt.NDArray
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
euler_angles
Type:npt.NDArray
Description:
Euler-angles in degrees to rotate around.
PAGE CONTENTS