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

salvus.mesh.layered_meshing.detail.realize

Functions to realize relative coordinates.

Functions

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.

Parameters
  • cs salvus.project.components.types.CoordinateSystem — The coordinate system.
  • coords numpy.ndarray — The coordinates.
  • shift_longitude_pi_2 bool — Subtract pi/2 to the longitude coordinate after conversion to radians. Only relevant for 2-D spherical systems.
  • convert_to_colat bool — Convert latitude values (-90.0 to +90.0 degrees) to colatitude values (0.0 to +180.0 degrees).
Returns numpy.ndarray — The coordinates in their internal form.

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.

Parameters
  • elevation Union[float, salvus.mesh.layered_meshing.interface.Depth, salvus.mesh.layered_meshing.interface.Height] — The elevation value to transform.
  • e_bot Optional[float] — The elevation of the bottom of the domain.
  • e_top Optional[float] — The elevation of the top of the domain.
Returns Union[float, salvus.mesh.layered_meshing.interface.Depth, salvus.mesh.layered_meshing.interface.Height] — The realized elevation.

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.

Parameters
  • db salvus.project.domain.DomainBounds — The domain bounds.
  • cs salvus.project.components.types.CoordinateSystem — The coordinate system.
  • i_bot salvus.mesh.layered_meshing.interface.Interface — The bottom interface (which may signify radius == 0).
Returns bool — Whether the domain represents a full sphere.

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.

Parameters
  • bounds Union[salvus.project.domain.DomainBounds, Dict[str, Tuple[float, float]]] — The domain bounds.
  • cs salvus.project.components.types.CoordinateSystem — The coordinate system.
Returns bool — Whether the domain represents a full spherical shell.

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.

Parameters
  • d salvus.project.domain.Domain — The domain to realize.
  • t_ref salvus.mesh.layered_meshing.interface.Interface — The reference coordinate of the top interface.
  • b_ref salvus.mesh.layered_meshing.interface.Interface — The reference coordinate of the bottom interface.
Returns salvus.project.domain.Domain — A domain bounds object with absolute coordinates.

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.

Parameters
  • interface salvus.mesh.layered_meshing.interface.Interface — The interface to realize.
  • bounds salvus.project.domain.DomainBounds — The bounds of the realized domain.
Returns salvus.mesh.layered_meshing.interface.Interface — A realized interface which spans the domain bounds.

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.

Parameters
  • domain salvus.project.domain.Domain — The domain to realize from.
  • layered_model _layered_model.LayeredModel — The layered model containing the interfaces to realize.
Returns _layered_model.LayeredModel — A new layered model with the interfaces realized.

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.

Parameters
  • domain salvus.project.domain.Domain — The domain to realize.
  • layered_model _layered_model.LayeredModel — The layered model to realize.
Returns Tuple[salvus.project.domain.Domain, _layered_model.LayeredModel] — A tuple comprised of the realized domain and the realized layered model.

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.

Parameters
  • d salvus.project.domain.Domain — The realized domain.
  • lm _layered_model.LayeredModel — The layered model.
  • mesh_resolution salvus.project.components.types.MeshResolution — The mesh resolution.
  • oracle_filter List[coarsening_policy.OracleFilter] — The oracle filtered.
  • ab_params Optional[salvus.mesh.simple_mesh.basic_mesh.AbsorbingBoundaryParameters] — Parameters governing absorbing boundary extrusion.
Returns Tuple[salvus.project.domain.Domain, _layered_model.LayeredModel, List[salvus.mesh.layered_meshing.material.parameter._RealizedParameter], List[str], float] — A tuple containing: - The realized domain, extruded to account for absorbing boundaries. - The realized layered model, extruded to account for absorbing boundaries. - A list of (potentially volumetric) minimum wavelengths, encapsulated within the relevant _RealizedParameter class. - A list of side set names that should be marked as absorbing.

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.

Parameters
  • top_interface salvus.mesh.layered_meshing.interface.Interface — The top realized interface of the material’s layer.
  • material salvus.mesh.layered_meshing.material._material.Material — The material.
  • bot_interface salvus.mesh.layered_meshing.interface.Interface — The bottom realized interface of the material’s layer.
  • domain salvus.project.domain.Domain — The realized domain.
Returns salvus.mesh.layered_meshing.material._material.Material — A realized material which spans the domain bounds.