Version:

salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.intralayer_detail

salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.intralayer_detail salvus mesh layered_meshing meshing_protocol coarsening_policy intralayer_detail
Implementation details for intralayer policies.

Functions

construct_mesh_block()

Create a list of MeshBlocks that span the bounds of a size function.
SIGNATURE
def construct_mesh_block(
    policy: IntralayerCoarseningPolicy,
    windowed_n_elm_h: tuple[list[list[int]], list[list[int]], list[list[int]]],
    ct: list[tuple[int, _InterlayerConnectorProtocol]],
    cb: list[tuple[int, _InterlayerConnectorProtocol]],
    epw: tuple[float, ...],
    i_bot: Interface,
    i_top: Interface,
    mw: realized.RealizedParameter,
    cs: CoordinateSystem,
) -> list[MeshBlock]: ...
ARGUMENTS
Required
policy
Type:IntralayerCoarseningPolicy
Description:
The intralayer policy.
Required
windowed_n_elm_h
Type:tuple[list[list[int]], list[list[int]], list[list[int]]]
Description:
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.
Required
ct
Type:list[tuple[int, _InterlayerConnectorProtocol]]
Description:
A list of connectors for the layer's top.
Required
cb
Type:list[tuple[int, _InterlayerConnectorProtocol]]
Description:
A list of connectors to the layer's bottom.
Required
epw
Type:tuple[float, ...]
Description:
The requested elements per wavelength.
Required
i_bot
Type:Interface
Description:
The bottom bounding interface.
Required
i_top
Type:Interface
Description:
The top bounding interface.
Required
mw
Type:realized.RealizedParameter
Description:
The minimum wavelength.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: list[MeshBlock]
A list of MeshBlocks spanning the bounds of the size function.

elm_locs_horizontal()

Compute the horizontal element location.
Takes into account any fixed horizontal boundaries in the mesh.
SIGNATURE
def elm_locs_horizontal(
    fixed_horizontal_boundaries: list[list[float]],
    h_bounds: list[tuple[float, float]],
    n_elem: list[int],
) -> list[np.ndarray]: ...
ARGUMENTS
Required
fixed_horizontal_boundaries
Type:list[list[float]]
Description:
Horizontal element boundaries that should be respected.
Required
h_bounds
Type:list[tuple[float, float]]
Description:
A list of (min, max) horizontal boundaries.
Required
n_elem
Type:list[int]
Description:
A list of elements in each horizontal direction.
RETURNS
Return type: list[np.ndarray]
A list of the horizontal element locations in each dimension.

fix_horizontal_spacing()

Compute the horizontal element location.
Takes into account any fixed horizontal boundaries in the mesh.
SIGNATURE
def fix_horizontal_spacing(
    fixed_horizontal_boundaries: list[list[float]],
    h_bounds: list[tuple[float, float]],
    n_elem: list[int],
    cs: CoordinateSystem,
) -> list[np.ndarray] | None: ...
ARGUMENTS
Required
fixed_horizontal_boundaries
Type:list[list[float]]
Description:
Horizontal element boundaries that should be respected.
Required
h_bounds
Type:list[tuple[float, float]]
Description:
A list of (min, max) horizontal boundaries.
Required
n_elem
Type:list[int]
Description:
A list of elements in each horizontal direction.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: list[np.ndarray] | None
A list of the horizontal element locations in each dimension.

get_chunk_dimensions()

Fill EquiAzimuthalGrid based on the desired discretization and spatial extent.
SIGNATURE
def get_chunk_dimensions(
    n_elm: list[int],
    bounds: dict[str, tuple[float, float]],
    cs: CoordinateSystem,
) -> typing.Sequence[EquiAzimuthalGrid]: ...
ARGUMENTS
Required
n_elm
Type:list[int]
Description:
List of elements in the x, [y] direction.
Required
bounds
Type:dict[str, tuple[float, float]]
Description:
The coordinate bounds of the layer.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: typing.Sequence[EquiAzimuthalGrid]
A list of 1D chunk dimensions along each axis.

