Belos  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | List of all members
Belos::StatusTestGenResSubNorm< ScalarType, MV, OP > Class Template Reference

An implementation of StatusTestResNorm using a family of norms of subvectors of the residual vectors. More...

#include <BelosStatusTestGenResSubNorm.hpp>

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

Public Types

typedef Teuchos::ScalarTraits
< ScalarType > 
SCT
 
typedef SCT::magnitudeType MagnitudeType
 
typedef MultiVecTraits
< ScalarType, MV > 
MVT
 
- Public Types inherited from Belos::StatusTestResNorm< ScalarType, MV, OP >
typedef Teuchos::ScalarTraits
< ScalarType > 
SCT
 
typedef SCT::magnitudeType MagnitudeType
 
typedef MultiVecTraits
< ScalarType, MV > 
MVT
 

Public Member Functions

Constructors/destructors.
 StatusTestGenResSubNorm (MagnitudeType, size_t, int=-1, bool=false)
 Constructor. More...
 
virtual ~StatusTestGenResSubNorm ()
 Destructor. More...
 
Form and parameter definition methods.
int defineResForm (NormType)
 Define norm of the residual. More...
 
int defineScaleForm (ScaleType, NormType, MagnitudeType=Teuchos::ScalarTraits< MagnitudeType >::one())
 Define form of the scaling, its norm, its optional weighting std::vector, or, alternatively, define an explicit value. More...
 
int setTolerance (MagnitudeType)
 Set the value of the tolerance. More...
 
int setSubIdx (size_t subIdx)
 Set the block index of which we want to check the norm of the sub-residuals. More...
 
int setQuorum (int)
 Sets the number of residuals that must pass the convergence test before Passed is returned. More...
 
int setShowMaxResNormOnly (bool)
 Set whether the only maximum residual norm is displayed when the print() method is called. More...
 
Status methods
StatusType checkStatus (Iteration< ScalarType, MV, OP > *)
 Check convergence status: Passed, Failed, or Undefined. More...
 
StatusType getStatus () const
 Return the result of the most recent CheckStatus call. More...
 
Reset methods
void reset ()
 Resets the internal configuration to the initial state. More...
 
Print methods
void print (std::ostream &, int=0) const
 Output formatted description of stopping test to output stream. More...
 
void printStatus (std::ostream &, StatusType) const
 Print message for each status specific to this stopping test. More...
 
Methods to access data members.
Teuchos::RCP< MV > getSolution ()
 Returns the current solution estimate that was computed for the most recent residual test. More...
 
int getQuorum () const
 Returns the number of residuals that must pass the convergence test before Passed is returned. More...
 
size_t getSubIdx () const
 Returns the index of the block row the norms are calculated for. More...
 
bool getShowMaxResNormOnly ()
 Returns whether the only maximum residual norm is displayed when the print() method is called. More...
 
std::vector< int > convIndices ()
 Returns the std::vector containing the indices of the residuals that passed the test. More...
 
MagnitudeType getTolerance () const
 Returns the value of the tolerance, $ \tau $, set in the constructor. More...
 
const std::vector
< MagnitudeType > * 
getTestValue () const
 Returns the test value, $ \frac{\|r\|}{\sigma} $, computed in most recent call to CheckStatus. More...
 
const std::vector
< MagnitudeType > * 
getResNormValue () const
 Returns the residual norm value, $ \|r\| $, computed in most recent call to CheckStatus. More...
 
const std::vector
< MagnitudeType > * 
getScaledNormValue () const
 Returns the scaled norm value, $ \sigma $. More...
 
bool getLOADetected () const
 Returns a boolean indicating a loss of accuracy has been detected in computing the residual. More...
 
Misc.
StatusType firstCallCheckStatusSetup (Iteration< ScalarType, MV, OP > *iSolver)
 Call to setup initial scaling std::vector. More...
 
Overridden from Teuchos::Describable
std::string description () const
 Method to return description of the maximum iteration status test. More...
 
