Belos Package Browser (Single Doxygen Collection)
Development
|
An implementation of StatusTestResNorm using a family of residual norms. More...
#include <BelosStatusTestGenResNorm.hpp>
Public Types | |
typedef Teuchos::ScalarTraits< ScalarType > | SCT |
typedef SCT::magnitudeType | MagnitudeType |
typedef MultiVecTraits< ScalarType, MV > | MVT |
![]() | |
typedef Teuchos::ScalarTraits< ScalarType > | SCT |
typedef SCT::magnitudeType | MagnitudeType |
typedef MultiVecTraits< ScalarType, MV > | MVT |
Enums. | |
enum | ResType { Implicit, Explicit } |
Select how the residual std::vector is produced. More... | |
Constructors/destructors. | |
StatusTestGenResNorm (MagnitudeType Tolerance, int quorum=-1, bool showMaxResNormOnly=false) | |
Constructor. More... | |
virtual | ~StatusTestGenResNorm () |
Destructor. More... | |
Form and parameter definition methods. | |
int | defineResForm (ResType TypeOfResidual, NormType TypeOfNorm) |
Define form of the residual, its norm and optional weighting std::vector. More... | |
int | defineScaleForm (ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue=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 tolerance) |
Set the value of the tolerance. More... | |
int | setQuorum (int quorum) |
Sets the number of residuals that must pass the convergence test before Passed is returned. More... | |
int | setShowMaxResNormOnly (bool showMaxResNormOnly) |
Set whether the only maximum residual norm is displayed when the print() method is called. More... | |
Status methods | |
StatusType | checkStatus (Iteration< ScalarType, MV, OP > *iSolver) |
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 &os, int indent=0) const |
Output formatted description of stopping test to output stream. More... | |
void | printStatus (std::ostream &os, StatusType type) 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... | |
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, ![]() | |
const std::vector< MagnitudeType > * | getTestValue () const |
Returns the test value, ![]() | |
const std::vector< MagnitudeType > * | getResNormValue () const |
Returns the residual norm value, ![]() | |
const std::vector< MagnitudeType > * | getScaledNormValue () const |
Returns the scaled norm value, ![]() | |
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... | |
Private methods. | |
std::string | resFormStr () const |
Description of current residual form. More... | |
Private data members. | |
MagnitudeType | tolerance_ |
Tolerance used to determine convergence. More... | |
int | quorum_ |
Number of residuals that must pass the convergence test before Passed is returned. More... | |
bool | showMaxResNormOnly_ |
Determines if the entries for all of the residuals are shown or just the max. More... | |
ResType | restype_ |
Type of residual to use (explicit or implicit) More... | |
NormType | resnormtype_ |
Type of norm to use on residual (OneNorm, TwoNorm, or InfNorm). More... | |
ScaleType | scaletype_ |
Type of scaling to use (Norm of RHS, Norm of Initial Residual, None or User provided) More... | |
NormType | scalenormtype_ |
Type of norm to use on the scaling (OneNorm, TwoNorm, or InfNorm) More... | |
MagnitudeType | scalevalue_ |
Scaling value. More... | |
std::vector< MagnitudeType > | scalevector_ |
Scaling std::vector. More... | |
std::vector< MagnitudeType > | resvector_ |
Residual norm std::vector. More... | |
std::vector< MagnitudeType > | testvector_ |
Test std::vector = resvector_ / scalevector_. More... | |
std::vector< int > | ind_ |
Vector containing the indices for the vectors that passed the test. More... | |
Teuchos::RCP< MV > | curSoln_ |
Most recent solution vector used by this status test. More... | |
StatusType | status_ |
Status. More... | |
int | curBlksz_ |
The current blocksize of the linear system being solved. More... | |
int | curNumRHS_ |
The current number of right-hand sides being solved for. More... | |
std::vector< int > | curLSIdx_ |
The indices of the current number of right-hand sides being solved for. More... | |
int | curLSNum_ |
The current number of linear systems that have been loaded into the linear problem. More... | |
int | numrhs_ |
The total number of right-hand sides being solved for. More... | |
bool | firstcallCheckStatus_ |
Is this the first time CheckStatus is called? More... | |
bool | firstcallDefineResForm_ |
Is this the first time DefineResForm is called? More... | |
bool | firstcallDefineScaleForm_ |
Is this the first time DefineScaleForm is called? More... | |
Additional Inherited Members | |
![]() | |
virtual int | setTolerance (MagnitudeType tolerance)=0 |
Set the value of the tolerance. More... | |
virtual int | defineScaleForm (ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue=Teuchos::ScalarTraits< MagnitudeType >::one())=0 |
Define the form of the scaling for the residual. More... | |
![]() | |
StatusTest () | |
Constructor. More... | |
virtual | ~StatusTest () |
Destructor. More... | |
![]() | |
DescribableStreamManipulatorState | describe (const Describable &describable, const EVerbosityLevel verbLevel=Describable::verbLevel_default) |
std::ostream & | operator<< (std::ostream &os, const DescribableStreamManipulatorState &d) |
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 |
![]() | |
static const EVerbosityLevel | verbLevel_default |
An implementation of StatusTestResNorm using a family of residual norms.
StatusTestGenResNorm 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. The form of the test is
where
Definition at line 79 of file BelosStatusTestGenResNorm.hpp.
typedef Teuchos::ScalarTraits<ScalarType> Belos::StatusTestGenResNorm< ScalarType, MV, OP >::SCT |
Definition at line 84 of file BelosStatusTestGenResNorm.hpp.
typedef SCT::magnitudeType Belos::StatusTestGenResNorm< ScalarType, MV, OP >::MagnitudeType |
Definition at line 85 of file BelosStatusTestGenResNorm.hpp.
typedef MultiVecTraits<ScalarType,MV> Belos::StatusTestGenResNorm< ScalarType, MV, OP >::MVT |
Definition at line 86 of file BelosStatusTestGenResNorm.hpp.
enum Belos::StatusTestGenResNorm::ResType |
Select how the residual std::vector is produced.
Enumerator | |
---|---|
Implicit | Use the residual std::vector produced by the iterative solver. |
Explicit | Explicitly compute the residual std::vector r = b - A*x using the linear problem. |
Definition at line 94 of file BelosStatusTestGenResNorm.hpp.
Belos::StatusTestGenResNorm< ScalarType, MV, OP >::StatusTestGenResNorm | ( | MagnitudeType | Tolerance, |
int | quorum = -1 , |
||
bool | showMaxResNormOnly = false |
||
) |
Constructor.
The constructor takes a single argument specifying the tolerance ( ). If none of the form definition methods are called, we use
as the stopping criterion, where
uses the least costly form of the 2-norm of residual available from the iterative method and
is the corresponding norm of the initial residual. The least costly form of the 2-norm depends on the chosen iterative method. Most Krylov methods produce the preconditioned residual std::vector in a form that would be exact in infinite precision arithmetic. This std::vector may be different from the true residual either because left preconditioning was used, or because round-off error has introduced significant error, or both.
You can also state the number of vectors that must pass the convergence criteria before the status test passes by using the quorum
argument.
Definition at line 385 of file BelosStatusTestGenResNorm.hpp.
|
virtual |
Destructor.
Definition at line 408 of file BelosStatusTestGenResNorm.hpp.
int Belos::StatusTestGenResNorm< ScalarType, MV, OP >::defineResForm | ( | ResType | TypeOfResidual, |
NormType | TypeOfNorm | ||
) |
Define form of the residual, its norm and optional weighting std::vector.
This method defines the form of . We specify:
Definition at line 425 of file BelosStatusTestGenResNorm.hpp.
int Belos::StatusTestGenResNorm< ScalarType, MV, OP >::defineScaleForm | ( | ScaleType | TypeOfScaling, |
NormType | TypeOfNorm, | ||
MagnitudeType | ScaleValue = Teuchos::ScalarTraits<MagnitudeType>::one() |
||
) |
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:
User-provided scaling value:
Definition at line 438 of file BelosStatusTestGenResNorm.hpp.
|
inline |
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.
Definition at line 163 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Sets the number of residuals that must pass the convergence test before Passed is returned.
quorum=-1
then all residuals must pass the convergence test before Passed is returned. Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 167 of file BelosStatusTestGenResNorm.hpp.
|
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 170 of file BelosStatusTestGenResNorm.hpp.
|
virtual |
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.
Implements Belos::StatusTest< ScalarType, MV, OP >.
Definition at line 453 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Return the result of the most recent CheckStatus call.
Implements Belos::StatusTest< ScalarType, MV, OP >.
Definition at line 186 of file BelosStatusTestGenResNorm.hpp.
|
virtual |
Resets the internal configuration to the initial state.
Implements Belos::StatusTest< ScalarType, MV, OP >.
Definition at line 412 of file BelosStatusTestGenResNorm.hpp.
|
virtual |
Output formatted description of stopping test to output stream.
Implements Belos::StatusTest< ScalarType, MV, OP >.
Definition at line 589 of file BelosStatusTestGenResNorm.hpp.
|
virtual |
Print message for each status specific to this stopping test.
Reimplemented from Belos::StatusTest< ScalarType, MV, OP >.
Definition at line 621 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns the current solution estimate that was computed for the most recent residual test.
Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 213 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns the number of residuals that must pass the convergence test before Passed is returned.
quorum=-1
then all residuals must pass the convergence test before Passed is returned. Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 217 of file BelosStatusTestGenResNorm.hpp.
|
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 220 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns the std::vector containing the indices of the residuals that passed the test.
Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 223 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns the value of the tolerance, , set in the constructor.
Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 226 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns the test value, , computed in most recent call to CheckStatus.
Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 229 of file BelosStatusTestGenResNorm.hpp.
|
inline |
Returns the residual norm value, , computed in most recent call to CheckStatus.
Definition at line 232 of file BelosStatusTestGenResNorm.hpp.
|
inline |
Returns the scaled norm value, .
Definition at line 235 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Returns a boolean indicating a loss of accuracy has been detected in computing the residual.
Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.
Definition at line 239 of file BelosStatusTestGenResNorm.hpp.
StatusType Belos::StatusTestGenResNorm< ScalarType, MV, OP >::firstCallCheckStatusSetup | ( | Iteration< ScalarType, MV, OP > * | iSolver | ) |
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 641 of file BelosStatusTestGenResNorm.hpp.
|
inlinevirtual |
Method to return description of the maximum iteration status test.
Reimplemented from Teuchos::Describable.
Definition at line 259 of file BelosStatusTestGenResNorm.hpp.
|
inlineprivate |
Description of current residual form.
Definition at line 275 of file BelosStatusTestGenResNorm.hpp.
|
private |
Tolerance used to determine convergence.
Definition at line 314 of file BelosStatusTestGenResNorm.hpp.
|
private |
Number of residuals that must pass the convergence test before Passed is returned.
Definition at line 317 of file BelosStatusTestGenResNorm.hpp.
|
private |
Determines if the entries for all of the residuals are shown or just the max.
Definition at line 320 of file BelosStatusTestGenResNorm.hpp.
|
private |
Type of residual to use (explicit or implicit)
Definition at line 323 of file BelosStatusTestGenResNorm.hpp.
|
private |
Type of norm to use on residual (OneNorm, TwoNorm, or InfNorm).
Definition at line 326 of file BelosStatusTestGenResNorm.hpp.
|
private |
Type of scaling to use (Norm of RHS, Norm of Initial Residual, None or User provided)
Definition at line 329 of file BelosStatusTestGenResNorm.hpp.
|
private |
Type of norm to use on the scaling (OneNorm, TwoNorm, or InfNorm)
Definition at line 332 of file BelosStatusTestGenResNorm.hpp.
|
private |
Scaling value.
Definition at line 335 of file BelosStatusTestGenResNorm.hpp.
|
private |
Scaling std::vector.
Definition at line 338 of file BelosStatusTestGenResNorm.hpp.
|
private |
Residual norm std::vector.
Definition at line 341 of file BelosStatusTestGenResNorm.hpp.
|
private |
Test std::vector = resvector_ / scalevector_.
Definition at line 344 of file BelosStatusTestGenResNorm.hpp.
|
private |
Vector containing the indices for the vectors that passed the test.
Definition at line 347 of file BelosStatusTestGenResNorm.hpp.
|
private |
Most recent solution vector used by this status test.
Definition at line 350 of file BelosStatusTestGenResNorm.hpp.
|
private |
Status.
Definition at line 353 of file BelosStatusTestGenResNorm.hpp.
|
private |
The current blocksize of the linear system being solved.
Definition at line 356 of file BelosStatusTestGenResNorm.hpp.
|
private |
The current number of right-hand sides being solved for.
Definition at line 359 of file BelosStatusTestGenResNorm.hpp.
|
private |
The indices of the current number of right-hand sides being solved for.
Definition at line 362 of file BelosStatusTestGenResNorm.hpp.
|
private |
The current number of linear systems that have been loaded into the linear problem.
Definition at line 365 of file BelosStatusTestGenResNorm.hpp.
|
private |
The total number of right-hand sides being solved for.
Definition at line 368 of file BelosStatusTestGenResNorm.hpp.
|
private |
Is this the first time CheckStatus is called?
Definition at line 371 of file BelosStatusTestGenResNorm.hpp.
|
private |
Is this the first time DefineResForm is called?
Definition at line 374 of file BelosStatusTestGenResNorm.hpp.
|
private |
Is this the first time DefineScaleForm is called?
Definition at line 377 of file BelosStatusTestGenResNorm.hpp.