salvus.project.components.types
salvus.project.components.types salvus project components types Types to be used throughout project.
Classes
Dim
Dimclass Dim(enum.Enum):
def __init__(self): ...The spatial dimension.
MeshResolution
MeshResolutionclass MeshResolution(builtins.object):
def __init__(
self,
reference_frequency: salvus._core.types.float_,
elements_per_wavelength: (
salvus._core.types.float_ | tuple[salvus._core.types.float_, ...]
) = 1.5,
model_order: salvus._core.types.int_ = 1,
model_precision: type[np.number] = numpy.float64,
): ...The mesh resolution specification.
The canonical measure of the resolution of a Salvus waveform simulation is the number of elements that span a given reference wavelength in the mesh. For instance, a phrase like “we design our mesh so that there are 1.5 elements per minimum wavelength at 1 MHz” would communicate that signals up to 1 MHz can be interpreted with confidence. Often, however, one does not know the minimum wavelength a-priori, and only in fact knows the cutoff frequency of their transducer, or the minimum period of their earthquake source model, for instance. This class enables the user to express their intent to resolve waves up to a given maximum frequency, and it will be used in conjunction with the meshing algorithms and model interpolators to produce a mesh that attempts to honor that intent.
Specify resolution in terms of frequency and elements per wavelength.
Users can to specify the desired elements per wavelength per dimension and per layer. For example, in a 2-D 2-layer model one could specify:
- [(1.0, 2.0), (2.0, 4.0)] to request, in the first layer, 1.0
element per wavelength in the horizontal direction and 2.0 in
the vertical direction, and in the second layer, 2.0 elements
per wavelength in the horizontal direction and 4.0 in the
vertical direction.
While in a 3-D 2-layer model one could specify:
- [(1.0, 1.0, 2.0), (2.0, 2.0, 4.0)] to request, in the first
layer, 1.0 element per wavelength in _both_ horizontal
directions and 2.0 in the vertical direction, and in the
second layer, 2.0 elements per wavelength in _both_
horizontal directions and 4.0 in the vertical direction.
Broadcasting rules in 2-D, where values for not all dimensions or layers are specified, are as follows:
- 1.0 => 1.0 elements per wavelength in all dimensions for all
layers.
- (1.0, 2.0) => 1.0 elements per wavelength in the horizontal
direction, 2.0 in the vertical direction, for all layers.
- [(1.0, 2.0), (2.0, 4.0)] => That which is described in the
2-D example above, with the additional comment that the last
entry (2.0, 4.0) will be used for all subsequent layers beyond 2.
Broadcasting rules in 3-D, where values for not all dimensions or layers are specified, are slightly different: - 1.0 => 1.0 elements per wavelength in all dimensions for all layers. - (1.0, 2.0) => 1.0 elements per wavelength in both horizontal direction, 2.0 in the vertical direction, for all layers. - [(1.0, 2.0), (2.0, 4.0)] => That which is described in the 3-D example above: note that the horizontal direction is broadcast to become (1.0, 1.0, 2.0) and (2.0, 2.0, 4.0) respectively. The last entry (2.0, 4.0) will be used for all subsequent layers beyond 2, with the same horizontal broadcasting rules applied.
The corresponding dimensions to each of the elements per wavelength are independent of the coordinate system, and simply reference horizontal and vertical directions, respectively. Coordinate names will always be alphabetical, so:
- in 2-D: x, y
- in 3-D: x, y, z
- in 2-D spherical: latitude, radius
- in 3-D spherical: latitude, longitude, radiusreference_frequencysalvus._core.types.float_ — Reference frequency at which to compute the local wavelengths.elements_per_wavelengthsalvus._core.types.float_ | tuple[salvus._core.types.float_, ...] — The number of elements per wavelength, specified according to the description above.model_ordersalvus._core.types.int_ — The polynomial order of the model representation on each element.model_precisiontype[np.number] — The numerical precision of the model parameters in the mesh. Defaults tonp.float64for double precision.
elements_per_wavelength tuple[float, ...]
elements_per_wavelength tuple[float, ...]Return the elements per wavelength as a tuple of at least length 1.
The elements per wavelength parameter can be specified differently in
different dimensions. Since the MeshResolution object has no concept
of dimension itself, for a scalar _epw parameter is upcast to a
1-element tuple so it can easily be repeated where necessary in an
iterable context.
Returns: A tuple of the number of elements per length in each dimension. A 1-element tuple return implies that the elements_per_wavelength parameter is constant in all dimensions.
model_order int
model_order intThe polynomial order of the model representation on each element.
model_precision type[np.number]
model_precision type[np.number]The numerical precision of the model parameters in the mesh.
reference_frequency float
reference_frequency floatReference frequency at which to compute the local wavelengths.
from_period()
from_period()def from_period(
reference_period: salvus._core.types.float_,
elements_per_wavelength: salvus._core.types.float_ = 1.5,
model_order: salvus._core.types.int_ = 1,
) -> MeshResolution: ...Specify resolution in terms of period and elements per wavelength.
reference_periodsalvus._core.types.float_ — Reference period at which to compute the local wavelengths.elements_per_wavelengthsalvus._core.types.float_ — Number of elements that should span the local wavelength.model_ordersalvus._core.types.int_ — The polynomial order of the model representation on each element.
broadcast_elements_per_wavelength()
broadcast_elements_per_wavelength()def broadcast_elements_per_wavelength(
self, n_dim: int, n_layers: int
) -> list[tuple[salvus._core.types.float_, ...]]: ...Get the elements per wavelength expanded across dimensions and layers.
See the docstring of elements_per_wavelength in this class’ init
method for a description of broadcasting behavior over dimensions and
layers.
n_dimint — The number of dimensions in the model.n_layersint — The number of layers in the model.
replace()
replace()def replace(self) -> MeshResolution: ...Return a copy of this MeshResolution with some fields replaced.
Used in tutorials
- Layered Meshing 01: Basics
- Layered Meshing 02: Basics of partitioning and policies
- Layered Meshing 03: Meshing complex geophysical domains
- Materials 1: Introduction to materials
- Materials 4: Simulating with Materials and Exotic Waveforms from Anisotropy
- Salvus' UnstructuredMesh - Part 3 - Jacobians and Time Step Estimation
- Units in Coupled Simulations
- Volume output in a selected region
- Working with Salvus' wavefield output files