Form and parameter definition methods.
Methods to access data members.
- Public Member Functions inherited from Belos::StatusTest< ScalarType, MV, OP >
 StatusTest ()
 Constructor. More...
 
virtual ~StatusTest ()
 Destructor. More...
 
- Public Member Functions inherited from Teuchos::Describable
virtual void describe (FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 
void describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 
virtual ~Describable ()
 
 LabeledObject ()
 
virtual ~LabeledObject ()
 
virtual void setObjectLabel (const std::string &objectLabel)
 
virtual std::string getObjectLabel () const
 
DescribableStreamManipulatorState describe (const Describable &describable, const EVerbosityLevel verbLevel=Describable::verbLevel_default)
 
std::ostream & operator<< (std::ostream &os, const DescribableStreamManipulatorState &d)
 

Additional Inherited Members

- Static Public Attributes inherited from Teuchos::Describable
static const EVerbosityLevel verbLevel_default
 

Detailed Description

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

An implementation of StatusTestResNorm using a family of norms of subvectors of the residual vectors.

StatusTestGenResSubNorm is an implementation of StatusTestResNorm that allows a user to construct one of a family of residual tests for use as a status/convergence test for Belos.

Definition at line 40 of file BelosStatusTestGenResSubNorm.hpp.

Member Typedef Documentation

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

Definition at line 44 of file BelosStatusTestGenResSubNorm.hpp.

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

Definition at line 45 of file BelosStatusTestGenResSubNorm.hpp.

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

Definition at line 46 of file BelosStatusTestGenResSubNorm.hpp.

Constructor & Destructor Documentation

template<class ScalarType , class MV , class OP >
Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::StatusTestGenResSubNorm ( MagnitudeType  ,
size_t  ,
int  = -1,
bool  = false 
)
inline

Constructor.

The constructor takes a single argument specifying the tolerance ( $\tau$). If none of the form definition methods are called, we use $\|r\|_2/\|r^{(0)}\|_2 \le \tau$ as the stopping criterion, where $\|r\|_2$ uses the least costly form of the 2-norm of residual available from the iterative method and $\|r^{(0)}\|_2$ is the corresponding norm of the initial residual. The least costly form of the 2-norm depends on the chosen iterative method.

Parameters
Tolerance,:Specifies tolerance $\tau$
subIdx,:index of block row in the n x n block system we want to check the residual of
quorum,:Number of residual (sub-)vectors which are needed to be within the tolerance before check is considered to be passed
showMaxResNormOnly,:for output only

Definition at line 64 of file BelosStatusTestGenResSubNorm.hpp.

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

Destructor.

Definition at line 70 of file BelosStatusTestGenResSubNorm.hpp.

Member Function Documentation

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::defineResForm ( NormType  )
inline

Define norm of the residual.

This method defines the form of $\|r\|$. We specify:

  • The norm to be used on the residual (this may be different than the norm used in DefineScaleForm()).

Definition at line 83 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::defineScaleForm ( ScaleType  ,
NormType  ,
MagnitudeType  = Teuchos::ScalarTraits<MagnitudeType>::one() 
)
inlinevirtual

Define form of the scaling, its norm, its optional weighting std::vector, or, alternatively, define an explicit value.

This method defines the form of how the residual is scaled (if at all). It operates in two modes:

  1. User-provided scaling value:

    • Set argument TypeOfScaling to UserProvided.
    • Set ScaleValue to a non-zero value that the residual norm will be divided by.
    • TypeOfNorm argument will be ignored.
    • Sample use: Define ScaleValue = $\|A\|_{\infty}$ where $ A $ is the matrix of the linear problem.

  2. Use a supported Scaling Form:
    • Define TypeOfScaling to be the norm of the right hand side, the initial residual std::vector, or to none.
    • Define norm to be used on the scaling std::vector (this may be different than the norm used in DefineResForm()).

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

Definition at line 110 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::setTolerance ( MagnitudeType  )
inlinevirtual

Set the value of the tolerance.

We allow the tolerance to be reset for cases where, in the process of testing the residual, we find that the initial tolerance was too tight or too lax.

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

Definition at line 120 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::setSubIdx ( size_t  subIdx)
inline

Set the block index of which we want to check the norm of the sub-residuals.

It does not really make sense to change/reset the index during the solution process

Definition at line 125 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::setQuorum ( int  )
inlinevirtual

Sets the number of residuals that must pass the convergence test before Passed is returned.

Note
If quorum=-1 then all residuals must pass the convergence test before Passed is returned.

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

Definition at line 129 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::setShowMaxResNormOnly ( bool  )
inlinevirtual

Set whether the only maximum residual norm is displayed when the print() method is called.

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

Definition at line 132 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::checkStatus ( Iteration< ScalarType, MV, OP > *  )
inlinevirtual

Check convergence status: Passed, Failed, or Undefined.

This method checks to see if the convergence criteria are met. Depending on how the residual test is constructed this method will return the appropriate status type.

Returns
StatusType: Passed, Failed, or Undefined.

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

Definition at line 145 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getStatus ( ) const
inlinevirtual

Return the result of the most recent CheckStatus call.

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

Definition at line 148 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::reset ( )
inlinevirtual

Resets the internal configuration to the initial state.

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

Definition at line 155 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::print ( std::ostream &  ,
int  = 0 
) const
inlinevirtual

Output formatted description of stopping test to output stream.

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

Definition at line 163 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::printStatus ( std::ostream &  ,
StatusType   
) const
inlinevirtual

Print message for each status specific to this stopping test.

Reimplemented from Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 166 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getSolution ( )
inlinevirtual

Returns the current solution estimate that was computed for the most recent residual test.

Note
This is useful for explicit residual tests, if this test is an implicit residual test a null pointer will be returned.

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

Definition at line 175 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getQuorum ( ) const
inlinevirtual

Returns the number of residuals that must pass the convergence test before Passed is returned.

Note
If quorum=-1 then all residuals must pass the convergence test before Passed is returned.

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

Definition at line 179 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
size_t Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getSubIdx ( ) const
inline

Returns the index of the block row the norms are calculated for.

Definition at line 182 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getShowMaxResNormOnly ( )
inlinevirtual

Returns whether the only maximum residual norm is displayed when the print() method is called.

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

Definition at line 185 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<int> Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::convIndices ( )
inlinevirtual

Returns the std::vector containing the indices of the residuals that passed the test.

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

Definition at line 188 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getTolerance ( ) const
inlinevirtual

Returns the value of the tolerance, $ \tau $, set in the constructor.

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

Definition at line 191 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getTestValue ( ) const
inlinevirtual

Returns the test value, $ \frac{\|r\|}{\sigma} $, computed in most recent call to CheckStatus.

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

Definition at line 194 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getResNormValue ( ) const
inline

Returns the residual norm value, $ \|r\| $, computed in most recent call to CheckStatus.

Definition at line 197 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getScaledNormValue ( ) const
inline

Returns the scaled norm value, $ \sigma $.

Definition at line 200 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::getLOADetected ( ) const
inlinevirtual

Returns a boolean indicating a loss of accuracy has been detected in computing the residual.

Note
This status test does not check for loss of accuracy, so this method will always return false.

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

Definition at line 204 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::firstCallCheckStatusSetup ( Iteration< ScalarType, MV, OP > *  iSolver)
inline

Call to setup initial scaling std::vector.

After this function is called getScaledNormValue() can be called to get the scaling std::vector.

Definition at line 217 of file BelosStatusTestGenResSubNorm.hpp.

template<class ScalarType , class MV , class OP >
std::string Belos::StatusTestGenResSubNorm< ScalarType, MV, OP >::description ( ) const
inlinevirtual

Method to return description of the maximum iteration status test.

Reimplemented from Teuchos::Describable.

Definition at line 226 of file BelosStatusTestGenResSubNorm.hpp.


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

Generated on Thu Nov 21 2024 09:25:08 for Belos by doxygen 1.8.5