Mondaic
This API reference is not for the latest stable Salvus version.

salvus.mesh.algorithms.unstructured_mesh.deformations

Deformation algorithms of unstructured meshes.

Functions

apply_deformations()

def apply_deformations(
    mesh: UnstructuredMesh, names: typing.Optional[typing.List[str]] = None
) -> None: ...

Apply the previously added deformations.

Parameters
  • mesh UnstructuredMesh — The mesh.
  • names typing.Optional[typing.List[str]] — Names of the deformations to apply. Defaults to all added ones.
Returns None

apply_scale()

def apply_scale(mesh: UnstructuredMesh) -> None: ...

Apply the scaling factor to the mesh.

Parameters
  • mesh UnstructuredMesh — The mesh.
Returns None

compute_deformation_2D()

def compute_deformation_2D(
    points: npt.NDArray,
    x: npt.NDArray,
    deformation: npt.NDArray,
    mode: DeformationMode2D,
    vertical_reference: float | None = None,
    vertical_begin_deformation: float = 0.0,
    vertical_end_deformation: float = inf,
) -> npt.NDArray: ...

Compute vertical deformation of a 2-D array of points.

The deformation is applied to the points at vertical_reference with control over how the points above and below move.

Any keyword arguments are passed to scipy’s RectBivariateSpline interpolator.

Parameters
  • points npt.NDArray — The points to deform.
  • x npt.NDArray — horizontal coordinates of the deformation. Angle in radians for spherical models.
  • deformation npt.NDArray — The deformation sampled at coordinates x.
  • mode DeformationMode2D — The interpolation mode.
  • vertical_reference float | None — Vertical coordinate, at which the deformation should be applied, e.g. y-coordinate of the surface for surface deformation. Defaults to the max y coordinate / radius in case at least one of y0, y1 are finite.
  • vertical_begin_deformation float — Don’t deform any points with a vertical coordinate smaller than this.
  • vertical_end_deformation float — Don’t deform any points with a vertical coordinate larger than this.
Returns npt.NDArray

compute_deformations_3D()

def compute_deformations_3D(
    points: npt.NDArray,
    x: npt.NDArray,
    y: npt.NDArray,
    deformation: npt.NDArray,
    mode: DeformationMode3D,
    vertical_reference: typing.Optional[float] = None,
    vertical_begin_deformation: float = 0.0,
    vertical_end_deformation: float = inf,
    interpolation_order: int = 3,
) -> npt.NDArray: ...

Compute vertical deformation of a 3-D array of points.

The deformation is applied to the points at vertical_reference with control over how the points above and below move.

Any keyword arguments are passed to scipy’s RectBivariateSpline interpolator.

Parameters
  • points npt.NDArray — The points to deform.
  • x npt.NDArray — first horizontal coordinate of the deformation. Angle in radians for spherical models.
  • y npt.NDArray — second horizontal coordinate of the deformation. Angle in radians for spherical models.
  • deformation npt.NDArray — The deformation sampled at coordinates x and y.
  • mode DeformationMode3D — Interpolation mode.
  • vertical_reference typing.Optional[float] — Vertical coordinate, at which the deformation should be applied, e.g. y-coordinate of the surface for surface deformation. Defaults to the max z coordinate / radius in case at least one of z0, z1 are finite.
  • vertical_begin_deformation float — Don’t deform any points with a vertical coordinate smaller than this.
  • vertical_end_deformation float — Don’t deform any points with a vertical coordinate larger than this.
  • interpolation_order int — horizontal degree of the spline interpolation. For unstructured data either 1 or 3.
Returns npt.NDArray

compute_deformations_cylindrical()

def compute_deformations_cylindrical(
    points: npt.NDArray,
    phi: npt.NDArray,
    z: npt.NDArray,
    deformation: npt.NDArray,
    r0: float = 0.0,
    r1: float = inf,
    rref: typing.Optional[float] = None,
    kx: int = 1,
    ky: int = 1,
) -> npt.NDArray: ...

Compute mesh deformations in a cylindrical coordinate system.

Add deformation for cylindrical meshes where the axis of the cylinder is aligned with the z component. The DEM radially stretches the domain in the region of (x,y)-radii in [r0, r1] - points below r0 are kept fixed, points above r1 are moved as the DEM, points in between are interpolated and the full DEM is applied to points at rref.

Usage: first call add_dem_cylindrical for each boundary that is to be perturbed and finally call apply_dem to add the perturbation to the mesh coordinates.

Parameters
  • points npt.NDArray — The points whose deformation is to be computed.
  • phi npt.NDArray — Angle in the x-y-plane of the DEM in radians.
  • z npt.NDArray — z-coordinates of the DEM.
  • deformation npt.NDArray — the DEM sampled at the coordinates (phi,z)
  • r0 float — radius in x-y-plane at which the stretching begins
  • r1 float — radius in x-y-plane at which the stretching ends, can be infinity
  • rref typing.Optional[float] — radius in x-y-plane at which the deformation should be applied
  • kx int — horizontal degree of the spline interpolation
  • ky int — vertical degree of the spline interpolation
Returns npt.NDArray

