Mondaic

salvus.mesh.algorithms.improve

salvus.mesh.algorithms.improve salvus mesh algorithms improve

Routines to perform mesh smoothing.

Functions

centroidal()

def centroidal(
    mesh: UnstructuredMesh,
    iterations: int = 50,
    fixed_side_sets: str | collections.abc.Sequence[str] | None = None,
    fixed_outer_boundaries: bool = True,
) -> UnstructuredMesh: ...

Area-weighted centroidal smoothing for uniform element sizes.

Every node that is not held fixed is repeatedly moved to the size-weighted average of the centroids of its incident elements (a Lloyd iteration), where the weight is each element’s area in 2-D or volume in 3-D. This pulls nodes towards larger elements and away from smaller ones, relaxing the mesh towards uniform element sizes. It holds all nodes on a side of a fixed side set in place, so the geometry and interfaces are preserved; only the coordinates change and the connectivity and all fields are untouched.

The smoothing is a Jacobi iteration: within a sweep every free node is updated from the previous sweep’s positions.

Parameters
  • mesh UnstructuredMesh — The mesh to smooth.
  • iterations int — Number of smoothing sweeps.
  • fixed_side_sets str | collections.abc.Sequence[str] | None — Name or names of the side sets whose nodes are held fixed. If None, every side set in mesh.side_sets is used.
  • fixed_outer_boundaries bool — If True, the mesh’s outer surface is detected with find_surface and its nodes are held fixed too, so the outer geometry is preserved. The temporary side set used to do this is removed from the returned mesh.
Returns UnstructuredMesh — A copy of mesh with the free nodes relocated.

laplacian()

def laplacian(
    mesh: UnstructuredMesh,
    iterations: int = 50,
    fixed_side_sets: str | collections.abc.Sequence[str] | None = None,
    fixed_outer_boundaries: bool = True,
) -> UnstructuredMesh: ...

Laplacian-smooth a mesh, holding the chosen side-set nodes fixed.

Every node that is not held fixed is repeatedly moved to the average of the nodes it shares an element edge with, which relaxes the mesh towards better-shaped elements. All nodes that lie on a side of a fixed side set are held in place, so the corresponding geometry and interfaces are preserved. Only the coordinates change; the connectivity and all fields are untouched.

The smoothing is a Jacobi iteration: within a sweep every free node is updated from the previous sweep’s positions.

Parameters
  • mesh UnstructuredMesh — The mesh to smooth.
  • iterations int — Number of smoothing sweeps.
  • fixed_side_sets str | collections.abc.Sequence[str] | None — Name or names of the side sets whose nodes are held fixed. If None, every side set in mesh.side_sets is used.
  • fixed_outer_boundaries bool — If True, the mesh’s outer surface is detected with find_surface and its nodes are held fixed too, so the outer geometry is preserved. The temporary side set used to do this is removed from the returned mesh.
Returns UnstructuredMesh — A copy of mesh with the free nodes relocated.