Belos
Version of the Day
|
A factory for making common cases of stopping criteria. More...
#include <BelosStatusTestFactory.hpp>
Public Types | |
typedef Teuchos::ScalarTraits< Scalar >::magnitudeType | magnitude_type |
typedef StatusTest< Scalar, MV, OP > | base_test |
typedef StatusTestGenResNorm< Scalar, MV, OP > | res_norm_test |
typedef StatusTestMaxIters< Scalar, MV, OP > | max_iter_test |
typedef StatusTestCombo< Scalar, MV, OP > | combo_test |
Public Member Functions | |
Teuchos::RCP< const Teuchos::ParameterList > | getValidGmresParameters () |
Default parameters for a status test suitable for GMRES. More... | |
Static Public Member Functions | |
static Teuchos::RCP< base_test > | gmresTest (const magnitude_type convTol, const int maxIterCount, const bool haveLeftPreconditioner, const ScaleType implicitScaleType=Belos::NormOfPrecInitRes, const ScaleType explicitScaleType=Belos::NormOfInitRes, const int blockSize=1, const int defQuorum=-1, const bool showMaxResNormOnly=false) |
Status test suitable for (preconditioned) GMRES. More... | |
static Teuchos::RCP< base_test > | gmresTest (const bool haveLeftPreconditioner, const Teuchos::RCP< Teuchos::ParameterList > ¶ms) |
Overloaded gmresTest() for ParameterList input. More... | |
static std::pair< bool, bool > | changeConvTolAndMaxIters (const Teuchos::RCP< base_test > &test, const magnitude_type convTol, const int maxIterCount) |
Change convergence tolerance and max number of iterations. More... | |
static bool | changeMaxNumIters (const Teuchos::RCP< base_test > &test, const int maxIterCount) |
Change max number of iterations in place. More... | |
static bool | changeConvTol (const Teuchos::RCP< base_test > &test, const magnitude_type convTol) |
Change convergence tolerance in place. More... | |
static ScaleType | stringToScaleType (const std::string &scaleType) |
Convert string to enum that tells residual test how to scale. More... | |
A factory for making common cases of stopping criteria.
This factory also provides ways to change the convergence tolerance and/or maximum number of iterations, in place, for existing and possibly aggregate status tests. This is an experimental optimization that attempts to avoid the overhead of constructing new status tests, but it comes at the cost of requiring dynamic casts for each test in an aggregate collection (StatusTestCombo) of tests. It may be useful if you are not allowed to create new status test objects, for example if you only have access to them through a copied RCP and not through a reference to the RCP.
The general idea of factory classes like this one is to avoid duplicated code whenever possible. Scientific programmers' time is limited, so it's often better to avoid duplicated code, even if it means adding a new class or making the nonduplicated code a bit more complicated.
Definition at line 81 of file BelosStatusTestFactory.hpp.
typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Belos::StatusTestFactory< Scalar, MV, OP >::magnitude_type |
Definition at line 83 of file BelosStatusTestFactory.hpp.
typedef StatusTest<Scalar,MV,OP> Belos::StatusTestFactory< Scalar, MV, OP >::base_test |
Definition at line 84 of file BelosStatusTestFactory.hpp.
typedef StatusTestGenResNorm<Scalar,MV,OP> Belos::StatusTestFactory< Scalar, MV, OP >::res_norm_test |
Definition at line 85 of file BelosStatusTestFactory.hpp.
typedef StatusTestMaxIters<Scalar,MV,OP> Belos::StatusTestFactory< Scalar, MV, OP >::max_iter_test |
Definition at line 86 of file BelosStatusTestFactory.hpp.
typedef StatusTestCombo<Scalar,MV,OP> Belos::StatusTestFactory< Scalar, MV, OP >::combo_test |
Definition at line 87 of file BelosStatusTestFactory.hpp.
|
static |
Status test suitable for (preconditioned) GMRES.
The returned status test stops iteration if the maximum number of iterations has been reached, OR if the residual norm has converged. The latter first iterates until the implicit residual norm (the one computed as a side effect of solving the projected least-squares problem in GMRES) reaches the given tolerance. Then, it switches to computing the explicit residual norm ( ) and iterates until that has reached the tolerance.
convTol | [in] Convergence tolerance. The meaning of this depends on the scaling used. |
maxIterCount | [in] Maximum number of iterations of GMRES to execute before stopping. |
haveLeftPreconditioner | [in] Whether we will be running GMRES with a left preconditioner. This affects the residual norm computation. |
implicitScaleType | [in] Type of scaling to use for the implicit residual norm computation. Default is to scale by the norm of the preconditioned (if applicable) initial residual vector. The stringToScaleType() method might be useful. |
explicitScaleType | [in] Type of scaling to use for the explicit residual norm computation. Default is to scale by the norm of the (nonpreconditioned) initial residual vector. The stringToScaleType() method might be useful. |
blockSize | [in] Number of linear system(s) that the solver can solve at one time. Block iterative methods support blockSize > 1. Non-block iterative methods require blockSize = 1. This parameter is only used to verify defQuorum, if the latter is not -1. |
defQuorum | [in] "Deflation Quorum": number of converged systems before deflation is allowed. Cannot be larger than "Block Size". -1 is the default in Belos::StatusTestGenResNorm, and it means that all of the systems must converge before deflation is allowed. |
showMaxResNormOnly | [in] "Show Maximum Residual Norm
Only" is only meaningful when the "Block Size" parameter is
|
|
static |
Overloaded gmresTest()
for ParameterList input.
Does the same thing as the other gmresTest()
, except it reads the values from the given parameter list. The parameter list must be nonnull and valid. We make only a modest effort to fill in default values for nonrequired parameters only. We throw std::invalid_argument if any required parameter is missing or any provided value is invalid.
Definition at line 314 of file BelosStatusTestFactory.hpp.
|
static |
Change convergence tolerance and max number of iterations.
The changes take place in place in the given status test. If the status test is a StatusTestCombo, we recurse on all children, changing them if they are of the appropriate type. If we don't find anything to change, we do nothing, except report back in the return value.
|
static |
Change max number of iterations in place.
See the notes for changeConvTolAndMaxIters()
.
Definition at line 405 of file BelosStatusTestFactory.hpp.
|
static |
Change convergence tolerance in place.
See the notes for changeConvTolAndMaxIters()
.
Definition at line 511 of file BelosStatusTestFactory.hpp.
|
static |
Convert string to enum that tells residual test how to scale.
scaleType | [in] A string describing the type of scaling to be used in a residual norm convergence test. Valid values include:
|
Definition at line 560 of file BelosStatusTestFactory.hpp.
Teuchos::RCP<const Teuchos::ParameterList> Belos::StatusTestFactory< Scalar, MV, OP >::getValidGmresParameters | ( | ) |
Default parameters for a status test suitable for GMRES.
This method is nonconst because it creates and caches the list of default parameters on demand.