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::vector< int > &boundary_nodes, const std::vector< mesh::LocalBoundary > &local_boundary, const int n_boundary_samples, const assembler::RhsAssembler &rhs_assembler, const std::shared_ptr< utils::PeriodicBoundary > &periodic_bc, const double t, const std::vector< std::shared_ptr< Form > > &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
 
void set_apply_DBC (const TVector &x, const bool val)
 
- 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
 

Protected Types

enum class  CurrentSize { FULL_SIZE , REDUCED_SIZE }
 

Protected Member Functions

 NLProblem (const int full_size, const std::vector< int > &boundary_nodes, const std::vector< std::shared_ptr< Form > > &forms)
 
virtual Eigen::MatrixXd boundary_values () const
 
int current_size () const
 

Protected Attributes

const std::vector< int > full_boundary_nodes_
 
const std::vector< int > boundary_nodes_
 
const int full_size_
 Size of the full problem.
 
const 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

template<class FullMat , class ReducedMat >
void full_to_reduced_aux (const std::vector< int > &boundary_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 > &boundary_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 > &boundary_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const
 

Private Attributes

const assembler::RhsAssemblerrhs_assembler_
 
const std::vector< mesh::LocalBoundary > * local_boundary_
 
const int n_boundary_samples_
 

Detailed Description

Definition at line 10 of file NLProblem.hpp.

Member Enumeration Documentation

◆ CurrentSize

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

Definition at line 78 of file NLProblem.hpp.

Constructor & Destructor Documentation

◆ NLProblem() [1/2]

polyfem::solver::NLProblem::NLProblem ( const int  full_size,
const std::vector< int > &  boundary_nodes,
const std::vector< std::shared_ptr< Form > > &  forms 
)
protected

Definition at line 21 of file NLProblem.cpp.

References use_reduced_size().

Here is the call graph for this function:

◆ NLProblem() [2/2]

polyfem::solver::NLProblem::NLProblem ( const int  full_size,
const std::vector< int > &  boundary_nodes,
const std::vector< mesh::LocalBoundary > &  local_boundary,
const int  n_boundary_samples,
const assembler::RhsAssembler rhs_assembler,
const std::shared_ptr< utils::PeriodicBoundary > &  periodic_bc,
const double  t,
const std::vector< std::shared_ptr< Form > > &  forms 
)

Definition at line 37 of file NLProblem.cpp.

References full_size_, and use_reduced_size().

Here is the call graph for this function:

◆ ~NLProblem()

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

Member Function Documentation

◆ boundary_values()

Eigen::MatrixXd polyfem::solver::NLProblem::boundary_values ( ) const
protectedvirtual

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

Definition at line 169 of file NLProblem.cpp.

References full_boundary_nodes_, full_size(), local_boundary_, n_boundary_samples_, rhs_assembler_, polyfem::assembler::RhsAssembler::set_bc(), and t_.

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

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

Definition at line 54 of file NLProblem.hpp.

References full_size_.

Referenced by boundary_values(), polyfem::solver::NLHomoProblem::boundary_values(), current_size(), full_hessian_to_reduced_hessian(), full_to_reduced(), full_to_reduced_aux(), full_to_reduced_aux_grad(), full_to_reduced_grad(), reduced_to_full(), reduced_to_full_aux(), polyfem::solver::ALSolver::solve_al(), and polyfem::solver::ALSolver::solve_reduced().

Here is the caller graph for this function:

◆ full_to_reduced()

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

Reimplemented in polyfem::solver::NLHomoProblem.

Definition at line 148 of file NLProblem.cpp.

References boundary_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 > &  boundary_nodes,
const int  full_size,
const int  reduced_size,
const FullMat &  full,
ReducedMat &  reduced 
) const
private

Definition at line 178 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 > &  boundary_nodes,
const int  full_size,
const int  reduced_size,
const FullMat &  full,
ReducedMat &  reduced 
) const
private

Definition at line 253 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 155 of file NLProblem.cpp.

References boundary_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 106 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 113 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 62 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 95 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 90 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 80 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 85 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 126 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 162 of file NLProblem.cpp.

References boundary_nodes_, boundary_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(), set_apply_DBC(), 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 > &  boundary_nodes,
const int  full_size,
const int  reduced_size,
const ReducedMat &  reduced,
const Eigen::MatrixXd &  rhs,
FullMat &  full 
) const
private

Definition at line 217 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:

◆ set_apply_DBC()

void polyfem::solver::NLProblem::set_apply_DBC ( const TVector &  x,
const bool  val 
)

Definition at line 141 of file NLProblem.cpp.

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

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

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 121 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 67 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 72 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 57 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 58 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 100 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

◆ boundary_nodes_

const std::vector<int> polyfem::solver::NLProblem::boundary_nodes_
protected

◆ current_size_

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

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

Definition at line 83 of file NLProblem.hpp.

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

◆ full_boundary_nodes_

const std::vector<int> polyfem::solver::NLProblem::full_boundary_nodes_
protected

Definition at line 70 of file NLProblem.hpp.

Referenced by boundary_values().

◆ full_size_

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

◆ local_boundary_

const std::vector<mesh::LocalBoundary>* polyfem::solver::NLProblem::local_boundary_
private

Definition at line 93 of file NLProblem.hpp.

Referenced by boundary_values().

◆ n_boundary_samples_

const int polyfem::solver::NLProblem::n_boundary_samples_
private

Definition at line 94 of file NLProblem.hpp.

Referenced by boundary_values().

◆ periodic_bc_

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

◆ reduced_size_

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

Size of the reduced problem.

Definition at line 74 of file NLProblem.hpp.

Referenced by reduced_size().

◆ rhs_assembler_

const assembler::RhsAssembler* polyfem::solver::NLProblem::rhs_assembler_
private

Definition at line 92 of file NLProblem.hpp.

Referenced by boundary_values().

◆ t_

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

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