salvus.mesh.simple_mesh.basic_mesh
Useful meshing classes.
Functions
extrude_domain_ab()
extrude_domain_ab()def extrude_domain_ab(
d: _domain.Domain,
ab: Optional[AbsorbingBoundaryParameters],
h_max: List[float],
side_sets: Optional[List[str]] = None,
force: bool = False,
) -> Tuple[_domain.Domain, List[str], float]: ...Extrude the domain to account for absorbing boundaries.
If no absorbing boundaries are passed, the domain is just returned as is (except when force is True — see below).
Returns the extruded domain and a list of realized side sets (i.e. [‘x0’, ‘x1’, ‘y0’] when given ‘all_except_free_surface’ in a 2-D domain).
d_domain.Domain — The domain to extrude.abOptional[AbsorbingBoundaryParameters] — The optional absorbing boundaries.h_maxList[float] — A list of the element sizes along each dimension.side_setsOptional[List[str]] — The side sets to extrude along.forcebool — Force extrusion even if ab is None. Useful for extruding by h_max only — kept to retain legacy behavior.
get_domain_radius()
get_domain_radius()def get_domain_radius(layered_model: lm.LayeredModel) -> float: ...Get the domain radius from a layered model.
Useful when the radius is set outside of the layered model itself, i.e. in the RADIUS attribute. This can be the case for some BM files.
layered_modellm.LayeredModel — The layered model.
get_poissons_ratio()
get_poissons_ratio()def get_poissons_ratio(vp: float, vs: float) -> float: ...Determine Poisson’s ratio from VP and VS.
vpfloat — P-wave velocity.vsfloat — S-wave velocity.
rho_from_gardeners()
rho_from_gardeners()def rho_from_gardeners(
vp: Union[numpy.ndarray, float]
) -> Union[numpy.ndarray, float]: ...Compute density using Gardner’s relationship.
vpUnion[numpy.ndarray, float] — VP array.
rho_from_gardners()
rho_from_gardners()def rho_from_gardners(
vp: Union[numpy.ndarray, float], alpha: float = 310.0, beta: float = 0.25
) -> Union[numpy.ndarray, float]: ...Compute density using Gardner’s relationship.
According to Gardner’s equation, density [kg/m] is related to vp [m/s] using ho = lpha v_p^eta, with empirically derived constants lpha and eta. Note that the original work used units of g/cc and ft/s, respectively.
Reference: https://www.subsurfwiki.org/wiki/Gardner%27s_equation
vpUnion[numpy.ndarray, float] — P-wave velocity.alphafloat — Gardner’s first contant.betafloat — Gardner’s second contant.
vs_from_poisson()
vs_from_poisson()def vs_from_poisson(
vp: Union[numpy.ndarray, float], poisson_ratio: float = 0.25
) -> Union[numpy.ndarray, float]: ...Compute VS from VP given a certain Poisson’s ratio.
vpUnion[numpy.ndarray, float] — VP array.poisson_ratiofloat — Poisson’s ratio to apply.
Classes
AbsorbingBoundaryParameters
AbsorbingBoundaryParametersclass AbsorbingBoundaryParameters(
salvus.flow.utils.serialization_helpers.SerializationMixin
):
def __init__(
self,
reference_velocity: float,
number_of_wavelengths: float,
reference_frequency: float,
free_surface: Union[bool, List[str]] = True,
) -> None: ...Required information to extend the mesh for absorbing boundaries.
This class encapsulates the parameters required for mesh extrusion in the
presence of absorbing boundary layers. All parameters need to be
specified and will be used in relation to each other to calculate an
appropriate distance by which to extend the mesh.
A good rule of thumb is to extend the domain by 3.5 or more wavelengths
at each boundary which is marked as absorbing. In domain with
heterogeneous velocities some experimentation may be required to find the
optimal settings which balance the performance of the solver (e.g. # of
total elements) with the performance of the absorbing boundaries (e.g.
maximum reflection coefficient).
Initialize the absorbing boundary parameters.
reference_velocityfloat — Wave velocity in the absorbing boundary layer.number_of_wavelengthsfloat — Number of wavelengths to pad the domain by.reference_frequencyfloat — Reference frequency for the distance calculation (i.e. the center frequency of the source).free_surfaceUnion[bool, List[str]] — If True, retain a free surface, and don’t mark the top surface (either r1 or z1) as absorbing. For Cartesian domains, one can also pass a list of side sets (i.e. [“z0”, “z1”] in the case of a thin plate) that should be kept as a free surface.
distance float
distance floatDistance in meters of the absorbing boundaries.
number_of_wavelengths float
number_of_wavelengths floatGet the stored number of wavelengths.
reference_frequency float
reference_frequency floatGet the stored reference frequency.
reference_velocity float
reference_velocity floatGet the stored velocity.
side_sets List[str]
side_sets List[str]Get the side sets for the schema.
from_json()
from_json()def from_json(d: Dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dDict — Dictionary containing its init parameters and a few other things.
no_sponge_layers()
no_sponge_layers()def no_sponge_layers(
free_surface: Union[bool, List[str]] = True
) -> AbsorbingBoundaryParameters: ...Simplified constructor to handle when sponge layers are not desired.
When applied to a mesh will signify that first-order absorbing boundary conditions should be applied at the requisite side, and no domain extrusion / sponge layer attachment should occur
free_surfaceUnion[bool, List[str]] — If True, retain a free surface, and don’t mark the top surface (either r1 or z1) as absorbing. For Cartesian domains, one can also pass a list of side sets (i.e. [“z0”, “z1”] in the case of a thin plate) that should be kept as a free surface.
AbsorbingBoundaryParameters object that requests the attachment of first-order absorbing boundary conditions only.to_json()
to_json()def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...Serialize the object to dictionary that can be written to JSON.
external_file_hashOptional[str] — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
CartesianFromBm2D
CartesianFromBm2Dclass CartesianFromBm2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian2D,
):
def __init__(
self,
bm_file: Union[pathlib.Path, str],
x_min: float = 0.0,
x_max: float,
y_min: float = 0.0,
y_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
interlayer_coarsening_policy: Optional[
lm.meshing_protocol.coarsening_policy.InterlayerCoarseningPolicy
] = None,
): ...Class to handle cartesian meshes created from BM files in 2D.
Initialize a mesh from an externally computed BM file. Useful for simple layered models.
bm_fileUnion[pathlib.Path, str] — Path to bm file.x_minfloat — Min extent of the x-dimension in meter.x_maxfloat — Max extent of the x-dimension in meter.y_minfloat — Min extent of the y-dimension in meter.y_maxfloat — Max extent of the y-dimension in meter.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.interlayer_coarsening_policyOptional[lm.meshing_protocol.coarsening_policy.InterlayerCoarseningPolicy] — Add a custom interlayer coarsening policy to the mesh.
CartesianFromBm3D
CartesianFromBm3Dclass CartesianFromBm3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian3D,
):
def __init__(
self,
bm_file: Union[pathlib.Path, str],
x_max: float,
y_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
z_range: Optional[Iterable[float]] = None,
use_lm: bool = True,
bm_shift: float = 0.0,
interlayer_coarsening_policy: Optional[
lm.meshing_protocol.coarsening_policy.InterlayerCoarseningPolicy
] = None,
): ...Class to handle cartesian meshes created from BM files in 3D.
Initialize a mesh from an externally computed BM file. Useful for simple layered models.
bm_fileUnion[pathlib.Path, str] — Path to bm file.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.z_rangeOptional[Iterable[float]] — Range in the vertical direction of the mesh.use_lmbool — Use the layered meshing backend.bm_shiftfloat — Used to offset layered models in project’s UTM domains to retain previous behavior.interlayer_coarsening_policyOptional[lm.meshing_protocol.coarsening_policy.InterlayerCoarseningPolicy] — Add a custom interlayer coarsening policy to the mesh.
CartesianHomogeneousAcoustic2D
CartesianHomogeneousAcoustic2Dclass CartesianHomogeneousAcoustic2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian2D,
):
def __init__(
self,
vp: float,
rho: float,
x_max: float,
y_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian acoustic meshes in 2D.
Initialize a simple homogeneous acoustic mesh.
vpfloat — P-wave velocity.rhofloat — Density.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.
CartesianHomogeneousAcoustic3D
CartesianHomogeneousAcoustic3Dclass CartesianHomogeneousAcoustic3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian3D,
):
def __init__(
self,
vp: float,
rho: float,
x_max: float,
y_max: float,
z_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian acoustic meshes in 3D.
Initialize a simple homogeneous acoustic mesh.
vpfloat — P-wave velocity.rhofloat — Density.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.z_maxfloat — Size of z-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.
CartesianHomogeneousIsotropicElastic2D
CartesianHomogeneousIsotropicElastic2Dclass CartesianHomogeneousIsotropicElastic2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian2D,
):
def __init__(
self,
vp: float,
vs: float,
rho: float,
x_max: float,
y_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian isotropic elastic meshes in 2D.
Initialize a simple homogeneous isotropic elastic mesh.
vpfloat — P-wave velocity.vsfloat — S-wave velocity.rhofloat — Density.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.
CartesianHomogeneousIsotropicElastic3D
CartesianHomogeneousIsotropicElastic3Dclass CartesianHomogeneousIsotropicElastic3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian3D,
):
def __init__(
self,
vp: float,
vs: float,
rho: float,
x_max: float,
y_max: float,
z_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian isotropic elastic meshes 3D.
Initialize a simple homogeneous isotropic elastic mesh.
vpfloat — P-wave velocity.vsfloat — S-wave velocity.rhofloat — Density.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.z_maxfloat — Size of z-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.
CartesianHomogeneousIsotropicViscoElastic2D
CartesianHomogeneousIsotropicViscoElastic2Dclass CartesianHomogeneousIsotropicViscoElastic2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian2D,
):
def __init__(
self,
vp: float,
vs: float,
rho: float,
qkappa: float,
qmu: float,
x_max: float,
y_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian isotropic elastic meshes in 2D.
Initialize a simple homogeneous isotropic elastic mesh.
vpfloat — P-wave velocity.vsfloat — S-wave velocity.rhofloat — Density.qkappafloat — Qkappa.qmufloat — Qmu.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing the absorbing boundaries.use_lmbool — Use the layered meshing backend.
CartesianTransverselyIsotropicElastic3D
CartesianTransverselyIsotropicElastic3Dclass CartesianTransverselyIsotropicElastic3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh.Cartesian3D,
):
def __init__(
self,
vpv: float,
vph: float,
vsv: float,
vsh: float,
eta: float,
rho: float,
x_max: float,
y_max: float,
z_max: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
use_lm: bool = True,
): ...Base class to handle homogeneous cartesian isotropic elastic meshes 3D.
Initialize a simple homogeneous isotropic elastic mesh.
vpvfloat — P-wave velocity (along symmetry axis).vphfloat — P-wave velocity (perpendicular to symmetry axis).vsvfloat — P-wave velocity (along symmetry axis).vshfloat — P-wave velocity (perpendicular to symmetry axis).etafloat — TTI Eta parameter.rhofloat — Density.x_maxfloat — Size of x-dimension in meters.y_maxfloat — Size of y-dimension in meters.z_maxfloat — Size of z-dimension in meters.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape.use_lmbool — Use the layered meshing backend.
Circular2D
Circular2Dclass Circular2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._Circular2D,
):
def __init__(self, radius: float = inf): ...Base class to handle simple spherical chunk meshes using one of the built in models.
Generate a circular mesh.
radiusfloat — The radius of the circle in meters.
GlobalBuiltIn3D
GlobalBuiltIn3Dclass GlobalBuiltIn3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._Globe3D,
):
def __init__(
self,
model: Union[str, Callable],
period: float,
tensor_order: int = 1,
constant_q_frequency_band: Optional[Tuple[float, float]] = None,
max_depth_in_meters: Optional[float] = None,
use_lm: bool = True,
): ...Base class to build global meshes using one of the built in models.
modelUnion[str, Callable] — Model name.periodfloat — Mesh period.tensor_orderint — Tensor order for the mesh.constant_q_frequency_bandOptional[Tuple[float, float]] — A tuple of frequencies (low, high) over which Q should be approximately constant. If not passed, the band will be estimatedmin_period_in_seconds.max_depth_in_metersOptional[float] — The maximum depth of the mesh. IfNone, a full sphere will be constructed.use_lmbool — Use the layered meshing backend.
Globe3D
Globe3Dclass Globe3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._Globe3D,
):
def __init__(self, radius: float = inf): ...Base class to handle simple spherical chunk meshes using one of the built in models.
Generate a spherical mesh.
radiusfloat — The radius of the sphere in meters.
SphericalChunkBuiltIn3D
SphericalChunkBuiltIn3Dclass SphericalChunkBuiltIn3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._SphericalChunk3D,
):
def __init__(
self,
model: Union[str, Callable],
period: float,
latitude_extent: float,
longitude_extent: float,
tensor_order: int = 1,
latitude_center: float = 0.0,
longitude_center: float = 0.0,
elements_per_wavelength: float = 2.0,
minimum_radius_in_km: float = 3755.0,
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
] = None,
constant_q_frequency_band: Optional[Tuple[float, float]] = None,
use_lm: bool = True,
): ...Base class to handle simple spherical chunk meshes using one of the built in models.
Get a spherical chunk mesh based on a 1-D background model.
This function returns a spherical chunk mesh with a 1-D model attached to it. The 1-D model is necessary, at it is used to set the element sizes and adjust the double and tripling layers with depth. It also defines a series of strict spherical discontinuities which the mesh will honour. Once the mesh is returned, one can then overwrite the background model with their own 3-D model as desired.
modelUnion[str, Callable] — The name of the 1-D background model.periodfloat — The minimum seismic period for which to generate the mesh. This value is used in conjunction withelements_per_wavelengthto control the accuracy of the simulation.latitude_extentfloat — The latitudinal extent of the mesh from its center in degrees.longitude_extentfloat — The longitudinal extent of the mesh from its center in degrees.tensor_orderint — The order of the model representation (1, 2, or 4). See the “Model Order” tutorial on the website for more details.latitude_centerfloat — The latitudinal center of the mesh in degrees.longitude_centerfloat — The longitudinal center of the mesh in degrees. elements_per_wavelength: Given the 1-D background model and period as specified, ensure that there are at least this many elements per minimum wavelength throughout the mesh volume.elements_per_wavelengthfloat — The desired elements per wavelength for the to be created mesh.minimum_radius_in_kmfloat — Minimum radius of the mesh in kilometers.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters controlling the extrusion of the domain for the purposes of adding absorbing boundaries.constant_q_frequency_bandOptional[Tuple[float, float]] — A tuple of frequencies (low, high) over which Q should be approximately constant. If not passed, the band will be estimatedmin_period_in_seconds.use_lmbool — Use the layered meshing backend.
SphericalFromBm3D
SphericalFromBm3Dclass SphericalFromBm3D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._Globe3D,
):
def __init__(
self,
bm_file: Union[str, pathlib.Path, Callable],
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
constant_q_frequency_band: Optional[Tuple[float, float]] = None,
use_lm: bool = True,
): ...Class to handle cartesian meshes created from BM files in 3D.
Initialize a mesh from an externally computed BM file. Useful for simple layered models.
bm_fileUnion[str, pathlib.Path, Callable] — Path to bm file.max_frequencyfloat — Maximum expected frequency in mesh.elements_per_wavelengthfloat — Elements per mimimum wavelength.tensor_orderint — Order of the GLL model and shape mapping.constant_q_frequency_bandOptional[Tuple[float, float]] — A tuple of frequencies (low, high) over which Q should be approximately constant. If not passed, the band will be estimatedmin_period_in_seconds.use_lmbool — Use the layered meshing backend.
SphericalHomogeneousAcoustic2D
SphericalHomogeneousAcoustic2Dclass SphericalHomogeneousAcoustic2D(
salvus.mesh.simple_mesh.basic_mesh._MigratedBasicMeshProtocol,
salvus.mesh.simple_mesh._Circular2D,
):
def __init__(
self,
vp: float,
rho: float,
radius: float,
max_frequency: float,
elements_per_wavelength: float = 2.0,
tensor_order: int = 1,
use_lm: bool = True,
): ...Base class to handle simple spherical chunk meshes using one of the built in models.
vpfloat — vp velocityrhofloat — densityradiusfloat — Radius of the sphere.max_frequencyfloat — Mesh frequency.elements_per_wavelengthfloat — The number of elements per wavelength.tensor_orderint — Tensor order of the mesh.use_lmbool — Use the layered meshing backend.