Version:

salvus.mesh.algorithms.unstructured_mesh.metrics

salvus.mesh.algorithms.unstructured_mesh.metrics salvus mesh algorithms unstructured_mesh metrics
Metrics for unstructured meshes.

Functions

compute_determinants()

Compute the determinant of the Jacobian for each element in the mesh.
SIGNATURE
def compute_determinants(mesh: UnstructuredMesh) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute it for.
RETURNS
Return type: npt.NDArray

compute_maximum_edge_length_per_element()

Return the max edge size for each element.
SIGNATURE
def compute_maximum_edge_length_per_element(
    mesh: UnstructuredMesh, mask: npt.NDArray | None = None
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute it for.
Optional
mask
Type:npt.NDArray | None
Default value:None
Description:
Apply a mask on the connectivity.
RETURNS
Return type: npt.NDArray

compute_mesh_quality()

Compute a few proxies for for mesh quality.
SIGNATURE
def compute_mesh_quality(
    mesh: UnstructuredMesh, quality_metric: str = "edge_aspect_ratio"
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute it for.
Optional
quality_metric
Type:str
Default value:'edge_aspect_ratio'
Description:
The quality metric to compute.
RETURNS
Return type: npt.NDArray

compute_minimum_edge_length_per_element()

Compute the smallest edge-length in an element.
Assumes a first order shape approximation.
SIGNATURE
def compute_minimum_edge_length_per_element(
    mesh: UnstructuredMesh,
    mask: npt.NDArray | None = None,
    direction: int | None = None,
    shape_order: int | None = None,
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute it for.
Optional
mask
Type:npt.NDArray | None
Default value:None
Description:
Optional mask to only compute it for a subset of elements. True includes elements.
Optional
direction
Type:int | None
Default value:None
Description:
Shortest edge-length along a given direction of the reference element in reference coordinates.
Optional
shape_order
Type:int | None
Default value:None
Description:
Override shape order for edge length computation.
RETURNS
Return type: npt.NDArray

compute_minimum_gll_distance()

Compute the minimum distance between GLL points per element.
Although the mesh is defined at a specific order, the GLL spacing may be computed at any arbitrary order. This is useful when computing spacing for higher order shape functions. For example, Salvus by default uses fourth order shape functions for the wavefield, unless explicitly changed in e.g.:
sn.WaveformSimulationConfiguration(
    spectral_element_order=spectral_element_order,
    ...,
)
To get the spacing required for computing the CFL criterion in those cases, one would need the minimum GLL distance for fourth order shape functions, even if the mesh is first order.
SIGNATURE
def compute_minimum_gll_distance(
    mesh: UnstructuredMesh,
    shape_order: int,
    execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
    use_bindings: bool = True,
) -> npt.NDArray: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute the minimum GLL distance for.
Required
shape_order
Type:int
Description:
The shape order to use for the GLL points.
Optional
execution_policy
Type:bindings.ExecutionPolicy
Default value:<salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy object at 0x7c032b939a30>
Description:
The execution policy to use for C++ bindings.
Optional
use_bindings
Type:bool
Default value:True
Description:
Whether to use the C++ bindings for improved performance.
RETURNS
Return type: npt.NDArray
The minimum GLL distance for each element.

compute_time_step()

Compute the time step for the given mesh and velocity.
The time step is estimated by means of the Courant-Friedrichs-Lewy (CFL) condition, which relates the time step to the spatial discretization and the wave propagation speed. This implementation accounts for deformed higher-order element.
Note that this implementation by defaults uses a shape order of 4 if not specified. This is the default order at which Salvus parametrizes wavefields, but can be changed by e.g.:
sn.WaveformSimulationConfiguration(
    spectral_element_order=spectral_element_order,
    ...,
)
The Courant-number in the CFL condition defaults to 0.6 for 2D meshes and 0.47 for 3D meshes.
SIGNATURE
def compute_time_step(
    mesh: UnstructuredMesh,
    max_velocity: npt.NDArray | float,
    courant_number: float | None = None,
    simulation_order: int | None = None,
    attach: bool = False,
    execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
    use_bindings: bool = True,
) -> tuple[float, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute the time step for.
Required
max_velocity
Type:npt.NDArray | float
Description:
The maximum velocity to use for the time step computation. Can be passed globally or per element.
Optional
courant_number
Type:float | None
Default value:None
Description:
The Courant number to use for the CFL condition.
Optional
simulation_order
Type:int | None
Default value:None
Description:
The shape order to use for the time step computation.
Optional
attach
Type:bool
Default value:False
Description:
Whether to attach the computed time step to the mesh. Will raise an error if the field time_step is already attached.
Optional
execution_policy
Type:bindings.ExecutionPolicy
Default value:<salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy object at 0x7c032bd0d7b0>
Description:
The execution policy to use for C++ bindings.
Optional
use_bindings
Type:bool
Default value:True
Description:
Whether to use the C++ bindings for improved performance.
EXCEPTIONS
ValueError
If the field time_step is already attached to the mesh and attach is True.
RETURNS
Return type: tuple[float, npt.NDArray]
The global minimum time step and the minimum time step per element.

estimate_resolved_frequency()

Estimate the highest resolved frequency in each element.
SIGNATURE
def estimate_resolved_frequency(
    mesh: UnstructuredMesh,
    min_velocity: npt.NDArray,
    elements_per_wavelength: float,
) -> tuple[float, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute it for.
Required
min_velocity
Type:npt.NDArray
Description:
Minimum velocity in each element.
Required
elements_per_wavelength
Type:float
Description:
The elements per wavelength.
RETURNS
Return type: tuple[float, npt.NDArray]

estimate_time_step()

Compute an estimation of the time step set by each element.
This function is deprecated in favor of compute_time_step, which uses more appropriate defaults and a simplified API.
The time step is estimated by means of the Courant-Friedrichs-Lewy (CFL) condition, which relates the time step to the spatial discretization and the wave propagation speed. This method is an estimation, as it does not fully account for heavily deformed elements.
SIGNATURE
def estimate_time_step(
    mesh: UnstructuredMesh,
    max_velocity: npt.NDArray | float,
    courant_number: float = 1.0,
    min_gll_point_distance: float = 1.0,
    fast: bool = True,
    return_hmin_elemnodes: bool = False,
    shape_order: int | None = None,
    execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
) -> tuple[float, npt.NDArray] | tuple[float, npt.NDArray, npt.NDArray]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to compute the time step for.
Required
max_velocity
Type:npt.NDArray | float
Description:
Fastest velocity overall or per element. If the velocities are heterogeneous, more accurate (and less conservative) estimates will be provided by passing the varying velocities.
Optional
courant_number
Type:float
Default value:1.0
Description:
The Courant number to use in the CFL-criterion.
Optional
min_gll_point_distance
Type:float
Default value:1.0
Description:
The minimum distance between GLL points.
Optional
fast
Type:bool
Default value:True
Description:
Whether to use the fast estimation method.
Optional
return_hmin_elemnodes
Type:bool
Default value:False
Description:
Whether to return the minimum within-element distances.
Optional
shape_order
Type:int | None
Default value:None
Description:
Override shape order for edge length computation. Useful, as Salvus meshes and wavefields are not necessarily defined at the same order. By default, Salvus will define wavefields on fourth order shape functions.
Optional
execution_policy
Type:bindings.ExecutionPolicy
Default value:<salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy object at 0x7c032d80be30>
Description:
The execution policy to use for C++ bindings.
RETURNS
Return type: tuple[float, npt.NDArray] | tuple[float, npt.NDArray, npt.NDArray]
PAGE CONTENTS