Belos Package Browser (Single Doxygen Collection) Development
Public Types | Public Member Functions | Private Types | Static Private Member Functions | Private Attributes
Belos::GmresBaseIteration< Scalar, MV, OP > Class Template Reference

Subclass of Belos::Iteration for GMRES-based solvers. More...

#include <BelosGmresBaseIteration.hpp>

Inheritance diagram for Belos::GmresBaseIteration< 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

void iterate ()
 Iterate until error or status test triggers.
void initialize ()
 Initialize the solver.
int getNumIters () const
 Return the current iteration count.
void resetNumIters (int iter=0)
 Reset the iteration count to iter.
void restart ()
 Restart GMRES.
Teuchos::RCP< const MV > getNativeResiduals (std::vector< magnitude_type > *norms) const
 Get the residuals native to the solver.
Teuchos::RCP< MV > getCurrentUpdate () const
 Force computation of the current solution update, if it has not already yet been computed.
const LinearProblem< Scalar,
MV, OP > & 
getProblem () const
 Get a constant reference to the linear problem.
int getBlockSize () const
 The block size to be used by the iterative solver in solving this linear problem.
void setBlockSize (int blockSize)
 Set blocksize (not allowed unless blockSize==1)
bool isInitialized ()
 Whether or not the solver has been initialized.
 GmresBaseIteration (const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &problem, const Teuchos::RCP< const OrthoManager< Scalar, MV > > &ortho, const Teuchos::RCP< OutputManager< Scalar > > &printer, const Teuchos::RCP< StatusTest< Scalar, MV, OP > > &tester, const Teuchos::RCP< const Teuchos::ParameterList > &params)
 Constructor.
virtual ~GmresBaseIteration ()
 Trivial destructor.
void updateSolution ()
 Update the current approximate solution.

Private Types

typedef GmresBase< Scalar, MV, OP > impl_type
 The implementation of all functionality of this Iteration.

Static Private Member Functions

static Teuchos::RCP
< LinearProblem< Scalar, MV,
OP > > 
validatedProblem (const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &problem)
 Return a validated version of the given LinearProblem.

Private Attributes

Teuchos::RCP< GmresBase
< Scalar, MV, OP > > 
impl_
 Current iteration state and implementation.
Teuchos::RCP< LinearProblem
< Scalar, MV, OP > > 
lp_
 The linear problem to solve.
Teuchos::RCP< const
OrthoManager< Scalar, MV > > 
ortho_
 Orthogonalization manager.
Teuchos::RCP< OutputManager
< Scalar > > 
outMan_
 Output manager, for intermediate output during iterations.
Teuchos::RCP< StatusTest
< Scalar, MV, OP > > 
stest_
 Status test for stopping iteration.
Teuchos::RCP< const
Teuchos::ParameterList
params_
 Configuration parameters. May be null (signifies defaults).

Detailed Description

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

Subclass of Belos::Iteration for GMRES-based solvers.

Author:
Mark Hoemmen
Warning:
This is EXPERIMENTAL CODE. DO NOT RELY ON THIS CODE. The interface or implementation may change at any time.
Note:
Belos already has a GmresIteration subclass of Iteration, so we named this class GmresBaseIteration, to indicate that it is implemented using GmresBase.

Definition at line 65 of file BelosGmresBaseIteration.hpp.


Member Typedef Documentation

template<class Scalar , class MV , class OP >
Belos::GmresBaseIteration< Scalar, MV, OP >::impl_type [private]

The implementation of all functionality of this Iteration.

Definition at line 69 of file BelosGmresBaseIteration.hpp.

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

Definition at line 72 of file BelosGmresBaseIteration.hpp.

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

Definition at line 73 of file BelosGmresBaseIteration.hpp.

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

Definition at line 74 of file BelosGmresBaseIteration.hpp.

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

Definition at line 75 of file BelosGmresBaseIteration.hpp.


Constructor & Destructor Documentation

