Version:

salvus.mesh.algorithms.unstructured_mesh.refinements

salvus.mesh.algorithms.unstructured_mesh.refinements salvus mesh algorithms unstructured_mesh refinements
Refinements of unstructured meshes.

Functions

change_tensor_order()

Change the tensor order of a mesh's elements.
Usually going from linear to higher order elements.
Please be aware that this will delete any potentially set element nodal fields and nodal fields. Elemental fields and side sets will be retained.
New grid points are created by interpolating the existing corner points. This function supports a variety of interpolation modes (some of which require extra kwargs to set as part of the interpolation_kwargs dictionary):
  • "linear": The default. Perform a bi/trilinear interpolation. No extra keyword arguments are supported or required for this mode.
  • "spherical": Linearly interpolate in radial direction, and apply spherical linear interpolation (slerp) laterally. The center of the sphere is always considered to be at the origin of the coordinate system. Supported additional keywords:
  • "r1_spherical": Apply slerp only for radii >= r1_spherical, default: 0.0.
  • "r0_spherical": Apply bi/trilinear interpolation for radii < r0_spherical, default: 0.0.
If r1_spherical > r0_spherical intermediate radii will linearly interpolate between both modes.
  • "cylindrical": Linearly interpolate radially and along the last dimension. Slerp in the middle dimension. Only defined in 3D, for 2D point symmetry use "spherical". Supported additional keywords:
  • "r1_cylindrical": Apply slerp only for radii >= r1_cylindrical, default: 0.0.
  • "r0_cylindrical": Apply bi/trilinear interpolation for radii < r0_cylindrical, default: 0.0.
If r1_cylindrical > r0_cylindrical intermediate radii will linearly interpolate between both modes.
  • "SmoothieSEM": Special interpolation mode for spherical SmoothieSEM mesh that preserves the cylindrical "inner core". Supported additional keywords: "r0_spherical", "r1_spherical", "r0_cylindrical", and "r1_cylindrical" with the same meaning as for the other interpolation modes.
SIGNATURE
def change_tensor_order(
    mesh: UnstructuredMesh,
    tensor_order: salvus._core.types.int_ | None = None,
    interpolation_mode: InterpolationMode | str = InterpolationMode.linear,
    interpolation_kwargs: dict | None = None,
    make_unique_points: bool = True,
    tensor_node_locations: npt.NDArray | None = None,
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh whose tensor order to change.
Optional
tensor_order
Type:salvus._core.types.int_ | None
Default value:None
Description:
Desired new tensor order of the elements.
Optional
interpolation_mode
Type:InterpolationMode | str
Default value:InterpolationMode.linear
Description:
How to interpolate the location of the new grid points. See above description.
Optional
interpolation_kwargs
Type:dict | None
Default value:None
Description:
Extra keyword arguments for the chosen interpolation mode. See above description.
Optional
make_unique_points
Type:bool
Default value:True
Description:
Remove duplicate points. Make sure to have a reason if you set this to False.
Optional
tensor_node_locations
Type:npt.NDArray | None
Default value:None
Description:
Locations of the tensor nodes. Defaults to the GLL locations of the chosen tensor order. In almost all cases you will not have to change this.

locally_refine_mesh_in_place()

Refine the mesh locally using various refinement templates.
Please not that this will modify the mesh. Create a copy if you don't desire this behavior.
New grid points are created by interpolating the existing corner points. This function supports a variety of interpolation modes (some of which require extra kwargs to set as part of the interpolation_kwargs dictionary):
  • "linear": The default. Perform a bi/trilinear interpolation. No extra keyword arguments are supported or required for this mode.
  • "spherical": Linearly interpolate radially, slerp laterally. The center of the sphere is always considered to be at the origin of the coordinate system. Supported additional keywords: "r0_spherical" and "r1_spherical". Don't slerp < r0, slerp => r0, and linearly interpolate between both modes in between.
  • "cylindrical": Linearly interpolate radially and along the last dimension. Slerp in the middle dimension. Only makes sense in 3D, for 2D point symmetry use "spherical" Supported additional keywords: "r0_cylindrical" and "r1_cylindrical". Don't slerp < r0, slerp => r0, and linearly interpolate between both modes in between.
  • "SmoothieSEM": Special for SmoothieSEM, only for expert usage.
SIGNATURE
def locally_refine_mesh_in_place(
    mesh: UnstructuredMesh,
    mask: npt.NDArray,
    refinement_level: int = 1,
    hierarchical_map: npt.NDArray | None = None,
    refinement_type: RefinementType | str = RefinementType.unstable,
    interpolation_mode: InterpolationMode | str = InterpolationMode.linear,
    interpolation_kwargs: dict | None = None,
    reinterpolate_nodal_fields: bool = False,
    unique_points_tolerance: int = 12,
) -> npt.NDArray | None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The unstructured mesh to refine.
Required
mask
Type:npt.NDArray
Description:
Mark either elements, nodes or edges to refine, boolean array with shape (nelem,), (npoint,) or (nelem, edges_per_element)
Optional
refinement_level
Type:int
Default value:1
Description:
Refinement level, can only be larger than 1 for stable schemes and an elemental mask.
Optional
hierarchical_map
Type:npt.NDArray | None
Default value:None
Description:
Pass a hierarchical map to keep track of which element in a coarser mesh the newly created elements belongs to.
Optional
refinement_type
Type:RefinementType | str
Default value:RefinementType.unstable
Description:
Choose the refinement style, currently available in 2D are 'stable', 'unstable', 'stable_convex' and 'unstable_convex', in 3D 'unstable_unidir', 'unstable', 'stable_convex', 'unstable_convex', 'unstable_convex_dir', 'unstable_dir'. Here stable refers to maintaining the angles in multilevel refinements, convexity refers to the region in the mesh in terms of its connectivity (which may be different to its geometric shape for non-rectilinar meshes) and directionality refers to isotropic or anisotropic refinements (where the latter need an edge based refinement mask).
Optional
interpolation_mode
Type:InterpolationMode | str
Default value:InterpolationMode.linear
Description:
How to interpolate the location of the new grid points. See above description.
Optional
interpolation_kwargs
Type:dict | None
Default value:None
Description:
Extra keyword arguments for the chosen interpolation mode. See above description.
Optional
reinterpolate_nodal_fields
Type:bool
Default value:False
Description:
map nodal fields to the newly created nodes using linear interpolation
Optional
unique_points_tolerance
Type:int
Default value:12
Description:
The number of decimal digits used to determine unique points in the refined mesh.
RETURNS
Return type: npt.NDArray | None

Classes

InterpolationMode

The interpolation mode.
SIGNATURE
class InterpolationMode(enum.Enum):
    def __init__(self): ...

RefinementType

The possible refinement types.
SIGNATURE
class RefinementType(enum.Enum):
    def __init__(self): ...
PAGE CONTENTS