get_horizontal_node_locations()

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.
SIGNATURE
def get_horizontal_node_locations(
    n_elm_h: list[int],
    layer_bounds: dict[str, tuple[float, float]],
    cs: CoordinateSystem,
) -> tuple[npt.NDArray, list[int], list[float] | None]: ...
ARGUMENTS
Required
n_elm_h
Type:list[int]
Description:
The number of elements in each horizontal direction.
Required
layer_bounds
Type:dict[str, tuple[float, float]]
Description:
The bounds of the layer. Dictionary of {coordinate name: bounds}; should be populated for all bounding coordinates.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: tuple[npt.NDArray, list[int], list[float] | None]
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()

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.
SIGNATURE
def get_layer_bounds(
    bounds: dict[str, tuple[float, float]], cs: CoordinateSystem
) -> list[dict[str, tuple[float, float]]]: ...
ARGUMENTS
Required
bounds
Type:dict[str, tuple[float, float]]
Description:
The bounds of the layer.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: list[dict[str, tuple[float, float]]]
A list of coordinate bounds.

h_dict()

Get the horizontal extents as a dictionary.
Formatted so as it can be passed to a MeshBlock constructor.
SIGNATURE
def h_dict(
    bounds: dict[str, tuple[float, float]], cs: CoordinateSystem
) -> dict[str, float]: ...
ARGUMENTS
Required
bounds
Type:dict[str, tuple[float, float]]
Description:
The horizontal boundaries.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: dict[str, float]
A dictionary of horizontal extents.

max_constant_elm_size()

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.
SIGNATURE
def max_constant_elm_size(
    mw: float, epw: tuple[float_, ...]
) -> tuple[float, ...]: ...
ARGUMENTS
Required
mw
Type:float
Description:
The minimum wavelength in a layer.
Required
epw
Type:tuple[float_, ...]
Description:
Elements per wavelength.
RETURNS
Return type: tuple[float, ...]
A tuple with the safe max element size along each dimension.

n_elm_vertical()

Maximum # of elements required along the vertical dimension.
SIGNATURE
def n_elm_vertical(
    i_bot: Interface,
    i_top: Interface,
    epw: tuple[float_, ...],
    nh: list[int],
    mw: realized.RealizedParameter,
    cs: CoordinateSystem,
    thickness_reduction: typing.Callable[[npt.NDArray[np.float64]], float],
    allow_crossing: bool = False,
) -> int: ...
ARGUMENTS
Required
i_bot
Type:Interface
Description:
The bottom bounding interface.
Required
i_top
Type:Interface
Description:
The top bounding interface.
Required
epw
Type:tuple[float_, ...]
Description:
Elements per wavelength.
Required
nh
Type:list[int]
Description:
The number of elements in the horizontal dimensions.
Required
mw
Type:realized.RealizedParameter
Description:
The minimum wavelength.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
Required
thickness_reduction
Type:typing.Callable[[npt.NDArray[np.float64]], float]
Description:
How to reduce the point-wise thickness for the n_elm calculation. For example can be max, min, mean, ...
Optional
allow_crossing
Type:bool
Default value:False
Description:
Allow for interfaces with 0.0 (or negative) thickness.
RETURNS
Return type: int
The maximum number of elements required in the vertical direction.

simplify_connectors()

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.
SIGNATURE
def simplify_connectors(
    connectors: tuple[
        list[tuple[int, _InterlayerConnectorProtocol]],
        list[tuple[int, _InterlayerConnectorProtocol]],
    ],
    n_elm_h: tuple,
    attempt: bool,
) -> tuple[
    list[tuple[int, _InterlayerConnectorProtocol]],
    list[tuple[int, _InterlayerConnectorProtocol]],
    list[int],
]: ...
ARGUMENTS
Required
connectors
Type:tuple[list[tuple[int, _InterlayerConnectorProtocol]], list[tuple[int, _InterlayerConnectorProtocol]]]
Description:
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).
Required
n_elm_h
Type:tuple
Description:
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.
Required
attempt
Type:bool
Description:
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
Return type: tuple[list[tuple[int, _InterlayerConnectorProtocol]], list[tuple[int, _InterlayerConnectorProtocol]], list[int]]
A new set of simplified connectors, along with the number of horizontal elements in the current layer.

v_dict()

Get the vertical extents as a dictionary.
Formatted so as it can be passed to a MeshBlock constructor.
SIGNATURE
def v_dict(
    min_v: float, max_v: float, cs: CoordinateSystem
) -> dict[str, float]: ...
ARGUMENTS
Required
min_v
Type:float
Description:
The minimum vertical coordinate.
Required
max_v
Type:float
Description:
The maximum vertical coordinate.
Required
cs
Type:CoordinateSystem
Description:
The coordinate system.
RETURNS
Return type: dict[str, float]
A dictionary of vertical extents.
PAGE CONTENTS