Wildmeshing Toolkit
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
wmtk::components::topological_offset::OffsetPotential< DIM > Class Template Referenceabstract

The offset potential: the scalar field on space whose level set the front is placed on. More...

#include <OffsetPotential.hpp>

Inheritance diagram for wmtk::components::topological_offset::OffsetPotential< DIM >:
wmtk::components::topological_offset::EuclideanOffsetPotential< DIM > wmtk::components::topological_offset::SmoothOffsetPotential< DIM >

Public Types

using VecD = Eigen::Matrix< double, DIM, 1 >
 
using MatD = Eigen::Matrix< double, DIM, DIM >
 

Public Member Functions

virtual ~OffsetPotential ()
 
double target_level () const
 The level value the offset boundary is placed on.
 
double delta () const
 The offset distance the field is calibrated to.
 
double dhat () const
 
double level_set_slope () const
 |d(field)/d(distance)| at the level set on a flat stretch of input.
 
virtual double value (const VecD &p) const =0
 
virtual bool is_euclidean () const
 The Euclidean field: value() is the distance, so a distance residual is the plain one.
 
virtual VecD gradient (const VecD &p) const =0
 
virtual MatD hessian (const VecD &p) const =0
 
virtual double residual_length (const VecD &p) const =0
 Distance from p to the level set, in length units.
 
virtual bool within_support (const VecD &p) const =0
 Whether p is somewhere the field can give a direction to the level set at all.
 
virtual bool is_inside_offset (const VecD &p) const =0
 Whether p lies inside the offset region – on the complex's side of the level set.
 
virtual std::string describe_active (const VecD &p) const =0
 Diagnostic: what the field is made of at p, one contribution per line.
 

Protected Member Functions

 OffsetPotential (const double delta, const double dhat)
 

Protected Attributes

double m_delta = 0.
 
double m_dhat = 0.
 
double m_c = 0.
 
double m_grad_ref = 1.
 

Detailed Description

template<int DIM>
class wmtk::components::topological_offset::OffsetPotential< DIM >

The offset potential: the scalar field on space whose level set the front is placed on.

Two implementations, chosen by the offset_field JSON option: SmoothOffsetPotential (a C^2 barrier with analytic derivatives, level set Phi = c, a smoothed offset) and EuclideanOffsetPotential (the distance d to the input complex, level set d = delta, the exact offset). Each is documented at its own declaration below.

The two are monotone in opposite directions, which is the one thing a caller must not get wrong: the barrier is huge on the complex and decays to 0 at dhat, so inside the offset region means Phi >= c, while the distance increases outward, so inside means d <= delta. Never compare value() against target_level() outside this file – ask is_inside_offset(), which each implementation answers with its own sense.

The rest of the interface is identical, so the optimization, the criterion, the sizing field and OffsetEnergy are written once against this base and never learn which field they have.

Constructor & Destructor Documentation

◆ ~OffsetPotential()

template<int DIM>
wmtk::components::topological_offset::OffsetPotential< DIM >::~OffsetPotential ( )
virtualdefault

Must stay out of line: it is this class's key function, so exactly one vtable is emitted, beside the explicit instantiations in OffsetPotential.cpp. Defaulted inline, there is no key function and the vtable goes weakly into every translation unit that sees the header.

◆ OffsetPotential()

template<int DIM>
wmtk::components::topological_offset::OffsetPotential< DIM >::OffsetPotential ( const double  delta,
const double  dhat 
)
inlineprotected

Subclasses set delta and the support here; m_c is theirs to fill in, because one calibrates it and the other simply knows it.

Member Function Documentation

◆ describe_active()

template<int DIM>
virtual std::string wmtk::components::topological_offset::OffsetPotential< DIM >::describe_active ( const VecD &  p) const
pure virtual

Diagnostic: what the field is made of at p, one contribution per line.

Implemented in wmtk::components::topological_offset::SmoothOffsetPotential< DIM >, and wmtk::components::topological_offset::EuclideanOffsetPotential< DIM >.

◆ dhat()

template<int DIM>
double wmtk::components::topological_offset::OffsetPotential< DIM >::dhat ( ) const
inline

Support radius, beyond which the field and its derivatives vanish. Infinite for a field with no compact support, which makes within_support() vacuously true.

◆ is_euclidean()

template<int DIM>
virtual bool wmtk::components::topological_offset::OffsetPotential< DIM >::is_euclidean ( ) const
inlinevirtual

The Euclidean field: value() is the distance, so a distance residual is the plain one.

Reimplemented in wmtk::components::topological_offset::EuclideanOffsetPotential< DIM >.

◆ is_inside_offset()

template<int DIM>
virtual bool wmtk::components::topological_offset::OffsetPotential< DIM >::is_inside_offset ( const VecD &  p) const
pure virtual

Whether p lies inside the offset region – on the complex's side of the level set.

Ask this, never value(p) >= target_level(): the two fields are monotone in opposite directions, so the literal comparison is right for one and silently inverted for the other.

Implemented in wmtk::components::topological_offset::SmoothOffsetPotential< DIM >, and wmtk::components::topological_offset::EuclideanOffsetPotential< DIM >.

◆ level_set_slope()

template<int DIM>
double wmtk::components::topological_offset::OffsetPotential< DIM >::level_set_slope ( ) const
inline

|d(field)/d(distance)| at the level set on a flat stretch of input.

The factor that turns a field difference into a length, so a criterion stated on the field's gradient is not by itself field-independent. The smoothing objective is E = (Phi - c)^2, so |grad E| ~ 2 * slope^2 * residual_length near the level set: a bound on |grad E| bounds a length only after dividing by slope^2. It is 1 for a distance field, where the two coincide, and 1/delta-ish for a barrier. The |grad Phi| ~ slope step is local to the level set on a flat stretch, not an identity.

See TopoOffsetTetMesh::offset_gradient_tolerance(), which is the only consumer.

◆ residual_length()

template<int DIM>
virtual double wmtk::components::topological_offset::OffsetPotential< DIM >::residual_length ( const VecD &  p) const
pure virtual

Distance from p to the level set, in length units.

What the convergence criterion measures: comparable to target_distance, while the field value need not be.

Implemented in wmtk::components::topological_offset::SmoothOffsetPotential< DIM >, and wmtk::components::topological_offset::EuclideanOffsetPotential< DIM >.

◆ within_support()

template<int DIM>
virtual bool wmtk::components::topological_offset::OffsetPotential< DIM >::within_support ( const VecD &  p) const
pure virtual

Whether p is somewhere the field can give a direction to the level set at all.

Implemented in wmtk::components::topological_offset::SmoothOffsetPotential< DIM >, and wmtk::components::topological_offset::EuclideanOffsetPotential< DIM >.

Member Data Documentation

◆ m_grad_ref

template<int DIM>
double wmtk::components::topological_offset::OffsetPotential< DIM >::m_grad_ref = 1.
protected

1 unless a subclass calibrates otherwise – see level_set_slope(). Leaving it alone is what makes the gradient criterion mean the same thing on both fields.


The documentation for this class was generated from the following files: