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

salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.intralayer_detail

Implementation details for intralayer policies.

Functions

construct_mesh_block()

def construct_mesh_block(
    policy: salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.IntralayerCoarseningPolicy,
    windowed_n_elm_h: Tuple[List[List[int]], List[List[int]], List[List[int]]],
    ct: List[
        Tuple[
            int,
            Union[
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
            ],
        ]
    ],
    cb: List[
        Tuple[
            int,
            Union[
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
            ],
        ]
    ],
    epw: Tuple[float, ...],
    i_bot: salvus.mesh.layered_meshing.interface.Interface,
    i_top: salvus.mesh.layered_meshing.interface.Interface,
    mw: salvus.material._details.parameter.parameter_types.RealizedParameter,
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> List[salvus.mesh.data_structures.mesh_block.mesh_block.MeshBlock]: ...

Create a list of MeshBlocks that span the bounds of a size function.

Parameters
  • policy salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.IntralayerCoarseningPolicy — The intralayer policy.
  • windowed_n_elm_h Tuple[List[List[int]], List[List[int]], List[List[int]]] — The number of elements in the horizontal directions. Should be a 3-tuple, with each entry a list of the number of elements per horizontal dimension. Index 0 of the tuple contain a list of the number of elements in the layer above, index 1 the number of elements in the current layer, and index 2 the number of elements below.
  • ct List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]] — A list of connectors for the layer’s top.
  • cb List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]] — A list of connectors to the layer’s bottom.
  • epw Tuple[float, ...] — The requested elements per wavelength.
  • i_bot salvus.mesh.layered_meshing.interface.Interface — The bottom bounding interface.
  • i_top salvus.mesh.layered_meshing.interface.Interface — The top bounding interface.
  • mw salvus.material._details.parameter.parameter_types.RealizedParameter — The minimum wavelength.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns List[salvus.mesh.data_structures.mesh_block.mesh_block.MeshBlock] — A list of MeshBlocks spanning the bounds of the size function.

elm_locs_horizontal()

def elm_locs_horizontal(
    fixed_horizontal_boundaries: List[List[float]],
    h_bounds: List[Tuple[float, float]],
    n_elem: List[int],
) -> List[numpy.ndarray]: ...

Compute the horizontal element location.

Takes into account any fixed horizontal boundaries in the mesh.

Parameters
  • fixed_horizontal_boundaries List[List[float]] — Horizontal element boundaries that should be respected.
  • h_bounds List[Tuple[float, float]] — A list of (min, max) horizontal boundaries.
  • n_elem List[int] — A list of elements in each horizontal direction.
Returns List[numpy.ndarray] — A list of the horizontal element locations in each dimension.

fix_horizontal_spacing()

