salvus.mesh.data_structures.salvus_mesh.migration.unstructured_mesh
salvus.mesh.data_structures.salvus_mesh.migration.unstructured_mesh salvus mesh data_structures salvus_mesh migration unstructured_mesh Migration utilities for UnstructuredMesh in relation to Mesh.
Functions
compare_um_migration_data()
compare_um_migration_data()def compare_um_migration_data(
md_A: UnstructuredMeshMigrationData,
md_B: typing.Any,
raise_with_error_if_not_equal: bool = False,
) -> bool: ...Compare two UnstructuredMeshMigrationData objects for equality.
md_AUnstructuredMeshMigrationData — First UnstructuredMeshMigrationData object to compare.md_Btyping.Any — Second object to compare with.raise_with_error_if_not_equalbool — If True, raise an error with a detailed report if the objects are not equal.
element_ordering_from_partitioning_field()
element_ordering_from_partitioning_field()def element_ordering_from_partitioning_field(
um: UnstructuredMesh, partitioning_field: str
) -> list[npt.NDArray]: ...Compute the original element indices per block from an unstructured mesh.
Helpful for reconstructing elemental fields on the original unstructured mesh after partitioning into blocks.
umUnstructuredMesh — The unstructured mesh.partitioning_fieldstr — The name of the elemental field used to partition the mesh into blocks.
mesh_from_unstructured_mesh()
mesh_from_unstructured_mesh()def mesh_from_unstructured_mesh(
um: UnstructuredMesh,
partitioning_field: str | None,
elemental_nodal_reduction: (
typing.Literal["safe", "mean"] | numpy_utils._UfuncLike | None
) = "safe",
) -> Mesh: ...Create mesh from an unstructured mesh.
As element-nodal fields cannot be represented in the new Mesh format, they are reduced to nodal fields during the conversion. Their discontinuities between blocks are preserved, but within-block discontinuities are handled according to the specified reduction method.
If global_element_ids is present as an elemental field in the
unstructured mesh, it is used to set the global_element_ids of the new
mesh (a dataclass member not considered a field), as well as being retained
as an elemental field. If it is not present, global_element_ids is set
to a consecutive numbering starting at zero for the first block, and
continuing consecutively across blocks.
umUnstructuredMesh — The unstructured mesh.partitioning_fieldstr | None — The name of the elemental field used to partition the mesh into blocks. If None, the following logic is applied in sequence, matching the first found: - If the fieldblockis present, use that. - If the fieldlayeris present, use that. - If neither is present, the entire mesh is treated as a single block.elemental_nodal_reductiontyping.Literal['safe', 'mean'] | numpy_utils._UfuncLike | None — The reduction method to use when converting elemental-nodal fields to nodal fields within each block. If “safe”, an error is raised if conflicting values are found at the same node. If “mean”, conflicting values are averaged. If None, the first occurrence is used. UFunc operations likenp.add,np.maximum,np.minimumare also supported.
_migration_data attribute.replace_side_sets_and_materials()
replace_side_sets_and_materials()def replace_side_sets_and_materials(
mesh: Mesh,
side_sets: tuple[SideSet, ...] | None,
materials: dict[int, type[PhysicalMaterial] | None] | None,
) -> Mesh: ...Replace side sets and materials in a mesh.
Useful when applying unstructured mesh algorithms to the new format, which doesn’t retain side sets and materials.
Will overwrite existing materials if None is explicitly passed for a block.
meshMesh — The mesh to modify.side_setstuple[SideSet, ...] | None — The new side sets to apply to the mesh.materialsdict[int, type[PhysicalMaterial] | None] | None — The new materials to apply to each block in the mesh.
unstructured_mesh_from_mesh()
unstructured_mesh_from_mesh()def unstructured_mesh_from_mesh(mesh: Mesh) -> UnstructuredMesh: ...Convert the Mesh to an UnstructuredMesh.
Note that any discontinuous elemental-nodal fields are mean-reduced to nodal fields during the conversion. Their discontinuities between blocks are preserved, but within-block discontinuities are averaged out.
Any scalar nodal fields in the mesh are broadcast to full nodal fields in the new mesh.
This method will add two extra fields to the mesh if they are not present in the fields of the blocks:
global_element_ids: An elemental scalar field containing the global element IDs for each element in the mesh.block: An elemental scalar field containing the block ID for each element in the mesh, which tells one which block the element came from. This is omitted if the mesh was constructed from an unstructured mesh. In that case, the migration data already contains the partitioning field, which is oftenblockorlayer.
meshMesh — The mesh to convert.
UnstructuredMesh object representing the same mesh.Classes
UmField
UmFieldclass UmField(enum.Enum):
def __init__(self): ...Field types in UnstructuredMesh.
UnstructuredMeshMigrationData
UnstructuredMeshMigrationDataclass UnstructuredMeshMigrationData(builtins.object):
def __init__(
self,
original_element_indices: list[npt.NDArray],
partitioning_field: str | None,
field_mappings: dict[str, UmField],
original_scale: float,
) -> None: ...Data required to migrate a Mesh back to an UnstructuredMesh.
This class is used internally by the Mesh class to store data required for migration back to an UnstructuredMesh. It is not intended to be used directly by users.
original_element_indiceslist[npt.NDArray] — List of original element indices per block. If one uses these arrays to index into fields on the original mesh, one obtains the fields in global element order of the new mesh blocks. Alternatively, the propertyreverse_orderingcan be used to permute fields on the new mesh back to the original unstructured mesh.partitioning_fieldstr | None — The name of the elemental field used to partition the mesh into blocks. Is also still present as elemental field in the new mesh.field_mappingsdict[str, UmField] — Fields in the new mesh, and how they were originally represented in the unstructured mesh.original_scalefloat — If a scale other than 1.0 was present on the original mesh, it is stored here to allow correct reconstruction of the original mesh.
reverse_ordering npt.NDArray
reverse_ordering npt.NDArrayThe reverse ordering of elements to reconstruct the original mesh.
Property, as the reverse ordering can be fully computed from
original_element_indices. This reverse ordering can be used to
reconstruct the original unstructured mesh from the partitioned blocks.