PolyFEM
Loading...
Searching...
No Matches
polyfem::solver::Form Class Referenceabstract

#include <Form.hpp>

Inheritance diagram for polyfem::solver::Form:
[legend]

Public Member Functions

virtual ~Form ()
 
virtual std::string name () const =0
 
virtual void init (const Eigen::VectorXd &x)
 Initialize the form.
 
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.
 
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)
 

Protected Member Functions

std::string resolve_output_path (const std::string &path) const
 
virtual double value_unweighted (const Eigen::VectorXd &x) const =0
 Compute the value of the form.
 
virtual Eigen::VectorXd value_per_element_unweighted (const Eigen::VectorXd &x) const
 Compute the value of the form multiplied per element.
 
virtual void first_derivative_unweighted (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const =0
 Compute the first derivative of the value wrt x.
 
virtual void second_derivative_unweighted (const Eigen::VectorXd &x, StiffnessMatrix &hessian) const =0
 Compute the second derivative of the value wrt x.
 

Protected Attributes

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

Definition at line 10 of file Form.hpp.

Constructor & Destructor Documentation

◆ ~Form()

virtual polyfem::solver::Form::~Form ( )
inlinevirtual

Definition at line 13 of file Form.hpp.

Member Function Documentation

◆ disable()

void polyfem::solver::Form::disable ( )
inline

Disable the form.

Definition at line 117 of file Form.hpp.

References enabled_.

Referenced by polyfem::solver::LaggedRegForm::LaggedRegForm().

Here is the caller graph for this function:

◆ enable()

void polyfem::solver::Form::enable ( )
inline

Enable the form.

Definition at line 115 of file Form.hpp.

References enabled_.

◆ enabled()

bool polyfem::solver::Form::enabled ( ) const
inline

Determine if the form is enabled.

Returns
True if the form is enabled else false

Definition at line 123 of file Form.hpp.

References enabled_.

Referenced by set_enabled(), and polyfem::solver::LaggedRegForm::update_lagging().

Here is the caller graph for this function:

◆ first_derivative()

virtual void polyfem::solver::Form::first_derivative ( const Eigen::VectorXd &  x,
Eigen::VectorXd &  gradv 
) const
inlinevirtual

Compute the first derivative of the value wrt x multiplied with the weigth.

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

Reimplemented in polyfem::solver::AdjointForm.

Definition at line 40 of file Form.hpp.

References first_derivative_unweighted(), weight(), and x.

Referenced by polyfem::solver::ElasticForm::is_step_valid().

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

◆ first_derivative_unweighted()

virtual void polyfem::solver::Form::first_derivative_unweighted ( const Eigen::VectorXd &  x,
Eigen::VectorXd &  gradv 
) const
protectedpure virtual

Compute the first derivative of the value wrt x.

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

Implemented in polyfem::solver::AdjointForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, polyfem::solver::ElasticForm, polyfem::solver::FrictionForm, polyfem::solver::InertiaForm, polyfem::solver::InversionBarrierForm, polyfem::solver::L2ProjectionForm, polyfem::solver::LaggedRegForm, polyfem::solver::BCLagrangianForm, polyfem::solver::GenericLagrangianForm, polyfem::solver::MacroStrainLagrangianForm, polyfem::solver::PeriodicContactForm, polyfem::solver::PressureForm, and polyfem::solver::RayleighDampingForm.

Referenced by first_derivative().

Here is the caller graph for this function:

◆ init()

virtual void polyfem::solver::Form::init ( const Eigen::VectorXd &  x)
inlinevirtual

Initialize the form.

Parameters
xCurrent solution

Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.

Definition at line 19 of file Form.hpp.

Referenced by polyfem::solver::TargetForm::set_reference().

Here is the caller graph for this function:

◆ init_lagging()

virtual void polyfem::solver::Form::init_lagging ( const Eigen::VectorXd &  x)
inlinevirtual

Initialize lagged fields TODO: more than one step.

Parameters
xCurrent solution

Reimplemented in polyfem::solver::AdjointForm, polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.

Definition at line 94 of file Form.hpp.

◆ is_project_to_psd()

bool polyfem::solver::Form::is_project_to_psd ( ) const
inline

Get if the form's second derivative is projected to psd.

Definition at line 112 of file Form.hpp.

References project_to_psd_.

◆ is_step_collision_free()

virtual bool polyfem::solver::Form::is_step_collision_free ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
) const
inlinevirtual

◆ is_step_valid()

virtual bool polyfem::solver::Form::is_step_valid ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
) const
inlinevirtual

Determine if a step from solution x0 to solution x1 is allowed.

Parameters
x0Current solution
x1Proposed next solution
Returns
True if the step is allowed

Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::AMIPSForm, polyfem::solver::TransientForm, polyfem::solver::ElasticForm, and polyfem::solver::InversionBarrierForm.

Definition at line 60 of file Form.hpp.

◆ line_search_begin()

virtual void polyfem::solver::Form::line_search_begin ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
inlinevirtual

Initialize variables used during the line search.

