BarrierPotential¶
- class BarrierPotential : public ipc::NormalPotential;¶
The barrier collision potential.
Public Functions¶
-
explicit BarrierPotential(
const double dhat, const bool use_physical_barrier = false);¶ Construct a barrier potential.
Construct a barrier potential.
The barrier function.
The activation distance of the barrier.
Whether to use the physical barrier.
- inline double dhat() const;¶
Get the activation distance of the barrier.
Set the barrier function used to compute the potential.
The barrier function used to compute the potential.
-
virtual double force_magnitude(const double distance_squared,
const double dmin,
const double barrier_stiffness) const override;¶ Compute the force magnitude for a collision.
-
virtual VectorMax12d force_magnitude_gradient(
const double distance_squared,
Eigen::ConstRef<VectorMax12d> distance_squared_gradient,
const double dmin,
const double barrier_stiffness) const override;¶ Compute the gradient of the force magnitude for a collision.
- Parameters:¶
- const double distance_squared¶
The squared distance between elements.
- Eigen::ConstRef<VectorMax12d> distance_squared_gradient¶
The gradient of the squared distance.
- const double dmin¶
The minimum distance offset to the barrier.
- const double barrier_stiffness¶
The stiffness of the barrier.
- Returns:¶
The gradient of the force.
- inline bool use_physical_barrier() const;¶
Get whether to use the physical barrier.
Note
When using the convergent formulation we want the barrier to have units of Pa⋅m, so κ gets units of Pa and the barrier function should have units of m. See notebooks/physical_barrier.ipynb for more details.
- inline void set_use_physical_barrier(bool use_physical_barrier);¶
Set use physical barrier flag.
Note
When using the convergent formulation we want the barrier to have units of Pa⋅m, so κ gets units of Pa and the barrier function should have units of m. See notebooks/physical_barrier.ipynb for more details.
-
VectorMax12d gradient(const NormalCollision& collision,
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the gradient of the potential for a single collision.
- Parameters:¶
- const NormalCollision &collision¶
The collision.
- Eigen::ConstRef<VectorMax12d> positions¶
The collision stencil’s positions.
- Returns:¶
The gradient of the potential.
-
virtual double gradient(
const double distance_squared, const double dmin = 0) const
= 0;¶ Compute the gradient of the unmollified distance-based potential for a collision.
-
MatrixMax12d hessian(const NormalCollision& collision,
Eigen::ConstRef<VectorMax12d> positions,
const PSDProjectionMethod project_hessian_to_psd
= PSDProjectionMethod::NONE) const override;¶ Compute the hessian of the potential for a single collision.
- Parameters:¶
- const NormalCollision &collision¶
The collision.
- Eigen::ConstRef<VectorMax12d> positions¶
The collision stencil’s positions.
- const PSDProjectionMethod project_hessian_to_psd = PSDProjectionMethod::NONE¶
Whether to project the hessian to the positive semi-definite cone.
- Returns:¶
The hessian of the potential.
-
virtual double hessian(
const double distance_squared, const double dmin = 0) const
= 0;¶ Compute the hessian of the unmollified distance-based potential for a collision.
Protected Functions¶
-
virtual double operator()(const double distance_squared,
const double dmin = 0) const override;¶ Compute the barrier potential for a collision.
-
virtual double gradient(const double distance_squared,
const double dmin = 0) const override; Compute the gradient of the barrier potential for a collision.
-
virtual double hessian(const double distance_squared,
const double dmin = 0) const override; Compute the hessian of the barrier potential for a collision.
Protected Attributes¶
-
std::shared_ptr<Barrier> m_barrier
= std::make_shared<ClampedLogBarrier>();¶ The barrier function used to compute the potential.
- double m_dhat;¶
The activation distance of the barrier.
- bool m_use_physical_barrier = false;¶
Whether to use the physical barrier.
Note
When using the convergent formulation we want the barrier to have units of Pa⋅m, so κ gets units of Pa and the barrier function should have units of m. See notebooks/physical_barrier.ipynb for more details.
Private Types¶
- using Super = NormalPotential;¶
-
explicit BarrierPotential(