Mondaic

salvus.mesh.algorithms.wrappers

salvus.mesh.algorithms.wrappers salvus mesh algorithms wrappers

Wrappers for c++ bindings that operate on meshes.

Functions

get_enclosing_elements()

def get_enclosing_elements(
    mesh: UnstructuredMesh | _ElementCollectionProtocol,
    points: npt.NDArray,
    execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
) -> tuple[npt.NDArray, npt.NDArray]: ...

Determine the enclosing elements for a set of points within a mesh.

This function identifies the elements in a mesh that enclose the specified points and computes the reference coordinates of the points within those elements.

The function first attempts to locate the points with a single tree doubling. If any points remain unfound, it retries with a maximum of 8 tree doublings. If an enclosing element is not found anywhere amongst the closest 256 elements surrounding a given point its index in marked as -1, signifying that an enclosing elements was not found.

Parameters
  • mesh UnstructuredMesh | _ElementCollectionProtocol — The mesh or element collection to search within.
  • points npt.NDArray — An array of points to locate within the mesh. The array should have shape (n_pnt, n_dim).
  • execution_policy bindings.ExecutionPolicy — Execution policy governing the maximum allowable parallelism of child routines.
Returns tuple[npt.NDArray, npt.NDArray] — A tuple containing: - e_idx (npt.NDArray): An array of element indices corresponding to the enclosing elements for each point. If a point is not found, its index will be -1. - ref (npt.NDArray): An array of reference coordinates for the points within their enclosing elements. The shape matches the input points.

interpolate_from_element_nodes()

def interpolate_from_element_nodes(
    ref: npt.NDArray,
    values: T,
    e_idx: npt.NDArray,
    fill_value: float = nan,
    execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
) -> T: ...

Interpolates values from element nodes to a reference point or points.

This function performs interpolation of values defined at element nodes to a specified reference point or points. It supports both single and multiple sets of values.

Parameters
  • ref npt.NDArray — The reference point(s) where interpolation is performed. This is typically a set of coordinates in the reference element.
  • values T — A sequence of arrays or a single array containing the values at the element nodes. If a sequence is provided, interpolation is performed for each set of values. If an array is provided it should be 3 dimensional, with the last dimension allowing for the batched interpolation of multiple values.
  • e_idx npt.NDArray — The element indices corresponding to the reference points.
  • fill_value float — The value to use for points outside the interpolation domain..
  • execution_policy bindings.ExecutionPolicy — An optional execution policy governing parallelism.
Returns T — The interpolated values. If values is a sequence, a list of arrays is returned, where each array corresponds to the interpolated values for a set of input values. If values is a single array, a single array of interpolated values is returned.