1#ifndef included_NonlinearKrylovAccelerator
2#define included_NonlinearKrylovAccelerator
4#include "AMP/solvers/SolverStrategy.h"
5#include "AMP/utils/AMP_MPI.h"
10class SolverStrategyParameters;
16template<
typename T =
double>
22 std::shared_ptr<AMP::Solver::SolverStrategyParameters> params );
26 static std::unique_ptr<AMP::Solver::SolverStrategy>
32 std::string
type()
const override {
return "NKASolver"; }
35 initialize( std::shared_ptr<const AMP::Solver::SolverStrategyParameters> parameters )
override;
42 void reset( std::shared_ptr<AMP::Solver::SolverStrategyParameters> parameters )
override;
44 void correction( std::shared_ptr<AMP::LinearAlgebra::Vector> f );
82 void apply( std::shared_ptr<const AMP::LinearAlgebra::Vector> f,
83 std::shared_ptr<AMP::LinearAlgebra::Vector>
u )
override;
100 std::shared_ptr<AMP::Operator::Operator>
119 std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector>>
d_v;
120 std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector>>
d_w;
int d_free
index of last subspace vector
void initialize(std::shared_ptr< AMP::LinearAlgebra::Vector > solution_vector)
void reset(std::shared_ptr< AMP::Solver::SolverStrategyParameters > parameters) override
T d_vtol
maximum number of subspace vectors
bool d_pending
boolean: a nonempty subspace
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_w
correction vectors
bool d_adaptive_damping
whether to use damping
void getFromInput(std::shared_ptr< AMP::Database > db)
std::vector< T > forwardbackwardSolve(std::shared_ptr< AMP::LinearAlgebra::Vector > f)
forward backward solve for Cholesky
NonlinearKrylovAccelerator(std::shared_ptr< AMP::Solver::SolverStrategyParameters > params)
int getMaxNonlinearIterations() const
void registerOperator(std::shared_ptr< AMP::Operator::Operator > op) override final
T d_eta
keeps track of the number of function applications
NonlinearKrylovAccelerator(const NonlinearKrylovAccelerator &)=delete
void initialize(std::shared_ptr< const AMP::Solver::SolverStrategyParameters > parameters) override
~NonlinearKrylovAccelerator()
bool d_uses_preconditioner
damping factor
std::string type() const override
Return the name of the solver.
int d_function_apply_count
keeps track of the number of preconditioner applications
std::shared_ptr< AMP::LinearAlgebra::Vector > d_solution_vector
vector drop tolerance
NonlinearKrylovAccelerator()=delete
std::vector< int > d_prev
next index link field
int d_first
matrix of w vector inner products
bool d_freeze_pc
whether the solver uses a preconditioner or not
std::shared_ptr< AMP::LinearAlgebra::Vector > d_correction_vector
correction vectors
void setMaxFunctionEvaluations(int max_feval)
T ** d_h
function difference vectors
bool d_solver_initialized
whether to print the residuals
bool d_print_residuals
flag determining whether the preconditioner is frozen or not
NonlinearKrylovAccelerator & operator=(const NonlinearKrylovAccelerator &)=delete
NonlinearKrylovAccelerator(NonlinearKrylovAccelerator &&)=delete
int d_mvec
use qr factorization to solve the least squares problem
void setMaxNonlinearIterations(int max_nli)
std::shared_ptr< AMP::LinearAlgebra::Vector > d_residual_vector
correction vectors
void factorizeNormalMatrix(void)
static std::unique_ptr< AMP::Solver::SolverStrategy > createSolver(std::shared_ptr< AMP::Solver::SolverStrategyParameters > solverStrategyParameters)
int d_maximum_function_evals
previous index link field in doubly-linked subspace v
int d_preconditioner_apply_count
void correction(std::shared_ptr< AMP::LinearAlgebra::Vector > f)
std::vector< int > d_next
index of the initial vector in free storage linked list
bool d_use_qr
contains pending vectors – boolean
std::shared_ptr< AMP::Operator::Operator > createPreconditionerOperator(std::shared_ptr< AMP::Operator::Operator > op)
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_v
correction vectors
void apply(std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< AMP::LinearAlgebra::Vector > u) override
int getMaxFunctionEvaluations() const
int d_last
index of first subspace vector
void printStatistics(std::ostream &os) override
std::shared_ptr< AMP::Solver::SolverStrategy > shared_ptr