Belos Version of the Day

Interface to standard and "pseudoblock" GMRES. More...
#include <BelosPseudoBlockGmresSolMgr.hpp>
Public Member Functions  
Constructors and destructor  
PseudoBlockGmresSolMgr ()  
Empty constructor.  
PseudoBlockGmresSolMgr (const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< Teuchos::ParameterList > &pl)  
Constructor that takes the problem to solve, and a list of solver options.  
virtual  ~PseudoBlockGmresSolMgr () 
Destructor.  
Accessor methods  
const LinearProblem < ScalarType, MV, OP > &  getProblem () const 
Return a reference to the linear problem being solved by this solver manager.  
Teuchos::RCP< const Teuchos::ParameterList >  getValidParameters () const 
A list of valid default parameters for this solver.  
Teuchos::RCP< const Teuchos::ParameterList >  getCurrentParameters () const 
The current parameters for this solver.  
Teuchos::Array< Teuchos::RCP < Teuchos::Time > >  getTimers () const 
Return the timers for this object.  
MagnitudeType  achievedTol () const 
Tolerance achieved by the last solve() invocation.  
int  getNumIters () const 
Iteration count for the most recent call to solve() .  
bool  isLOADetected () const 
Whether a "loss of accuracy" was detected during the last solve().  
Set methods  
void  setProblem (const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem) 
Set the linear problem to solve.  
void  setParameters (const Teuchos::RCP< Teuchos::ParameterList > ¶ms) 
Set the parameters the solver manager should use to solve the linear problem.  
virtual void  setUserConvStatusTest (const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &userConvStatusTest) 
Set a custom status test.  
Reset methods  
void  reset (const ResetType type) 
Performs a reset of the solver manager specified by the ResetType . This informs the solver manager that the solver should prepare for the next call to solve by resetting certain elements of the iterative solver strategy.  
Solver application methods  
ReturnType  solve () 
This method performs possibly repeated calls to the underlying linear solver's iterate() routine until the problem has been solved (as decided by the solver manager) or the solver manager decides to quit.  
Overridden from Teuchos::Describable  
std::string  description () const 
Return a description of the pseudoblock GMRES solver manager. 
Interface to standard and "pseudoblock" GMRES.
This class provides an interface to the following iterative solvers:
If you are a new Belos user and just want standard GMRES, use this class. If you want Flexible GMRES, use BlockGmresSolMgr
with the appropriate option set.
"Pseudoblock" GMRES is a way to improve performance when solving systems with multiple righthand sides, without changing the convergence characteristics. It is equivalent in terms of convergence to running a separate instance of (standard) GMRES for each righthand side, but should often be faster. When solving for multiple righthand sides, "Block GMRES" (as implemented by BlockGmresSolMgr
) is a different algorithm with different convergence characteristics than Pseudoblock GMRES.
BlockGmres/PseudoBlockGmresEpetraExFile.cpp, and BlockGmres/PseudoBlockPrecGmresEpetraExFile.cpp.
Definition at line 126 of file BelosPseudoBlockGmresSolMgr.hpp.
Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::PseudoBlockGmresSolMgr  (  ) 
Empty constructor.
This constructor takes no arguments. It sets default solver parameters, which you may change by calling setParameters(). Before you may call solve(), you must first give the solver a linear problem to solve, by calling setProblem().
Definition at line 550 of file BelosPseudoBlockGmresSolMgr.hpp.
Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::PseudoBlockGmresSolMgr  (  const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &  problem, 
const Teuchos::RCP< Teuchos::ParameterList > &  pl  
) 
Constructor that takes the problem to solve, and a list of solver options.
problem  [in/out] The linear problem to be solved. 
pl  [in/out] A list of solver options. 
Belos' solvers accept many different options. You may accept their default values, or set any of them yourself. We will explain the options by category.
The following options govern the number of iterations and restarts:
int
): The restart length. The number of vectors (or blocks, in the case of multiple righthand sides) allocated for the Krylov basis. Its default value is 300.int
): The maximum number of iterations the solver is allowed to perform. This does not include computing the initial residual, but it does include iterations before and after any restarts. Its default value is 1000.int
): The maximum number of restarts. This does not include the first "Num Blocks" iterations (before the first restart). Its default value is 20.We do not currently perform any sanity checks for these options. This may affect you if you set some of them but let others keep their default values. For example, if you set "Num Blocks" to 2 and "Maximum Iterations" to 100, but don't set "Maximum Restarts", you will only get 40 = 20*2 total iterations, rather than 100. Thus, if you set one of these parameters, you should always set them all.
When solving with multiple righthand sides, the "Block Size" (int
) parameter controls the number of righthand sides for which the solver solves at once. This setting controls both performance and total memory use. Doubling it (approximately) doubles the total amount of memory used by the solver, but might make the solves faster by reducing synchronization overhead and improving memory bandwidth utilization. The gain from increasing this tends to level off quickly. Making this setting too large may actually hurt performance.
These options govern convergence and the numerical algorithm:
MagnitudeType
): The level that residual norms must reach in order for the solver to stop iterating.std::string
): How to scale the implicit residual norm. The default is the norm of the preconditioned initial residual.std::string
): How to scale the explicit residual norm. The default is the norm of the (unpreconditioned) initial residual.int
): When solving with multiple righthand sides: the number of righthand sides that must have converged to the given tolerance, before the solver will consider all the systems converged. If 1, then the solver will require that all the righthand sides have converged before declaring all the systems converged. This must be no bigger than the "Block Size" parameter.std::string
): The desired orthogonalization method. Currently accepted values are "DGKS", "ICGS", and "IMGS". Please refer to Belos' documentation for more details.For an explanation of "implicit" vs. "explicit" residuals, please see the documentation of isLOADetected(). The difference matters if using left preconditioning. Otherwise, it is not so important to most users.
The residual scaling parameters ("Implicit Residual Scaling" and "Explicit Residual Scaling") accept the following values:
GMRES always uses the 2 norm (square root of sum of squares of magnitudes of entries) to measure convergence.
Belos' solvers let users control intermediate "status" output. This output tells you the current iteration and the values of current convergence criteria. The following parameters control output. The default values are fine for users who only care about the final result and don't want to see status output.
MsgType
enum values specifying the verbosity. Default: Belos::Errors.int
): How often (in terms of number of iterations) to print intermediate status output. The default (1) means not to print intermediate status output at all.OutputType
): The style of output. Accepted values are General and Brief. Default: General.Teuchos::RCP<std::ostream>
): A pointer to an output stream to which the solver will write status output. The default is a pointer to std::cout
. Currently, if Trilinos was built with MPI support, only the MPI process with rank 0 in MPI_COMM_WORLD will print to this output stream.Definition at line 578 of file BelosPseudoBlockGmresSolMgr.hpp.
virtual Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::~PseudoBlockGmresSolMgr  (  )  [inline, virtual] 
Destructor.
Definition at line 256 of file BelosPseudoBlockGmresSolMgr.hpp.
const LinearProblem<ScalarType,MV,OP>& Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::getProblem  (  )  const [inline, virtual] 
Return a reference to the linear problem being solved by this solver manager.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 262 of file BelosPseudoBlockGmresSolMgr.hpp.
Teuchos::RCP< const Teuchos::ParameterList > Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::getValidParameters  (  )  const [virtual] 
A list of valid default parameters for this solver.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 907 of file BelosPseudoBlockGmresSolMgr.hpp.
Teuchos::RCP<const Teuchos::ParameterList> Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::getCurrentParameters  (  )  const [inline, virtual] 
The current parameters for this solver.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 270 of file BelosPseudoBlockGmresSolMgr.hpp.
Teuchos::Array<Teuchos::RCP<Teuchos::Time> > Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::getTimers  (  )  const [inline] 
Return the timers for this object.
The timers are ordered as follows:
Definition at line 277 of file BelosPseudoBlockGmresSolMgr.hpp.
MagnitudeType Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::achievedTol  (  )  const [inline, virtual] 
Tolerance achieved by the last solve()
invocation.
This is the maximum over all righthand sides' achieved convergence tolerances, and is set whether or not the solve actually managed to achieve the desired convergence tolerance.
isLOADetected()
to check for a loss of accuracy during the last solve. Reimplemented from Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 291 of file BelosPseudoBlockGmresSolMgr.hpp.
int Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::getNumIters  (  )  const [inline, virtual] 
Iteration count for the most recent call to solve()
.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 296 of file BelosPseudoBlockGmresSolMgr.hpp.
bool Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::isLOADetected  (  )  const [inline, virtual] 
Whether a "loss of accuracy" was detected during the last solve().
This solver uses two different residual norms to predict convergence: "implicit" (also called "native") and "explicit" (also called "exact," not to be confused with "exact arithmetic"). The "implicit" residuals are computed by the solver via a recurrence relation (the Arnoldi relation, in the case of GMRES). The "explicit" residuals are computed directly as $B  A X_k$. Implicit residuals are much cheaper to compute, since they are available almost "for free" from the recurrence relation. In contrast, computing exact residuals requires computing the current approximate solution , applying the global operator to , and then computing the norm of the resulting vector(s) via a global reduction. Thus, GMRES favors using the cheaper implicit residuals to predict convergence. Users typically want convergence with respect to explicit residuals, though.
Implicit and explicit residuals may differ due to rounding error. However, the difference between implicit and explicit residuals matters most when using a left (or split) preconditioner. In that case, the implicit residuals are those of the leftpreconditioned problem instead of the original problem . The implicit residual norms may thus differ significantly from the explicit residual norms, even if one could compute without rounding error.
When using a left preconditioner, this solver tries to detect if the implicit residuals have converged but the explicit residuals have not. In that case, it will reduce the convergence tolerance and iterate a little while longer to attempt to reduce the explicit residual norm. However, if that doesn't work, it declares a "loss of accuracy" for the affected righthand side(s), and stops iterating on them. (Not all righthand sides may have experienced a loss of accuracy.) Thus, the affected righthand sides may or may not have converged to the desired residual norm tolerance. Calling this method tells you whether a "loss of accuracy" (LOA) occurred during the last solve()
invocation.
When not using a left preconditioner, this solver will iterate until both the implicit and explicit residuals converge. (It does not start testing the explicit residuals until the implicit residuals have converged. This avoids whenever possible the cost of computing explicit residuals.) Implicit and explicit residuals may differ due to rounding error, even though they are identical when no rounding error occurs. In this case, the algorithm does not report a "loss of accuracy," since it continues iterating until the explicit residuals converge.
solve()
again resets the flag that reports whether a loss of accuracy was detected. Thus, you should call this method immediately after calling solve()
. Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 355 of file BelosPseudoBlockGmresSolMgr.hpp.
void Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::setProblem  (  const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &  problem  )  [inline, virtual] 
Set the linear problem to solve.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 363 of file BelosPseudoBlockGmresSolMgr.hpp.
void Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::setParameters  (  const Teuchos::RCP< Teuchos::ParameterList > &  params  )  [virtual] 
Set the parameters the solver manager should use to solve the linear problem.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 614 of file BelosPseudoBlockGmresSolMgr.hpp.
void Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::setUserConvStatusTest  (  const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &  userConvStatusTest  )  [virtual] 
Set a custom status test.
A custom status test is not required. If you decide to set one, the current implementation will apply it sequentially (shortcircuiting OR, like the  operator in C++) after Pseudoblock GMRES' standard convergence test.
Reimplemented from Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 897 of file BelosPseudoBlockGmresSolMgr.hpp.
void Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::reset  (  const ResetType  type  )  [inline, virtual] 
Performs a reset of the solver manager specified by the ResetType
. This informs the solver manager that the solver should prepare for the next call to solve by resetting certain elements of the iterative solver strategy.
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 388 of file BelosPseudoBlockGmresSolMgr.hpp.
ReturnType Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::solve  (  )  [virtual] 
This method performs possibly repeated calls to the underlying linear solver's iterate() routine until the problem has been solved (as decided by the solver manager) or the solver manager decides to quit.
This method calls PseudoBlockGmresIter::iterate(), which will return either because a specially constructed status test evaluates to Passed or an std::exception is thrown.
A return from PseudoBlockGmresIter::iterate() signifies one of the following scenarios:
Implements Belos::SolverManager< ScalarType, MV, OP >.
Definition at line 1044 of file BelosPseudoBlockGmresSolMgr.hpp.
std::string Belos::PseudoBlockGmresSolMgr< ScalarType, MV, OP >::description  (  )  const [virtual] 
Return a description of the pseudoblock GMRES solver manager.
Reimplemented from Teuchos::Describable.
Definition at line 1449 of file BelosPseudoBlockGmresSolMgr.hpp.