salvus.mesh.data_structures.salvus_mesh.algorithms.transform
salvus.mesh.data_structures.salvus_mesh.algorithms.transform salvus mesh data_structures salvus_mesh algorithms transform Algorithms for transforming meshes.
Functions
merge_blocks()
merge_blocks()def merge_blocks(
mesh: Mesh,
block_ids: tuple[int, ...],
new_block_id: int,
nodal_field_reduction: (
typing.Literal["safe", "mean"] | np_utils._UfuncLike | None
) = "safe",
renumber_remaining_blocks: dict[int, int] | None = None,
) -> Mesh: ...Merge multiple blocks into a single block, returning a new Mesh.
The blocks are merged in deterministic order (lowest block_id first). Element IDs, connectivities, and fields are concatenated accordingly. Points are merged by computing the unique global point IDs from the combined connectivity and extracting the corresponding coordinates.
Please note that merging blocks removes discontinuities in elemental
nodal fields between the blocks. The way this is done is controlled
by the parameter nodal_field_reduction. The default is “safe”
which will error out if there are discontinuities between the
blocks.
Parameters
meshMesh — The source Mesh containing the blocks to merge.block_idstuple[int, ...] — Tuple of block IDs to merge. Must contain at least 2 IDs.new_block_idint — The block ID to assign to the merged block.nodal_field_reductiontyping.Literal['safe', 'mean'] | np_utils._UfuncLike | None — The reduction operation to apply when multiple blocks define the same nodal field at the same global point. If None, no reduction is applied and the value from the first block is used. If “safe”, an error is raised if multiple blocks define the field at the same point with different values. If “mean”, computes the mean of all values at the same point. UFunc operations likenp.add,np.maximum,np.minimumare also supported.renumber_remaining_blocksdict[int, int] | None — An optional dictionary mapping old block IDs to new block IDs for blocks that are not being merged. For example,{3: 2, 4: 3}renames block 3 to 2 and block 4 to 3. The keys must be block IDs that exist in the mesh and are not being merged. The values must not conflict with other block IDs in the resulting mesh.
Returns Mesh — A new Mesh with the specified blocks merged into one.