salvus.mesh.algorithms.unstructured_mesh.refinements
Refinements of unstructured meshes.
Functions
change_tensor_order()
change_tensor_order()def change_tensor_order(
mesh: UnstructuredMesh,
tensor_order: typing.Optional[salvus._core.types.int_] = None,
interpolation_mode: InterpolationMode | str = InterpolationMode.linear,
interpolation_kwargs: typing.Optional[typing.Dict] = None,
make_unique_points: bool = True,
tensor_node_locations: typing.Optional[npt.NDArray] = None,
) -> None: ...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.
meshUnstructuredMesh — The mesh whose tensor order to change.tensor_ordertyping.Optional[salvus._core.types.int_] — Desired new tensor order of the elements.interpolation_modeInterpolationMode | str — How to interpolate the location of the new grid points. See above description.interpolation_kwargstyping.Optional[typing.Dict] — Extra keyword arguments for the chosen interpolation mode. See above description.make_unique_pointsbool — Remove duplicate points. Make sure to have a reason if you set this toFalse.tensor_node_locationstyping.Optional[npt.NDArray] — 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()
locally_refine_mesh_in_place()def locally_refine_mesh_in_place(
mesh: UnstructuredMesh,
mask: npt.NDArray,
refinement_level: int = 1,
hierarchical_map: typing.Optional[npt.NDArray] = None,
refinement_type: RefinementType | str = RefinementType.unstable,
interpolation_mode: InterpolationMode | str = InterpolationMode.linear,
interpolation_kwargs: typing.Optional[typing.Dict] = None,
reinterpolate_nodal_fields: bool = False,
unique_points_tolerance: int = 12,
) -> typing.Optional[npt.NDArray]: ...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.
meshUnstructuredMesh — The unstructured mesh to refine.masknpt.NDArray — Mark either elements, nodes or edges to refine, boolean array with shape (nelem,), (npoint,) or (nelem, edges_per_element)refinement_levelint — Refinement level, can only be larger than 1 for stable schemes and an elemental mask.hierarchical_maptyping.Optional[npt.NDArray] — Pass a hierarchical map to keep track of which element in a coarser mesh the newly created elements belongs to.refinement_typeRefinementType | str — 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).interpolation_modeInterpolationMode | str — How to interpolate the location of the new grid points. See above description.interpolation_kwargstyping.Optional[typing.Dict] — Extra keyword arguments for the chosen interpolation mode. See above description.reinterpolate_nodal_fieldsbool — map nodal fields to the newly created nodes using linear interpolationunique_points_toleranceint — The number of decimal digits used to determine unique points in the refined mesh.
Classes
InterpolationMode
InterpolationModeclass InterpolationMode(enum.Enum):
def __init__(self): ...The interpolation mode.
RefinementType
RefinementTypeclass RefinementType(enum.Enum):
def __init__(self): ...The possible refinement types.