Version:

salvus.mesh.algorithms.unstructured_mesh.side_sets

salvus.mesh.algorithms.unstructured_mesh.side_sets salvus mesh algorithms unstructured_mesh side_sets
Side set related algorithms.

Functions

analyze_masks()

Analyze boolean masks to check for overlaps and coverage.
SIGNATURE
def analyze_masks(masks: list[npt.NDArray]) -> tuple[bool, bool]: ...
ARGUMENTS
Required
masks
Type:list[npt.NDArray]
Description:
List of boolean masks (same shape).
RETURNS
Return type: tuple[bool, bool]
A tuple of two booleans indicating whether the masks overlap and provide full coverage.

compute_normal_vectors_towards_side_set()

Compute the normal vectors over the entire mesh for side set-mask combinations.
Only active elements in a mask that are attached to the associated side set will be considered. Any element in a mask that is not attached to the associated side set is excluded.
Also requires the masks to not have overlap. If multiple normal vectors for one element are desired (e.g. to different side sets), run this routine separately per side set.
SIGNATURE
def compute_normal_vectors_towards_side_set(
    mesh: UnstructuredMesh,
    side_set_to_mask_map: dict[str, npt.NDArray],
    outward_pointing: bool = True,
    split_per_mask: bool = True,
) -> npt.NDArray | dict[str, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
side_set_to_mask_map
Type:dict[str, npt.NDArray]
Description:
A dictionary which maps a side set (string) to a boolean element mask.
Optional
outward_pointing
Type:bool
Default value:True
Description:
Whether to have the normal vectors outward (True) or inward (False) w.r.t to the side set. Outwards is defined as the direction from the elements in the mask towards the side-set.
Optional
split_per_mask
Type:bool
Default value:True
Description:
If set to True, will instead return a dictionary mapping every side set to the original element indices as appearing in order of the mask.
RETURNS
Return type: npt.NDArray | dict[str, npt.NDArray]
The normal vectors per element per GLL point, shaped like (mesh.nelem, mesh.points_per_element, mesh.ndim). If split_per_mask is True, will return a dictionary with the same keys as side_set_to_mask_map, with entries the normal vectors shaped as (nelem_in_mask, mesh.points_per_element, mesh.ndim). Points for which the normal vector computation failed are set to zero.

create_side_set()

Create a new side set on the mesh.
There are a two options here:
  • Provide the element and side indices.
  • Directly provide the side set set as provided by UnstructuredMesh.get_side_set().
SIGNATURE
def create_side_set(
    mesh: UnstructuredMesh,
    side_set_name: str,
    side_set: (
        tuple[npt.NDArray, npt.NDArray] | set[tuple[int, int]] | None
    ) = None,
    element_indices: npt.NDArray | None = None,
    side_indices: npt.NDArray | None = None,
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
side_set_name
Type:str
Description:
The name of the to be create side set.
Optional
side_set
Type:tuple[npt.NDArray, npt.NDArray] | set[tuple[int, int]] | None
Default value:None
Description:
Directly provide the side set.
Optional
element_indices
Type:npt.NDArray | None
Default value:None
Description:
The global element indices for the new side set.
Optional
side_indices
Type:npt.NDArray | None
Default value:None
Description:
The side ids to use for each element.

create_side_set_between_masks()

Create a side set between two masks or a mask and its inverse.
Ideal when creating internal side sets easily without a distance metric. Needs to be manually added to the mesh afterwards.
SIGNATURE
def create_side_set_between_masks(
    mesh: UnstructuredMesh,
    mask_A: npt.NDArray,
    mask_B: npt.NDArray | None = None,
    only_add_side_A: bool = True,
) -> tuple[npt.NDArray, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
mask_A
Type:npt.NDArray
Description:
The first mask.
Optional
mask_B
Type:npt.NDArray | None
Default value:None
Description:
The second mask. If None, the inverse of mask_A is taken.
Optional
only_add_side_A
Type:bool
Default value:True
Description:
Whether or not to only add the elements and facets relating to one side of the boundary. Functionally no different but setting to False will double surface data output size.
RETURNS
Return type: tuple[npt.NDArray, npt.NDArray]
The elements and sides of the mesh that are part of the internal side set. By default, will contain entries for elements in just mask A.

find_side_sets()

Find surfaces of simple box or spherical meshes in 2 or 3 dimension.
Use UnstructuredMesh.find_surface() for more complex shapes.
SIGNATURE
def find_side_sets(
    mesh: UnstructuredMesh, mode: str = "cartesian", tolerance: float = 1e-08
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The unstructured mesh.
Optional
mode
Type:str
Default value:'cartesian'
Description:
the side sets to be found depend on the shape of the mesh, should be one of "cartesian", "cylindrical", "spherical_full", "spherical_chunk", "spherical_chunk_z", or "spherical_SmoothieSEM".
Optional
tolerance
Type:float
Default value:1e-08
Description:
Floating point tolerance to assume a node is on a given side.

find_side_sets_cartesian()

Find cartesian side sets.
SIGNATURE
def find_side_sets_cartesian(
    mesh: UnstructuredMesh, tolerance: float = 1e-08
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
tolerance
Type:float
Default value:1e-08
Description:
Distance tolerance.

find_side_sets_cylindrical()

Find cylindrical side sets.
SIGNATURE
def find_side_sets_cylindrical(
    mesh: UnstructuredMesh, tolerance: float = 1e-08
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
tolerance
Type:float
Default value:1e-08
Description:
Distance tolerance.

find_side_sets_enclosing()

Find surfaces of simple box or spherical meshes in 2 or 3 dimension, augmented by a catch-all surface for unidentified portions of the surface, named "remainder_side_set".
Runs find_side_sets followed by find_surface to find the remainder side-sets of any non-found facets. Uniquefies side-sets, which will alter existing side-sets.
SIGNATURE
def find_side_sets_enclosing(
    mesh: UnstructuredMesh, mode: str = "cartesian", tolerance: float = 1e-08
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The unstructured mesh.
Optional
mode
Type:str
Default value:'cartesian'
Description:
the side sets to be found depend on the shape of the mesh, should be one of "cartesian", "cylindrical", "spherical_full", "spherical_chunk", "spherical_chunk_z", or "spherical_SmoothieSEM".
Optional
tolerance
Type:float
Default value:1e-08
Description:
Floating point tolerance to assume a node is on a given side.

find_side_sets_generic()

Find side sets based on a distance function.
SIGNATURE
def find_side_sets_generic(
    mesh: UnstructuredMesh,
    name: str,
    distance: typing.Callable[[npt.NDArray], npt.NDArray] | npt.NDArray,
    tolerance: float = 1e-08,
    attach_side_set: bool = True,
) -> tuple[npt.NDArray, npt.NDArray] | None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
name
Type:str
Description:
Name of the new side set.
Required
distance
Type:typing.Callable[[npt.NDArray], npt.NDArray] | npt.NDArray
Description:
Callback function taking in points and returning a distance.
Optional
tolerance
Type:float
Default value:1e-08
Description:
Point with a distance beneath this are part of the side set.
Optional
attach_side_set
Type:bool
Default value:True
Description:
If true, add the side set to the mesh, othewise return the side set elements and sides.
RETURNS
Return type: tuple[npt.NDArray, npt.NDArray] | None

find_side_sets_spherical()

Find spherical side sets.
SIGNATURE
def find_side_sets_spherical(
    mesh: UnstructuredMesh,
    tolerance: float = 1e-08,
    is_chunk: bool,
    is_vertical: bool,
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
tolerance
Type:float
Default value:1e-08
Description:
Distance tolerance.
Required
is_chunk
Type:bool
Description:
Is a chunk, not a full sphere.
Required
is_vertical
Type:bool
Description:
Is a vertically oriented chunk.

find_surface()

Mark all surface faces as a side set.
SIGNATURE
def find_surface(
    mesh: UnstructuredMesh, side_set_name: str = "surface"
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to use.
Optional
side_set_name
Type:str
Default value:'surface'
Description:
Name to give to the found surface.

get_side_set()

Get one side set as a set.
Useful for logical operations on side sets.
SIGNATURE
def get_side_set(
    mesh: UnstructuredMesh, name: str, allow_empty: bool = False
) -> set[tuple[int, int]]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
name
Type:str
Description:
Name of the side set.
Optional
allow_empty
Type:bool
Default value:False
Description:
Return an empty set if the side set is not present.
RETURNS
Return type: set[tuple[int, int]]

get_side_set_facet_indexer()

Get the facet indexer for a side set.
This is an array of shape (n_elem_on_side_set, n_dof_per_facet) which gives the facet id for each element in the side set. This is useful for indexing into element nodal fields to get parameter values along a side set. For instance, given a side set "r1" and an element nodal field "VP", you can get the VP values along the side set as follows:
elements, _ = mesh.side_sets["r1"]
indexer = get_side_set_facet_indexer(mesh, "r1")
vp_on_side_set_elms = mesh.element_nodal_fields["VP"][elements]
vp_on_side_set = np.take_along_axis( vp_on_side_set_elms, indexer, axis=1)
SIGNATURE
def get_side_set_facet_indexer(
    mesh: UnstructuredMesh, name: str
) -> npt.NDArray[np.int64]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
name
Type:str
Description:
The name of the side set.
RETURNS
Return type: npt.NDArray[np.int64]
An array of shape (n_elem_on_side_set, n_dof_per_facet) which gives the facet id for each element in the side set.

get_side_set_facet_nodes()

Get the tensorized nodes along a side set.
Note that this function respects the tensor order of the mesh, and will therefore return nodes equivalent to a tensorized quad in 3-D and all the nodes along an edge in 2-D.
SIGNATURE
def get_side_set_facet_nodes(
    mesh: UnstructuredMesh, name: str
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.int64]]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
name
Type:str
Description:
The name of the side set.
RETURNS
Return type: tuple[npt.NDArray[np.float64], npt.NDArray[np.int64]]
A tuple of two values: 1st value: The tensorized nodes along the side set, with the shape (n_elem_on_side_set, n_points_per_facet, n_dim). 2st value: The global element nodes indices corresponding to the returned tensorized points.

get_side_set_nodes()

Return side set node ids as an array.
SIGNATURE
def get_side_set_nodes(mesh: UnstructuredMesh, name: str) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
name
Type:str
Description:
Name of the side set.
RETURNS
Return type: npt.NDArray

side_sets_for_element_ids()

Determine the side sets associated with a set of element IDs.
Identifies which side sets in the mesh contain nodes that are part of the specified element IDs.
SIGNATURE
def side_sets_for_element_ids(
    mesh: UnstructuredMesh, ids: npt.NDArray
) -> set[str]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
ids
Type:npt.NDArray
Description:
An array of element IDs for which to find the associated side sets.
RETURNS
Return type: set[str]
set[str]: A set of side set names that are associated with the given element IDs.
PAGE CONTENTS