PolyFEM
Loading...
Searching...
No Matches
polyfem::solver::FrictionForm Class Reference

Form of the lagged friction disapative potential and forces. More...

#include <FrictionForm.hpp>

Inheritance diagram for polyfem::solver::FrictionForm:
[legend]
Collaboration diagram for polyfem::solver::FrictionForm:
[legend]

Public Member Functions

 FrictionForm (const ipc::CollisionMesh &collision_mesh, const std::shared_ptr< time_integrator::ImplicitTimeIntegrator > time_integrator, const double epsv, const double mu, const ipc::BroadPhaseMethod broad_phase_method, const ContactForm &contact_form, const int n_lagging_iters)
 Construct a new Friction Form object.
 
std::string name () const override
 
void force_shape_derivative (const Eigen::MatrixXd &prev_solution, const Eigen::MatrixXd &solution, const Eigen::MatrixXd &adjoint, const ipc::FrictionCollisions &friction_constraints_set, Eigen::VectorXd &term)
 
void init_lagging (const Eigen::VectorXd &x) override
 Initialize lagged fields.
 
void update_lagging (const Eigen::VectorXd &x, const int iter_num) override
 Update lagged fields.
 
void update_lagging (const Eigen::VectorXd &x)
 Update lagged fields.
 
int max_lagging_iterations () const override
 Get the maximum number of lagging iteration allowable.
 
bool uses_lagging () const override
 Does this form require lagging?
 
Eigen::MatrixXd compute_displaced_surface (const Eigen::VectorXd &x) const
 Compute the displaced positions of the surface nodes.
 
Eigen::MatrixXd compute_surface_velocities (const Eigen::VectorXd &x) const
 Compute the surface velocities.
 
double dv_dx () const
 Compute the derivative of the velocities wrt x.
 
double mu () const
 
double epsv () const
 
const ipc::FrictionCollisions & friction_collision_set () const
 
const ipc::FrictionPotential & friction_potential () const
 
- Public Member Functions inherited from polyfem::solver::Form
virtual ~Form ()
 
virtual void init (const Eigen::VectorXd &x)
 Initialize the 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 double max_step_size (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const
 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)
 Initialize variables used during the line search.
 
virtual void line_search_end ()
 Clear variables used during the line search.
 
virtual void post_step (const polysolve::nonlinear::PostStepData &data)
 Update fields after a step in the optimization.
 
virtual void solution_changed (const Eigen::VectorXd &new_x)
 Update cached fields upon a change in the solution.
 
virtual void update_quantities (const double t, const Eigen::VectorXd &x)
 Update time-dependent fields.
 
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.
 
virtual double weight () const
 Get the form's multiplicative constant weight.
 
void set_weight (const double weight)
 Set the form's multiplicative constant weight.
 
