Belos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Private Member Functions | Private Attributes | List of all members
Belos::CGIter< ScalarType, MV, OP > Class Template Reference

This class implements the preconditioned Conjugate Gradient (CG) iteration. More...

#include <BelosCGIter.hpp>

Inheritance diagram for Belos::CGIter< ScalarType, MV, OP >:
Inheritance graph
[legend]

Public Types

typedef MultiVecTraits
< ScalarType, MV > 
MVT
 
typedef OperatorTraits
< ScalarType, MV, OP > 
OPT
 
typedef Teuchos::ScalarTraits
< ScalarType > 
SCT
 
typedef SCT::magnitudeType MagnitudeType
 

Private Member Functions

void setStateSize ()
 Method for initalizing the state storage needed by CG. More...
 

Private Attributes

const Teuchos::RCP
< LinearProblem< ScalarType,
MV, OP > > 
lp_
 
const Teuchos::RCP
< OutputManager< ScalarType > > 
om_
 
const Teuchos::RCP< StatusTest
< ScalarType, MV, OP > > 
stest_
 
const Teuchos::RCP
< StatusTestGenResNorm
< ScalarType, MV, OP > > 
convTest_
 
bool initialized_
 
bool stateStorageInitialized_
 
int iter_
 
bool foldConvergenceDetectionIntoAllreduce_
 
ScalarType rHr_
 
bool assertPositiveDefiniteness_
 
Teuchos::ArrayRCP< MagnitudeTypediag_
 
Teuchos::ArrayRCP< MagnitudeTypeoffdiag_
 
int numEntriesForCondEst_
 
bool doCondEst_
 
Teuchos::RCP< MV > R_
 
Teuchos::RCP< MV > Z_
 
Teuchos::RCP< MV > P_
 
Teuchos::RCP< MV > AP_
 
Teuchos::RCP< MV > S_
 

Constructors/Destructor

 CGIter (const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &tester, const Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP > > &convTester, Teuchos::ParameterList &params)
 CGIter constructor with linear problem, solver utilities, and parameter list of solver options. More...
 
virtual ~CGIter ()
 Destructor. More...
 

Solver methods

void iterate ()
 This method performs CG iterations until the status test indicates the need to stop or an error occurs (in which case, an std::exception is thrown). More...
 
void initializeCG (CGIterationState< ScalarType, MV > &newstate)
 Initialize the solver to an iterate, providing a complete state. More...
 
void initialize ()
 Initialize the solver with the initial vectors from the linear problem or random data. More...
 
CGIterationState< ScalarType, MV > getState () const
 Get the current state of the linear solver. More...
 

Status methods

int getNumIters () const
 Get the current iteration count. More...
 
void resetNumIters (int iter=0)
 Reset the iteration count. More...
 
Teuchos::RCP< const MV > getNativeResiduals (std::vector< MagnitudeType > *norms) const
 Get the norms of the residuals native to the solver. More...
 
Teuchos::RCP< MV > getCurrentUpdate () const
 Get the current update to the linear system. More...
 

Accessor methods

const LinearProblem
< ScalarType, MV, OP > & 
getProblem () const
 Get a constant reference to the linear problem. More...
 
int getBlockSize () const
 Get the blocksize to be used by the iterative solver in solving this linear problem. More...
 
void setBlockSize (int blockSize)
 Set the blocksize to be used by the iterative solver in solving this linear problem. More...
 
bool isInitialized ()
 States whether the solver has been initialized or not. More...
 
void setDoCondEst (bool val)
 Sets whether or not to store the diagonal for condition estimation. More...
 
Teuchos::ArrayView< MagnitudeTypegetDiag ()
 Gets the diagonal for condition estimation. More...
 
Teuchos::ArrayView< MagnitudeTypegetOffDiag ()
 Gets the off-diagonal for condition estimation. More...
 

Additional Inherited Members

