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_masks()def analyze_masks(masks: list[npt.NDArray]) -> tuple[bool, bool]: ...Analyze boolean masks to check for overlaps and coverage.
maskslist[npt.NDArray] — List of boolean masks (same shape).
compute_normal_vectors_towards_side_set()
compute_normal_vectors_towards_side_set()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]: ...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.
meshUnstructuredMesh — The mesh.side_set_to_mask_mapdict[str, npt.NDArray] — A dictionary which maps a side set (string) to a boolean element mask.outward_pointingbool — 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.split_per_maskbool — 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.
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_side_set()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: ...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().
meshUnstructuredMesh — The mesh.side_set_namestr — The name of the to be create side set.side_settuple[npt.NDArray, npt.NDArray] | set[tuple[int, int]] | None — Directly provide the side set.element_indicesnpt.NDArray | None — The global element indices for the new side set.side_indicesnpt.NDArray | None — The side ids to use for each element.
create_side_set_between_masks()
create_side_set_between_masks()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]: ...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.
meshUnstructuredMesh — The mesh.mask_Anpt.NDArray — The first mask.mask_Bnpt.NDArray | None — The second mask. If None, the inverse of mask_A is taken.only_add_side_Abool — 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.
find_side_sets()
find_side_sets()def find_side_sets(
mesh: UnstructuredMesh, mode: str = "cartesian", tolerance: float = 1e-08
) -> None: ...Find surfaces of simple box or spherical meshes in 2 or 3 dimension.
Use UnstructuredMesh.find_surface() for more complex shapes.
meshUnstructuredMesh — The unstructured mesh.modestr — 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”.tolerancefloat — Floating point tolerance to assume a node is on a given side.
find_side_sets_cartesian()
find_side_sets_cartesian()def find_side_sets_cartesian(
mesh: UnstructuredMesh, tolerance: float = 1e-08
) -> None: ...Find cartesian side sets.
meshUnstructuredMesh — The mesh.tolerancefloat — Distance tolerance.
find_side_sets_cylindrical()
find_side_sets_cylindrical()def find_side_sets_cylindrical(
mesh: UnstructuredMesh, tolerance: float = 1e-08
) -> None: ...Find cylindrical side sets.
meshUnstructuredMesh — The mesh.tolerancefloat — Distance tolerance.
find_side_sets_enclosing()
find_side_sets_enclosing()def find_side_sets_enclosing(
mesh: UnstructuredMesh, mode: str = "cartesian", tolerance: float = 1e-08
) -> None: ...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.
meshUnstructuredMesh — The unstructured mesh.modestr — 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”.tolerancefloat — Floating point tolerance to assume a node is on a given side.
find_side_sets_generic()
find_side_sets_generic()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: ...Find side sets based on a distance function.
meshUnstructuredMesh — The mesh.namestr — Name of the new side set.distancetyping.Callable[[npt.NDArray], npt.NDArray] | npt.NDArray — Callback function taking in points and returning a distance.tolerancefloat — Point with a distance beneath this are part of the side set.attach_side_setbool — If true, add the side set to the mesh, othewise return the side set elements and sides.
find_side_sets_spherical()
find_side_sets_spherical()def find_side_sets_spherical(
mesh: UnstructuredMesh,
tolerance: float = 1e-08,
is_chunk: bool,
is_vertical: bool,
) -> None: ...Find spherical side sets.
meshUnstructuredMesh — The mesh.tolerancefloat — Distance tolerance.is_chunkbool — Is a chunk, not a full sphere.is_verticalbool — Is a vertically oriented chunk.
find_surface()
find_surface()def find_surface(
mesh: UnstructuredMesh, side_set_name: str = "surface"
) -> None: ...Mark all surface faces as a side set.
meshUnstructuredMesh — The mesh to use.side_set_namestr — Name to give to the found surface.
get_side_set()
get_side_set()def get_side_set(
mesh: UnstructuredMesh, name: str, allow_empty: bool = False
) -> set[tuple[int, int]]: ...Get one side set as a set.
Useful for logical operations on side sets.
meshUnstructuredMesh — The mesh.namestr — Name of the side set.allow_emptybool — Return an empty set if the side set is not present.
get_side_set_facet_indexer()
get_side_set_facet_indexer()def get_side_set_facet_indexer(
mesh: UnstructuredMesh, name: str
) -> npt.NDArray[np.int64]: ...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)meshUnstructuredMesh — The mesh.namestr — The name of the side set.
get_side_set_facet_nodes()
get_side_set_facet_nodes()def get_side_set_facet_nodes(
mesh: UnstructuredMesh, name: str
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.int64]]: ...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.
meshUnstructuredMesh — The mesh.namestr — The name of the side set.
get_side_set_nodes()
get_side_set_nodes()def get_side_set_nodes(mesh: UnstructuredMesh, name: str) -> npt.NDArray: ...Return side set node ids as an array.
meshUnstructuredMesh — The mesh.namestr — Name of the side set.
side_sets_for_element_ids()
side_sets_for_element_ids()def side_sets_for_element_ids(
mesh: UnstructuredMesh, ids: npt.NDArray
) -> set[str]: ...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.
meshUnstructuredMesh — The mesh.idsnpt.NDArray — An array of element IDs for which to find the associated side sets.