salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.intralayer_detail
Implementation details for intralayer policies.
Functions
construct_mesh_block()
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.
policysalvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.IntralayerCoarseningPolicy — The intralayer policy.windowed_n_elm_hTuple[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.ctList[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.cbList[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.epwTuple[float, ...] — The requested elements per wavelength.i_botsalvus.mesh.layered_meshing.interface.Interface — The bottom bounding interface.i_topsalvus.mesh.layered_meshing.interface.Interface — The top bounding interface.mwsalvus.material._details.parameter.parameter_types.RealizedParameter — The minimum wavelength.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
elm_locs_horizontal()
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.
fixed_horizontal_boundariesList[List[float]] — Horizontal element boundaries that should be respected.h_boundsList[Tuple[float, float]] — A list of (min, max) horizontal boundaries.n_elemList[int] — A list of elements in each horizontal direction.
fix_horizontal_spacing()
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.
fixed_horizontal_boundariesList[List[float]] — Horizontal element boundaries that should be respected.h_boundsList[Tuple[float, float]] — A list of (min, max) horizontal boundaries.n_elemList[int] — A list of elements in each horizontal direction.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
get_chunk_dimensions()
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.
n_elmList[int] — List of elements in the x, [y] direction.boundsDict[str, Tuple[float, float]] — The coordinate bounds of the layer.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
get_horizontal_node_locations()
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.
n_elm_hList[int] — The number of elements in each horizontal direction.layer_boundsDict[str, Tuple[float, float]] — The bounds of the layer. Dictionary of {coordinate name: bounds}; should be populated for all bounding coordinates.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
None (as this is not well defined in the spherical 3D case.)get_layer_bounds()
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.
boundsDict[str, Tuple[float, float]] — The bounds of the layer.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
h_dict()
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.
boundsDict[str, Tuple[float, float]] — The horizontal boundaries.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.
max_constant_elm_size()
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.
mwfloat — The minimum wavelength in a layer.epwTuple[float, ...] — Elements per wavelength.
n_elm_vertical()
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.
i_botsalvus.mesh.layered_meshing.interface.Interface — The bottom bounding interface.i_topsalvus.mesh.layered_meshing.interface.Interface — The top bounding interface.epwTuple[float, ...] — Elements per wavelength.nhList[int] — The number of elements in the horizontal dimensions.mwsalvus.material._details.parameter.parameter_types.RealizedParameter — The minimum wavelength.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.thickness_reductionCallable[[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float] — How to reduce the point-wise thickness for the n_elm calculation. For example can bemax,min,mean, …allow_crossingbool — Allow for interfaces with 0.0 (or negative) thickness.
simplify_connectors()
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.
connectorsTuple[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_hTuple — 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.attemptbool — 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.
v_dict()
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.
min_vfloat — The minimum vertical coordinate.max_vfloat — The maximum vertical coordinate.cssalvus.geometry.coordinates.coordinates.CoordinateSystem — The coordinate system.