compute_deformations_ellipticity()

def compute_deformations_ellipticity(
    points: npt.NDArray, deformation: npt.NDArray, scale: float = 1.0
) -> npt.NDArray: ...

Compute elliptic deformations of a 3-D set of points.

Parameters
  • points npt.NDArray — The points to compute it for.
  • deformation npt.NDArray — The deformation for each point.
  • scale float — Scale the radius by this value.
Returns npt.NDArray

queue_mesh_deformations_2D()

def queue_mesh_deformations_2D(
    mesh: UnstructuredMesh,
    x: npt.NDArray,
    deformation: npt.NDArray,
    vertical_begin_deformation: float = 0.0,
    vertical_end_deformation: float = inf,
    vertical_reference: typing.Optional[float] = None,
    name: typing.Optional[str] = None,
    mode: DeformationMode2D | str = DeformationMode2D.cartesian,
) -> None: ...

Queue a 2D deformation for later application.

Please see the compute_deformation_2D function for more information.

Parameters
  • mesh UnstructuredMesh — The mesh to queue for.
  • x npt.NDArray — horizontal coordinates of the deformation. Angle in radians for spherical models.
  • deformation npt.NDArray — The deformation sampled at coordinates x.
  • vertical_begin_deformation float — Don’t deform any points with a vertical coordinate smaller than this.
  • vertical_end_deformation float — Don’t deform any points with a vertical coordinate larger than this.
  • vertical_reference typing.Optional[float] — Vertical coordinate, at which the deformation should be applied, e.g. y-coordinate of the surface for surface deformation. Defaults to the max y coordinate / radius in case at least one of y0, y1 are finite.
  • name typing.Optional[str] — Optionally pass a name for the deformation.
  • mode DeformationMode2D | str — The deformation mode.
Returns None

queue_mesh_deformations_3D()

def queue_mesh_deformations_3D(
    mesh: UnstructuredMesh,
    x: npt.NDArray,
    y: npt.NDArray,
    deformation: npt.NDArray,
    vertical_begin_deformation: float = 0.0,
    vertical_end_deformation: float = inf,
    vertical_reference: typing.Optional[float] = None,
    interpolation_order: int = 3,
    mode: DeformationMode3D | str = DeformationMode3D.cartesian,
    name: typing.Optional[str] = None,
) -> None: ...

Queue a 3D deformation for later application.

Please see the compute_deformation_3D function for more information.

Parameters
  • mesh UnstructuredMesh — The mesh to queue for.
  • x npt.NDArray — first horizontal coordinate of the deformation. Angle in radians for spherical models.
  • y npt.NDArray — second horizontal coordinate of the deformation. Angle in radians for spherical models.
  • deformation npt.NDArray — The deformation sampled at coordinates x.
  • vertical_begin_deformation float — Don’t deform any points with a vertical coordinate smaller than this.
  • vertical_end_deformation float — Don’t deform any points with a vertical coordinate larger than this.
  • vertical_reference typing.Optional[float] — Vertical coordinate, at which the deformation should be applied, e.g. y-coordinate of the surface for surface deformation. Defaults to the max y coordinate / radius in case at least one of y0, y1 are finite.
  • interpolation_order int — Horizontal interpolation order.
  • mode DeformationMode3D | str — The deformation mode.
  • name typing.Optional[str] — Optionally pass a name for the deformation.
Returns None

queue_mesh_deformations_cylindrical()

def queue_mesh_deformations_cylindrical(
    mesh: UnstructuredMesh,
    phi: npt.NDArray,
    z: npt.NDArray,
    dem: npt.NDArray,
    r0: float = 0.0,
    r1: float = inf,
    rref: typing.Optional[float] = None,
    name: typing.Optional[str] = None,
) -> None: ...

Queue cylindrical deformations for later application.

Add deformation for cylindrical meshes where the axis of the cylinder is aligned with the z component. The DEM radially stretches the domain in the region of (x,y)-radii in [r0, r1] - points below r0 are kept fixed, points above r1 are moved as the DEM, points in between are interpolated and the full DEM is applied to points at rref.

Usage: first call add_dem_cylindrical for each boundary that is to be perturbed and finally call apply_dem to add the perturbation to the mesh coordinates.

Parameters
  • mesh UnstructuredMesh — The mesh.
  • phi npt.NDArray — Angle in the x-y-plane of the DEM in radians.
  • z npt.NDArray — z-coordinates of the DEM.
  • dem npt.NDArray — the DEM sampled at the coordinates (phi,z)
  • r0 float — radius in x-y-plane at which the stretching begins
  • r1 float — radius in x-y-plane at which the stretching ends, can be infinity
  • rref typing.Optional[float] — radius in x-y-plane at which the deformation should be applied
  • name typing.Optional[str] — name of this deformation to refer to it in UnstructuredMesh.apply_dem()
Returns None

Classes

DeformationMode2D

class DeformationMode2D(enum.Enum):
    def __init__(self): ...

The deformation mode for 2D deformations.

DeformationMode3D

class DeformationMode3D(enum.Enum):
    def __init__(self): ...

The deformation mode for 3D deformations.