Belos Version of the Day
Public Types
Belos::GmresSolMgr< Scalar, MV, OP > Class Template Reference

Solver manager for CA-GMRES and standard GMRES. More...

#include <BelosGmresSolMgr.hpp>

Inheritance diagram for Belos::GmresSolMgr< Scalar, MV, OP >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Scalar scalar_type
typedef Teuchos::ScalarTraits
< Scalar >::magnitudeType 
magnitude_type
typedef MV multivector_type
typedef OP operator_type

Public Member Functions

Constructors and destructor
 GmresSolMgr (const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &problem, const Teuchos::RCP< const Teuchos::ParameterList > &params, const bool debug=false)
 Preferred constructor.
 GmresSolMgr ()
 Default constructor; defers setting parameters.
virtual ~GmresSolMgr ()
 Destructor, defined virtual for safe inheritance.
"Set" methods
void setProblem (const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &problem)
 Set the linear problem to solve.
void setParameters (const Teuchos::RCP< Teuchos::ParameterList > &params)
 Set parameters for solving the linear problem.
void setUserConvStatusTest (const Teuchos::RCP< StatusTest< Scalar, MV, OP > > &userConvTest)
 Set a user-defined convergence stopping criterion.
"Reset" methods
void reset (const ResetType type)
 Reset the solver manager.
Solver application methods
ReturnType solve ()
 Attempt to solve the linear system $AX=B$.
void setRHS (const Teuchos::RCP< const MV > &B)
 Change the right-hand side of the linear system to solve.
void setLHS (const Teuchos::RCP< MV > &X)
 Change the initial guess of the linear system to solve.
void changeStoppingCriteria (const magnitude_type convTol, const int maxItersPerRestart, const int maxNumRestarts)
 Change stopping criteria for next invocation of solve().

"Get" methods

const LinearProblem< Scalar,
MV, OP > & 
getProblem () const
 Const reference to the linear problem being solved.
Teuchos::RCP< const
Teuchos::ParameterList
getValidParameters () const
 Valid default parameters for this solver manager.
Teuchos::RCP< const
Teuchos::ParameterList
getCurrentParameters () const
 Current parameters for this solver manager instance.
int getNumIters () const
 Iteration count for the most recent call to solve().
bool isLOADetected () const
 Was a loss of accuracy detected?
std::vector< std::pair< int,
int > > 
totalNumIters () const
 Last solve's number of restarts and total iterations.
static Teuchos::RCP< const
Teuchos::ParameterList
getDefaultParameters ()
 Valid default parameters for this solver manager.

Detailed Description

template<class Scalar, class MV, class OP>
class Belos::GmresSolMgr< Scalar, MV, OP >

Solver manager for CA-GMRES and standard GMRES.

Author:
Mark Hoemmen

Definition at line 67 of file BelosGmresSolMgr.hpp.


Member Typedef Documentation

template<class Scalar , class MV , class OP >
typedef Scalar Belos::GmresSolMgr< Scalar, MV, OP >::scalar_type

Definition at line 69 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Belos::GmresSolMgr< Scalar, MV, OP >::magnitude_type

Definition at line 70 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
typedef MV Belos::GmresSolMgr< Scalar, MV, OP >::multivector_type

Definition at line 71 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
typedef OP Belos::GmresSolMgr< Scalar, MV, OP >::operator_type

Definition at line 72 of file BelosGmresSolMgr.hpp.


Constructor & Destructor Documentation

template<class Scalar , class MV , class OP >
Belos::GmresSolMgr< Scalar, MV, OP >::GmresSolMgr ( const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &  problem,
const Teuchos::RCP< const Teuchos::ParameterList > &  params,
const bool  debug = false 
) [inline]

Preferred constructor.

Parameters:
problem[in/out] The linear problem to solve.
params[in] Parameters for the solve. If null, we use defaults, else we make a deep copy.

Definition at line 90 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
Belos::GmresSolMgr< Scalar, MV, OP >::GmresSolMgr ( ) [inline]

Default constructor; defers setting parameters.

Definition at line 100 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
virtual Belos::GmresSolMgr< Scalar, MV, OP >::~GmresSolMgr ( ) [inline, virtual]

Destructor, defined virtual for safe inheritance.

Definition at line 106 of file BelosGmresSolMgr.hpp.


Member Function Documentation

template<class Scalar , class MV , class OP >
const LinearProblem<Scalar,MV,OP>& Belos::GmresSolMgr< Scalar, MV, OP >::getProblem ( ) const [inline, virtual]

Const reference to the linear problem being solved.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 114 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP< const Teuchos::ParameterList > Belos::GmresSolMgr< Scalar, MV, OP >::getDefaultParameters ( ) [static]

Valid default parameters for this solver manager.

This class method is preferred to the instance method, because you can call it before you've instantiated the solver manager, and pass the parameters into the solver manager's constructor.

Warning:
This routine is not reentrant. It caches the default parameter list for later reuse.

Definition at line 764 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<const Teuchos::ParameterList> Belos::GmresSolMgr< Scalar, MV, OP >::getValidParameters ( ) const [inline, virtual]

Valid default parameters for this solver manager.

The class method getDefaultParameters() is preferred, since it may be called before the solver manager has been instantiated.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 133 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<const Teuchos::ParameterList> Belos::GmresSolMgr< Scalar, MV, OP >::getCurrentParameters ( ) const [inline, virtual]

Current parameters for this solver manager instance.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 138 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
int Belos::GmresSolMgr< Scalar, MV, OP >::getNumIters ( ) const [inline, virtual]