- Public Member Functions inherited from Belos::CGIteration< ScalarType, MV, OP >
- Public Member Functions inherited from Belos::Iteration< ScalarType, MV, OP >
 Iteration ()
 Default Constructor. More...
 
virtual ~Iteration ()
 Destructor. More...
 
virtual Teuchos::RCP< const MV > getNativeResiduals (std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > *norms) const =0
 Get the residuals native to the solver. More...
 

Detailed Description

template<class ScalarType, class MV, class OP>
class Belos::CGIter< ScalarType, MV, OP >

This class implements the preconditioned Conjugate Gradient (CG) iteration.

Author
Teri Barth and Heidi Thornquist

Definition at line 79 of file BelosCGIter.hpp.

Member Typedef Documentation

template<class ScalarType , class MV , class OP >
typedef MultiVecTraits<ScalarType,MV> Belos::CGIter< ScalarType, MV, OP >::MVT

Definition at line 86 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
typedef OperatorTraits<ScalarType,MV,OP> Belos::CGIter< ScalarType, MV, OP >::OPT

Definition at line 87 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
typedef Teuchos::ScalarTraits<ScalarType> Belos::CGIter< ScalarType, MV, OP >::SCT

Definition at line 88 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
typedef SCT::magnitudeType Belos::CGIter< ScalarType, MV, OP >::MagnitudeType

Definition at line 89 of file BelosCGIter.hpp.

Constructor & Destructor Documentation

template<class ScalarType , class MV , class OP >
Belos::CGIter< ScalarType, MV, OP >::CGIter ( const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &  problem,
const Teuchos::RCP< OutputManager< ScalarType > > &  printer,
const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &  tester,
const Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP > > &  convTester,
Teuchos::ParameterList params 
)

CGIter constructor with linear problem, solver utilities, and parameter list of solver options.

This constructor takes pointers required by the linear solver iteration, in addition to a parameter list of options for the linear solver.

Definition at line 320 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
virtual Belos::CGIter< ScalarType, MV, OP >::~CGIter ( )
inlinevirtual

Destructor.

Definition at line 106 of file BelosCGIter.hpp.

Member Function Documentation

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::iterate ( )
virtual

This method performs CG iterations until the status test indicates the need to stop or an error occurs (in which case, an std::exception is thrown).

iterate() will first determine whether the solver is initialized; if not, it will call initialize() using default arguments. After initialization, the solver performs CG iterations until the status test evaluates as Passed, at which point the method returns to the caller.

The status test is queried at the beginning of the iteration.

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

Definition at line 447 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::initializeCG ( CGIterationState< ScalarType, MV > &  newstate)
virtual

Initialize the solver to an iterate, providing a complete state.

The CGIter contains a certain amount of state, consisting of the current residual, preconditioned residual, and decent direction.

initialize() gives the user the opportunity to manually set these, although only the current unpreconditioned residual is required.

Postcondition
isInitialized() == true (see post-conditions of isInitialize())
Note
For any pointer in newstate which directly points to the multivectors in the solver, the data is not copied.

Implements Belos::CGIteration< ScalarType, MV, OP >.

Definition at line 389 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::initialize ( )
inlinevirtual

Initialize the solver with the initial vectors from the linear problem or random data.

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

Definition at line 146 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
CGIterationState<ScalarType,MV> Belos::CGIter< ScalarType, MV, OP >::getState ( ) const
inlinevirtual

Get the current state of the linear solver.

The data is only valid if isInitialized() == true.

Returns
A CGIterationState object containing const pointers to the current solver state.

Implements Belos::CGIteration< ScalarType, MV, OP >.

Definition at line 158 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
int Belos::CGIter< ScalarType, MV, OP >::getNumIters ( ) const
inlinevirtual

Get the current iteration count.

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

Definition at line 174 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::resetNumIters ( int  iter = 0)
inlinevirtual

Reset the iteration count.

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

