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

salvus.mesh.layered_meshing.layered_model.filters

Built-in partitioning filters.

Functions

enclosing_elements()

def enclosing_elements(
    um: salvus.mesh.unstructured_mesh.UnstructuredMesh, p: numpy.ndarray
) -> numpy.ndarray:
    ...

Get the unique elements in um that enclose the points p.

No points outside the mesh will be considered, and are removed from the results of unstructured_mesh_utils.get_enclosing_elements. Duplicates are also removed from the element list.

Kwargs is a list of keyword arguments to pass to `get_enclosing_elements.

Parameters
  • um salvus.mesh.unstructured_mesh.UnstructuredMesh — The unstructured mesh.
  • p numpy.ndarray — The points.
Returns numpy.ndarray

first_and_last()

def first_and_last(
    i: salvus.mesh.layered_meshing.interface.Interface,
) -> salvus.mesh.layered_meshing.interface.Interface:
    ...

Create a new interface containing only the first and last DEM values.

Parameters
  • i salvus.mesh.layered_meshing.interface.Interface — The interface.
Returns salvus.mesh.layered_meshing.interface.Interface — A new interface with only the first and last values.

remove_consecutive_duplicates()

def remove_consecutive_duplicates(
    i: salvus.mesh.layered_meshing.interface.Interface,
) -> salvus.mesh.layered_meshing.interface.Interface:
    ...

Remove consecutive duplicate DEM values from an interface.

Parameters
  • i salvus.mesh.layered_meshing.interface.Interface — The interface.
Returns salvus.mesh.layered_meshing.interface.Interface — An interface with consecutive duplicates removed.

simple_post_refinement()

def simple_post_refinement(
    lm: LayeredModel,
    fac: float = 3.0,
    restrict: Optional[List[int], int] = None,
    refinement_style: Optional[str] = None,
    refinement_level: Optional[int] = None,
    unique_points_tolerance: int = 8,
) -> Tuple[List[OracleFilter], LocalRefinementPolicy]:
    ...

Get structures used to refinements to regions with shorter wavelengths.

Mesh refinement in Salvus is a global operation, and therefore can only take place once a “template” mesh is generated. If local refinements are desired, then, it is helpful to clip, or filter, a material’s wavelength oracle to a minimum value during mesh generation time. Subsequently, it is then desirable to apply local refinements to the regions that were clipped, in order to respect the true values of the minimum wavelength in that region.

This function returns a (List[OracleFilter], LocalRefinementPolicy) tuple that streamlines a common case for the application of local refinements. The length of the list of OracleFilters is the same length as the number of layers in the model. The OracleFilter returned can be used as an argument to a MeshingProtocol’s oracle_filter parameters, which will clip the minimum value of each layer wavelength oracle as described above. The LocalRefinementPolicy will find mark all the points that were clipped for refinement, and can be passed as an argument to a MeshingProtocol’s local_refinement_policy argument.

fac refers to the multiple of an oracle’s minimum value below which refinements will be applied. The local refinements in Salvus effectively reduce the edge length in each dimension by a factor of 3, leading to 9 elements per unit volume in 2-D, and 27 elements per unit volume in 3-D. Therefore, the natural value, and default, for fac is 3.0, as after refinement the elements-per-wavelength criterion will be approximately met.

Kwargs is a list of keyword arguments to pass to `get_enclosing_elements.

Parameters
  • lm LayeredModel — The layered model to generate refinement structures for.
  • fac float — The factor above an oracle’s minimum at which to clip. Defaults to 3.0.
  • restrict Optional[List[int], int] — Only generate policies for these layers, and use pass-through for the others. If None, generate policies for all layers. Defaults to None.
  • refinement_style Optional[str] — Which refinement style to use. See documentation of unstructured_mesh.refine_locally(...) for more information. If None, will be automatically determined based on the value of refinement_level.
  • refinement_level Optional[int] — How many times to refine the mesh. See documentation of unstructured_mesh.refine_locally(...) for more information. If None, will be automatically determined from fac.
  • unique_points_tolerance int — The number of decimal digits used to determine unique points in the refined mesh.
Returns Tuple[List[OracleFilter], LocalRefinementPolicy] — A tuple of the (List[OracleFilter], LocalRefinementPolicy).