Loading [MathJax]/jax/output/HTML-CSS/config.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polyfem::solver::NLProblem Class Reference

#include <NLProblem.hpp>

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

Public Member Functions

 NLProblem (const int full_size, const std::shared_ptr< utils::PeriodicBoundary > &periodic_bc, const double t, const std::vector< std::shared_ptr< Form > > &forms, const std::vector< std::shared_ptr< AugmentedLagrangianForm > > &penalty_forms, const std::shared_ptr< polysolve::linear::Solver > &solver)
 
virtual ~NLProblem ()=default
 
virtual double value (const TVector &x) override
 
virtual void gradient (const TVector &x, TVector &gradv) override
 
virtual void hessian (const TVector &x, THessian &hessian) override
 
virtual bool is_step_valid (const TVector &x0, const TVector &x1) override
 
virtual bool is_step_collision_free (const TVector &x0, const TVector &x1) override
 
virtual double max_step_size (const TVector &x0, const TVector &x1) override
 
void line_search_begin (const TVector &x0, const TVector &x1) override
 
virtual void post_step (const polysolve::nonlinear::PostStepData &data) override
 
void solution_changed (const TVector &new_x) override
 
void init_lagging (const TVector &x) override
 
void update_lagging (const TVector &x, const int iter_num) override
 
virtual void update_quantities (const double t, const TVector &x)
 
int full_size () const
 
int reduced_size () const
 
void use_full_size ()
 
void use_reduced_size ()
 
TVector full_to_reduced (const TVector &full) const
 
virtual TVector full_to_reduced_grad (const TVector &full) const
 
TVector reduced_to_full (const TVector &reduced) const
 
void full_hessian_to_reduced_hessian (StiffnessMatrix &hessian) const
 
double normalize_forms () override
 
- Public Member Functions inherited from polyfem::solver::FullNLProblem
 FullNLProblem (const std::vector< std::shared_ptr< Form > > &forms)
 
virtual ~FullNLProblem ()=default
 
virtual void init (const TVector &x0) override
 
virtual void line_search_end () override
 
virtual void set_project_to_psd (bool val) override
 
int max_lagging_iterations () const
 
bool uses_lagging () const
 
std::vector< std::shared_ptr< Form > > & forms ()
 
virtual bool stop (const TVector &x) override
 
void finish ()
 

Protected Types

enum class  CurrentSize { FULL_SIZE , REDUCED_SIZE }
 

Protected Member Functions

 NLProblem (const int full_size, const std::vector< std::shared_ptr< Form > > &forms, const std::vector< std::shared_ptr< AugmentedLagrangianForm > > &penalty_forms, const std::shared_ptr< polysolve::linear::Solver > &solver)
 
int current_size () const
 
void setup_constraints ()
 
void update_constraint_values ()
 

Protected Attributes

const int full_size_
 Size of the full problem.
 
int reduced_size_
 Size of the reduced problem.
 
CurrentSize current_size_
 Current size of the problem (either full or reduced size)
 
double t_
 
std::vector< std::shared_ptr< AugmentedLagrangianForm > > penalty_forms_
 
StiffnessMatrix Q1_
 Q1 block of the QR decomposition of the constraints matrix.
 
StiffnessMatrix Q2_
 Q2 block of the QR decomposition of the constraints matrix.
 
StiffnessMatrix Q2t_
 Q2 transpose.
 
StiffnessMatrix R1_
 R1 block of the QR decomposition of the constraints matrix.
 
Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic > P_
 Permutation matrix of the QR decomposition of the constraints matrix.
 
TVector Q1R1iTb_
 Q1_ * (R1_.transpose().triangularView<Eigen::Upper>().solve(constraint_values_))
 
std::shared_ptr< polysolve::linear::Solver > solver_
 
std::shared_ptr< FullNLProblempenalty_problem_
 
int num_penalty_constraints_
 
- Protected Attributes inherited from polyfem::solver::FullNLProblem
std::vector< std::shared_ptr< Form > > forms_
 

Detailed Description

Definition at line 14 of file NLProblem.hpp.

Member Enumeration Documentation

◆ CurrentSize

