|
PolyFEM
|
#include <StackedForm.hpp>
Classes | |
| class | Block |
| struct | Term |
Public Member Functions | |
| std::string | name () const override |
| Block | add_block (const int size) |
| void | add (const Block &block, std::shared_ptr< Form > form) |
| void | add (const Block &a, const Block &b, std::shared_ptr< Form > form) |
| int | size () const |
| void | init (const Eigen::VectorXd &x) override |
| Initialize the form. | |
| void | finish () override |
| bool | is_step_valid (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override |
| Determine if a step from solution x0 to solution x1 is allowed. | |
| bool | is_step_collision_free (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override |
| Checks if the step is collision free. | |
| 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. | |
| 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 | post_step (const polysolve::nonlinear::PostStepData &data) override |
| Update fields after a step in the optimization. | |
| void | solution_changed (const Eigen::VectorXd &new_x) override |
| Update cached fields upon a change in the solution. | |
| void | set_project_to_psd (bool val) override |
| Set project to psd. | |
| void | update_quantities (const double t, const Eigen::VectorXd &x) override |
| Update time-dependent fields. | |
| void | init_lagging (const Eigen::VectorXd &x) override |
| Initialize lagged fields TODO: more than one step. | |
| void | update_lagging (const Eigen::VectorXd &x, const int iter_num) override |
| 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? | |
Public Member Functions inherited from polyfem::solver::Form | |
| virtual | ~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. | |
| 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. | |
| 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 | |
| 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 Member Functions | |
| void | validate_block (const Block &block) const |
| int | term_size (const Term &term) const |
| Eigen::VectorXd | gather (const Eigen::VectorXd &x, const Term &term) const |
| int | global_index (const Term &term, const int local_index) const |
Private Attributes | |
| std::vector< Block > | blocks_ |
| std::vector< Term > | terms_ |
| int | size_ = 0 |
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_ |
Definition at line 10 of file StackedForm.hpp.
| void polyfem::solver::StackedForm::add | ( | const Block & | a, |
| const Block & | b, | ||
| std::shared_ptr< Form > | form | ||
| ) |
Definition at line 27 of file StackedForm.cpp.
References polyfem::solver::StackedForm::Block::id(), terms_, and validate_block().
Definition at line 20 of file StackedForm.cpp.
References polyfem::solver::StackedForm::Block::id(), terms_, and validate_block().
| StackedForm::Block polyfem::solver::StackedForm::add_block | ( | const int | size | ) |
Definition at line 9 of file StackedForm.cpp.
References blocks_, size(), and size_.
|
overridevirtual |
Reimplemented from polyfem::solver::Form.
Definition at line 43 of file StackedForm.cpp.
References terms_.
|
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.
Definition at line 193 of file StackedForm.cpp.
References gather(), global_index(), size_, term_size(), terms_, and x.
|
private |
Definition at line 264 of file StackedForm.cpp.
References polyfem::solver::StackedForm::Term::a, polyfem::solver::StackedForm::Term::b, blocks_, polyfem::solver::StackedForm::Term::has_second_block(), polyfem::solver::StackedForm::Block::offset(), polyfem::solver::StackedForm::Block::size(), size_, and x.
Referenced by first_derivative_unweighted(), init(), init_lagging(), is_step_collision_free(), is_step_valid(), line_search_begin(), max_step_size(), post_step(), second_derivative_unweighted(), solution_changed(), update_lagging(), update_quantities(), and value_unweighted().
|
private |
Definition at line 278 of file StackedForm.cpp.
References polyfem::solver::StackedForm::Term::a, polyfem::solver::StackedForm::Term::b, blocks_, polyfem::solver::StackedForm::Term::has_second_block(), polyfem::solver::StackedForm::Block::offset(), polyfem::solver::StackedForm::Block::size(), and term_size().
Referenced by first_derivative_unweighted(), and second_derivative_unweighted().
|
overridevirtual |
Initialize the form.
| x | Current solution |
Reimplemented from polyfem::solver::Form.
Definition at line 36 of file StackedForm.cpp.
References gather(), size_, terms_, and x.
|
overridevirtual |
Initialize lagged fields TODO: more than one step.
| x | Current solution |
Reimplemented from polyfem::solver::Form.
Definition at line 147 of file StackedForm.cpp.
References gather(), size_, terms_, and x.
|
overridevirtual |
Checks if the step is collision free.
Reimplemented from polyfem::solver::Form.
Definition at line 65 of file StackedForm.cpp.
References gather(), size_, and terms_.
|
overridevirtual |
Determine if a step from solution x0 to solution x1 is allowed.
| x0 | Current solution |
| x1 | Proposed next solution |
Reimplemented from polyfem::solver::Form.
Definition at line 49 of file StackedForm.cpp.
References gather(), size_, and terms_.
|
overridevirtual |
Initialize variables used during the line search.
| x0 | Current solution |
| x1 | Next solution |
Reimplemented from polyfem::solver::Form.
Definition at line 97 of file StackedForm.cpp.
References gather(), size_, and terms_.
|
overridevirtual |
Clear variables used during the line search.
Reimplemented from polyfem::solver::Form.
Definition at line 106 of file StackedForm.cpp.
References terms_.
|
overridevirtual |
Get the maximum number of lagging iteration allowable.
Reimplemented from polyfem::solver::Form.
Definition at line 161 of file StackedForm.cpp.
References max_lagging_iterations(), and terms_.
Referenced by max_lagging_iterations().
|
overridevirtual |
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 from polyfem::solver::Form.
Definition at line 81 of file StackedForm.cpp.
References gather(), size_, and terms_.
|
inlineoverridevirtual |
Implements polyfem::solver::Form.
Definition at line 31 of file StackedForm.hpp.
|
overridevirtual |
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 from polyfem::solver::Form.
Definition at line 112 of file StackedForm.cpp.
References gather(), size_, terms_, and x.
|
overrideprotectedvirtual |
Compute the second derivative of the value wrt x.
| [in] | x | Current solution |
| [out] | hessian | Output Hessian of the value wrt x |
Implements polyfem::solver::Form.
Definition at line 212 of file StackedForm.cpp.
References entries, gather(), global_index(), size_, term_size(), terms_, and x.
|
overridevirtual |
Set project to psd.
| val | If true, the form's second derivative is projected to be positive semidefinite |
Reimplemented from polyfem::solver::Form.
Definition at line 133 of file StackedForm.cpp.
References polyfem::solver::Form::set_project_to_psd(), terms_, and val.
|
inline |
Definition at line 37 of file StackedForm.hpp.
References size_.
Referenced by add_block().
|
overridevirtual |
Update cached fields upon a change in the solution.
| new_x | New solution |
Reimplemented from polyfem::solver::Form.
Definition at line 126 of file StackedForm.cpp.
References gather(), size_, and terms_.
|
private |
Definition at line 254 of file StackedForm.cpp.
References polyfem::solver::StackedForm::Term::a, polyfem::solver::StackedForm::Term::b, blocks_, polyfem::solver::StackedForm::Term::has_second_block(), and polyfem::solver::StackedForm::Block::size().
Referenced by first_derivative_unweighted(), global_index(), and second_derivative_unweighted().
|
overridevirtual |
Update lagged fields.
| x | Current solution |
Reimplemented from polyfem::solver::Form.
Definition at line 154 of file StackedForm.cpp.
References gather(), size_, terms_, and x.
|
overridevirtual |
Update time-dependent fields.
| t | Current time |
| x | Current solution at time t |
Reimplemented from polyfem::solver::Form.
Definition at line 140 of file StackedForm.cpp.
References gather(), size_, terms_, and x.
|
overridevirtual |
Does this form require lagging?
Reimplemented from polyfem::solver::Form.
Definition at line 169 of file StackedForm.cpp.
References terms_.
|
private |
Definition at line 246 of file StackedForm.cpp.
References blocks_, polyfem::solver::StackedForm::Block::id(), polyfem::solver::StackedForm::Block::offset(), and polyfem::solver::StackedForm::Block::size().
Referenced by add(), and add().
|
overrideprotectedvirtual |
Compute the value of the form.
| x | Current solution |
Implements polyfem::solver::Form.
Definition at line 179 of file StackedForm.cpp.
References gather(), size_, terms_, polyfem::solver::Form::value(), and x.
|
private |
Definition at line 75 of file StackedForm.hpp.
Referenced by add_block(), gather(), global_index(), term_size(), and validate_block().
|
private |
Definition at line 77 of file StackedForm.hpp.
Referenced by add_block(), first_derivative_unweighted(), gather(), init(), init_lagging(), is_step_collision_free(), is_step_valid(), line_search_begin(), max_step_size(), post_step(), second_derivative_unweighted(), size(), solution_changed(), update_lagging(), update_quantities(), and value_unweighted().
|
private |
Definition at line 76 of file StackedForm.hpp.
Referenced by add(), add(), finish(), first_derivative_unweighted(), init(), init_lagging(), is_step_collision_free(), is_step_valid(), line_search_begin(), line_search_end(), max_lagging_iterations(), max_step_size(), post_step(), second_derivative_unweighted(), set_project_to_psd(), solution_changed(), update_lagging(), update_quantities(), uses_lagging(), and value_unweighted().