Parameters
x0Current solution
x1Next solution

Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.

Definition at line 71 of file Form.hpp.

◆ line_search_end()

virtual void polyfem::solver::Form::line_search_end ( )
inlinevirtual

Clear variables used during the line search.

Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, and polyfem::solver::ContactForm.

Definition at line 74 of file Form.hpp.

◆ max_lagging_iterations()

virtual int polyfem::solver::Form::max_lagging_iterations ( ) const
inlinevirtual

Get the maximum number of lagging iteration allowable.

Reimplemented in polyfem::solver::FrictionForm, and polyfem::solver::RayleighDampingForm.

Definition at line 101 of file Form.hpp.

◆ max_step_size()

virtual double polyfem::solver::Form::max_step_size ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
) const
inlinevirtual

Determine the maximum step size allowable between the current and next solution.

Parameters
x0Current solution (step size = 0)
x1Next solution (step size = 1)
Returns
Maximum allowable step size

Reimplemented in polyfem::solver::ParametrizationForm, polyfem::solver::CompositeForm, polyfem::solver::CollisionBarrierForm, polyfem::solver::LayerThicknessForm, polyfem::solver::DeformedCollisionBarrierForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.

Definition at line 66 of file Form.hpp.

◆ name()

◆ post_step()

virtual void polyfem::solver::Form::post_step ( const polysolve::nonlinear::PostStepData &  data)
inlinevirtual

Update fields after a step in the optimization.

Parameters
iter_numOptimization iteration number
xCurrent solution
dataData containing info about the current iteration

Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.

Definition at line 80 of file Form.hpp.

◆ resolve_output_path()

std::string polyfem::solver::Form::resolve_output_path ( const std::string &  path) const
inlineprotected

Definition at line 149 of file Form.hpp.

References output_dir_.

Referenced by polyfem::solver::ContactForm::max_step_size().

Here is the caller graph for this function:

◆ second_derivative()

void polyfem::solver::Form::second_derivative ( const Eigen::VectorXd &  x,
StiffnessMatrix hessian 
) const
inline

Compute the second derivative of the value wrt x multiplied with the weigth.

Note
This is not marked const because ElasticForm needs to cache the matrix assembly.
Parameters
[in]xCurrent solution
[out]hessianOutput Hessian of the value wrt x

Definition at line 50 of file Form.hpp.

References second_derivative_unweighted(), weight(), and x.

Referenced by polyfem::solver::RayleighDampingForm::update_lagging().

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

◆ second_derivative_unweighted()

virtual void polyfem::solver::Form::second_derivative_unweighted ( const Eigen::VectorXd &  x,
StiffnessMatrix hessian 
) const
protectedpure virtual

Compute the second derivative of the value wrt x.

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

Implemented in polyfem::solver::AdjointForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, polyfem::solver::ElasticForm, polyfem::solver::FrictionForm, polyfem::solver::InertiaForm, polyfem::solver::InversionBarrierForm, polyfem::solver::L2ProjectionForm, polyfem::solver::LaggedRegForm, polyfem::solver::BCLagrangianForm, polyfem::solver::GenericLagrangianForm, polyfem::solver::MacroStrainLagrangianForm, polyfem::solver::PeriodicContactForm, polyfem::solver::PressureForm, and polyfem::solver::RayleighDampingForm.

Referenced by second_derivative().

Here is the caller graph for this function:

◆ set_enabled()

void polyfem::solver::Form::set_enabled ( const bool  enabled)
inline

Set if the form is enabled.

Definition at line 119 of file Form.hpp.

References enabled(), and enabled_.

Referenced by polyfem::solver::LaggedRegForm::update_lagging().

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

◆ set_output_dir()

void polyfem::solver::Form::set_output_dir ( const std::string &  output_dir)
inline

Definition at line 138 of file Form.hpp.

References output_dir_.

◆ set_project_to_psd()

void polyfem::solver::Form::set_project_to_psd ( bool  val)
inline

Set project to psd.

Parameters
valIf true, the form's second derivative is projected to be positive semidefinite

Definition at line 109 of file Form.hpp.

References project_to_psd_, and val.

◆ set_weight()

void polyfem::solver::Form::set_weight ( const double  weight)
inline

Set the form's multiplicative constant weight.

Parameters
weightNew weight to use

Definition at line 130 of file Form.hpp.

References weight(), and weight_.

Here is the call graph for this function:

◆ solution_changed()

virtual void polyfem::solver::Form::solution_changed ( const Eigen::VectorXd &  new_x)
inlinevirtual

◆ update_lagging()

virtual void polyfem::solver::Form::update_lagging ( const Eigen::VectorXd &  x,
const int  iter_num 
)
inlinevirtual

Update lagged fields.

Parameters
xCurrent solution

Reimplemented in polyfem::solver::AdjointForm, polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.

Definition at line 98 of file Form.hpp.

◆ update_quantities()

virtual void polyfem::solver::Form::update_quantities ( const double  t,
const Eigen::VectorXd &  x 
)
inlinevirtual