template<class Scalar , class MV , class OP >
Belos::GmresBaseIteration< Scalar, MV, OP >::GmresBaseIteration ( const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &  problem,
const Teuchos::RCP< const OrthoManager< Scalar, MV > > &  ortho,
const Teuchos::RCP< OutputManager< Scalar > > &  printer,
const Teuchos::RCP< StatusTest< Scalar, MV, OP > > &  tester,
const Teuchos::RCP< const Teuchos::ParameterList > &  params 
)

Constructor.

Parameters:
problem[in/out] The linear problem to solve, along with any preconditioner(s)
ortho[in] Orthogonalization manager
printer[in/out] Output manager
tester[in] Status test for stopping iteration
params[in(/out???)] Parameters and options for GMRES. An important parameter, required for correctness if the preconditioner might change from iteration to iteration, is the "Flexible" boolean parameter which tells us whether or not to run Flexible GMRES.
Note:
Other Belos solvers take a MatOrthoManager instead of an OrthoManager. This iteration doesn't use the "Mat" features, so we only take an OrthoManager.

Definition at line 327 of file BelosGmresBaseIteration.hpp.

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

Trivial destructor.

Definition at line 273 of file BelosGmresBaseIteration.hpp.


Member Function Documentation

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::iterate ( ) [inline, virtual]

Iterate until error or status test triggers.

Note:
(mfh 30 Dec 2010) The convention in Belos, for some reason, is that iterate() does not call updateSolution() on the LinearProblem instance. In fact, getCurrentUpdate() doesn't even do that. Iteration subclasses that implement GMRES simply don't call updateSolution() on the LinearProblem instance. Instead, the solution manager first calls getCurrentUpdate() on the Iteration subclass instance, and then calls updateSolution(update,true) on the LinearProblem instance. This is a reasonable convention.
(mfh 30 Dec 2010) Nevertheless, Belos' (block) GMRES solution manager's solve() method is messy and invasive of the Iteration subclass' state. For example, the Iteration should be responsible for the mechanics of restarting, not the solution manager. The Iteration has the LinearProblem instance anyway, so it should call updateSolution() before the restart.

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

Definition at line 97 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::initialize ( ) [virtual]

Initialize the solver.

Note:
This Iteration subclass assumes that the linear problem is ready to solve, i.e., that the matrix, any preconditioner(s), and right-hand side have been set.

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

Definition at line 343 of file BelosGmresBaseIteration.hpp.

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

Return the current iteration count.

Restarting resets the current iteration count.