enum class polyfem::solver::NLProblem::CurrentSize
strongprotected
Enumerator
FULL_SIZE 
REDUCED_SIZE 

Definition at line 74 of file NLProblem.hpp.

Constructor & Destructor Documentation

◆ NLProblem() [1/2]

polyfem::solver::NLProblem::NLProblem ( const int  full_size,
const std::vector< std::shared_ptr< Form > > &  forms,
const std::vector< std::shared_ptr< AugmentedLagrangianForm > > &  penalty_forms,
const std::shared_ptr< polysolve::linear::Solver > &  solver 
)
protected

Definition at line 91 of file NLProblem.cpp.

References setup_constraints(), and use_reduced_size().

Here is the call graph for this function:

◆ NLProblem() [2/2]

polyfem::solver::NLProblem::NLProblem ( const int  full_size,
const std::shared_ptr< utils::PeriodicBoundary > &  periodic_bc,
const double  t,
const std::vector< std::shared_ptr< Form > > &  forms,
const std::vector< std::shared_ptr< AugmentedLagrangianForm > > &  penalty_forms,
const std::shared_ptr< polysolve::linear::Solver > &  solver 
)

Definition at line 106 of file NLProblem.cpp.

References setup_constraints(), and use_reduced_size().

Here is the call graph for this function:

◆ ~NLProblem()

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

Member Function Documentation

◆ current_size()

int polyfem::solver::NLProblem::current_size ( ) const
inlineprotected

Definition at line 80 of file NLProblem.hpp.

References current_size_, full_size(), FULL_SIZE, and reduced_size().

Referenced by full_to_reduced(), polyfem::solver::NLHomoProblem::gradient(), gradient(), hessian(), init_lagging(), is_step_collision_free(), is_step_valid(), line_search_begin(), max_step_size(), post_step(), reduced_to_full(), solution_changed(), update_lagging(), polyfem::solver::NLHomoProblem::value(), and value().

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

◆ full_hessian_to_reduced_hessian()

void polyfem::solver::NLProblem::full_hessian_to_reduced_hessian ( StiffnessMatrix hessian) const

Definition at line 620 of file NLProblem.cpp.

References hessian(), penalty_forms_, Q2_, Q2t_, and value().

Referenced by hessian().

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

◆ full_size()

◆ full_to_reduced()

NLProblem::TVector polyfem::solver::NLProblem::full_to_reduced ( const TVector &  full) const

Definition at line 564 of file NLProblem.cpp.

References current_size(), full_size(), Q1R1iTb_, Q2_, Q2t_, reduced_size(), and solver_.

Referenced by polyfem::solver::NLHomoProblem::extended_to_reduced(), polyfem::solver::NLHomoProblem::full_to_reduced(), polyfem::solver::ALSolver::solve_al(), polyfem::solver::ALSolver::solve_reduced(), and polyfem::State::solve_tensor_nonlinear().

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

◆ full_to_reduced_grad()

NLProblem::TVector polyfem::solver::NLProblem::full_to_reduced_grad ( const TVector &  full) const
virtual

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 586 of file NLProblem.cpp.

References penalty_forms_, and Q2t_.

Referenced by polyfem::solver::NLHomoProblem::extended_to_reduced_grad(), and polyfem::solver::NLHomoProblem::full_to_reduced_grad().

Here is the caller graph for this function:

◆ gradient()

