Loading [MathJax]/extensions/tex2jax.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polyfem::solver::NormalAdhesionForm Class Reference

Form representing the contact potential and forces. More...

#include <NormalAdhesionForm.hpp>

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

Public Member Functions

 NormalAdhesionForm (const ipc::CollisionMesh &collision_mesh, const double dhat_p, const double dhat_a, const double Y, 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 NormalAdhesion Form object.
 
virtual ~NormalAdhesionForm ()=default
 
std::string name () const override
 
void init (const Eigen::VectorXd &x) override
 Initialize the form.
 
virtual void force_shape_derivative (const ipc::NormalCollisions &collision_set, const Eigen::MatrixXd &solution, const Eigen::VectorXd &adjoint_sol, Eigen::VectorXd &term)
 
void update_quantities (const double t, const Eigen::VectorXd &x) override
 Update time-dependent fields.
 
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.
 
void solution_changed (const Eigen::VectorXd &new_x) override
 Update cached fields upon a change in the solution.
 
void post_step (const polysolve::nonlinear::PostStepData &data) override
 Update fields after a step in the optimization.
 
Eigen::MatrixXd compute_displaced_surface (const Eigen::VectorXd &x) const
 Compute the displaced positions of the surface nodes.
 
bool enable_shape_derivatives () const
 
double dhat_a () const
 
double dhat_p () const
 
double Y () const
 
const ipc::NormalCollisions & collision_set () const
 
const ipc::NormalAdhesionPotential & normal_adhesion_potential () 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 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 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.
 
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)
 
virtual void set_scale (const double scale)
 sets the scale for the form
 

Public Attributes

bool save_ccd_debug_meshes = false
 If true, output debug files.
 

Protected Member Functions

virtual double value_unweighted (const Eigen::VectorXd &x) const override
 Compute the normal adhesion 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)
 Update the cached candidate set for the current solution.
 
- Protected Member Functions inherited from polyfem::solver::Form
std::string resolve_output_path (const std::string &path) const
 

Protected Attributes

const ipc::CollisionMesh & collision_mesh_
 Collision mesh.
 
const double dhat_p_
 Maximum adhesion strength distance.
 
const double dhat_a_
 Adhesion activation distance.
 
const double Y_
 Adhesion strength.
 
const double dmin_ = 0
 Minimum distance between elements.
 
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 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::NormalCollisions collision_set_
 Cached constraint set for the current solution.
 
ipc::Candidates candidates_
 Cached candidate set for the current solution.
 
const ipc::NormalAdhesionPotential normal_adhesion_potential_
 
- 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 representing the contact potential and forces.

Definition at line 18 of file NormalAdhesionForm.hpp.

Constructor & Destructor Documentation

◆ NormalAdhesionForm()

