Required
meshes| Type: | list[UnstructuredMesh] |
| Description: | List of UnstructuredMesh objects to add together. |
def add_element_nodal_fields(
meshes: list[UnstructuredMesh],
) -> UnstructuredMesh: ...| Type: | list[UnstructuredMesh] |
| Description: | List of UnstructuredMesh objects to add together. |
UnstructuredMeshdef compute_topological_facet_normals(
topological_facets: np.ndarray, points: np.ndarray
) -> np.ndarray: ...| Type: | np.ndarray |
| Description: | An array of a mesh's topological facets. |
| Type: | np.ndarray |
| Description: | The point (node) locations of a mesh. |
np.ndarrayvectors_from onto vectors_to.
Will always create 3D rotation matrices. If either vectors_from or
vectors_to is passed in shape (..., 2), zeros are appended to create 3D
vectors in the last index. Follows general broadcasting rules, output shape
will be np.broadcast(vectors_A, vectors_B).shape[:-1] + (3, 3). If
drop_dimension is True, and one of the original input shapes was 2
dimensional, the returned rotation matrices will be 2D. This might be
incorrect, if rotation in 3D is required to fully make the rotation.def create_rotation_matrices(
vectors_from: npt.NDArray, vectors_to: npt.NDArray
) -> npt.NDArray: ...| Type: | npt.NDArray |
| Description: | Vectors to rotate from. Length of last dimensions should be 2 or 3. |
| Type: | npt.NDArray |
| Description: | Vectors to rotate to. Length of last dimensions should be 2 or 3, matching vectors_from. |
npt.NDArraydef disconnect_along_side_set(
mesh: UnstructuredMesh,
side_set: str,
disconnection_decider: typing.Callable[
[UnstructuredMesh, npt.NDArray, npt.NDArray, npt.NDArray, npt.NDArray],
typing.Iterable[bool],
],
) -> UnstructuredMesh: ...| Type: | UnstructuredMesh |
| Description: | The mesh to disconnect. |
| Type: | str |
| Description: | The internal sideset to disconnect. |
| Type: | typing.Callable[[UnstructuredMesh, npt.NDArray, npt.NDArray, npt.NDArray, npt.NDArray], typing.Iterable[bool]] |
| Description: | A function that takes in a mesh, an array containing element and local point indices to candidates to disconnect, an array of sorted overlapping points global ids, an array of their multiplicity, and an array of offsets that indexes into the first two arrays to get the start of grouped elements. |
UnstructuredMeshdef edge_lengths(mesh: UnstructuredMesh) -> np.ndarray: ...| Type: | UnstructuredMesh |
| Description: | The mesh to compute the edge lengths of. |
np.ndarraydef edge_lengths_projected(mesh: UnstructuredMesh) -> np.ndarray: ...| Type: | UnstructuredMesh |
| Description: | The mesh to compute the edge lengths of. |
np.ndarraydef edges(mesh: UnstructuredMesh) -> np.ndarray: ...| Type: | UnstructuredMesh |
| Description: | The mesh to get the ordered edges of. |
np.ndarraydef element_ids_to_node_ids(
mesh: UnstructuredMesh, element_ids: npt.NDArray
) -> npt.NDArray: ...| Type: | UnstructuredMesh |
| Description: | The mesh. |
| Type: | npt.NDArray |
| Description: | The element ids. |
npt.NDArray"z_node_1D" be present as an element nodal field in the mesh, and that it
represents the normalized z-coordinate. The normalized value of this
parameter will be clipped to a maximum value of 1.0, in case intermediate
mesh manipulations resulted in the stretching of the 1-D radial values.def extract_conservative_bm_file(
mesh: UnstructuredMesh,
max_radius: float = 6371000.0,
exclude_filter: tuple[str, int] | None = None,
) -> str: ...| Type: | UnstructuredMesh |
| Description: | The mesh to extract the 1-D model from. |
| Type: | float |
| Default value: | 6371000.0 |
| Description: | The maximum radius of the 1-D model. Defaults to 6371e3. |
| Type: | tuple[str, int] | None |
| Default value: | None |
| Description: | An additional flag which can be passed to ensure that certain elements are not considered in BM file generation. In a global mesh with real oceans, a common use for this parameter might be to exclude all fluid elements in the BM file generation. This could be done, for example, by passing the tuple ("fluid", 1). |
str{"x", "y"}, {"x", "y", "z"}, {"latitude", "longitude", "radius"}, or {"latitude", "longitude", "depth"}.
max_tree_doublings
controls the maximum amount of times that a search will be retried for a
delinquent point; in each pass the number of elements searched will be
doubled. If an element truly is outside of the mesh (as it may well be
when interpolating from a spherical domain), extracted values at those
points after max_tree_doublings tries will be marked with np.nan --
no extrapolation is performed. This convention was chosen to match the
standard xarray and CF convention for missing data.def extract_model_to_regular_grid(
mesh: UnstructuredMesh,
ds: xr.Dataset,
pars: str | list[str],
max_tree_doublings: int = 4,
number_of_threads: int | None = None,
verbose: bool = False,
_use_legacy_version: bool = False,
) -> xr.Dataset: ...| Type: | UnstructuredMesh |
| Description: | The mesh to interpolate from. |
| Type: | xr.Dataset |
| Description: | Xarray Dataset with coordinates to interpolate to. |
| Type: | str | list[str] |
| Description: | Parameters to interpolate. |
| Type: | int |
| Default value: | 4 |
| Description: | Maximum number of times the number of closest candidate elements will be doubled. Doubling only occurs for points which were not already claimed by previous passes. Defaults to 4. |
| Type: | int | None |
| Default value: | None |
| Description: | The number of parallel threads to use. If not given it will use the smaller of the total number of cores on the system and 120. |
| Type: | bool |
| Default value: | False |
| Description: | Show a progress bar when extracting models from a spherical mesh. No progress bar will be shown for cartesian meshes as that uses a much faster algorithm. |
| Type: | bool |
| Default value: | False |
| Description: | Force the Python version of the regular grid extraction to be used. |
xr.Datasetmax_tree_doublings is reached. For well behaved meshes, the enclosing
element should just be found in at most a few passes (likely just one).
If you are having issues with unclaimed points, you can try increasing
the iteration count. Note: be careful to ensure that most of your points
are actually in the domain! The algorithm can get slow at higher
iteration counts, so it pays to match up your input point extents with
the mesh extents as much as possible.allow_points_outside_mesh flag. If
this is set to false, then the function will throw if a single point
remains unclaimed after max_tree_doublings. This may suggest that
either a) the point is indeed outside the mesh (in which case no
extrapolation is performed), or b) more iterations are needed.def get_enclosing_elements(
mesh: _ElementCollectionProtocol,
points: np.ndarray,
max_tree_doublings: str | int = "auto",
allow_points_outside_mesh: bool = True,
verbose: bool = False,
element_restrict: np.ndarray | None = None,
point_restrict: np.ndarray | None = None,
) -> tuple[np.ndarray, np.ndarray]: ...| Type: | _ElementCollectionProtocol |
| Description: | Mesh to query. |
| Type: | np.ndarray |
| Description: | Array of query points, dimension [n_points, d]. |
| Type: | str | int |
| Default value: | 'auto' |
| Description: | Finding the enclosing element may be nontrivial in deformed meshes. The internal algorithm will double the number of closest candidate elements considered in each retry. Defaults to 4 doublings. |
| Type: | bool |
| Default value: | True |
| Description: | In some cases, it may be acceptable for some points to be located outside of the queried mesh. If this flag is set to true, an exception will not be thrown if this is the case. Points which are flagged as outside the mesh will have their corresponding element indices set to -(closet_centroid_element_id + 1). Defaults to True. |
| Type: | bool |
| Default value: | False |
| Description: | Show a progress bar. Also, if the query fails, setting verbose to true will print the indices of the failed points. Defaults to False. |
| Type: | np.ndarray | None |
| Default value: | None |
| Description: | Only interpolate from elements with these ids. |
| Type: | np.ndarray | None |
| Default value: | None |
| Description: | Only interpolate to these point indices. |
tuple[np.ndarray, np.ndarray]def get_hierarchical_map(
m_coarse: UnstructuredMesh,
m_fine: UnstructuredMesh,
number_of_neighbours: int = 8,
verify: bool = True,
) -> np.ndarray: ...| Type: | UnstructuredMesh |
| Description: | the coarser mesh |
| Type: | UnstructuredMesh |
| Description: | the finer mesh |
| Type: | int |
| Default value: | 8 |
| Description: | number of neighbours to use in tree search |
| Type: | bool |
| Default value: | True |
| Description: | verify that m_fine actually is a refinement of m_coarse. |
np.ndarraydef get_internal_side_set_facets(
mesh: UnstructuredMesh, side_set: str
) -> tuple[npt.NDArray, npt.NDArray]: ...| Type: | UnstructuredMesh |
| Description: | The mesh. |
| Type: | str |
| Description: | The sideset. |
tuple[npt.NDArray, npt.NDArray]def get_interpolation_coefficients(
mesh: _ElementCollectionProtocol, points: np.ndarray
) -> npt.NDArray: ...| Type: | _ElementCollectionProtocol |
| Description: | The mesh object to query. |
| Type: | np.ndarray |
| Description: | The points to get the interpolation coordinates for. |
npt.NDArray- Finds the elements that enclose a set of points - Interpolates the vertical coordinate value from the nodes of element to those points.
def get_side_set_elevations(
mesh: UnstructuredMesh,
side_set: str,
points: npt.NDArray,
execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
) -> npt.NDArray: ...| Type: | UnstructuredMesh |
| Description: | The mesh to extract a side set from. |
| Type: | str |
| Description: | The side set to extract. |
| Type: | npt.NDArray |
| Description: | The points to extract to. Should be an array of shape [n_pnt, n_dim_mesh - 1], i.e. only horizontal coordinates should be passed. |
| Type: | bindings.ExecutionPolicy |
| Default value: | <salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy object at 0x7c032d004e30> |
| Description: | Execution policy governing the maximum allowable parallelism of child routines. |
npt.NDArraydef get_surface_unit_vectors(
points: npt.NDArray,
mesh: UnstructuredMesh,
side_set: str,
num_threads: int = 2,
) -> npt.NDArray: ...| Type: | npt.NDArray |
| Description: | Points to return surface vectors on. Need to lie on the sideset. Should be of shape (N, mesh.ndim). |
| Type: | UnstructuredMesh |
| Description: | Mesh to calculate surface vectors on. |
| Type: | str |
| Description: | Side set to calculate surface vectors relative to. |
| Type: | int |
| Default value: | 2 |
| Description: | Number of threads to use for the computation. |
npt.NDArraydef get_topological_facets(mesh: UnstructuredMesh) -> npt.NDArray: ...| Type: | UnstructuredMesh |
| Description: | The mesh. |
npt.NDArraydef get_unique_facets(mesh: UnstructuredMesh) -> npt.NDArray: ...| Type: | UnstructuredMesh |
| Description: | The mesh. |
npt.NDArraydef interpolate_from_element_nodes(
ref: npt.NDArray, values: npt.NDArray, n_dim: int, num_threads: int = 2
) -> tuple[npt.NDArray, npt.NDArray]: ...| Type: | npt.NDArray |
| Description: | An array of shape [n_pnt, n_dim] reference coordinates. |
| Type: | npt.NDArray |
| Description: | An array of shape [n_pnt, n_ctrl], or [n_pnt, n_ctrl, n_par], containing the values of the field to interpolate. |
| Type: | int |
| Description: | The number of dimensions. |
| Type: | int |
| Default value: | 2 |
| Description: | The number of threads to use in parallel execution. |
tuple[npt.NDArray, npt.NDArray]def inverse_coordinate_transform(
control_nodes: npt.NDArray,
points: npt.NDArray,
max_iter: int = 100,
rtol: float = 1e-08,
atol: float = 1e-11,
atol_ref: float = 0.001,
num_threads: int = 2,
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.int64]]: ...| Type: | npt.NDArray |
| Description: | The tensorized control nodes defining the element's (or it's facet's, or ridge's) geometry. Should be of dimension [n_trial_points, n_ctrl_nodes, n_dim]. |
| Type: | npt.NDArray |
| Description: | The point to locate within the element. Should be of dimension [n_trial_pnts, d_dim]. |
| Type: | int |
| Default value: | 100 |
| Description: | The maximum number of iterations to attempt. |
| Type: | float |
| Default value: | 1e-08 |
| Description: | The relative tolerance that determines whether a point is considered as inside an element. |
| Type: | float |
| Default value: | 1e-11 |
| Description: | The absolute tolerance that determines whether a point is considered as inside the element. |
| Type: | float |
| Default value: | 0.001 |
| Description: | The tolerance in reference coordinates that determines whether a point is considered inside the element. |
| Type: | int |
| Default value: | 2 |
| Description: | The number of threads to use for parallel opertions. |
tuple[npt.NDArray[np.float64], npt.NDArray[np.int64]]def name_free_side_set(mesh: UnstructuredMesh, name: str) -> None: ...| Type: | UnstructuredMesh |
| Description: | The mesh to assign the new side set to. Will be mutated in place. |
| Type: | str |
| Description: | The name of the new side set. |
Nonedef normalize_block_coordinates(
mesh: UnstructuredMesh,
block: int | list[int],
top_side_set: str,
bot_side_set: str,
execution_policy: bindings.ExecutionPolicy = salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy,
interior_deformation_order: int = 1,
) -> tuple[npt.NDArray, npt.NDArray, npt.NDArray]: ...| Type: | UnstructuredMesh |
| Description: | The mesh to normalize coordinates from. |
| Type: | int | list[int] |
| Description: | The block ID, or a list of block IDS, of the elements to be normalized. |
| Type: | str |
| Description: | The top side set of the normalized region. |
| Type: | str |
| Description: | The bottom side set of the normalized region. |
| Type: | bindings.ExecutionPolicy |
| Default value: | <salvus._core.lib.salvus_core_python_bindings.ExecutionPolicy object at 0x7c032c766bf0> |
| Description: | Execution policy object controlling parallelization options. |
| Type: | int |
| Default value: | 1 |
| Description: | The polynomial order used to interpolate boundary deformations from a mesh's side sets to its interior nodes. The default order of 1 (linear interpolation) is sufficient for most cases. If the resulting mesh has geometric issues (like invalid Jacobians), increasing this value to match the mesh's model order may help create a valid mesh with smoother internal deformations. Only considered for Cartesian meshes. |
tuple[npt.NDArray, npt.NDArray, npt.NDArray]def read_model_from_h5(
filename: pathlib.Path | str, fields: typing.Sequence[str] | None = None
) -> dict[str, np.ndarray]: ...| Type: | pathlib.Path | str |
| Description: | Mesh file. |
| Type: | typing.Sequence[str] | None |
| Default value: | None |
| Description: | Optional field names to read. |
dict[str, np.ndarray]mesh.side_sets[side_set].def remove_from_side_set(
mesh: UnstructuredMesh,
side_set: str,
indices_to_remove: npt.NDArray | None = None,
indices_to_retain: npt.NDArray | None = None,
) -> None: ...| Type: | UnstructuredMesh |
| Description: | The mesh to modify. |
| Type: | str |
| Description: | The side set to modify. |
| Type: | npt.NDArray | None |
| Default value: | None |
| Description: | Facets to be removed. Must be None if indices_to_retain is not. |
| Type: | npt.NDArray | None |
| Default value: | None |
| Description: | Facets to be retained. Must be None if indices_to_remove is not. |
def retain_unique_facets(
mesh: UnstructuredMesh, side_set: str, verbosity: int = 0
) -> None: ...| Type: | UnstructuredMesh |
| Description: | Mesh. |
| Type: | str |
| Description: | Sideset to reduce to uniquely appearing facets. |
| Type: | int |
| Default value: | 0 |
| Description: | Verbosity of the operation, informing how side-set is altered. |
def uniquefy_side_sets(
mesh: UnstructuredMesh,
order: typing.Iterable[str] | None = None,
verbosity: int = 0,
) -> None: ...| Type: | UnstructuredMesh |
| Description: | Mesh. |
| Type: | typing.Iterable[str] | None |
| Default value: | None |
| Description: | Order in which the sidesets are parsed. |
| Type: | int |
| Default value: | 0 |
| Description: | Verbosity of the operation, informing how side-sets are altered. |