PolyFEM
Loading...
Searching...
No Matches
polyfem::solver::AdjointNLProblem Class Reference

#include <AdjointNLProblem.hpp>

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

Public Member Functions

 AdjointNLProblem (std::shared_ptr< AdjointForm > form, const VariableToSimulationGroup &variables_to_simulation, const std::vector< std::shared_ptr< State > > &all_states, const json &args)
 
 AdjointNLProblem (std::shared_ptr< AdjointForm > form, const std::vector< std::shared_ptr< AdjointForm > > &stopping_conditions, const VariableToSimulationGroup &variables_to_simulation, const std::vector< std::shared_ptr< State > > &all_states, const json &args)
 
virtual ~AdjointNLProblem ()=default
 
double value (const Eigen::VectorXd &x) override
 
void gradient (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) override
 
void hessian (const Eigen::VectorXd &x, StiffnessMatrix &hessian) override
 
void save_to_file (const int iter_num, const Eigen::VectorXd &x0)
 
bool is_step_valid (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
 
bool is_step_collision_free (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
 
double max_step_size (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
 
void line_search_begin (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
 
void line_search_end () override
 
void post_step (const polysolve::nonlinear::PostStepData &data) override
 
bool stop (const TVector &x) override
 
void solution_changed (const Eigen::VectorXd &new_x) override
 
bool after_line_search_custom_operation (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
 
void solve_pde ()
 
- 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 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)
 
virtual double max_step_size (const TVector &x0, const TVector &x1) override
 
virtual void line_search_begin (const TVector &x0, const TVector &x1) override
 
virtual void set_project_to_psd (bool val) override
 
virtual void solution_changed (const TVector &new_x) override
 
virtual void init_lagging (const TVector &x)
 
virtual void update_lagging (const TVector &x, const int iter_num)
 
int max_lagging_iterations () const
 
bool uses_lagging () const
 
std::vector< std::shared_ptr< Form > > & forms ()
 
void finish ()
 

Private Attributes

std::shared_ptr< AdjointFormform_
 
const VariableToSimulationGroup variables_to_simulation_
 
std::vector< std::shared_ptr< State > > all_states_
 
std::vector< bool > active_state_mask
 
Eigen::VectorXd cur_grad
 
Eigen::VectorXd curr_x
 
const int save_freq
 
std::ofstream solution_ostream
 
const bool enable_slim
 
const bool smooth_line_search
 
const bool solve_in_parallel
 
std::vector< int > solve_in_order
 
int save_iter = 0
 
std::vector< std::shared_ptr< AdjointForm > > stopping_conditions_
 

Additional Inherited Members

- Protected Attributes inherited from polyfem::solver::FullNLProblem
std::vector< std::shared_ptr< Form > > forms_
 

Detailed Description

Definition at line 18 of file AdjointNLProblem.hpp.

Constructor & Destructor Documentation

◆ AdjointNLProblem() [1/2]

polyfem::solver::AdjointNLProblem::AdjointNLProblem ( std::shared_ptr< AdjointForm form,
const VariableToSimulationGroup variables_to_simulation,
const std::vector< std::shared_ptr< State > > &  all_states,
const json args 
)

Definition at line 119 of file AdjointNLProblem.cpp.

◆ AdjointNLProblem() [2/2]

polyfem::solver::AdjointNLProblem::AdjointNLProblem ( std::shared_ptr< AdjointForm form,
const std::vector< std::shared_ptr< AdjointForm > > &  stopping_conditions,
const VariableToSimulationGroup variables_to_simulation,
const std::vector< std::shared_ptr< State > > &  all_states,
const json args 
)

Definition at line 174 of file AdjointNLProblem.cpp.

References stopping_conditions_.

◆ ~AdjointNLProblem()

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

Member Function Documentation

◆ after_line_search_custom_operation()

bool polyfem::solver::AdjointNLProblem::after_line_search_custom_operation ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
override

Definition at line 379 of file AdjointNLProblem.cpp.

References polyfem::adjoint_logger(), all_states_, polyfem::mesh::apply_slim(), enable_slim, polyfem::F, polyfem::log_and_throw_adjoint_error(), V, and variables_to_simulation_.

Here is the call graph for this function:

◆ gradient()

void polyfem::solver::AdjointNLProblem::gradient ( const Eigen::VectorXd &  x,
Eigen::VectorXd &  gradv 
)
override

Definition at line 189 of file AdjointNLProblem.cpp.

References polyfem::adjoint_logger(), all_states_, cur_grad, form_, POLYFEM_SCOPED_TIMER, and x.

Here is the call graph for this function:

◆ hessian()

void polyfem::solver::AdjointNLProblem::hessian ( const Eigen::VectorXd &  x,
StiffnessMatrix hessian 
)
override

Definition at line 179 of file AdjointNLProblem.cpp.

References polyfem::log_and_throw_adjoint_error().

Here is the call graph for this function:

◆ is_step_collision_free()

bool polyfem::solver::AdjointNLProblem::is_step_collision_free ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
override

Definition at line 265 of file AdjointNLProblem.cpp.

References form_.

◆ is_step_valid()

bool polyfem::solver::AdjointNLProblem::is_step_valid ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
override

Definition at line 217 of file AdjointNLProblem.cpp.

References polyfem::adjoint_logger(), all_states_, polyfem::mesh::apply_slim(), polyfem::F, form_, polyfem::solver::AdjointTools::is_flipped(), polyfem::solver::PeriodicShape, polyfem::solver::Shape, smooth_line_search, polyfem::utils::unflatten(), polyfem::mesh::V0, polyfem::mesh::V1, and variables_to_simulation_.

Here is the call graph for this function:

◆ line_search_begin()

void polyfem::solver::AdjointNLProblem::line_search_begin ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
override

Definition at line 275 of file AdjointNLProblem.cpp.

References form_.

◆ line_search_end()

void polyfem::solver::AdjointNLProblem::line_search_end ( )
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 280 of file AdjointNLProblem.cpp.

References form_.

◆ max_step_size()

double polyfem::solver::AdjointNLProblem::max_step_size ( const Eigen::VectorXd &  x0,
const Eigen::VectorXd &  x1 
)
override

Definition at line 270 of file AdjointNLProblem.cpp.

References form_.

◆ post_step()

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

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 285 of file AdjointNLProblem.cpp.

References form_, save_iter, and save_to_file().

Here is the call graph for this function:

◆ save_to_file()

void polyfem::solver::AdjointNLProblem::save_to_file ( const int  iter_num,
const Eigen::VectorXd &  x0 
)

Definition at line 292 of file AdjointNLProblem.cpp.

References polyfem::adjoint_logger(), all_states_, polyfem::F, save_freq, solution_ostream, V, polyfem::io::OBJWriter::write(), and polyfem::io::MshWriter::write().

Referenced by post_step().

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

◆ solution_changed()

void polyfem::solver::AdjointNLProblem::solution_changed ( const Eigen::VectorXd &  new_x)
override

Definition at line 353 of file AdjointNLProblem.cpp.

References all_states_, curr_x, form_, polyfem::solver::PeriodicShape, polyfem::solver::Shape, solve_pde(), and variables_to_simulation_.

Here is the call graph for this function:

◆ solve_pde()

void polyfem::solver::AdjointNLProblem::solve_pde ( )

Definition at line 420 of file AdjointNLProblem.cpp.

References polyfem::adjoint_logger(), all_states_, polyfem::utils::maybe_parallel_for(), and solve_in_parallel.

Referenced by solution_changed().

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

◆ stop()

bool polyfem::solver::AdjointNLProblem::stop ( const TVector &  x)
overridevirtual

Reimplemented from polyfem::solver::FullNLProblem.

Definition at line 461 of file AdjointNLProblem.cpp.

References stopping_conditions_, and x.

◆ value()

double polyfem::solver::AdjointNLProblem::value ( const Eigen::VectorXd &  x)
override

Definition at line 184 of file AdjointNLProblem.cpp.

References form_, and x.

Member Data Documentation

◆ active_state_mask

std::vector<bool> polyfem::solver::AdjointNLProblem::active_state_mask
private

Definition at line 47 of file AdjointNLProblem.hpp.

◆ all_states_

std::vector<std::shared_ptr<State> > polyfem::solver::AdjointNLProblem::all_states_
private

◆ cur_grad

Eigen::VectorXd polyfem::solver::AdjointNLProblem::cur_grad
private

Definition at line 48 of file AdjointNLProblem.hpp.

Referenced by gradient().

◆ curr_x

Eigen::VectorXd polyfem::solver::AdjointNLProblem::curr_x
private

Definition at line 49 of file AdjointNLProblem.hpp.

Referenced by solution_changed().

◆ enable_slim

const bool polyfem::solver::AdjointNLProblem::enable_slim
private

Definition at line 54 of file AdjointNLProblem.hpp.

Referenced by after_line_search_custom_operation().

◆ form_

std::shared_ptr<AdjointForm> polyfem::solver::AdjointNLProblem::form_
private

◆ save_freq

const int polyfem::solver::AdjointNLProblem::save_freq
private

Definition at line 51 of file AdjointNLProblem.hpp.

Referenced by save_to_file().

◆ save_iter

int polyfem::solver::AdjointNLProblem::save_iter = 0
private

Definition at line 60 of file AdjointNLProblem.hpp.

Referenced by post_step().

◆ smooth_line_search

const bool polyfem::solver::AdjointNLProblem::smooth_line_search
private

Definition at line 55 of file AdjointNLProblem.hpp.

Referenced by is_step_valid().

◆ solution_ostream

std::ofstream polyfem::solver::AdjointNLProblem::solution_ostream
private

Definition at line 52 of file AdjointNLProblem.hpp.

Referenced by save_to_file().

◆ solve_in_order

std::vector<int> polyfem::solver::AdjointNLProblem::solve_in_order
private

Definition at line 58 of file AdjointNLProblem.hpp.

◆ solve_in_parallel

const bool polyfem::solver::AdjointNLProblem::solve_in_parallel
private

Definition at line 57 of file AdjointNLProblem.hpp.

Referenced by solve_pde().

◆ stopping_conditions_

std::vector<std::shared_ptr<AdjointForm> > polyfem::solver::AdjointNLProblem::stopping_conditions_
private

Definition at line 62 of file AdjointNLProblem.hpp.

Referenced by AdjointNLProblem(), and stop().

◆ variables_to_simulation_

const VariableToSimulationGroup polyfem::solver::AdjointNLProblem::variables_to_simulation_
private

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