polyfem::solver::NormalAdhesionForm::NormalAdhesionForm ( const ipc::CollisionMesh &  collision_mesh,
const double  dhat_p,
const double  dhat_a,
const double  Y,
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 NormalAdhesion Form object.

Parameters
collision_meshReference to the collision mesh
dhat_pDistance of largest adhesion force
dhat_aAdhesion activation distance
YAdhesion strength
is_time_dependentIs the simulation time dependent?
enable_shape_derivativesEnable shape derivatives
broad_phase_methodBroad phase method to use for distance and CCD evaluations
ccd_toleranceContinuous collision detection tolerance
ccd_max_iterationsContinuous collision detection maximum iterations

Definition at line 20 of file NormalAdhesionForm.cpp.

References collision_set_, dhat_a(), dhat_p(), enable_shape_derivatives(), and prev_distance_.

Here is the call graph for this function:

◆ ~NormalAdhesionForm()

virtual polyfem::solver::NormalAdhesionForm::~NormalAdhesionForm ( )
virtualdefault

Member Function Documentation

◆ collision_set()

const ipc::NormalCollisions & polyfem::solver::NormalAdhesionForm::collision_set ( ) const
inline

Definition at line 105 of file NormalAdhesionForm.hpp.

References collision_set_.

Referenced by force_shape_derivative().

Here is the caller graph for this function:

◆ compute_displaced_surface()

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

Compute the displaced positions of the surface nodes.

Definition at line 67 of file NormalAdhesionForm.cpp.

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

Referenced by polyfem::solver::TangentialAdhesionForm::compute_displaced_surface(), first_derivative_unweighted(), force_shape_derivative(), init(), line_search_begin(), post_step(), second_derivative_unweighted(), solution_changed(), update_quantities(), value_per_element_unweighted(), and value_unweighted().

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

◆ dhat_a()

double polyfem::solver::NormalAdhesionForm::dhat_a ( ) const
inline

Definition at line 102 of file NormalAdhesionForm.hpp.

References dhat_a_.

Referenced by NormalAdhesionForm(), and polyfem::solver::TangentialAdhesionForm::update_lagging().

Here is the caller graph for this function:

◆ dhat_p()

double polyfem::solver::NormalAdhesionForm::dhat_p ( ) const
inline

Definition at line 103 of file NormalAdhesionForm.hpp.

References dhat_p_.

Referenced by NormalAdhesionForm().

Here is the caller graph for this function:

◆ enable_shape_derivatives()

bool polyfem::solver::NormalAdhesionForm::enable_shape_derivatives ( ) const
inline

Definition at line 97 of file NormalAdhesionForm.hpp.

References enable_shape_derivatives_.

Referenced by NormalAdhesionForm().

Here is the caller graph for this function:

◆ first_derivative_unweighted()

void polyfem::solver::NormalAdhesionForm::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 143 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set_, compute_displaced_surface(), normal_adhesion_potential_, and x.

Here is the call graph for this function:

◆ force_shape_derivative()

void polyfem::solver::NormalAdhesionForm::force_shape_derivative ( const ipc::NormalCollisions &  collision_set,
const Eigen::MatrixXd &  solution,
const Eigen::VectorXd &  adjoint_sol,
Eigen::VectorXd &  term 
)
virtual

Definition at line 52 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set(), compute_displaced_surface(), and normal_adhesion_potential_.

Here is the call graph for this function:

◆ init()

void polyfem::solver::NormalAdhesionForm::init ( const Eigen::VectorXd &  x)
overridevirtual

Initialize the form.

Parameters
xCurrent solution

Reimplemented from polyfem::solver::Form.

Definition at line 47 of file NormalAdhesionForm.cpp.

References compute_displaced_surface(), update_collision_set(), and x.

Here is the call graph for this function:

◆ line_search_begin()

void polyfem::solver::NormalAdhesionForm::line_search_begin ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
overridevirtual

Initialize variables used during the line search.

Parameters
x0Current solution
x1Next solution

Reimplemented from polyfem::solver::Form.

Definition at line 170 of file NormalAdhesionForm.cpp.

References broad_phase_method_, candidates_, collision_mesh_, compute_displaced_surface(), dhat_a_, and use_cached_candidates_.

Here is the call graph for this function:

◆ line_search_end()

void polyfem::solver::NormalAdhesionForm::line_search_end ( )
overridevirtual

Clear variables used during the line search.

Reimplemented from polyfem::solver::Form.

Definition at line 182 of file NormalAdhesionForm.cpp.

References candidates_, and use_cached_candidates_.

◆ name()

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

Implements polyfem::solver::Form.

Definition at line 42 of file NormalAdhesionForm.hpp.

◆ normal_adhesion_potential()

const ipc::NormalAdhesionPotential & polyfem::solver::NormalAdhesionForm::normal_adhesion_potential ( ) const
inline

Definition at line 106 of file NormalAdhesionForm.hpp.

References normal_adhesion_potential_.

Referenced by polyfem::solver::TangentialAdhesionForm::force_shape_derivative(), and polyfem::solver::TangentialAdhesionForm::update_lagging().

Here is the caller graph for this function:

◆ post_step()

void polyfem::solver::NormalAdhesionForm::post_step ( const polysolve::nonlinear::PostStepData &  data)
overridevirtual

Update fields after a step in the optimization.

Parameters
iter_numOptimization iteration number
xCurrent solution

Reimplemented from polyfem::solver::Form.

Definition at line 188 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set_, compute_displaced_surface(), and prev_distance_.

Here is the call graph for this function:

◆ second_derivative_unweighted()

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

Compute the second derivative of the value wrt x.

Parameters
xCurrent solution
hessianOutput Hessian of the value wrt x

Implements polyfem::solver::Form.

Definition at line 149 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set_, compute_displaced_surface(), normal_adhesion_potential_, POLYFEM_SCOPED_TIMER, polyfem::solver::Form::project_to_psd_, and x.

Here is the call graph for this function:

◆ solution_changed()

void polyfem::solver::NormalAdhesionForm::solution_changed ( const Eigen::VectorXd &  new_x)
overridevirtual

Update cached fields upon a change in the solution.

Parameters
new_xNew solution

Reimplemented from polyfem::solver::Form.

Definition at line 165 of file NormalAdhesionForm.cpp.

References compute_displaced_surface(), and update_collision_set().

Here is the call graph for this function:

◆ update_collision_set()

void polyfem::solver::NormalAdhesionForm::update_collision_set ( const Eigen::MatrixXd &  displaced_surface)
protected

Update the cached candidate set for the current solution.

Parameters
displaced_surfaceVertex positions displaced by the current solution

Definition at line 72 of file NormalAdhesionForm.cpp.

References broad_phase_method_, candidates_, collision_mesh_, collision_set_, dhat_a_, dmin_, and use_cached_candidates_.

Referenced by init(), solution_changed(), and update_quantities().

Here is the caller graph for this function:

◆ update_quantities()

void polyfem::solver::NormalAdhesionForm::update_quantities ( const double  t,
const Eigen::VectorXd &  x 
)
overridevirtual

Update time-dependent fields.

Parameters
tCurrent time
xCurrent solution at time t

Reimplemented from polyfem::solver::Form.

Definition at line 62 of file NormalAdhesionForm.cpp.

References compute_displaced_surface(), update_collision_set(), and x.

Here is the call graph for this function:

◆ value_per_element_unweighted()

Eigen::VectorXd polyfem::solver::NormalAdhesionForm::value_per_element_unweighted ( const Eigen::VectorXd &  x) const
overrideprotectedvirtual

Compute the value of the form multiplied per element.

Parameters
xCurrent solution
Returns
Computed value

Reimplemented from polyfem::solver::Form.

Definition at line 93 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set_, compute_displaced_surface(), polyfem::F, polyfem::utils::maybe_parallel_for(), V, and x.

Here is the call graph for this function:

◆ value_unweighted()

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

Compute the normal adhesion potential value.

Parameters
xCurrent solution
Returns
Value of the normal adhesion potential

Implements polyfem::solver::Form.

Definition at line 88 of file NormalAdhesionForm.cpp.

References collision_mesh_, collision_set_, compute_displaced_surface(), normal_adhesion_potential_, and x.

Here is the call graph for this function:

◆ Y()

double polyfem::solver::NormalAdhesionForm::Y ( ) const
inline

Definition at line 104 of file NormalAdhesionForm.hpp.

References Y_.

Member Data Documentation

◆ broad_phase_method_

const ipc::BroadPhaseMethod polyfem::solver::NormalAdhesionForm::broad_phase_method_
protected

Broad phase method to use for distance and CCD evaluations.

Definition at line 135 of file NormalAdhesionForm.hpp.

Referenced by line_search_begin(), and update_collision_set().

◆ candidates_

ipc::Candidates polyfem::solver::NormalAdhesionForm::candidates_
protected

Cached candidate set for the current solution.

Definition at line 147 of file NormalAdhesionForm.hpp.

Referenced by line_search_begin(), line_search_end(), and update_collision_set().

◆ collision_mesh_

const ipc::CollisionMesh& polyfem::solver::NormalAdhesionForm::collision_mesh_
protected

◆ collision_set_

ipc::NormalCollisions polyfem::solver::NormalAdhesionForm::collision_set_
protected

◆ dhat_a_

const double polyfem::solver::NormalAdhesionForm::dhat_a_
protected

Adhesion activation distance.

Definition at line 120 of file NormalAdhesionForm.hpp.

Referenced by dhat_a(), line_search_begin(), and update_collision_set().

◆ dhat_p_

const double polyfem::solver::NormalAdhesionForm::dhat_p_
protected

Maximum adhesion strength distance.

Definition at line 117 of file NormalAdhesionForm.hpp.

Referenced by dhat_p().

◆ dmin_

const double polyfem::solver::NormalAdhesionForm::dmin_ = 0
protected

Minimum distance between elements.

Definition at line 126 of file NormalAdhesionForm.hpp.

Referenced by update_collision_set().

◆ enable_shape_derivatives_

const bool polyfem::solver::NormalAdhesionForm::enable_shape_derivatives_
protected

Enable shape derivatives computation.

Definition at line 132 of file NormalAdhesionForm.hpp.

Referenced by enable_shape_derivatives().

◆ is_time_dependent_

const bool polyfem::solver::NormalAdhesionForm::is_time_dependent_
protected

Is the simulation time dependent?

Definition at line 129 of file NormalAdhesionForm.hpp.

◆ normal_adhesion_potential_

const ipc::NormalAdhesionPotential polyfem::solver::NormalAdhesionForm::normal_adhesion_potential_
protected

◆ prev_distance_

double polyfem::solver::NormalAdhesionForm::prev_distance_
protected

Previous minimum distance between all elements.

Definition at line 140 of file NormalAdhesionForm.hpp.

Referenced by NormalAdhesionForm(), and post_step().

◆ save_ccd_debug_meshes

bool polyfem::solver::NormalAdhesionForm::save_ccd_debug_meshes = false

If true, output debug files.

Definition at line 100 of file NormalAdhesionForm.hpp.

◆ tight_inclusion_ccd_

const ipc::TightInclusionCCD polyfem::solver::NormalAdhesionForm::tight_inclusion_ccd_
protected

Continuous collision detection specification object.

Definition at line 137 of file NormalAdhesionForm.hpp.

◆ use_cached_candidates_

bool polyfem::solver::NormalAdhesionForm::use_cached_candidates_ = false
protected

If true, use the cached candidate set for the current solution.

Definition at line 143 of file NormalAdhesionForm.hpp.

Referenced by line_search_begin(), line_search_end(), and update_collision_set().

◆ Y_

const double polyfem::solver::NormalAdhesionForm::Y_
protected

Adhesion strength.

Definition at line 123 of file NormalAdhesionForm.hpp.

Referenced by Y().


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