#include <GMRESSolver.h>

Public Types | |
| typedef std::shared_ptr< AMP::Solver::SolverStrategy > | shared_ptr |
| enum class | SolverStatus { ConvergedOnAbsTol , ConvergedOnRelTol , ConvergedUserCondition , MaxIterations , DivergedLineSearch , DivergedStepSize , DivergedFunctionCount , DivergedOnNan , DivergedNestedSolver , DivergedOther } |
Static Public Member Functions | |
| static std::unique_ptr< SolverStrategy > | createSolver (std::shared_ptr< SolverStrategyParameters > params) |
| static std::string | statusToString (SolverStatus status) |
Protected Member Functions | |
| void | addCorrection (const int nr, std::shared_ptr< AMP::LinearAlgebra::Vector > z, std::shared_ptr< AMP::LinearAlgebra::Vector > z1, std::shared_ptr< AMP::LinearAlgebra::Vector > u) |
| void | applyGivensRotation (const int i, const int k) |
| apply the i-th Givens rotation to the k-th column of the Hessenberg matrix | |
| void | backwardSolve (const int nr) |
| std::vector< T > | basisInnerProducts (const int k, std::shared_ptr< AMP::LinearAlgebra::Vector > v) |
| return the inner products of v against the first k basis vectors | |
| void | cgs (const int k, std::shared_ptr< AMP::LinearAlgebra::Vector > v) |
| orthogonalize the vector against the existing vectors in the basis | |
| void | cgs2 (const int k, std::shared_ptr< AMP::LinearAlgebra::Vector > v) |
| orthogonalize the vector against the existing vectors in the basis | |
| virtual bool | checkStoppingCriteria (AMP::Scalar res_norm, bool check_iters=true) |
| void | computeGivensRotation (const int k) |
| void | computeInitialResidual (bool use_zero_guess, std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< AMP::LinearAlgebra::Vector > u, std::shared_ptr< AMP::LinearAlgebra::Vector > tmp, std::shared_ptr< AMP::LinearAlgebra::Vector > res) |
| void | getBaseFromInput (std::shared_ptr< AMP::Database > db) |
| void | getFromInput (std::shared_ptr< AMP::Database > db) |
| virtual void | orthogonalize (const int k, std::shared_ptr< AMP::LinearAlgebra::Vector > v) |
| orthogonalize the vector against the existing vectors in the basis | |
Static Protected Attributes | |
| static int | d_iInstanceId |
Private Member Functions | |
| void | allocateBasis (std::shared_ptr< const AMP::LinearAlgebra::Vector > u=nullptr) |
Private Attributes | |
| bool | d_bFlexibleGMRES = false |
| bool | d_bRestart = false |
| bool | d_bUsesPreconditioner = false |
| boolean, for whether a preconditioner present or not | |
| std::vector< T > | d_dcos |
| stores the cosine and sine values required for Givens rotations | |
| AMP::Array< T > | d_dHessenberg |
| stores the upper Hessenberg matrix formed during the GMRES iteration | |
| std::vector< T > | d_dsin |
| std::vector< T > | d_dw |
| stores the right hand side for the Hessenberg least squares system | |
| std::vector< T > | d_dy |
| stores the solution for the least squares system | |
| int | d_iBasisAllocSize = 4 |
| int | d_iMaxKrylovDimension = 50 |
| whether to restart | |
| std::string | d_preconditioner_side = "right" |
| int | d_restarts |
| size of the allocation increases for the vector basis | |
| std::string | d_sOrthogonalizationMethod = "MGS" |
| logs number of times the solver is restarted | |
| std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > | d_vBasis |
| std::shared_ptr< AMP::LinearAlgebra::Vector > | d_z |
| stores the vectors needed for right and left preconditioning | |
| std::shared_ptr< AMP::LinearAlgebra::Vector > | d_z1 |
| std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > | d_zBasis |
The GMRESSolver class implements the GMRES method for non-symmetric linear systems introduced by Saad and Schultz Y. Saad and M.H. Schultz "GMRES: A generalized minimal residual algorithm for solving nonsymmetric linear systems", SIAM J. Sci. Stat. Comput., 7:856-869, 1986. doi:10.1137/0907058 If a preconditioner is provided right preconditioning is done
Definition at line 22 of file GMRESSolver.h.
|
inherited |
Definition at line 30 of file SolverStrategy.h.
|
stronginherited |
| Enumerator | |
|---|---|
| ConvergedOnAbsTol | |
| ConvergedOnRelTol | |
| ConvergedUserCondition | |
| MaxIterations | |
| DivergedLineSearch | |
| DivergedStepSize | |
| DivergedFunctionCount | |
| DivergedOnNan | |
| DivergedNestedSolver | |
| DivergedOther | |
Definition at line 62 of file SolverStrategy.h.
| AMP::Solver::GMRESSolver< T >::GMRESSolver | ( | ) |
default constructor
|
explicit |
main constructor
| [in] | params | The parameters object contains a database objects containing the following fields: |
|
virtualdefault |
Default destructor
|
protected |
update current approximation with the correction.
| [in] | nr | dimension of least squares system. |
| [in] | z | shared pointer to temporary vector used if there is right preconditioning. |
| [in] | z1 | shared pointer to temporary vector used if there is right preconditioning. |
| [out] | u | shared pointer to approximate computed solution to correct. |
|
private |
Allocate the vector basis in d_iBasisAllocSize chunks (d_vBasis & d_zBasis)
|
override |
Solve the system Au=f. The implementation is based on the paper "Implementations of the GMRES method", H. Walker Computer Physics Communications 53 (1989) 311-320
| [in] | f | : const shared pointer to right hand side vector |
| [out] | u | : shared pointer to approximate computed solution |
|
pure virtualinherited |
Solve the system \(A(u) = f\). This is a pure virtual function that the derived classes need to provide an implementation of.
| [in] | f | shared pointer to right hand side vector |
| [out] | u | shared pointer to approximate computed solution |
Implemented in AMP::Solver::BDFRadDifOpPJacOpSplitPrec, AMP::Solver::AMG::UASolver, AMP::Solver::BandedSolver, AMP::Solver::BiCGSTABSolver< T >, AMP::Solver::CGSolver< T >, AMP::Solver::ColumnSolver, AMP::Solver::ConstraintsEliminationSolver, AMP::Solver::DiagonalSolver< T >, AMP::Solver::BoomerAMGSolver, AMP::Solver::HypreSolver, AMP::Solver::CoupledFlow1DSolver, AMP::Solver::Flow1DSolver, AMP::Solver::PelletStackMechanicsSolver, AMP::Solver::NonlinearKrylovAccelerator< T >, AMP::Solver::OnePointSolver, AMP::Solver::PetscKrylovSolver, AMP::Solver::PetscSNESSolver, AMP::Solver::QMRCGSTABSolver< T >, AMP::Solver::TFQMRSolver< T >, AMP::Solver::TrilinosMLSolver, AMP::Solver::TrilinosMueLuSolver, and AMP::Solver::TrilinosNOXSolver.
apply the i-th Givens rotation to the k-th column of the Hessenberg matrix
|
protected |
perform a back solve for the upper triangular system generated for the least squares minimization problem
| [in] | nr | dimension of least squares system. |
|
protected |
return the inner products of v against the first k basis vectors
|
protected |
orthogonalize the vector against the existing vectors in the basis
|
protected |
orthogonalize the vector against the existing vectors in the basis
|
protectedvirtualinherited |
|
protected |
compute the Givens rotation required to zero out the sbub-diagonal element on the k-th column of the Hessenberg matrix and add it to the stored rotations Note that zero based indexing is being used
|
protected |
Compute initial residual for a GMRES cycle.
| [in] | use_zero_guess | specify if zero should be used for the initial guess. |
| [in] | f | right hand side for residual. |
| [in,out] | u | initial guess if use_zero_guess is false (set to zero otherwise). |
| [in] | tmp | temporary vector needed if preconditiong is used. |
| [out] | res | residual vector. |
|
inlinestatic |
static create routine that is used by SolverFactory
| [in] | params | The parameters object contains a database objects with the fields listed for the constructor above |
Definition at line 55 of file GMRESSolver.h.
|
inlineinherited |
Definition at line 208 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dAbsoluteTolerance.
|
protectedinherited |
Definition at line 225 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::ConvergedUserCondition, and AMP::Solver::SolverStrategy::d_ConvergenceStatus.
|
inlineinherited |
Definition at line 230 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_ConvergenceStatus.
|
inlineinherited |
Definition at line 232 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_ConvergenceStatus, and AMP::Solver::SolverStrategy::statusToString().
Get level of diagnostic information printed during iterations.
Definition at line 137 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iDebugPrintInfoLevel.
|
inlineinherited |
Definition at line 269 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_exec_space.
|
protected |
|
inlineinherited |
Definition at line 267 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_pFunctionScaling.
|
inlinevirtualinherited |
Definition at line 241 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dInitialResidual.
|
inlinevirtualinherited |
Definition at line 243 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iterationHistory.
Return the number of iterations taken by the solver to converge.
Definition at line 142 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iNumberIterations.
Definition at line 218 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iMaxIterations.
|
inlinevirtualinherited |
Return a nested solver (eg preconditioner) if it exists. By default return a nullptr
Reimplemented in AMP::Solver::PetscSNESSolver.
Definition at line 172 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_pNestedSolver.
|
virtualinherited |
Return a shared pointer to the operator registered with the solver.
|
inlineinherited |
Definition at line 212 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dRelativeTolerance.
|
inlinevirtualinherited |
Definition at line 239 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dResidualNorm.
|
inlineinherited |
Definition at line 266 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_pSolutionScaling.
|
overridevirtual |
Initialize the GMRESSolver. Should not be necessary for the user to call in general.
| params |
Reimplemented from AMP::Solver::SolverStrategy.
|
protectedvirtual |
orthogonalize the vector against the existing vectors in the basis
Definition at line 237 of file SolverStrategy.h.
|
inlinevirtualinherited |
Reimplemented in AMP::Solver::PetscSNESSolver.
Definition at line 251 of file SolverStrategy.h.
|
inlinevirtualinherited |
Reimplemented in AMP::Solver::NonlinearKrylovAccelerator< T >.
Definition at line 220 of file SolverStrategy.h.
|
overridevirtual |
Register the operator that the solver will use during solves
| [in] | op | shared pointer to operator $A()$ for equation \(A(u) = f\) |
Reimplemented from AMP::Solver::SolverStrategy.
|
inlinevirtualinherited |
Registers a writer with the solver.
This function will register a writer with the solver. The solver may then register any vector components it "owns" with the writer.
| writer | The writer to register |
Definition at line 186 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_writer.
|
virtualinherited |
Resets the solver internally with new parameters if necessary
| parameters | SolverStrategyParameters object that is NULL by default |
Reimplemented in AMP::Solver::TrilinosNOXSolver, AMP::Solver::BandedSolver, AMP::Solver::BoomerAMGSolver, AMP::Solver::HypreBiCGSTABSolver, AMP::Solver::HypreGMRESSolver, AMP::Solver::HyprePCGSolver, AMP::Solver::HypreSolver, AMP::Solver::TrilinosMLSolver, AMP::Solver::TrilinosMueLuSolver, AMP::Solver::CoupledFlow1DSolver, and AMP::Solver::Flow1DSolver.
|
virtualinherited |
Resets the operator registered with the solver with new parameters if necessary
| parameters | OperatorParameters object that is NULL by default |
Reimplemented in AMP::Solver::PetscKrylovSolver, AMP::Solver::BandedSolver, AMP::Solver::ColumnSolver, AMP::Solver::HypreSolver, AMP::Solver::CoupledFlow1DSolver, AMP::Solver::Flow1DSolver, AMP::Solver::PelletStackMechanicsSolver, AMP::Solver::TrilinosMLSolver, and AMP::Solver::TrilinosMueLuSolver.
|
virtualinherited |
|
inline |
Checks if the restart is allowed
Definition at line 93 of file GMRESSolver.h.
References AMP::Solver::GMRESSolver< T >::d_bRestart.
|
inlinevirtualinherited |
Definition at line 210 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dAbsoluteTolerance.
|
inlineinherited |
for multiphysics problems it may be necessary to scale the solution
Definition at line 259 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_pFunctionScaling, and AMP::Solver::SolverStrategy::d_pSolutionScaling.
|
inlinevirtualinherited |
Specify level of diagnostic information printed during iterations.
| [in] | print_level | integer level value with permissible values 0 and higher. Setting to zero should provide minimial debugging information with higher values resulting in increasingly verbose information being printed out. |
Definition at line 132 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iDebugPrintInfoLevel.
|
inlineinherited |
Definition at line 270 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_exec_space.
|
virtualinherited |
Provide the initial guess for the solver. This is a pure virtual function that the derived classes need to provide an implementation of.
| [in] | initialGuess | shared pointer to the initial guess vector. |
Reimplemented in AMP::Solver::ColumnSolver, AMP::Solver::CoupledFlow1DSolver, AMP::Solver::Flow1DSolver, AMP::Solver::PetscSNESSolver, and AMP::Solver::TrilinosNOXSolver.
Tell a solver that it is nested inside some outer solver.
Definition at line 166 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_bIsNestedSolver.
|
inlinevirtualinherited |
Definition at line 216 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_iMaxIterations.
|
inlinevirtualinherited |
Set a nested solver, eg, Krylov for Newton, preconditioner for Krylov etc. Null op in base class
Definition at line 159 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_pNestedSolver.
|
inlinevirtualinherited |
Definition at line 214 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_dRelativeTolerance.
|
inlinevirtualinherited |
Tells the solver to use an initial guess of zero and not try to copy an initial guess into the solution vector
| [in] | use_zero_guess | boolean to specify whether zero initial guess should be used or not. |
Reimplemented in AMP::Solver::PetscKrylovSolver.
Definition at line 150 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::d_bUseZeroInitialGuess.
|
inlinestaticinherited |
Definition at line 75 of file SolverStrategy.h.
References AMP::Solver::SolverStrategy::ConvergedOnAbsTol, AMP::Solver::SolverStrategy::ConvergedOnRelTol, AMP::Solver::SolverStrategy::ConvergedUserCondition, AMP::Solver::SolverStrategy::DivergedFunctionCount, AMP::Solver::SolverStrategy::DivergedLineSearch, AMP::Solver::SolverStrategy::DivergedNestedSolver, AMP::Solver::SolverStrategy::DivergedOnNan, AMP::Solver::SolverStrategy::DivergedStepSize, and AMP::Solver::SolverStrategy::MaxIterations.
Referenced by AMP::Solver::SolverStrategy::getConvergenceStatusString().
|
inlineoverridevirtual |
Return the name of the solver.
Implements AMP::Solver::SolverStrategy.
Definition at line 65 of file GMRESSolver.h.
Definition at line 295 of file SolverStrategy.h.
boolean, for whether the flexible version of GMRES is used note that it makes sense to use it only if right preconditioning is on
Definition at line 188 of file GMRESSolver.h.
Definition at line 294 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::setIsNestedSolver().
Definition at line 161 of file GMRESSolver.h.
Referenced by AMP::Solver::GMRESSolver< T >::restarted().
|
private |
boolean, for whether a preconditioner present or not
Definition at line 184 of file GMRESSolver.h.
Definition at line 292 of file SolverStrategy.h.
Referenced by AMP::Solver::OnePointSolver::apply(), and AMP::Solver::SolverStrategy::setZeroInitialGuess().
|
protectedinherited |
Definition at line 276 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getConverged(), AMP::Solver::SolverStrategy::getConvergenceStatus(), and AMP::Solver::SolverStrategy::getConvergenceStatusString().
|
protectedinherited |
Definition at line 287 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getAbsoluteTolerance(), and AMP::Solver::SolverStrategy::setAbsoluteTolerance().
|
protectedinherited |
Definition at line 304 of file SolverStrategy.h.
|
private |
stores the cosine and sine values required for Givens rotations
Definition at line 195 of file GMRESSolver.h.
|
private |
stores the upper Hessenberg matrix formed during the GMRES iteration
Definition at line 191 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 285 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getInitialResidual().
|
protectedinherited |
Definition at line 288 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getRelativeTolerance(), and AMP::Solver::SolverStrategy::setRelativeTolerance().
|
protectedinherited |
Definition at line 284 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getResidualNorm().
|
private |
Definition at line 196 of file GMRESSolver.h.
|
private |
stores the right hand side for the Hessenberg least squares system
Definition at line 199 of file GMRESSolver.h.
|
private |
stores the solution for the least squares system
Definition at line 202 of file GMRESSolver.h.
|
protectedinherited |
execution space for the solver
Definition at line 324 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getExecutionSpace(), and AMP::Solver::SolverStrategy::setExecutionSpace().
|
protectedinherited |
Pointer to global database This is temporary fix and eventually either d_global_db or d_db should go away This is introduced to allow for solver factories to access databases in the global database for the construction of nested solvers
Definition at line 311 of file SolverStrategy.h.
|
private |
maximum dimension of the Krylov subspace before a restart or termination happens
Definition at line 166 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 290 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getDebugPrintInfoLevel(), and AMP::Solver::SolverStrategy::setDebugPrintInfoLevel().
|
staticprotectedinherited |
Definition at line 299 of file SolverStrategy.h.
|
protectedinherited |
Definition at line 282 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getMaxIterations(), and AMP::Solver::SolverStrategy::setMaxIterations().
|
private |
whether to restart
Definition at line 163 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 280 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getIterations().
|
protectedinherited |
Definition at line 297 of file SolverStrategy.h.
|
protectedinherited |
keeps track of iteration statistics over solver lifetime
Definition at line 302 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getIterationHistory().
|
protectedinherited |
memory storage address space
Definition at line 327 of file SolverStrategy.h.
|
protectedinherited |
Definition at line 314 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getFunctionScaling(), and AMP::Solver::SolverStrategy::setComponentScalings().
|
protectedinherited |
nested solver used by this solver
Definition at line 319 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getNestedSolver(), and AMP::Solver::SolverStrategy::setNestedSolver().
|
protectedinherited |
Definition at line 316 of file SolverStrategy.h.
|
private |
string, determining left, right or both side preconditioning this flag only applies if d_bUsesPreconditioner is true valid values are "left", "right", "both" currently only right and left are implemented
Definition at line 181 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 313 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::getSolutionScaling(), and AMP::Solver::SolverStrategy::setComponentScalings().
|
private |
size of the allocation increases for the vector basis
Definition at line 168 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 278 of file SolverStrategy.h.
|
private |
logs number of times the solver is restarted
string, determines orthogonalization method in Arnoldi options are "CGS", "MGS", "HR", where "CGS" : classical Gram-Schmidt ( fast but potentially unstable ) "MGS" : modified Gram-Schmidt ( stable ) "HR" : Householder reflections (use when highly ill conditioned)
Definition at line 175 of file GMRESSolver.h.
|
private |
stores the orthonormal basis for the Krylov space we do not preallocate by default
Definition at line 206 of file GMRESSolver.h.
|
protectedinherited |
Definition at line 321 of file SolverStrategy.h.
Referenced by AMP::Solver::SolverStrategy::registerWriter().
|
private |
stores the vectors needed for right and left preconditioning
Definition at line 213 of file GMRESSolver.h.
|
private |
Definition at line 214 of file GMRESSolver.h.
|
private |
stores the orthonormal basis for the Krylov space in case of FGMRES we do not preallocate by default
Definition at line 210 of file GMRESSolver.h.
|
Advanced Multi-Physics (AMP) Oak Ridge National Laboratory Idaho National Laboratory Los Alamos National Laboratory |
This page automatically produced from the source code by Last updated: Tue Mar 10 2026 13:06:45. Comments on this page |