◆ uses_lagging()

virtual bool polyfem::solver::Form::uses_lagging ( ) const
inlinevirtual

Does this form require lagging?

Returns
True if the form requires lagging

Reimplemented in polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.

Definition at line 105 of file Form.hpp.

◆ value()

virtual double polyfem::solver::Form::value ( const Eigen::VectorXd &  x) const
inlinevirtual

Compute the value of the form multiplied with the weigth.

Parameters
xCurrent solution
Returns
Computed value

Reimplemented in polyfem::solver::AdjointForm.

Definition at line 24 of file Form.hpp.

References value_unweighted(), weight(), and x.

Referenced by polyfem::solver::InertiaForm::force_shape_derivative(), polyfem::solver::BodyForm::force_shape_derivative(), polyfem::solver::BCLagrangianForm::init_masked_lumped_mass(), and polyfem::solver::AdjointForm::value().

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

◆ value_per_element()

Eigen::VectorXd polyfem::solver::Form::value_per_element ( const Eigen::VectorXd &  x) const
inline

Compute the value of the form multiplied with the weigth.

Parameters
xCurrent solution
Returns
Computed value

Definition at line 32 of file Form.hpp.

References value_per_element_unweighted(), weight_, and x.

Here is the call graph for this function:

◆ value_per_element_unweighted()

virtual Eigen::VectorXd polyfem::solver::Form::value_per_element_unweighted ( const Eigen::VectorXd &  x) const
inlineprotectedvirtual

Compute the value of the form multiplied per element.

Parameters
xCurrent solution
Returns
Computed value per element

Reimplemented in polyfem::solver::ContactForm, and polyfem::solver::ElasticForm.

Definition at line 164 of file Form.hpp.

Referenced by value_per_element().

Here is the caller graph for this function:

◆ value_unweighted()

◆ weight()

virtual double polyfem::solver::Form::weight ( ) const
inlinevirtual

Get the form's multiplicative constant weight.

Reimplemented in polyfem::solver::ContactForm.

Definition at line 126 of file Form.hpp.

References weight_.

Referenced by polyfem::solver::MinTargetDistForm::compute_adjoint_rhs(), polyfem::solver::TransientForm::compute_adjoint_rhs(), polyfem::solver::ProxyTransientForm::compute_adjoint_rhs(), polyfem::solver::SpatialIntegralForm::compute_adjoint_rhs_step(), polyfem::solver::ProxyContactForceForm::compute_adjoint_rhs_step(), polyfem::solver::NodeTargetForm::compute_adjoint_rhs_step(), polyfem::solver::BarycenterTargetForm::compute_adjoint_rhs_step(), polyfem::solver::AMIPSForm::compute_partial_gradient(), polyfem::solver::CollisionBarrierForm::compute_partial_gradient(), polyfem::solver::DeformedCollisionBarrierForm::compute_partial_gradient(), polyfem::solver::BoundarySmoothingForm::compute_partial_gradient(), polyfem::solver::MinTargetDistForm::compute_partial_gradient(), polyfem::solver::TransientForm::compute_partial_gradient(), polyfem::solver::ProxyTransientForm::compute_partial_gradient(), polyfem::solver::CompositeForm::compute_partial_gradient(), polyfem::solver::SpatialIntegralForm::compute_partial_gradient_step(), polyfem::solver::ElasticEnergyForm::compute_partial_gradient_step(), polyfem::solver::StressNormForm::compute_partial_gradient_step(), polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::StressForm::compute_partial_gradient_step(), polyfem::solver::ProxyContactForceForm::compute_partial_gradient_step(), polyfem::solver::NodeTargetForm::compute_partial_gradient_step(), polyfem::solver::BarycenterTargetForm::compute_partial_gradient_step(), polyfem::solver::ParametrizedProductForm::compute_partial_gradient_with_param(), polyfem::solver::WeightedVolumeForm::compute_partial_gradient_with_param(), polyfem::solver::CompositeForm::compute_reduced_adjoint_rhs(), first_derivative(), second_derivative(), set_weight(), polyfem::solver::RayleighDampingForm::update_lagging(), and value().

Here is the caller graph for this function:

Member Data Documentation

◆ enabled_

bool polyfem::solver::Form::enabled_ = true
protected

If true, the form is enabled.

Definition at line 145 of file Form.hpp.

Referenced by disable(), enable(), enabled(), and set_enabled().

◆ output_dir_

std::string polyfem::solver::Form::output_dir_
protected

Definition at line 147 of file Form.hpp.

Referenced by resolve_output_path(), and set_output_dir().

◆ project_to_psd_

bool polyfem::solver::Form::project_to_psd_ = false
protected

◆ weight_

double polyfem::solver::Form::weight_ = 1
protected

weight of the form (e.g., AL penalty weight or Δt²)

Definition at line 143 of file Form.hpp.

Referenced by set_weight(), polyfem::solver::ContactForm::update_barrier_stiffness(), value_per_element(), weight(), and polyfem::solver::ContactForm::weight().


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