Note:
The first iteration (after the initial residual computation) counts as 1. Belos likes to measure the iterations while they are in progress, not after they are done (when we increment them. That's why we add one in the code below.

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

Definition at line 127 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::resetNumIters ( int  iter = 0) [inline, virtual]

Reset the iteration count to iter.

Reset the iteration count to iter, typically zero (the default value).

Parameters:
iter[in] New iteration count (>= 0)
Note:
The implementation actually saves state up to and including iteration number iter, by "backing out" state beyond that iteration. Iterations may be resumed from there. Thus it promises more than the Iteration interface, which reserves the right to invalidate all iteration state (???).

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

Definition at line 141 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::restart ( ) [inline]

Restart GMRES.

Definition at line 149 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<const MV> Belos::GmresBaseIteration< Scalar, MV, OP >::getNativeResiduals ( std::vector< magnitude_type > *  norms) const [inline]

Get the residuals native to the solver.

Parameters:
norms[out] norms[j] is set to the "native" residual norm for the j-th residual vector. (This is not block Arnoldi, so blockSize==1 always, and there should only be one residual vector.)
Returns:
Optionally, a multivector with blockSize vectors containing the native residuals. Subclasses reserve the right to return Teuchos::null.
Note:
The Iteration interface requires that this method be const. However, we reserve the right to cache computed results.
(mfh 30 Dec 2010) Belos::StatusTestGenResNorm's checkStatus() method (re)computes the norms (using a norm of its own specification, like the 1-norm, 2-norm, etc. -- but not a general norm, since it calls MVT::MvNorm() to do the work) if this method returns non-null. If it returns null, StatusTestGenResNorm's checkStatus() method uses the "norms" parameter. It never calls getNativeResiduals(NULL). This is a waste, since GmresBase is always able to return a native residual vector _and_ a native residual norm. Iteration should really have two separate pure virtual methods: getNativeResidualVector() and getNativeResidualNorm().

Definition at line 183 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<MV> Belos::GmresBaseIteration< Scalar, MV, OP >::getCurrentUpdate ( ) const [inline, virtual]

Force computation of the current solution update, if it has not already yet been computed.

Returns:
Current approximate solution update
Note:
The Iteration interface requires that this method be const, but we reserve the right to cache the current solution update.

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

Definition at line 214 of file BelosGmresBaseIteration.hpp.

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

Get a constant reference to the linear problem.

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

Definition at line 219 of file BelosGmresBaseIteration.hpp.

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

The block size to be used by the iterative solver in solving this linear problem.

Our GMRES/Arnoldi implementations only solve for one right-hand side at a time, so the block size is always one.

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

Definition at line 225 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::setBlockSize ( int  blockSize) [inline, virtual]

Set blocksize (not allowed unless blockSize==1)

Set the block size to use when solving this linear problem. The Arnoldi/GMRES implementations used by this Iteration subclass can only solve for one right-hand side at a time, so the block size must always be one. We deal with this hackishly by raising an std::invalid_argument if a non-1 input is given. (It's hackish because it violates the "is-a" requirement of class hierarchies; GmresBaseIteration "is not an" Iteration, because it does not support arbitrary block sizes.)

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

Definition at line 238 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
bool Belos::GmresBaseIteration< Scalar, MV, OP >::isInitialized ( ) [inline, virtual]

Whether or not the solver has been initialized.

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

Definition at line 246 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
void Belos::GmresBaseIteration< Scalar, MV, OP >::updateSolution ( ) [inline]

Update the current approximate solution.

Modify the LinearProblem instance's current approximate solution (the multivector returned by getLHS()) by adding in the current solution update (xUpdate_). Tell the LinearProblem to compute a new residual vector as well.

Definition at line 282 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP< LinearProblem< Scalar, MV, OP > > Belos::GmresBaseIteration< Scalar, MV, OP >::validatedProblem ( const Teuchos::RCP< LinearProblem< Scalar, MV, OP > > &  problem) [static, private]

Return a validated version of the given LinearProblem.

"Validated" means that the returned LinearProblem is not null, and problem->isProblemSet() returns true.

Definition at line 355 of file BelosGmresBaseIteration.hpp.


Member Data Documentation

template<class Scalar , class MV , class OP >
Teuchos::RCP<GmresBase<Scalar, MV, OP> > Belos::GmresBaseIteration< Scalar, MV, OP >::impl_ [mutable, private]

Current iteration state and implementation.

Note:
This is mutable because of some odd design choices in Belos, in particular the convention that Iteration subclasses are "stateless," even though they have internal mutable state. For example, the "initialize()" member function enforces the maintenance of internal mutable state in Iteration subclasses (otherwise, how could it initialize anything?).

Definition at line 296 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<LinearProblem<Scalar, MV, OP> > Belos::GmresBaseIteration< Scalar, MV, OP >::lp_ [private]

The linear problem to solve.

Note:
We have to keep a pointer to this because the interface that we must implement (in order for the iteration status checks to work) requires that initialization be separate from construction.

Definition at line 304 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<const OrthoManager<Scalar, MV> > Belos::GmresBaseIteration< Scalar, MV, OP >::ortho_ [private]

Orthogonalization manager.

We're not using MatOrthoManager, because GMRES doesn't need that expanded interface.

Definition at line 309 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<OutputManager<Scalar> > Belos::GmresBaseIteration< Scalar, MV, OP >::outMan_ [private]

Output manager, for intermediate output during iterations.

Definition at line 311 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<StatusTest<Scalar, MV, OP> > Belos::GmresBaseIteration< Scalar, MV, OP >::stest_ [private]

Status test for stopping iteration.

Definition at line 313 of file BelosGmresBaseIteration.hpp.

template<class Scalar , class MV , class OP >
Teuchos::RCP<const Teuchos::ParameterList> Belos::GmresBaseIteration< Scalar, MV, OP >::params_ [private]

Configuration parameters. May be null (signifies defaults).

Definition at line 315 of file BelosGmresBaseIteration.hpp.


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