PolyFEM
Loading...
Searching...
No Matches
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)
 
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 ()
 
virtual TVector full_to_reduced (const TVector &full) const
 
virtual TVector full_to_reduced_grad (const TVector &full) const
 
virtual void full_hessian_to_reduced_hessian (const THessian &full, THessian &reduced) const
 
virtual TVector reduced_to_full (const TVector &reduced) const
 
- 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)
 
virtual Eigen::MatrixXd constraint_values (const TVector &reduced) const
 
int current_size () const
 

Protected Attributes

std::vector< int > constraint_nodes_
 
const int full_size_
 Size of the full problem.
 
int reduced_size_
 Size of the reduced problem.
 
std::shared_ptr< utils::PeriodicBoundaryperiodic_bc_
 
CurrentSize current_size_
 Current size of the problem (either full or reduced size)
 
double t_
 
- Protected Attributes inherited from polyfem::solver::FullNLProblem
std::vector< std::shared_ptr< Form > > forms_
 

Private Member Functions

void setup_constrain_nodes ()
 
template<class FullMat , class ReducedMat >
void full_to_reduced_aux (const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const
 
template<class ReducedMat , class FullMat >
void reduced_to_full_aux (const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const ReducedMat &reduced, const Eigen::MatrixXd &rhs, FullMat &full) const
 
template<class FullMat , class ReducedMat >
void full_to_reduced_aux_grad (const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const
 

Private Attributes

std::vector< std::shared_ptr< AugmentedLagrangianForm > > penalty_forms_
 

Detailed Description

Definition at line 9 of file NLProblem.hpp.

Member Enumeration Documentation

◆ CurrentSize

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

Definition at line 70 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 
)
protected

Definition at line 22 of file NLProblem.cpp.

References constraint_nodes_, full_size_, reduced_size_, setup_constrain_nodes(), 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 
)

Definition at line 37 of file NLProblem.cpp.

References constraint_nodes_, full_size(), full_size_, reduced_size_, setup_constrain_nodes(), and use_reduced_size().

Here is the call graph for this function:

◆ ~NLProblem()

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

Member Function Documentation

◆ constraint_values()

Eigen::MatrixXd polyfem::solver::NLProblem::constraint_values ( const TVector &  reduced) const
protectedvirtual

Reimplemented in polyfem::solver::NLHomoProblem, and polyfem::solver::StaticBoundaryNLProblem.

Definition at line 170 of file NLProblem.cpp.

References full_size(), and penalty_forms_.

Referenced by reduced_to_full().

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

◆ current_size()

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

Definition at line 76 of file NLProblem.hpp.

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

Referenced by full_hessian_to_reduced_hessian(), full_to_reduced(), full_to_reduced_grad(), and reduced_to_full().

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 ( const THessian &  full,
THessian &  reduced 
) const
virtual

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 295 of file NLProblem.cpp.

References constraint_nodes_, current_size(), full_size(), polyfem::utils::full_to_reduced_matrix(), and periodic_bc_.

Referenced by polyfem::solver::NLHomoProblem::extended_hessian_to_reduced_hessian(), polyfem::solver::NLHomoProblem::full_hessian_to_reduced_hessian(), and hessian().

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

◆ full_size()

int polyfem::solver::NLProblem::full_size ( ) const
inline

◆ full_to_reduced()

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

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 149 of file NLProblem.cpp.

References constraint_nodes_, current_size(), full_size(), and full_to_reduced_aux().

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_aux()

template<class FullMat , class ReducedMat >
void polyfem::solver::NLProblem::full_to_reduced_aux ( const std::vector< int > &  constraint_nodes,
const int  full_size,
const int  reduced_size,
const FullMat &  full,
ReducedMat &  reduced 
) const
private

Definition at line 185 of file NLProblem.cpp.

References full_size(), periodic_bc_, and reduced_size().

Referenced by full_to_reduced().

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

◆ full_to_reduced_aux_grad()

template<class FullMat , class ReducedMat >
void polyfem::solver::NLProblem::full_to_reduced_aux_grad ( const std::vector< int > &  constraint_nodes,
const int  full_size,
const int  reduced_size,
const FullMat &  full,
ReducedMat &  reduced 
) const
private

Definition at line 260 of file NLProblem.cpp.

References full_size(), periodic_bc_, and reduced_size().

Referenced by full_to_reduced_grad().

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 156 of file NLProblem.cpp.

References constraint_nodes_, current_size(), full_size(), and full_to_reduced_aux_grad().

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

Here is the call graph for this function:
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 114 of file NLProblem.cpp.

References full_to_reduced_grad(), polyfem::solver::FullNLProblem::gradient(), reduced_to_full(), and x.

Referenced by polyfem::solver::NLHomoProblem::gradient(), and 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 121 of file NLProblem.cpp.

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

Referenced by polyfem::solver::NLHomoProblem::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 70 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::init_lagging(), 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 103 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::is_step_collision_free(), 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 98 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::is_step_valid(), 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 88 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::line_search_begin(), 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 93 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::max_step_size(), 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:

◆ 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 134 of file NLProblem.cpp.

References 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
virtual

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 163 of file NLProblem.cpp.

References constraint_nodes_, constraint_values(), current_size(), full_size(), and reduced_to_full_aux().

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:

◆ reduced_to_full_aux()

template<class ReducedMat , class FullMat >
void polyfem::solver::NLProblem::reduced_to_full_aux ( const std::vector< int > &  constraint_nodes,
const int  full_size,
const int  reduced_size,
const ReducedMat &  reduced,
const Eigen::MatrixXd &  rhs,
FullMat &  full 
) const
private

Definition at line 224 of file NLProblem.cpp.

References full_size(), periodic_bc_, and reduced_size().

Referenced by reduced_to_full().

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

◆ setup_constrain_nodes()

void polyfem::solver::NLProblem::setup_constrain_nodes ( )
private

Definition at line 57 of file NLProblem.cpp.

References constraint_nodes_, and penalty_forms_.

Referenced by NLProblem(), and NLProblem().

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 129 of file NLProblem.cpp.

References 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_lagging()

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

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 75 of file NLProblem.cpp.

References 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 80 of file NLProblem.cpp.

References polyfem::solver::FullNLProblem::forms_, reduced_to_full(), t_, 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 52 of file NLProblem.hpp.

References current_size_, and FULL_SIZE.

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

Here is the caller graph for this function:

◆ use_reduced_size()

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

Definition at line 53 of file NLProblem.hpp.

References current_size_, and REDUCED_SIZE.

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

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 108 of file NLProblem.cpp.

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

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

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

Member Data Documentation

◆ constraint_nodes_

std::vector<int> polyfem::solver::NLProblem::constraint_nodes_
protected

◆ current_size_

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

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

Definition at line 75 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

◆ penalty_forms_

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

Definition at line 84 of file NLProblem.hpp.

Referenced by constraint_values(), and setup_constrain_nodes().

◆ periodic_bc_

std::shared_ptr<utils::PeriodicBoundary> polyfem::solver::NLProblem::periodic_bc_
protected

◆ reduced_size_

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

Size of the reduced problem.

Definition at line 66 of file NLProblem.hpp.

Referenced by NLProblem(), NLProblem(), and reduced_size().

◆ t_

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

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