|
PolyFEM
|
#include <BarrierContactForm.hpp>
Public Member Functions | |
| BarrierContactForm (const ipc::CollisionMesh &collision_mesh, const double dhat, const double avg_mass, const bool use_area_weighting, const bool use_improved_max_operator, const bool use_physical_barrier, const bool use_adaptive_barrier_stiffness, const bool is_time_dependent, const bool enable_shape_derivatives, const ipc::BroadPhaseMethod broad_phase_method, const double ccd_tolerance, const int ccd_max_iterations) | |
| virtual std::string | name () const override |
| virtual void | update_barrier_stiffness (const Eigen::VectorXd &x, const Eigen::MatrixXd &grad_energy) override |
| Update the barrier stiffness based on the current elasticity energy. | |
| void | post_step (const polysolve::nonlinear::PostStepData &data) override |
| Update fields after a step in the optimization. | |
| bool | use_convergent_formulation () const override |
| Get use_convergent_formulation. | |
| bool | use_area_weighting () const |
| Get use_area_weighting. | |
| bool | use_improved_max_operator () const |
| Get use_improved_max_operator. | |
| bool | use_physical_barrier () const |
| Get use_physical_barrier. | |
| void | force_shape_derivative (const ipc::NormalCollisions &collision_set, const Eigen::MatrixXd &solution, const Eigen::VectorXd &adjoint_sol, Eigen::VectorXd &term) const |
| const ipc::NormalCollisions & | collision_set () const |
| const ipc::BarrierPotential & | barrier_potential () const |
Public Member Functions inherited from polyfem::solver::ContactForm | |
| ContactForm (const ipc::CollisionMesh &collision_mesh, const double dhat, const double avg_mass, const bool use_adaptive_barrier_stiffness, const bool is_time_dependent, const bool enable_shape_derivatives, const ipc::BroadPhaseMethod broad_phase_method, const double ccd_tolerance, const int ccd_max_iterations) | |
| Construct a new Contact Form object. | |
| virtual | ~ContactForm ()=default |
| virtual void | init (const Eigen::VectorXd &x) override |
| Initialize the form. | |
| virtual void | update_quantities (const double t, const Eigen::VectorXd &x) override |
| Update time-dependent fields. | |
| virtual double | max_step_size (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override |
| Determine the maximum step size allowable between the current and next solution. | |
| virtual void | line_search_begin (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override |
| Initialize variables used during the line search. | |
| void | line_search_end () override |
| Clear variables used during the line search. | |
| virtual void | solution_changed (const Eigen::VectorXd &new_x) override |
| Update cached fields upon a change in the solution. | |
| virtual bool | is_step_collision_free (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override |
| Checks if the step is collision free. | |
| Eigen::MatrixXd | compute_displaced_surface (const Eigen::VectorXd &x) const |
| Compute the displaced positions of the surface nodes. | |
| double | barrier_stiffness () const |
| Get the current barrier stiffness. | |
| void | set_barrier_stiffness (const double barrier_stiffness) |
| Get the current barrier stiffness. | |
| bool | use_adaptive_barrier_stiffness () const |
| Get use_adaptive_barrier_stiffness. | |
| bool | enable_shape_derivatives () const |
| double | weight () const override |
| Get the form's multiplicative constant weight. | |
| double | dhat () const |
| std::shared_ptr< ipc::BroadPhase > | get_broad_phase () const |
Public Member Functions inherited from polyfem::solver::Form | |
| virtual | ~Form () |
| virtual void | finish () |
| virtual double | value (const Eigen::VectorXd &x) const |
| Compute the value of the form multiplied with the weigth. | |
| Eigen::VectorXd | value_per_element (const Eigen::VectorXd &x) const |
| Compute the value of the form multiplied with the weigth. | |
| virtual void | first_derivative (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const |
| Compute the first derivative of the value wrt x multiplied with the weigth. | |
| void | second_derivative (const Eigen::VectorXd &x, StiffnessMatrix &hessian) const |
| Compute the second derivative of the value wrt x multiplied with the weigth. | |
| virtual bool | is_step_valid (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const |
| Determine if a step from solution x0 to solution x1 is allowed. | |
| virtual void | init_lagging (const Eigen::VectorXd &x) |
| Initialize lagged fields TODO: more than one step. | |
| virtual void | update_lagging (const Eigen::VectorXd &x, const int iter_num) |
| Update lagged fields. | |
| virtual int | max_lagging_iterations () const |
| Get the maximum number of lagging iteration allowable. | |
| virtual bool | uses_lagging () const |
| Does this form require lagging? | |
| void | set_project_to_psd (bool val) |
| Set project to psd. | |
| bool | is_project_to_psd () const |
| Get if the form's second derivative is projected to psd. | |
| void | enable () |
| Enable the form. | |
| void | disable () |
| Disable the form. | |
| void | set_enabled (const bool enabled) |
| Set if the form is enabled. | |
| bool | enabled () const |
| Determine if the form is enabled. | |
| void | set_weight (const double weight) |
| Set the form's multiplicative constant weight. | |
| void | set_output_dir (const std::string &output_dir) |
| virtual void | set_scale (const double scale) |
| sets the scale for the form | |
Protected Member Functions | |
| virtual 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. | |
| virtual void | first_derivative_unweighted (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override |
| Compute the first derivative of the value wrt x. | |
| virtual void | second_derivative_unweighted (const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override |
| Compute the second derivative of the value wrt x. | |
| void | update_collision_set (const Eigen::MatrixXd &displaced_surface) override |
| Update the cached candidate set for the current solution. | |
Protected Member Functions inherited from polyfem::solver::ContactForm | |
| virtual double | barrier_support_size () const |
Protected Member Functions inherited from polyfem::solver::Form | |
| std::string | resolve_output_path (const std::string &path) const |
Protected Attributes | |
| ipc::NormalCollisions | collision_set_ |
| Cached constraint set for the current solution. | |
| const ipc::BarrierPotential | barrier_potential_ |
| Contact potential. | |
Protected Attributes inherited from polyfem::solver::ContactForm | |
| const ipc::CollisionMesh & | collision_mesh_ |
| Collision mesh. | |
| const double | dhat_ |
| Barrier activation distance. | |
| const double | dmin_ = 0 |
| Minimum distance between elements. | |
| const bool | use_adaptive_barrier_stiffness_ |
| If true, use an adaptive barrier stiffness. | |
| double | barrier_stiffness_ |
| Barrier stiffness. | |
| double | max_barrier_stiffness_ |
| Maximum barrier stiffness to use when using adaptive barrier stiffness. | |
| const double | avg_mass_ |
| Average mass of the mesh (used for adaptive barrier stiffness) | |
| const bool | is_time_dependent_ |
| Is the simulation time dependent? | |
| const bool | enable_shape_derivatives_ |
| Enable shape derivatives computation. | |
| const ipc::BroadPhaseMethod | broad_phase_method_ |
| Broad phase method to use for distance and CCD evaluations. | |
| const std::shared_ptr< ipc::BroadPhase > | broad_phase_ |
| const ipc::TightInclusionCCD | tight_inclusion_ccd_ |
| Continuous collision detection specification object. | |
| double | prev_distance_ |
| Previous minimum distance between all elements. | |
| bool | use_cached_candidates_ = false |
| If true, use the cached candidate set for the current solution. | |
| ipc::Candidates | candidates_ |
| Cached candidate set for the current solution. | |
Protected Attributes inherited from polyfem::solver::Form | |
| bool | project_to_psd_ = false |
| If true, the form's second derivative is projected to be positive semidefinite. | |
| double | weight_ = 1 |
| weight of the form (e.g., AL penalty weight or Δt²) | |
| bool | enabled_ = true |
| If true, the form is enabled. | |
| std::string | output_dir_ |
Additional Inherited Members | |
Public Attributes inherited from polyfem::solver::ContactForm | |
| bool | save_ccd_debug_meshes = false |
| If true, output debug files. | |
Definition at line 8 of file BarrierContactForm.hpp.
| polyfem::solver::BarrierContactForm::BarrierContactForm | ( | const ipc::CollisionMesh & | collision_mesh, |
| const double | dhat, | ||
| const double | avg_mass, | ||
| const bool | use_area_weighting, | ||
| const bool | use_improved_max_operator, | ||
| const bool | use_physical_barrier, | ||
| const bool | use_adaptive_barrier_stiffness, | ||
| const bool | is_time_dependent, | ||
| const bool | enable_shape_derivatives, | ||
| const ipc::BroadPhaseMethod | broad_phase_method, | ||
| const double | ccd_tolerance, | ||
| const int | ccd_max_iterations | ||
| ) |
Definition at line 14 of file BarrierContactForm.cpp.
References collision_set_, polyfem::solver::ContactForm::enable_shape_derivatives(), use_area_weighting(), and use_improved_max_operator().
|
inline |
Definition at line 47 of file BarrierContactForm.hpp.
References barrier_potential_.
Referenced by polyfem::solver::PeriodicContactForm::force_periodic_shape_derivative().
|
inline |
Definition at line 46 of file BarrierContactForm.hpp.
References collision_set_.
Referenced by force_shape_derivative(), use_area_weighting(), and use_improved_max_operator().
|
overrideprotectedvirtual |
Compute the first derivative of the value wrt x.
| [in] | x | Current solution |
| [out] | gradv | Output gradient of the value wrt x |
Implements polyfem::solver::Form.
Reimplemented in polyfem::solver::PeriodicContactForm.
Definition at line 170 of file BarrierContactForm.cpp.
References barrier_potential_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), and x.
Referenced by polyfem::solver::PeriodicContactForm::first_derivative_unweighted().
| void polyfem::solver::BarrierContactForm::force_shape_derivative | ( | const ipc::NormalCollisions & | collision_set, |
| const Eigen::MatrixXd & | solution, | ||
| const Eigen::VectorXd & | adjoint_sol, | ||
| Eigen::VectorXd & | term | ||
| ) | const |
Definition at line 32 of file BarrierContactForm.cpp.
References barrier_potential_, polyfem::solver::ContactForm::barrier_stiffness(), polyfem::solver::ContactForm::collision_mesh_, collision_set(), and polyfem::solver::ContactForm::compute_displaced_surface().
|
inlineoverridevirtual |
Reimplemented from polyfem::solver::ContactForm.
Definition at line 24 of file BarrierContactForm.hpp.
|
overridevirtual |
Update fields after a step in the optimization.
| iter_num | Optimization iteration number |
| x | Current solution |
Reimplemented from polyfem::solver::Form.
Reimplemented in polyfem::solver::PeriodicContactForm.
Definition at line 192 of file BarrierContactForm.cpp.
References polyfem::solver::ContactForm::barrier_stiffness(), polyfem::solver::ContactForm::barrier_stiffness_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), polyfem::solver::ContactForm::dhat(), polyfem::solver::ContactForm::is_time_dependent_, polyfem::logger(), polyfem::solver::ContactForm::max_barrier_stiffness_, polyfem::solver::ContactForm::prev_distance_, and polyfem::solver::ContactForm::use_adaptive_barrier_stiffness_.
Referenced by polyfem::solver::PeriodicContactForm::post_step().
|
overrideprotectedvirtual |
Compute the second derivative of the value wrt x.
| x | Current solution |
| hessian | Output Hessian of the value wrt x |
Implements polyfem::solver::Form.
Reimplemented in polyfem::solver::PeriodicContactForm.
Definition at line 176 of file BarrierContactForm.cpp.
References barrier_potential_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), POLYFEM_SCOPED_TIMER, polyfem::solver::Form::project_to_psd_, and x.
Referenced by polyfem::solver::PeriodicContactForm::force_periodic_shape_derivative(), and polyfem::solver::PeriodicContactForm::second_derivative_unweighted().
|
overridevirtual |
Update the barrier stiffness based on the current elasticity energy.
| x | Current solution |
Implements polyfem::solver::ContactForm.
Reimplemented in polyfem::solver::PeriodicContactForm.
Definition at line 42 of file BarrierContactForm.cpp.
References polyfem::solver::ContactForm::avg_mass_, barrier_potential_, polyfem::solver::ContactForm::barrier_stiffness(), polyfem::solver::ContactForm::barrier_stiffness_, polyfem::solver::ContactForm::broad_phase_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), polyfem::solver::ContactForm::dhat_, polyfem::solver::ContactForm::dmin_, polyfem::logger(), polyfem::solver::ContactForm::max_barrier_stiffness_, update_collision_set(), polyfem::solver::ContactForm::use_adaptive_barrier_stiffness(), use_convergent_formulation(), polyfem::solver::Form::weight_, and x.
Referenced by polyfem::solver::PeriodicContactForm::update_barrier_stiffness().
|
overrideprotectedvirtual |
Update the cached candidate set for the current solution.
| displaced_surface | Vertex positions displaced by the current solution |
Implements polyfem::solver::ContactForm.
Definition at line 99 of file BarrierContactForm.cpp.
References polyfem::solver::ContactForm::broad_phase_, polyfem::solver::ContactForm::candidates_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::dhat_, polyfem::solver::ContactForm::dmin_, and polyfem::solver::ContactForm::use_cached_candidates_.
Referenced by update_barrier_stiffness().
|
inline |
Get use_area_weighting.
Definition at line 36 of file BarrierContactForm.hpp.
References collision_set().
Referenced by BarrierContactForm(), and use_convergent_formulation().
|
inlineoverridevirtual |
Get use_convergent_formulation.
Reimplemented from polyfem::solver::ContactForm.
Definition at line 33 of file BarrierContactForm.hpp.
References use_area_weighting(), use_improved_max_operator(), and use_physical_barrier().
Referenced by update_barrier_stiffness().
|
inline |
Get use_improved_max_operator.
Definition at line 39 of file BarrierContactForm.hpp.
References collision_set().
Referenced by BarrierContactForm(), and use_convergent_formulation().
|
inline |
Get use_physical_barrier.
Definition at line 42 of file BarrierContactForm.hpp.
References barrier_potential_.
Referenced by use_convergent_formulation().
|
overrideprotectedvirtual |
Compute the value of the form multiplied per element.
| x | Current solution |
Reimplemented from polyfem::solver::Form.
Definition at line 120 of file BarrierContactForm.cpp.
References polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), polyfem::F, polyfem::utils::maybe_parallel_for(), V, and x.
|
overrideprotectedvirtual |
Compute the contact barrier potential value.
| x | Current solution |
Implements polyfem::solver::Form.
Reimplemented in polyfem::solver::PeriodicContactForm.
Definition at line 115 of file BarrierContactForm.cpp.
References barrier_potential_, polyfem::solver::ContactForm::collision_mesh_, collision_set_, polyfem::solver::ContactForm::compute_displaced_surface(), and x.
Referenced by polyfem::solver::PeriodicContactForm::value_unweighted().
|
protected |
Contact potential.
Definition at line 76 of file BarrierContactForm.hpp.
Referenced by barrier_potential(), first_derivative_unweighted(), force_shape_derivative(), second_derivative_unweighted(), update_barrier_stiffness(), use_physical_barrier(), and value_unweighted().
|
protected |
Cached constraint set for the current solution.
Definition at line 73 of file BarrierContactForm.hpp.
Referenced by BarrierContactForm(), collision_set(), first_derivative_unweighted(), post_step(), second_derivative_unweighted(), update_barrier_stiffness(), update_collision_set(), value_per_element_unweighted(), and value_unweighted().