Advanced Multi-Physics (AMP)
On-Line Documentation
NonlinearKrylovAccelerator.h
Go to the documentation of this file.
1#ifndef included_NonlinearKrylovAccelerator
2#define included_NonlinearKrylovAccelerator
3
4#include "AMP/solvers/SolverStrategy.h"
5#include "AMP/utils/AMP_MPI.h"
6
7namespace AMP {
8class Database;
9namespace Solver {
10class SolverStrategyParameters;
11}
12} // namespace AMP
13
14namespace AMP::Solver {
15
16template<typename T = double>
18{
19
20public:
22 std::shared_ptr<AMP::Solver::SolverStrategyParameters> params );
23
25
26 static std::unique_ptr<AMP::Solver::SolverStrategy>
27 createSolver( std::shared_ptr<AMP::Solver::SolverStrategyParameters> solverStrategyParameters )
28 {
29 return std::make_unique<NonlinearKrylovAccelerator<T>>( solverStrategyParameters );
30 }
31
32 std::string type() const override { return "NKASolver"; }
33
34 void
35 initialize( std::shared_ptr<const AMP::Solver::SolverStrategyParameters> parameters ) override;
36
42 void reset( std::shared_ptr<AMP::Solver::SolverStrategyParameters> parameters ) override;
43
44 void correction( std::shared_ptr<AMP::LinearAlgebra::Vector> f );
45
46 void restart( void );
47
48 void relax( void );
49
54
59
64
69
82 void apply( std::shared_ptr<const AMP::LinearAlgebra::Vector> f,
83 std::shared_ptr<AMP::LinearAlgebra::Vector> u ) override;
84
85 void printStatistics( std::ostream &os ) override;
86
87 void registerOperator( std::shared_ptr<AMP::Operator::Operator> op ) override final;
88
89private:
94
95
96 void getFromInput( std::shared_ptr<AMP::Database> db );
97
98 void initialize( std::shared_ptr<AMP::LinearAlgebra::Vector> solution_vector );
99
100 std::shared_ptr<AMP::Operator::Operator>
101 createPreconditionerOperator( std::shared_ptr<AMP::Operator::Operator> op );
102
104
106 std::vector<T> forwardbackwardSolve( std::shared_ptr<AMP::LinearAlgebra::Vector> f );
107
108 bool d_subspace = false;
109 bool d_pending = false;
110 bool d_use_qr = false;
111
112 int d_mvec = 0;
113 T d_vtol = 0.0;
114
115 std::shared_ptr<AMP::LinearAlgebra::Vector> d_solution_vector;
116 std::shared_ptr<AMP::LinearAlgebra::Vector> d_residual_vector;
117 std::shared_ptr<AMP::LinearAlgebra::Vector> d_correction_vector;
118
119 std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector>> d_v;
120 std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector>> d_w;
121 T **d_h;
122
123 /* Linked-list organization of the vector storage. */
124 int d_first = 0;
125 int d_last = 0;
126 int d_free = 0;
127 std::vector<int> d_next;
128 std::vector<int> d_prev;
129
134 0;
136
137 T d_eta = 1.0;
138
140 bool d_freeze_pc = true;
141 bool d_print_residuals = false;
143 bool d_use_damping = false;
144 bool d_adaptive_damping = false;
145};
146} // namespace AMP::Solver
147
148#endif
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
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_w
correction vectors
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)
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
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
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)
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
std::shared_ptr< AMP::LinearAlgebra::Vector > d_residual_vector
correction vectors
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
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
void printStatistics(std::ostream &os) override
std::shared_ptr< AMP::Solver::SolverStrategy > shared_ptr



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page