PolyFEM
Loading...
Searching...
No Matches
GCPContactForm.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ContactForm.hpp"
4
6#include <polysolve/nonlinear/PostStepData.hpp>
7
8#include <ipc/gcp/gcp_collisions.hpp>
9#include <ipc/gcp/gcp_potential.hpp>
10
11namespace polyfem::solver
12{
14 {
16
17 public:
18 GCPContactForm(const ipc::CollisionMesh &collision_mesh,
19 const double dhat,
20 const double avg_mass,
21 const double alpha_t,
22 const double alpha_n,
23 const bool use_adaptive_dhat,
24 const double min_distance_ratio,
26 const bool is_time_dependent,
27 const bool enable_shape_derivatives,
28 const ipc::BroadPhaseMethod broad_phase_method,
29 const double ccd_tolerance,
30 const int ccd_max_iterations,
31 const double dhat_epsilon_scale);
32
33 virtual std::string name() const override { return "smooth-contact"; }
34
35 void update_barrier_stiffness(const Eigen::VectorXd &x, const Eigen::MatrixXd &grad_energy) override;
36
40 void post_step(const polysolve::nonlinear::PostStepData &data) override;
41
42 bool using_adaptive_dhat() const { return use_adaptive_dhat; }
43 const ipc::GCPParameters &get_params() const { return params; }
44
45 const ipc::GCPCollisions &collision_set() const { return collision_set_; }
46
47 const ipc::GCPPotential &barrier_potential() const { return barrier_potential_; }
48
49 protected:
53 double value_unweighted(const Eigen::VectorXd &x) const override;
54
58 Eigen::VectorXd value_per_element_unweighted(const Eigen::VectorXd &x) const override;
59
63 void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
64
68 void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override;
69
70 double barrier_support_size() const override { return dhat_; }
71
72 void update_collision_set(const Eigen::MatrixXd &displaced_surface) override;
73
74 private:
75 ipc::GCPParameters params;
77
79 ipc::GCPCollisions collision_set_;
80
82 ipc::GCPPotential barrier_potential_;
83 };
84} // namespace polyfem::solver
int x
Form representing the contact potential and forces.
bool use_adaptive_barrier_stiffness() const
Get use_adaptive_barrier_stiffness.
const double dhat_
Barrier activation distance.
double dhat_epsilon_scale() const
Get the dhat_epsilon_scale passed to ipc::update_barrier_stiffness.
void post_step(const polysolve::nonlinear::PostStepData &data) override
Update fields after a step in the optimization.
void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
Compute the second derivative of the value wrt x.
virtual std::string name() const override
double barrier_support_size() const override
void update_barrier_stiffness(const Eigen::VectorXd &x, const Eigen::MatrixXd &grad_energy) override
Update the barrier stiffness based on the current elasticity energy.
const ipc::GCPCollisions & collision_set() const
void update_collision_set(const Eigen::MatrixXd &displaced_surface) override
Update the cached candidate set for the current solution.
ipc::GCPPotential barrier_potential_
Contact potential.
const ipc::GCPParameters & get_params() const
void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Compute the first derivative of the value wrt x.
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the contact barrier potential value.
Eigen::VectorXd value_per_element_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form multiplied per element.
ipc::GCPCollisions collision_set_
Cached constraint set for the current solution.
const ipc::GCPPotential & barrier_potential() const
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:24