virtual bool is_step_collision_free (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const
 Checks if the step is collision free.
 
void set_output_dir (const std::string &output_dir)
 

Protected Member Functions

double value_unweighted (const Eigen::VectorXd &x) const override
 Compute the value of the form.
 
void first_derivative_unweighted (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
 Compute the first derivative of the value wrt x.
 
void second_derivative_unweighted (const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
 Compute the second derivative of the value wrt x.
 
- Protected Member Functions inherited from polyfem::solver::Form
std::string resolve_output_path (const std::string &path) const
 
virtual Eigen::VectorXd value_per_element_unweighted (const Eigen::VectorXd &x) const
 Compute the value of the form multiplied per element.
 

Private Attributes

const ipc::CollisionMesh & collision_mesh_
 Reference to the collision mesh.
 
const std::shared_ptr< time_integrator::ImplicitTimeIntegratortime_integrator_
 Pointer to the time integrator.
 
const double epsv_
 Smoothing factor between static and dynamic friction.
 
const double mu_
 Global coefficient of friction.
 
const ipc::BroadPhaseMethod broad_phase_method_
 Broad-phase method used for distance computation and collision detection.
 
const int n_lagging_iters_
 Number of lagging iterations.
 
ipc::FrictionCollisions friction_collision_set_
 Lagged friction constraint set.
 
const ContactFormcontact_form_
 necessary to have the barrier stiffnes, maybe clean me
 
const ipc::FrictionPotential friction_potential_
 

Additional Inherited Members

- 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_
 

Detailed Description

Form of the lagged friction disapative potential and forces.

Definition at line 18 of file FrictionForm.hpp.

Constructor & Destructor Documentation

◆ FrictionForm()

polyfem::solver::FrictionForm::FrictionForm ( const ipc::CollisionMesh &  collision_mesh,
const std::shared_ptr< time_integrator::ImplicitTimeIntegrator time_integrator,
const double  epsv,
const double  mu,
const ipc::BroadPhaseMethod  broad_phase_method,
const ContactForm contact_form,
const int  n_lagging_iters 
)

Construct a new Friction Form object.

Parameters
collision_meshReference to the collision mesh
time_integratorPointer to the time integrator
epsvSmoothing factor between static and dynamic friction
muGlobal coefficient of friction
dhatBarrier activation distance
broad_phase_methodBroad-phase method used for distance computation and collision detection
contact_formPointer to contact form; necessary to have the barrier stiffnes, maybe clean me
n_lagging_itersNumber of lagging iterations

Definition at line 9 of file FrictionForm.cpp.

References epsv_.

Member Function Documentation

◆ compute_displaced_surface()

Eigen::MatrixXd polyfem::solver::FrictionForm::compute_displaced_surface ( const Eigen::VectorXd &  x) const

Compute the displaced positions of the surface nodes.

Definition at line 88 of file FrictionForm.cpp.

References polyfem::solver::ContactForm::compute_displaced_surface(), contact_form_, and x.

Referenced by update_lagging().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_surface_velocities()

Eigen::MatrixXd polyfem::solver::FrictionForm::compute_surface_velocities ( const Eigen::VectorXd &  x) const

Compute the surface velocities.

Definition at line 93 of file FrictionForm.cpp.

References collision_mesh_, time_integrator_, polyfem::utils::unflatten(), and x.

Referenced by first_derivative_unweighted(), second_derivative_unweighted(), and value_unweighted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dv_dx()

double polyfem::solver::FrictionForm::dv_dx ( ) const

Compute the derivative of the velocities wrt x.

Definition at line 100 of file FrictionForm.cpp.

References time_integrator_.

Referenced by second_derivative_unweighted(), and value_unweighted().

Here is the caller graph for this function:

◆ epsv()

double polyfem::solver::FrictionForm::epsv ( ) const
inline

Definition at line 87 of file FrictionForm.hpp.

References epsv_.

◆ first_derivative_unweighted()

void polyfem::solver::FrictionForm::first_derivative_unweighted ( const Eigen::VectorXd &  x,
Eigen::VectorXd &  gradv 
) const
overrideprotectedvirtual

Compute the first derivative of the value wrt x.

Parameters
[in]xCurrent solution
[out]gradvOutput gradient of the value wrt x

Implements polyfem::solver::Form.

Definition at line 110 of file FrictionForm.cpp.

References collision_mesh_, compute_surface_velocities(), friction_collision_set_, friction_potential_, and x.

Here is the call graph for this function:

◆ force_shape_derivative()

void polyfem::solver::FrictionForm::force_shape_derivative ( const Eigen::MatrixXd &  prev_solution,
const Eigen::MatrixXd &  solution,
const Eigen::MatrixXd &  adjoint,
const ipc::FrictionCollisions &  friction_constraints_set,
Eigen::VectorXd &  term 
)

Definition at line 29 of file FrictionForm.cpp.

References polyfem::solver::ContactForm::barrier_potential(), polyfem::solver::ContactForm::barrier_stiffness(), collision_mesh_, contact_form_, friction_potential_, time_integrator_, and polyfem::utils::unflatten().

Here is the call graph for this function:

◆ friction_collision_set()

const ipc::FrictionCollisions & polyfem::solver::FrictionForm::friction_collision_set ( ) const
inline

Definition at line 88 of file FrictionForm.hpp.

References friction_collision_set_.

◆ friction_potential()

const ipc::FrictionPotential & polyfem::solver::FrictionForm::friction_potential ( ) const
inline

Definition at line 89 of file FrictionForm.hpp.

References friction_potential_.

◆ init_lagging()

void polyfem::solver::FrictionForm::init_lagging ( const Eigen::VectorXd &  x)
inlineoverridevirtual

Initialize lagged fields.

Parameters
xCurrent solution

Reimplemented from polyfem::solver::Form.

Definition at line 62 of file FrictionForm.hpp.

References update_lagging(), and x.

Here is the call graph for this function:

◆ max_lagging_iterations()

int polyfem::solver::FrictionForm::max_lagging_iterations ( ) const
inlineoverridevirtual

Get the maximum number of lagging iteration allowable.

Reimplemented from polyfem::solver::Form.

Definition at line 73 of file FrictionForm.hpp.

References n_lagging_iters_.

◆ mu()

double polyfem::solver::FrictionForm::mu ( ) const
inline

Definition at line 86 of file FrictionForm.hpp.

References mu_.

◆ name()

std::string polyfem::solver::FrictionForm::name ( ) const
inlineoverridevirtual

Implements polyfem::solver::Form.

Definition at line 39 of file FrictionForm.hpp.

◆ second_derivative_unweighted()

void polyfem::solver::FrictionForm::second_derivative_unweighted ( const Eigen::VectorXd &  x,
StiffnessMatrix hessian 
) const
overrideprotectedvirtual

Compute the second derivative of the value wrt x.

Parameters
[in]xCurrent solution
[out]hessianOutput Hessian of the value wrt x

Implements polyfem::solver::Form.

Definition at line 117 of file FrictionForm.cpp.

References collision_mesh_, compute_surface_velocities(), dv_dx(), friction_collision_set_, friction_potential_, POLYFEM_SCOPED_TIMER, polyfem::solver::Form::project_to_psd_, and x.

Here is the call graph for this function:

◆ update_lagging() [1/2]

void polyfem::solver::FrictionForm::update_lagging ( const Eigen::VectorXd &  x)
inline

Update lagged fields.

Parameters
xCurrent solution

Definition at line 70 of file FrictionForm.hpp.

References update_lagging(), and x.

Referenced by update_lagging().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_lagging() [2/2]

void polyfem::solver::FrictionForm::update_lagging ( const Eigen::VectorXd &  x,
const int  iter_num 
)
overridevirtual

Update lagged fields.

Parameters
xCurrent solution

Reimplemented from polyfem::solver::Form.

Definition at line 127 of file FrictionForm.cpp.

References polyfem::solver::ContactForm::barrier_potential(), polyfem::solver::ContactForm::barrier_stiffness(), broad_phase_method_, collision_mesh_, compute_displaced_surface(), contact_form_, polyfem::solver::ContactForm::dhat(), polyfem::solver::ContactForm::enable_shape_derivatives(), friction_collision_set_, mu_, polyfem::solver::ContactForm::use_convergent_formulation(), and x.

Referenced by init_lagging().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uses_lagging()

bool polyfem::solver::FrictionForm::uses_lagging ( ) const
inlineoverridevirtual

Does this form require lagging?

Returns
True if the form requires lagging

Reimplemented from polyfem::solver::Form.

Definition at line 77 of file FrictionForm.hpp.

◆ value_unweighted()

double polyfem::solver::FrictionForm::value_unweighted ( const Eigen::VectorXd &  x) const
overrideprotectedvirtual

Compute the value of the form.

Parameters
xCurrent solution
Returns
Computed value

Implements polyfem::solver::Form.

Definition at line 105 of file FrictionForm.cpp.

References collision_mesh_, compute_surface_velocities(), dv_dx(), friction_collision_set_, friction_potential_, and x.

Here is the call graph for this function:

Member Data Documentation

◆ broad_phase_method_

const ipc::BroadPhaseMethod polyfem::solver::FrictionForm::broad_phase_method_
private

Broad-phase method used for distance computation and collision detection.

Definition at line 100 of file FrictionForm.hpp.

Referenced by update_lagging().

◆ collision_mesh_

const ipc::CollisionMesh& polyfem::solver::FrictionForm::collision_mesh_
private

◆ contact_form_

const ContactForm& polyfem::solver::FrictionForm::contact_form_
private

necessary to have the barrier stiffnes, maybe clean me

Definition at line 105 of file FrictionForm.hpp.

Referenced by compute_displaced_surface(), force_shape_derivative(), and update_lagging().

◆ epsv_

const double polyfem::solver::FrictionForm::epsv_
private

Smoothing factor between static and dynamic friction.

Definition at line 98 of file FrictionForm.hpp.

Referenced by epsv(), and FrictionForm().

◆ friction_collision_set_

ipc::FrictionCollisions polyfem::solver::FrictionForm::friction_collision_set_
private

Lagged friction constraint set.

Definition at line 103 of file FrictionForm.hpp.

Referenced by first_derivative_unweighted(), friction_collision_set(), second_derivative_unweighted(), update_lagging(), and value_unweighted().

◆ friction_potential_

const ipc::FrictionPotential polyfem::solver::FrictionForm::friction_potential_
private

◆ mu_

const double polyfem::solver::FrictionForm::mu_
private

Global coefficient of friction.

Definition at line 99 of file FrictionForm.hpp.

Referenced by mu(), and update_lagging().

◆ n_lagging_iters_

const int polyfem::solver::FrictionForm::n_lagging_iters_
private

Number of lagging iterations.

Definition at line 101 of file FrictionForm.hpp.

Referenced by max_lagging_iterations().

◆ time_integrator_

const std::shared_ptr<time_integrator::ImplicitTimeIntegrator> polyfem::solver::FrictionForm::time_integrator_
private

Pointer to the time integrator.

Definition at line 96 of file FrictionForm.hpp.

Referenced by compute_surface_velocities(), dv_dx(), and force_shape_derivative().


The documentation for this class was generated from the following files: