Distance namespace
Module which provides models for computation of the distance function.
The Distance module offers several methods for computing distance functions on finite element meshes, each with different trade-offs between accuracy, speed, and smoothness.
Available Methods
| Method | Class | Equation | Properties |
|---|---|---|---|
| Eikonal | Distance:: | Exact distances via FMM; supports signed distance with interior/interface regions | |
| Poisson | Distance:: | Smooth approximation; fast (one linear solve); does not give exact distances | |
| SignedPoisson | Distance:: | Region-dependent forcing yields a signed smooth distance | |
| Rvachev | Distance:: | Normalizes a level-set field to approximate distance; preserves zero set and sign |
| SpaldingTucker | Distance:: | | Better gradient normalization than Rvachev; more accurate near the interface |
All methods except Rvachev and SpaldingTucker inherit from a common CRTP Base<Derived> that provides setInterior() and setInterface() methods for specifying the signed-distance regions (mesh boundary attributes).
Eikonal Distance (FMM)
The Eikonal class wraps the FMM solver and provides the most accurate distance computation. Seeds are automatically identified from the interface attributes. Calling sign() after solve() negates interior values to produce a signed distance field.
P1 Vh(mesh); GridFunction d(Vh); Distance::Eikonal eikonal(d); eikonal.setInterface(interfaceAttr) .setInterior(interiorAttr) .solve() .sign();
Poisson Distance Approximation
Poisson solves with on in a single linear solve. The result is smooth but only approximates the true distance.
SignedPoisson extends this with region-dependent forcing: inside a specified region and elsewhere, with on the interface. It supports both single-attribute and attribute-set overloads:
// Unsigned Poisson distance Distance::Poisson poisson; auto d1 = poisson(Vh); // Signed Poisson distance with interface/region attributes Distance::SignedPoisson signedPoisson; auto d2 = signedPoisson(interfaceAttr, regionAttr, Vh);
Level-Set Normalization
Rvachev and SpaldingTucker are post-processing operators that normalize an existing level-set field into an approximate distance function without solving any PDE:
Distance::Rvachev rvachev; auto dR = rvachev(phi); Distance::SpaldingTucker st; auto dST = st(phi);
Classes
-
template<class Derived>class Base
- Base class for distance function computation models using CRTP.
-
template<class FES, class Data>class Eikonal
- Distance function computation using the Eikonal equation.
- class Poisson
- Poisson approximation to the distance function.
- class Rvachev
- Rvachev normalization for a level set function.
- class SignedPoisson
- Poisson approximation to the signed distance function.
- class SpaldingTucker
- Spalding-Tucker normalization for a level set function.