salvus.mesh.layered_meshing.detail.realize
Functions to realize relative coordinates.
Functions
canonicalize_coordinates()
canonicalize_coordinates()def canonicalize_coordinates(
cs: salvus.project.components.types.CoordinateSystem,
coords: numpy.ndarray,
shift_longitude_pi_2: bool = False,
convert_to_colat: bool = False,
) -> numpy.ndarray:
...Transform a coordinate array into a form suitable for the layered mesher.
For cartesian coordinates, no transformation is required. Spherical coordinates are transformed to radians, and optionally shifted by pi / 2 to account for differences in coordinate conventions in different parts of Salvus.
cssalvus.project.components.types.CoordinateSystem — The coordinate system.coordsnumpy.ndarray — The coordinates.shift_longitude_pi_2bool — Subtract pi/2 to the longitude coordinate after conversion to radians. Only relevant for 2-D spherical systems.convert_to_colatbool — Convert latitude values (-90.0 to +90.0 degrees) to colatitude values (0.0 to +180.0 degrees).
compute_elevation()
compute_elevation()def compute_elevation(
elevation: Union[
float,
salvus.mesh.layered_meshing.interface.Depth,
salvus.mesh.layered_meshing.interface.Height,
],
e_bot: Optional[float],
e_top: Optional[float],
) -> Union[
float,
salvus.mesh.layered_meshing.interface.Depth,
salvus.mesh.layered_meshing.interface.Height,
]:
...Realize a relative elevation into an absolute elevation.
Absolute coordinates are passed-through.
elevationUnion[float, salvus.mesh.layered_meshing.interface.Depth, salvus.mesh.layered_meshing.interface.Height] — The elevation value to transform.e_botOptional[float] — The elevation of the bottom of the domain.e_topOptional[float] — The elevation of the top of the domain.
is_full_sphere()
is_full_sphere()def is_full_sphere(
db: salvus.project.domain.DomainBounds,
cs: salvus.project.components.types.CoordinateSystem,
i_bot: salvus.mesh.layered_meshing.interface.Interface,
) -> bool:
...Returns true if the domain represents a full sphere.
dbsalvus.project.domain.DomainBounds — The domain bounds.cssalvus.project.components.types.CoordinateSystem — The coordinate system.i_botsalvus.mesh.layered_meshing.interface.Interface — The bottom interface (which may signify radius == 0).
is_full_spherical_shell()
is_full_spherical_shell()def is_full_spherical_shell(
bounds: Union[
salvus.project.domain.DomainBounds, Dict[str, Tuple[float, float]]
],
cs: salvus.project.components.types.CoordinateSystem,
) -> bool:
...Returns true if the domain represents a full spherical shell.
boundsUnion[salvus.project.domain.DomainBounds, Dict[str, Tuple[float, float]]] — The domain bounds.cssalvus.project.components.types.CoordinateSystem — The coordinate system.
realize_domain()
realize_domain()def realize_domain(
d: salvus.project.domain.Domain,
t_ref: salvus.mesh.layered_meshing.interface.Interface,
b_ref: salvus.mesh.layered_meshing.interface.Interface,
) -> salvus.project.domain.Domain:
...‘Realize’ a domain by resolving any non-absolute coordinates.
Domains can sometimes have extents that are specified at a later point than domain creation. For instance, domains can have top and bottom bounds of infinity, which instructs the mesher to realize the maximum and minimum vertical coordinates to those specified by the top / bottom interfaces.
If the coordinates of a relevant interface are relative, and the domain top / bottom is not yet defined, an exception will be raised.
dsalvus.project.domain.Domain — The domain to realize.t_refsalvus.mesh.layered_meshing.interface.Interface — The reference coordinate of the top interface.b_refsalvus.mesh.layered_meshing.interface.Interface — The reference coordinate of the bottom interface.
realize_interface()
realize_interface()def realize_interface(
interface: salvus.mesh.layered_meshing.interface.Interface,
bounds: salvus.project.domain.DomainBounds,
) -> salvus.mesh.layered_meshing.interface.Interface:
...Realize an interface to ensure it is suitable for further processing.
Realization here refers to ensuring that the xarray representation of the interface contains all the dimensions that are expected given the dimensions of the domain, that any relative reference coordinates are transformed to absolute coordinates, and that the interface has an extent that is great enough to cover the bounds of the domain.
interfacesalvus.mesh.layered_meshing.interface.Interface — The interface to realize.boundssalvus.project.domain.DomainBounds — The bounds of the realized domain.
realize_interfaces()
realize_interfaces()def realize_interfaces(
domain: salvus.project.domain.Domain,
layered_model: _layered_model.LayeredModel,
) -> _layered_model.LayeredModel:
...Realize all interfaces in a model.
Does not realize materials, or check for consistency of layering.
domainsalvus.project.domain.Domain — The domain to realize from.layered_model_layered_model.LayeredModel — The layered model containing the interfaces to realize.
realize_layered_model()
realize_layered_model()def realize_layered_model(
domain: salvus.project.domain.Domain,
layered_model: _layered_model.LayeredModel,
) -> Tuple[salvus.project.domain.Domain, _layered_model.LayeredModel]:
...Realize a layered model and domain simultaneously.
Realization of a domain and associated layered model are dependent on each other, as the domain bounds may be set by the domain itself, or the extrema of the layered model, (or both — in which case a conflict will be detected and an exception raised). This function serves as the top-level entry point to the realization process and will sequentially realize the domain and layered model accordingly. As a result, a realized domain and realized layered model will be returned, which will be guaranteed to only hold absolute elevation values.
Note that this process does not transform models parameterized using relative coordinates to a parameterization based on absolute coordinates, as that process requires a mesh to complete. However, any materials containing parameters with relative coordinates will still be returned with proper extrusions along all relevant axes, and with relative elevations realized.
domainsalvus.project.domain.Domain — The domain to realize.layered_model_layered_model.LayeredModel — The layered model to realize.
realize_layered_model_ab()
realize_layered_model_ab()def realize_layered_model_ab(
d: salvus.project.domain.Domain,
lm: _layered_model.LayeredModel,
mesh_resolution: salvus.project.components.types.MeshResolution,
oracle_filter: List[coarsening_policy.OracleFilter],
ab_params: Optional[
salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters
],
) -> Tuple[
salvus.project.domain.Domain,
_layered_model.LayeredModel,
List[salvus.mesh.layered_meshing.material.parameter._RealizedParameter],
List[str],
float,
]:
...Extrude a realized layered model to respect absorbing boundary layers.
The extrusion logic for absorbing boundary layers is somewhat complex — for example we must recursively realize and extrude to ensure that consistent extrusion behavior is maintained even when nD materials contain variations within the extrusion layers. The current complexity is also affected by the need to match legacy behavior, which conditionally extrudes by an additional element edge depending on the domain and axis under consideration.
dsalvus.project.domain.Domain — The realized domain.lm_layered_model.LayeredModel — The layered model.mesh_resolutionsalvus.project.components.types.MeshResolution — The mesh resolution.oracle_filterList[coarsening_policy.OracleFilter] — The oracle filtered.ab_paramsOptional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing absorbing boundary extrusion.
realize_material()
realize_material()def realize_material(
top_interface: salvus.mesh.layered_meshing.interface.Interface,
material: salvus.mesh.layered_meshing.material._material.Material,
bot_interface: salvus.mesh.layered_meshing.interface.Interface,
domain: salvus.project.domain.Domain,
) -> salvus.mesh.layered_meshing.material._material.Material:
...Realize a material to ensure it is suitable for further processing.
Realization here refers to transforming material parameters parametrized
using relative coordinates (i.e. depth, or height) or generic coordinates
(i.e. v for vertical) to absolute coordinates with proper dimension
names. The will result for, in 2-D Cartesian domains, v being mapped to
y, and depths / heights being transformed to absolute vertical
coordinates using the domain bounds as a reference.
What will not be transformed is the vertical coordinate value of
v_relative. This is a special dimension name that will be realized later
on in the meshing process, once the discrete boundaries or a layer are
known.
top_interfacesalvus.mesh.layered_meshing.interface.Interface — The top realized interface of the material’s layer.materialsalvus.mesh.layered_meshing.material._material.Material — The material.bot_interfacesalvus.mesh.layered_meshing.interface.Interface — The bottom realized interface of the material’s layer.domainsalvus.project.domain.Domain — The realized domain.