void polyfem::solver::NLProblem::gradient ( const TVector &  x,
TVector &  gradv 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 500 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::gradient(), penalty_forms_, penalty_problem_, Q2t_, reduced_to_full(), and x.

Referenced by polyfem::State::solve_tensor_nonlinear().

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

◆ hessian()

void polyfem::solver::NLProblem::hessian ( const TVector &  x,
THessian &  hessian 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 519 of file NLProblem.cpp.

References current_size(), full_hessian_to_reduced_hessian(), full_size(), polyfem::solver::FullNLProblem::hessian(), hessian(), penalty_problem_, reduced_to_full(), and x.

Referenced by full_hessian_to_reduced_hessian(), and hessian().

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

◆ init_lagging()

void polyfem::solver::NLProblem::init_lagging ( const TVector &  x)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 419 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::init_lagging(), penalty_problem_, reduced_to_full(), and x.

Referenced by polyfem::solver::NLHomoProblem::init_lagging(), and polyfem::State::solve_tensor_nonlinear().

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

◆ is_step_collision_free()

bool polyfem::solver::NLProblem::is_step_collision_free ( const TVector &  x0,
const TVector &  x1 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 477 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::is_step_collision_free(), penalty_problem_, and reduced_to_full().

Referenced by polyfem::solver::NLHomoProblem::is_step_collision_free(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

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

◆ is_step_valid()

bool polyfem::solver::NLProblem::is_step_valid ( const TVector &  x0,
const TVector &  x1 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 467 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::is_step_valid(), penalty_problem_, and reduced_to_full().

Referenced by polyfem::solver::NLHomoProblem::is_step_valid(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

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

◆ line_search_begin()

void polyfem::solver::NLProblem::line_search_begin ( const TVector &  x0,
const TVector &  x1 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 449 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::line_search_begin(), penalty_problem_, and reduced_to_full().

Referenced by polyfem::solver::NLHomoProblem::line_search_begin(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

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

◆ max_step_size()

double polyfem::solver::NLProblem::max_step_size ( const TVector &  x0,
const TVector &  x1 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 457 of file NLProblem.cpp.

References current_size(), full_size(), polyfem::solver::FullNLProblem::max_step_size(), penalty_problem_, and reduced_to_full().

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

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

◆ normalize_forms()

double polyfem::solver::NLProblem::normalize_forms ( )
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 123 of file NLProblem.cpp.

Referenced by polyfem::solver::ALSolver::solve_al(), polyfem::solver::ALSolver::solve_reduced(), and polyfem::State::solve_tensor_nonlinear().

Here is the caller graph for this function:

◆ post_step()

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

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 543 of file NLProblem.cpp.

References current_size(), full_size(), penalty_problem_, polyfem::solver::FullNLProblem::post_step(), and reduced_to_full().

Referenced by polyfem::solver::NLHomoProblem::post_step().

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

◆ reduced_size()

◆ reduced_to_full()

NLProblem::TVector polyfem::solver::NLProblem::reduced_to_full ( const TVector &  reduced) const

Definition at line 597 of file NLProblem.cpp.

References current_size(), full_size(), penalty_forms_, Q1R1iTb_, and Q2_.

Referenced by gradient(), hessian(), init_lagging(), is_step_collision_free(), is_step_valid(), line_search_begin(), max_step_size(), post_step(), polyfem::solver::NLHomoProblem::reduced_to_extended(), polyfem::solver::NLHomoProblem::reduced_to_full(), solution_changed(), polyfem::solver::ALSolver::solve_reduced(), polyfem::State::solve_tensor_nonlinear(), update_lagging(), update_quantities(), and value().

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

◆ setup_constraints()

void polyfem::solver::NLProblem::setup_constraints ( )
protected

Definition at line 146 of file NLProblem.cpp.

References full_size_, polyfem::log_and_throw_error(), polyfem::logger(), num_penalty_constraints_, P_, penalty_forms_, penalty_problem_, Q1_, Q2_, Q2t_, R1_, reduced_size_, solver_, and update_constraint_values().

Referenced by NLProblem(), and NLProblem().

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

◆ solution_changed()

void polyfem::solver::NLProblem::solution_changed ( const TVector &  new_x)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 535 of file NLProblem.cpp.

References current_size(), full_size(), penalty_problem_, reduced_to_full(), and polyfem::solver::FullNLProblem::solution_changed().

Referenced by polyfem::solver::NLHomoProblem::solution_changed().

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

◆ update_constraint_values()

void polyfem::solver::NLProblem::update_constraint_values ( )
protected

Definition at line 345 of file NLProblem.cpp.

References polyfem::log_and_throw_error(), polyfem::logger(), num_penalty_constraints_, P_, penalty_forms_, Q1_, Q1R1iTb_, and R1_.

Referenced by setup_constraints(), and update_quantities().

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

◆ update_lagging()

void polyfem::solver::NLProblem::update_lagging ( const TVector &  x,
const int  iter_num 
)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 427 of file NLProblem.cpp.

References current_size(), full_size(), penalty_problem_, reduced_to_full(), polyfem::solver::FullNLProblem::update_lagging(), and x.

Referenced by polyfem::State::solve_tensor_nonlinear(), and polyfem::solver::NLHomoProblem::update_lagging().

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

◆ update_quantities()

void polyfem::solver::NLProblem::update_quantities ( const double  t,
const TVector &  x 
)
virtual

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 435 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::forms_, full_size_, penalty_forms_, reduced_to_full(), t_, update_constraint_values(), and x.

Referenced by polyfem::solver::NLHomoProblem::update_quantities().

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

◆ use_full_size()

void polyfem::solver::NLProblem::use_full_size ( )
inline

Definition at line 59 of file NLProblem.hpp.

References current_size_, and FULL_SIZE.

Referenced by polyfem::solver::ALSolver::solve_al().

Here is the caller graph for this function:

◆ use_reduced_size()

void polyfem::solver::NLProblem::use_reduced_size ( )
inline

Definition at line 60 of file NLProblem.hpp.

References current_size_, and REDUCED_SIZE.

Referenced by NLProblem(), NLProblem(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

Here is the caller graph for this function:

◆ value()

double polyfem::solver::NLProblem::value ( const TVector &  x)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 487 of file NLProblem.cpp.

References current_size(), full_size(), penalty_problem_, reduced_to_full(), polyfem::solver::FullNLProblem::value(), and x.

Referenced by full_hessian_to_reduced_hessian(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

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

Member Data Documentation

◆ current_size_

CurrentSize polyfem::solver::NLProblem::current_size_
protected

Current size of the problem (either full or reduced size)

Definition at line 79 of file NLProblem.hpp.

Referenced by current_size(), use_full_size(), and use_reduced_size().

◆ full_size_

const int polyfem::solver::NLProblem::full_size_
protected

◆ num_penalty_constraints_

int polyfem::solver::NLProblem::num_penalty_constraints_
protected

Definition at line 99 of file NLProblem.hpp.

Referenced by setup_constraints(), and update_constraint_values().

◆ P_

Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> polyfem::solver::NLProblem::P_
protected

Permutation matrix of the QR decomposition of the constraints matrix.

Definition at line 94 of file NLProblem.hpp.

Referenced by setup_constraints(), and update_constraint_values().

◆ penalty_forms_

std::vector<std::shared_ptr<AugmentedLagrangianForm> > polyfem::solver::NLProblem::penalty_forms_
protected

◆ penalty_problem_

◆ Q1_

StiffnessMatrix polyfem::solver::NLProblem::Q1_
protected

Q1 block of the QR decomposition of the constraints matrix.

Definition at line 90 of file NLProblem.hpp.

Referenced by setup_constraints(), and update_constraint_values().

◆ Q1R1iTb_

TVector polyfem::solver::NLProblem::Q1R1iTb_
protected

Q1_ * (R1_.transpose().triangularView<Eigen::Upper>().solve(constraint_values_))

Definition at line 95 of file NLProblem.hpp.

Referenced by full_to_reduced(), reduced_to_full(), and update_constraint_values().

◆ Q2_

◆ Q2t_

StiffnessMatrix polyfem::solver::NLProblem::Q2t_
protected

◆ R1_

StiffnessMatrix polyfem::solver::NLProblem::R1_
protected

R1 block of the QR decomposition of the constraints matrix.

Definition at line 93 of file NLProblem.hpp.

Referenced by setup_constraints(), and update_constraint_values().

◆ reduced_size_

int polyfem::solver::NLProblem::reduced_size_
protected

Size of the reduced problem.

Definition at line 72 of file NLProblem.hpp.

Referenced by reduced_size(), and setup_constraints().

◆ solver_

std::shared_ptr<polysolve::linear::Solver> polyfem::solver::NLProblem::solver_
protected

Definition at line 96 of file NLProblem.hpp.

Referenced by full_to_reduced(), and setup_constraints().

◆ t_

double polyfem::solver::NLProblem::t_
protected

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