def fix_horizontal_spacing(
    fixed_horizontal_boundaries: List[List[float]],
    h_bounds: List[Tuple[float, float]],
    n_elem: List[int],
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> Optional[List[numpy.ndarray]]: ...

Compute the horizontal element location.

Takes into account any fixed horizontal boundaries in the mesh.

Parameters
  • fixed_horizontal_boundaries List[List[float]] — Horizontal element boundaries that should be respected.
  • h_bounds List[Tuple[float, float]] — A list of (min, max) horizontal boundaries.
  • n_elem List[int] — A list of elements in each horizontal direction.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns Optional[List[numpy.ndarray]] — A list of the horizontal element locations in each dimension.

get_chunk_dimensions()

def get_chunk_dimensions(
    n_elm: List[int],
    bounds: Dict[str, Tuple[float, float]],
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> Sequence[salvus.mesh.algorithms.spherical.EquiAzimuthalGrid]: ...

Fill EquiAzimuthalGrid based on the desired discretization and spatial extent.

Parameters
  • n_elm List[int] — List of elements in the x, [y] direction.
  • bounds Dict[str, Tuple[float, float]] — The coordinate bounds of the layer.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns Sequence[salvus.mesh.algorithms.spherical.EquiAzimuthalGrid] — A list of 1D chunk dimensions along each axis.

get_horizontal_node_locations()

def get_horizontal_node_locations(
    n_elm_h: List[int],
    layer_bounds: Dict[str, Tuple[float, float]],
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> Tuple[
    numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]],
    List[int],
    Optional[float],
]: ...

Get the proposed horizontal node locations for a structured layer.

For cases other than 3-d spherical, this can simply be done via a linspace between the layer bounds. However, in the later case we need to do a cubed sphere mapping before computing the locations.

Parameters
  • n_elm_h List[int] — The number of elements in each horizontal direction.
  • layer_bounds Dict[str, Tuple[float, float]] — The bounds of the layer. Dictionary of {coordinate name: bounds}; should be populated for all bounding coordinates.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns Tuple[numpy.ndarray[Any, numpy.dtype[+_ScalarType_co]], List[int], Optional[float]] — A tuple of: - The horizontal node locations in units of the coordinate system (i.e. degrees or m). - The shape of the coordinate grid. - The spacing between adjacent element nodes, or None (as this is not well defined in the spherical 3D case.)

get_layer_bounds()

def get_layer_bounds(
    bounds: Dict[str, Tuple[float, float]],
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> List[Dict[str, Tuple[float, float]]]: ...

Get the bounds of a layer given its coordinate system.

This function is important as when we’re constructing a 3-D full sphere we need to consider all constituent chunks. So, here we return a list of bounds that correspond to each chunk in the correct order as expected by cubed_sphere_vertical_refine.... If we’re not constructing this case, just return a list with a single element, containing the trivial layer bounds as passed in.

Parameters
  • bounds Dict[str, Tuple[float, float]] — The bounds of the layer.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns List[Dict[str, Tuple[float, float]]] — A list of coordinate bounds.

h_dict()

def h_dict(
    bounds: Dict[str, Tuple[float, float]],
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> Dict[str, float]: ...

Get the horizontal extents as a dictionary.

Formatted so as it can be passed to a MeshBlock constructor.

Parameters
  • bounds Dict[str, Tuple[float, float]] — The horizontal boundaries.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns Dict[str, float] — A dictionary of horizontal extents.

max_constant_elm_size()

def max_constant_elm_size(
    mw: float, epw: Tuple[float, ...]
) -> Tuple[float, ...]: ...

The maximum allowable element sizes for constant intralayer coarsening.

A safe upper bound on the element size, which can then be used to compute a safe lower bound on the number of elements per dimension.

Parameters
  • mw float — The minimum wavelength in a layer.
  • epw Tuple[float, ...] — Elements per wavelength.
Returns Tuple[float, ...] — A tuple with the safe max element size along each dimension.

n_elm_vertical()

def n_elm_vertical(
    i_bot: salvus.mesh.layered_meshing.interface.Interface,
    i_top: salvus.mesh.layered_meshing.interface.Interface,
    epw: Tuple[float, ...],
    nh: List[int],
    mw: salvus.material._details.parameter.parameter_types.RealizedParameter,
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
    thickness_reduction: Callable[
        [numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float
    ],
    allow_crossing: bool = False,
) -> int: ...

Maximum # of elements required along the vertical dimension.

Parameters
  • i_bot salvus.mesh.layered_meshing.interface.Interface — The bottom bounding interface.
  • i_top salvus.mesh.layered_meshing.interface.Interface — The top bounding interface.
  • epw Tuple[float, ...] — Elements per wavelength.
  • nh List[int] — The number of elements in the horizontal dimensions.
  • mw salvus.material._details.parameter.parameter_types.RealizedParameter — The minimum wavelength.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
  • thickness_reduction Callable[[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float] — How to reduce the point-wise thickness for the n_elm calculation. For example can be max, min, mean, …
  • allow_crossing bool — Allow for interfaces with 0.0 (or negative) thickness.
Returns int — The maximum number of elements required in the vertical direction.

simplify_connectors()

def simplify_connectors(
    connectors: Tuple[
        List[
            Tuple[
                int,
                Union[
                    salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                    salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
                ],
            ]
        ],
        List[
            Tuple[
                int,
                Union[
                    salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                    salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
                ],
            ]
        ],
    ],
    n_elm_h: Tuple,
    attempt: bool,
) -> Tuple[
    List[
        Tuple[
            int,
            Union[
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
            ],
        ]
    ],
    List[
        Tuple[
            int,
            Union[
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D,
                salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D,
            ],
        ]
    ],
    List[int],
]: ...

Remove any redundant connectors from a layer.

Useful when a layer is very thin, or when a layer is at the edge of a model and it is composed only of refinements. Takes advantage of the fact that connectors are always guaranteed to be placed in the faster of any neighboring layers.

Parameters
  • connectors Tuple[List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]], List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]]] — A tuple information regarding the connectors at the top and bottom of this layer. This information should be in the form of: a list of tuples, one for each connector, with the first element of the information tuple the number of vertical elements the connector takes up, and the second the protocol’s partial constructor (as returned from its policy).
  • n_elm_h Tuple — The number of elements in the horizontal directions. Should be a 3-tuple, with each entry a list of the number of elements per horizontal dimension. Index 0 of the tuple contain a list of the number of elements in the layer above, index 1 the number of elements in the current layer, and index 2 the number of elements below. Relevant for this function is that the entries representing the off-the-end direction of bounding layers should be of length 0.
  • attempt bool — Whether or not to attempt the simplification. Usually should be a condition that is True if the number of connector layers is close to the minimum number of vertical elements in the layer.
Returns Tuple[List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]], List[Tuple[int, Union[salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol2D, salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy._InterlayerConnectorProtocol3D]]], List[int]] — A new set of simplified connectors, along with the number of horizontal elements in the current layer.

v_dict()

def v_dict(
    min_v: float,
    max_v: float,
    cs: salvus.geometry.coordinates.coordinates.CoordinateSystem,
) -> Dict[str, float]: ...

Get the vertical extents as a dictionary.

Formatted so as it can be passed to a MeshBlock constructor.

Parameters
  • min_v float — The minimum vertical coordinate.
  • max_v float — The maximum vertical coordinate.
  • cs salvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
Returns Dict[str, float] — A dictionary of vertical extents.