NormalPotential¶
- class NormalPotential : public ipc::Potential<NormalCollisions>;¶
Base class for distance-based potentials.
Subclassed by ipc::BarrierPotential, ipc::NormalAdhesionPotential
Public Functions¶
- NormalPotential() = default;¶
- virtual ~NormalPotential() = default;¶
-
Eigen::SparseMatrix<double> shape_derivative(
const NormalCollisions& collisions, const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices) const;¶ Compute the shape derivative of the potential.
- Parameters:¶
- const NormalCollisions &collisions¶
The set of collisions.
- const CollisionMesh &mesh¶
The collision mesh.
- Eigen::ConstRef<Eigen::MatrixXd> vertices¶
Vertices of the collision mesh.
- Throws:¶
std::runtime_error
– If the collision collisions were not built with shape derivatives enabled.- Returns:¶
The derivative of the force with respect to X, the rest vertices.
-
double operator()(const NormalCollision& collision,
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the potential for a single collision.
- Parameters:¶
- const NormalCollision &collision¶
The collision.
- Eigen::ConstRef<VectorMax12d> positions¶
The collision stencil’s positions.
- Returns:¶
The potential.
-
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.
-
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.
-
void shape_derivative(const NormalCollision& collision,
const std::array<index_t, 4>& vertex_ids,
Eigen::ConstRef<VectorMax12d> rest_positions,
Eigen::ConstRef<VectorMax12d> positions,
std::vector<Eigen::Triplet<double>>& out) const;¶ Compute the shape derivative of the potential for a single collision.
- Parameters:¶
- const NormalCollision &collision¶
[in] The collision.
- const std::array<index_t, 4> &vertex_ids¶
[in] The collision stencil’s vertex ids.
- Eigen::ConstRef<VectorMax12d> rest_positions¶
[in] The collision stencil’s rest positions.
- Eigen::ConstRef<VectorMax12d> positions¶
[in] The collision stencil’s positions.
- std::vector<Eigen::Triplet<double>> &out¶
[inout] Store the triplets of the shape derivative here.
-
virtual double force_magnitude(const double distance_squared,
const double dmin, const double barrier_stiffness) const
= 0;¶ 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
= 0;¶ 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.
Protected Functions¶
-
virtual double operator()(
const double distance_squared, const double dmin = 0) const
= 0;¶ Compute the unmollified distance-based potential for a collisions.
-
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.
-
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.
Private Types¶
- using Super = Potential<NormalCollisions>;¶