Mondaic

salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.detail

salvus.mesh.layered_meshing.meshing_protocol.coarsening_policy.detail salvus mesh layered_meshing meshing_protocol coarsening_policy detail

Implementation details for coarsening policies.

Functions

construct_interlayer_policies()

def construct_interlayer_policies(
    layered_model: layered_model.LayeredModel,
    thickness_threshold: float,
    n_dim: int,
    mesh_resolution: MeshResolution,
    coarsening_policy: InterlayerCoarseningPolicy = InterlayerDoubling(
        n_layers="auto"
    ),
) -> list[InterlayerCoarseningPolicy]: ...

Construct a set of interlayer policies given a layered model.

This function is primarily useful for preventing the introduction of mesh coarsenings where the host layer is too thin.

Parameters
  • layered_model layered_model.LayeredModel — The layered model.
  • thickness_threshold float — The minimum thickness above which coarsening is allowed. Should be expressed as a ratio of the minimum thickness to the maximum edge length.
  • n_dim int — The dimension of the layered model.
  • mesh_resolution MeshResolution — The resolution of the mesh.
  • coarsening_policy InterlayerCoarseningPolicy — Which coarsening policy to introduce within layers that are thick enough.
Returns list[InterlayerCoarseningPolicy] — A list of coarsening policies.

crossing_layer_allowed()

def crossing_layer_allowed(p: IntralayerCoarseningPolicy) -> bool: ...

Collection of conditions that allow layers to cross.

Parameters
  • p IntralayerCoarseningPolicy — A layer’s coarsening policy.
Returns bool — Whether or not crossing layers should be allowed.

n_elm_dict()

def n_elm_dict(
    n_elm: list[int],
    cs: CoordinateSystem,
    bounds: dict[str, tuple[float, float]],
) -> dict[str, int]: ...

A dictionary of element_count_x[y,z] to be passed to a MeshBlock constructor.

Correct argument names will be returned depending on the coordinate system.

Parameters
  • n_elm list[int] — List of elements in the x, [y] direction.
  • cs CoordinateSystem — The coordinate system.
  • bounds dict[str, tuple[float, float]] — The coordinate bounds of the layer.
Returns dict[str, int] — A dict with the proper parameter names and values.

rotate_cubed_sphere_chunk()

def rotate_cubed_sphere_chunk(
    domain_or_euler_angles: domain.Domain | tuple[float, float, float],
    mb: MeshBlock,
) -> MeshBlock: ...

Rotate the cubed sphere to center it within a SphericalChunkDomain.

If the domain is not a SphericalChunkDomain, simply return the mesh blocks as they were passed in.

Parameters
  • domain_or_euler_angles domain.Domain | tuple[float, float, float] — The domain of the cubed sphere, or a set of explicit euler angles to rotate by. If euler angles, they should be in degrees and describe an extrinsic rotation around the z->y->z axes, respectively.
  • mb MeshBlock — The mesh block.
Returns MeshBlock — A potentially rotated mesh block.

solve_interlayer_coarsening()

def solve_interlayer_coarsening(
    nh: list[tuple[int, ...]],
    policies: list[InterlayerCoarseningPolicy] | None = None,
    layer_modulo_constraint: int = 1,
    bottom_layer_modulo_constraint: int = 1,
) -> list[list[int]]: ...

Compute the number of horizontal elements across successive layers.

Will return a solution that respects the interlayer coarsening policies while minimizing the total number of elements in the mesh.

Parameters
  • nh list[tuple[int, ...]] — The minimum number of elements in each horizontal dimension, for each layer.
  • policies list[InterlayerCoarseningPolicy] | None — A list of interlayer coarsening policies. Should either be equal to the number of interfaces, or None, in which a constant policy will be applied to each interface.
  • layer_modulo_constraint int — Ensure that all layers include elements along each dimension that are multiples of this number.
  • bottom_layer_modulo_constraint int — Ensure that the bottom layer (i.e. the last entry in nh) is a multiple of this number.
Returns list[list[int]] — The optimal number of horizontal elements spanning each layer.