Iteration count for the most recent call to solve().

It's not entirely clear what the SolutionManager interface expects this to mean. We've interpreted it to mean the maximum (over all right-hand side(s)) of the total number of iterations over all restart cycle(s).

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 148 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
bool Belos::GmresSolMgr< Scalar, MV, OP >::isLOADetected ( ) const [inline, virtual]

Was a loss of accuracy detected?

Some GMRES-type solvers have the capability to detect loss of accuracy. If this solver does not, this method always returns false. If the solver does have this capability, this flag starts out false, and will be (re)set the next time solve() is called.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 162 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
std::vector<std::pair<int, int> > Belos::GmresSolMgr< Scalar, MV, OP >::totalNumIters ( ) const [inline]

Last solve's number of restarts and total iterations.

After calling solve(), you may call this method. For each right-hand side solved, it returns (total number of restart cycles, total number of iterations over all restart cycles). Before calling solve(), the result of calling this method is undefined.

Definition at line 174 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::setProblem ( const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &  problem) [inline, virtual]

Set the linear problem to solve.

This method restarts the current solve that might be in progress.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 187 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::setParameters ( const Teuchos::RCP< Teuchos::ParameterList > &  params) [virtual]

Set parameters for solving the linear problem.

If necessary, this method restarts (by calling reset(Belos::Problem)) the current solve that might be in progress. Currently, it does so only if the parameters have not yet been set, or if the maximum number of iterations has changed (which affects GMRES storage).

Parameters:
params[in] New parameters for the linear solve. The original parameter list is not modified. Since setParameters() implements a pure virtual method of Belos::SolutionManager, the ParameterList has to be passed in as non-const, even though we don't modify it.
Note:
We don't actually keep a pointer to params. This is because we might fill in unsupplied parameters with their default values. Instead, we make a deep copy.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 888 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::setUserConvStatusTest ( const Teuchos::RCP< StatusTest< Scalar, MV, OP > > &  userConvTest) [virtual]

Set a user-defined convergence stopping criterion.

This test will be applied in short-circuiting Boolean AND sequence after the other convergence tests. All convergence tests are invoked (in short-circuiting Boolean OR fashion) after testing whether the maximum number of iterations has been exceeded.

Parameters:
userConvTest[in] The user-defined convergence stopping criterion.

Reimplemented from Belos::SolverManager< Scalar, MV, OP >.

Definition at line 1089 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::reset ( const ResetType  type) [virtual]

Reset the solver manager.

"Reset" with type = Belos::Problem means the following:

  • Tell the LinearProblem instance to recompute initial residual(s) (both left-preconditioned, if applicable, and unpreconditioned) with its stored current approximate solution
  • Restart GMRES, using the newly (re)computed residual vector(s).

This method does not currently support values of type for which (type & Belos::RecycleSubspace) != 0.

Parameters:
type[in] The type of reset to perform. Only type = Belos::Problem is currently supported.

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 1295 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
ReturnType Belos::GmresSolMgr< Scalar, MV, OP >::solve ( ) [virtual]

Attempt to solve the linear system $AX=B$.

Do so by calling the underlying linear solver's iterate() routine zero or more times, until the problem has been solved (as decided by the solver manager) or the solver manager decides to quit.

Returns:
ReturnType enum specifying Converged (the linear problem was solved to the desired tolerance) or Unconverged (the linear problem was not thusly solved).

Implements Belos::SolverManager< Scalar, MV, OP >.

Definition at line 1345 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::setRHS ( const Teuchos::RCP< const MV > &  B) [inline]

Change the right-hand side of the linear system to solve.

This works like a special case of setProblem(), when the only part of the problem that has changed is the right-hand side, and the new right-hand side is in the same vector space as the previous right-hand side. This avoids possibly expensive reinitialization of things like the orthogonalization manager. The initial guess will be left the same; in fact, if solve() has been called before, the initial guess will be the approximate solution from the last invocation of solve().

Note:
This does _not_ create a new LinearProblem instance. The LinearProblem reference returned by getProblem() will still be valid and will still point to the original LinearProblem, except that the original LinearProblem's right-hand side will be different. The original right-hand side will not be overwritten, though, so it will not go away if you retain an RCP to it.

Definition at line 285 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::setLHS ( const Teuchos::RCP< MV > &  X) [inline]

Change the initial guess of the linear system to solve.

This works like a special case of setProblem(), when the only part of the problem that has changed is the initial guess, and the new initial guess is in the same vector space as the previous initial guess. This avoids possibly expensive reinitialization of things like the orthogonalization manager.

Note:
This does _not_ create a new LinearProblem instance. The LinearProblem reference returned by getProblem() will still be valid and will still point to the original LinearProblem, except that the original LinearProblem's initial guess will be different. The original initial guess will not be overwritten, though, so it will not go away if you retain an RCP to it.

Definition at line 313 of file BelosGmresSolMgr.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresSolMgr< Scalar, MV, OP >::changeStoppingCriteria ( const magnitude_type  convTol,
const int  maxItersPerRestart,
const int  maxNumRestarts 
) [inline]

Change stopping criteria for next invocation of solve().

Parameters:
convTol[in] The new convergence tolerance. Interpretation of this depends on how the residual norm test(s) were initially set up.
maxItersPerRestart[in] Maximum number of iterations per restart cycle.
maxNumRestarts[in] Maximum number of restart cycle(s).

Definition at line 334 of file BelosGmresSolMgr.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines