11#ifndef BELOS_STATUS_TEST_LOGRESNORM_HPP
12#define BELOS_STATUS_TEST_LOGRESNORM_HPP
20#include "Teuchos_ScalarTraits.hpp"
21#include "Teuchos_RCP.hpp"
34template <
class ScalarType,
class MV,
class OP,
class DM = DefaultDenseMatrix<
int,ScalarType>>
39 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
MagnitudeType;
80 void setMaxIters(
int maxIters) { maxIters_ = maxIters; logResNorm_.reserve( maxIters_ ); }
94 const std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>&
103 void print(std::ostream& os,
int indent = 0)
const;
116 std::ostringstream oss;
133 std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> logResNorm_;
139 template <
class ScalarType,
class MV,
class OP,
class DM>
145 maxIters_ = maxIters;
147 logResNorm_.reserve( maxIters_ );
152 template <
class ScalarType,
class MV,
class OP,
class DM>
162 if ( (numRHS==1) && (blkSize==1) && (currIters!=nIters_) )
164 std::vector<MagnitudeType> tmp_resvector( 1 );
166 if (! residMV.is_null ())
172 logResNorm_.push_back( tmp_resvector[0] );
179 template <
class ScalarType,
class MV,
class OP,
class DM>
184 logResNorm_.reserve( maxIters_ );
187 template <
class ScalarType,
class MV,
class OP,
class DM>
190 for (
int j = 0; j < indent; j ++)
193 os <<
"Logging Absolute Residual 2-Norm" << std::endl;
196 template <
class ScalarType,
class MV,
class OP,
class DM>
199 os << std::left << std::setw(13) << std::setfill(
'.');
201 os << std::left << std::setfill(
' ');
Pure virtual base class for defining the status testing capabilities of Belos.
virtual Teuchos::RCP< const MV > getNativeResiduals(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > *norms) const =0
virtual int getNumIters() const =0
Get the current iteration count.
virtual const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const =0
Get a constant reference to the linear problem.
Teuchos::RCP< const MV > getRHS() const
A pointer to the right-hand side B.
const std::vector< int > & getLSIndex() const
(Zero-based) indices of the linear system(s) currently being solved.
Traits class which defines basic operations on multivectors.
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm)
static int GetNumberVecs(const MV &mv)
void reset()
Resets the status test to the initial internal state.
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
The type of the magnitude (absolute value) of a ScalarType.
void setMaxIters(int maxIters)
Sets the maximum number of iterations allowed so internal storage can be resized.
int getMaxIters() const
Returns the maximum number of iterations set in the constructor.
const std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > & getLogResNorm() const
Returns the log of the absolute residual norm from the iteration.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
StatusTestLogResNorm(int maxIters)
Constructor.
virtual ~StatusTestLogResNorm()
Destructor.
std::string description() const
Method to return description of the debugging status test.
int getNumIters() const
Returns the current number of iterations from the most recent StatusTest call.
void printStatus(std::ostream &os, StatusType type) const
Print message for each status specific to this stopping test.
StatusType checkStatus(Iteration< ScalarType, MV, OP, DM > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed.
StatusType getStatus() const
Return the result of the most recent CheckStatus call.
StatusType
Whether the StatusTest wants iteration to stop.