Definition at line 177 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<const MV> Belos::CGIter< ScalarType, MV, OP >::getNativeResiduals ( std::vector< MagnitudeType > *  norms) const
inline

Get the norms of the residuals native to the solver.

Returns
A std::vector of length blockSize containing the native residuals.

Definition at line 181 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::getCurrentUpdate ( ) const
inlinevirtual

Get the current update to the linear system.

Note
This method returns a null pointer because the linear problem is current.

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

Definition at line 192 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
const LinearProblem<ScalarType,MV,OP>& Belos::CGIter< ScalarType, MV, OP >::getProblem ( ) const
inlinevirtual

Get a constant reference to the linear problem.

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

Definition at line 200 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
int Belos::CGIter< ScalarType, MV, OP >::getBlockSize ( ) const
inlinevirtual

Get the blocksize to be used by the iterative solver in solving this linear problem.

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

Definition at line 203 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::setBlockSize ( int  blockSize)
inlinevirtual

Set the blocksize to be used by the iterative solver in solving this linear problem.

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

Definition at line 206 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::isInitialized ( )
inlinevirtual

States whether the solver has been initialized or not.

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

Definition at line 212 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::setDoCondEst ( bool  val)
inlinevirtual

Sets whether or not to store the diagonal for condition estimation.

Implements Belos::CGIteration< ScalarType, MV, OP >.

Definition at line 216 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::ArrayView<MagnitudeType> Belos::CGIter< ScalarType, MV, OP >::getDiag ( )
inlinevirtual

Gets the diagonal for condition estimation.

Implements Belos::CGIteration< ScalarType, MV, OP >.

Definition at line 221 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::ArrayView<MagnitudeType> Belos::CGIter< ScalarType, MV, OP >::getOffDiag ( )
inlinevirtual

Gets the off-diagonal for condition estimation.

Implements Belos::CGIteration< ScalarType, MV, OP >.

Definition at line 234 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
void Belos::CGIter< ScalarType, MV, OP >::setStateSize ( )
private

Method for initalizing the state storage needed by CG.

Definition at line 342 of file BelosCGIter.hpp.

Member Data Documentation

template<class ScalarType , class MV , class OP >
const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > Belos::CGIter< ScalarType, MV, OP >::lp_
private

Definition at line 261 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
const Teuchos::RCP<OutputManager<ScalarType> > Belos::CGIter< ScalarType, MV, OP >::om_
private

Definition at line 262 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > Belos::CGIter< ScalarType, MV, OP >::stest_
private

Definition at line 263 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
const Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > Belos::CGIter< ScalarType, MV, OP >::convTest_
private

Definition at line 264 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::initialized_
private

Definition at line 272 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::stateStorageInitialized_
private

Definition at line 277 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
int Belos::CGIter< ScalarType, MV, OP >::iter_
private

Definition at line 280 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::foldConvergenceDetectionIntoAllreduce_
private

Definition at line 283 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
ScalarType Belos::CGIter< ScalarType, MV, OP >::rHr_
private

Definition at line 286 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::assertPositiveDefiniteness_
private

Definition at line 289 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::ArrayRCP<MagnitudeType> Belos::CGIter< ScalarType, MV, OP >::diag_
private

Definition at line 292 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::ArrayRCP<MagnitudeType> Belos::CGIter< ScalarType, MV, OP >::offdiag_
private

Definition at line 292 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
int Belos::CGIter< ScalarType, MV, OP >::numEntriesForCondEst_
private

Definition at line 293 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::CGIter< ScalarType, MV, OP >::doCondEst_
private

Definition at line 294 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::R_
private

Definition at line 302 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::Z_
private

Definition at line 305 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::P_
private

Definition at line 308 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::AP_
private

Definition at line 311 of file BelosCGIter.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::CGIter< ScalarType, MV, OP >::S_
private

Definition at line 313 of file BelosCGIter.hpp.


The documentation for this class was generated from the following file: