PolyFEM
|
#include <Form.hpp>
Public Member Functions | |
virtual | ~Form () |
virtual std::string | name () const =0 |
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. | |
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_ |
|
inline |
Disable the form.
Definition at line 119 of file Form.hpp.
References enabled_.
Referenced by polyfem::solver::LaggedRegForm::LaggedRegForm().
|
inline |
|
inline |
Determine if the form is enabled.
Definition at line 125 of file Form.hpp.
References enabled_.
Referenced by set_enabled(), and polyfem::solver::LaggedRegForm::update_lagging().
|
inlinevirtual |
|
inlinevirtual |
Compute the first derivative of the value wrt x multiplied with the weigth.
[in] | x | Current solution |
[out] | gradv | Output gradient of the value wrt x |
Reimplemented in polyfem::solver::AdjointForm.
Definition at line 42 of file Form.hpp.
References first_derivative_unweighted(), weight(), and x.
|
protectedpure virtual |
Compute the first derivative of the value wrt x.
[in] | x | Current solution |
[out] | gradv | Output gradient of the value wrt x |
Implemented in polyfem::solver::AdjointForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, 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().
|
inlinevirtual |
Initialize the form.
x | Current 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().
|
inlinevirtual |
Initialize lagged fields TODO: more than one step.
x | Current solution |
Reimplemented in polyfem::solver::AdjointForm, polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.
|
inline |
Get if the form's second derivative is projected to psd.
Definition at line 114 of file Form.hpp.
References project_to_psd_.
|
inlinevirtual |
Checks if the step is collision free.
Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::CollisionBarrierForm, polyfem::solver::DeformedCollisionBarrierForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.
|
inlinevirtual |
Determine if a step from solution x0 to solution x1 is allowed.
x0 | Current solution |
x1 | Proposed next solution |
Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::AMIPSForm, polyfem::solver::TransientForm, and polyfem::solver::InversionBarrierForm.
|
inlinevirtual |
Initialize variables used during the line search.
x0 | Current solution |
x1 | Next solution |
Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.
|
inlinevirtual |
Clear variables used during the line search.
Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, and polyfem::solver::ContactForm.
|
inlinevirtual |
Get the maximum number of lagging iteration allowable.
Reimplemented in polyfem::solver::FrictionForm, and polyfem::solver::RayleighDampingForm.
|
inlinevirtual |
Determine the maximum step size allowable between the current and next solution.
x0 | Current solution (step size = 0) |
x1 | Next solution (step size = 1) |
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.
|
pure virtual |
Implemented in polyfem::solver::AdjointForm, polyfem::solver::StaticForm, polyfem::solver::MaxStressForm, polyfem::solver::MinJacobianForm, polyfem::solver::AMIPSForm, polyfem::solver::CollisionBarrierForm, polyfem::solver::LayerThicknessForm, polyfem::solver::DeformedCollisionBarrierForm, polyfem::solver::SpatialIntegralForm, polyfem::solver::ElasticEnergyForm, polyfem::solver::StressNormForm, polyfem::solver::ComplianceForm, polyfem::solver::StressForm, polyfem::solver::TargetForm, polyfem::solver::SDFTargetForm, polyfem::solver::MeshTargetForm, polyfem::solver::NodeTargetForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, 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::PressureForm, and polyfem::solver::RayleighDampingForm.
|
inlinevirtual |
Update fields after a step in the optimization.
iter_num | Optimization iteration number |
x | Current solution |
data | Data containing info about the current iteration |
Reimplemented in polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, and polyfem::solver::PeriodicContactForm.
|
inlineprotected |
Definition at line 151 of file Form.hpp.
References output_dir_.
Referenced by polyfem::solver::ContactForm::max_step_size().
|
inline |
Compute the second derivative of the value wrt x multiplied with the weigth.
[in] | x | Current solution |
[out] | hessian | Output Hessian of the value wrt x |
Definition at line 52 of file Form.hpp.
References second_derivative_unweighted(), weight(), and x.
Referenced by polyfem::solver::RayleighDampingForm::update_lagging().
|
protectedpure virtual |
Compute the second derivative of the value wrt x.
[in] | x | Current solution |
[out] | hessian | Output Hessian of the value wrt x |
Implemented in polyfem::solver::AdjointForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, 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().
|
inline |
Set if the form is enabled.
Definition at line 121 of file Form.hpp.
References enabled(), and enabled_.
Referenced by polyfem::solver::LaggedRegForm::update_lagging().
|
inline |
Definition at line 140 of file Form.hpp.
References output_dir_.
|
inline |
Set project to psd.
val | If true, the form's second derivative is projected to be positive semidefinite |
Definition at line 111 of file Form.hpp.
References project_to_psd_, and val.
|
inline |
|
inlinevirtual |
Update cached fields upon a change in the solution.
new_x | New solution |
Reimplemented in polyfem::solver::StaticForm, polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::AdjointForm, polyfem::solver::TransientForm, polyfem::solver::ContactForm, polyfem::solver::PeriodicContactForm, polyfem::solver::CollisionBarrierForm, and polyfem::solver::DeformedCollisionBarrierForm.
|
inlinevirtual |
Update lagged fields.
x | Current solution |
Reimplemented in polyfem::solver::AdjointForm, polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.
|
inlinevirtual |
Update time-dependent fields.
t | Current time |
x | Current solution at time t |
Reimplemented in polyfem::solver::AdjointForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, polyfem::solver::BCLagrangianForm, polyfem::solver::MacroStrainLagrangianForm, polyfem::solver::PeriodicContactForm, and polyfem::solver::PressureForm.
|
inlinevirtual |
Does this form require lagging?
Reimplemented in polyfem::solver::FrictionForm, polyfem::solver::LaggedRegForm, and polyfem::solver::RayleighDampingForm.
|
inlinevirtual |
Compute the value of the form multiplied with the weigth.
x | Current solution |
Reimplemented in polyfem::solver::AdjointForm.
Definition at line 26 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().
|
inline |
Compute the value of the form multiplied with the weigth.
x | Current solution |
Definition at line 34 of file Form.hpp.
References value_per_element_unweighted(), weight_, and x.
|
inlineprotectedvirtual |
Compute the value of the form multiplied per element.
x | Current solution |
Reimplemented in polyfem::solver::ContactForm.
Definition at line 166 of file Form.hpp.
Referenced by value_per_element().
|
protectedpure virtual |
Compute the value of the form.
x | Current solution |
Implemented in polyfem::solver::StaticForm, polyfem::solver::CompositeForm, polyfem::solver::ParametrizationForm, polyfem::solver::MinJacobianForm, polyfem::solver::AMIPSForm, polyfem::solver::CollisionBarrierForm, polyfem::solver::DeformedCollisionBarrierForm, polyfem::solver::BoundarySmoothingForm, polyfem::solver::MinTargetDistForm, polyfem::solver::TransientForm, polyfem::solver::ProxyTransientForm, polyfem::solver::BodyForm, polyfem::solver::ContactForm, 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 value().
|
inlinevirtual |
Get the form's multiplicative constant weight.
Reimplemented in polyfem::solver::ContactForm.
Definition at line 128 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().
|
protected |
|
protected |
Definition at line 149 of file Form.hpp.
Referenced by resolve_output_path(), and set_output_dir().
|
protected |
If true, the form's second derivative is projected to be positive semidefinite.
Definition at line 143 of file Form.hpp.
Referenced by is_project_to_psd(), polyfem::solver::ContactForm::second_derivative_unweighted(), polyfem::solver::FrictionForm::second_derivative_unweighted(), polyfem::solver::PressureForm::second_derivative_unweighted(), and set_project_to_psd().
|
protected |
weight of the form (e.g., AL penalty weight or Δt²)
Definition at line 145 of file Form.hpp.
Referenced by set_weight(), polyfem::solver::ContactForm::update_barrier_stiffness(), value_per_element(), weight(), and polyfem::solver::ContactForm::weight().