Near-Far Barrier¶
-
template <typename T = double>
class NearFarBarrier : public ipc::BarrierBase<double>;¶ Inheritance diagram for ipc::NearFarBarrier:
Collaboration diagram for ipc::NearFarBarrier:
Near-Far barrier function.
This barrier function takes another “base” barrier object as argument. All operations defined in BarrierBase defer the computation to its base barrier. In addition, it splits the base barrier \(b\) into a near and a far part,
\[ b_\text{near}(d) = b(d)\,(1 - H(d)), \quad b_\text{far}(d) = b(d)\,H(d), \quad b_\text{near} + b_\text{far} = b, \]where \(H\) is a C² piecewise-cubic step rising from 0 at \(d = \alpha\hat{d}/2\) to 1 at \(d = \alpha\hat{d}\). Below \(\alpha\hat{d}/2\) the near part is exactly \(b\) and the far part exactly 0, so the identity also holds at contact, where the log barriers give \(b_\text{near} = +\infty\). For \(\alpha \ge 2\) the far part vanishes identically, since \(b = 0\) for \(d \ge \hat{d}\). ESPPotential uses \(\alpha =\) dbar_factor.
Public Functions¶
-
inline NearFarBarrier(
const BarrierBase<T>* const base_barrier, const double alpha);¶ Construct a NearFarBarrier that borrows its base barrier.
- Parameters:¶
- const BarrierBase<T> *const base_barrier¶
The base barrier function to use. This does not take ownership, so the base barrier must outlive this object.
- const double alpha¶
Split parameter: the far weight H rises from 0 at d = alpha * dhat / 2 to 1 at d = alpha * dhat.
- Throws:¶
std::invalid_argument– if alpha is not positive and finite. At alpha = 0 the step H collapses to a jump and its derivatives are NaN.
Construct a NearFarBarrier holding shared ownership of the base barrier.
Prefer this over the raw-pointer overload whenever the caller already has a shared_ptr — it pins the base barrier for the lifetime of this object, eliminating dangling-pointer risk.
- inline virtual T operator()(const T d, const T dhat) const override;¶
Evaluate the barrier function.
-
inline virtual T first_derivative(
const T d, const T dhat) const override;¶ Evaluate the first derivative of the barrier function wrt d.
-
inline virtual T second_derivative(
const T d, const T dhat) const override;¶ Evaluate the second derivative of the barrier function wrt d.
- T first_derivative_near(const T d, const T dhat) const;¶
Evaluate the first derivative of the near part wrt d.
- T first_derivative_far(const T d, const T dhat) const;¶
Evaluate the first derivative of the far part wrt d.
Private Types¶
Private Functions¶
- inline void validate_alpha() const;¶
- Mask is_purely_near(const T d, const T dhat) const;¶
Whether d lies where the far weight H vanishes identically (d <= alpha * dhat / 2), so near = b and far = 0.
Private Members¶
- const std::shared_ptr<const BarrierBase<T>> m_base_barrier;¶
The base barrier.
It owns the barrier when built from a shared_ptr and only aliases it when built from a raw pointer.
- const double m_alpha;¶
-
inline NearFarBarrier(