10 #ifndef BELOS_CG_SINGLE_RED_ITER_HPP 
   11 #define BELOS_CG_SINGLE_RED_ITER_HPP 
   53   template <
class ScalarType, 
class MV>
 
   71       W = MVT::Clone( *tmp, 3 );
 
   72       std::vector<int> index2(2,0);
 
   73       std::vector<int> index(1,0);
 
   78       S = MVT::CloneViewNonConst( *
W, index2 );
 
   83       U = MVT::CloneViewNonConst( *
W, index2 );
 
   86       this->
R = MVT::CloneViewNonConst( *
W, index );
 
   88       AZ = MVT::CloneViewNonConst( *
W, index );
 
   90       this->
Z = MVT::CloneViewNonConst( *
W, index );
 
   95       T = MVT::CloneViewNonConst( *
W, index2 );
 
   98       V = MVT::Clone( *tmp, 2 );
 
  100       this->
AP = MVT::CloneViewNonConst( *
V, index );
 
  102       this->
P = MVT::CloneViewNonConst( *
V, index );
 
  126 template<
class ScalarType, 
class MV, 
class OP>
 
  269            "Belos::CGSingleRedIter::setBlockSize(): Cannot use a block size that is not one.");
 
  317   bool foldConvergenceDetectionIntoAllreduce_;
 
  353   template<
class ScalarType, 
class MV, 
class OP>
 
  362     convTest_(convTester),
 
  366     foldConvergenceDetectionIntoAllreduce_ = params.
get<
bool>(
"Fold Convergence Detection Into Allreduce",
false);
 
  371   template <
class ScalarType, 
class MV, 
class OP>
 
  380       newstate->initialize(tmp, 1);
 
  383     std::string errstr(
"Belos::CGSingleRedIter::initialize(): Specified multivectors must have a consistent length and width.");
 
  388                           std::invalid_argument, errstr );
 
  390                           std::invalid_argument, errstr );
 
  395   MVT::Assign( *R_0, *R_ );
 
  401       if ( lp_->getLeftPrec() != Teuchos::null ) {
 
  402         lp_->applyLeftPrec( *R_, *Z_ );
 
  403         if ( lp_->getRightPrec() != Teuchos::null ) {
 
  405           lp_->applyRightPrec( *Z_, *tmp2 );
 
  406           MVT::Assign( *tmp2, *Z_ );
 
  409       else if ( lp_->getRightPrec() != Teuchos::null ) {
 
  410         lp_->applyRightPrec( *R_, *Z_ );
 
  413         MVT::Assign( *R_, *Z_ );
 
  417       lp_->applyOp( *Z_, *AZ_ );
 
  421       MVT::Assign( *U_, *V_);
 
  431   template <
class ScalarType, 
class MV, 
class OP>
 
  436       return Teuchos::null;
 
  437     } 
else if (foldConvergenceDetectionIntoAllreduce_ && convTest_->getResNormType() == 
Belos::TwoNorm) {
 
  439       return Teuchos::null;
 
  447   template <
class ScalarType, 
class MV, 
class OP>
 
  474                         "Belos::CGSingleRedIter::iterate(): current linear system has more than one vector!" );
 
  476     if (foldConvergenceDetectionIntoAllreduce_ && convTest_->getResNormType() == 
Belos::TwoNorm) {
 
  478       MVT::MvTransMv( one, *S_, *T_, sHt );
 
  484       MVT::MvTransMv( one, *S_, *Z_, sHz );
 
  489         (stest_->checkStatus(
this) == 
Passed))
 
  491     alpha = rHz_ / delta;
 
  495       "Belos::CGSingleRedIter::iterate(): non-positive value for p^H*A*p encountered!" );
 
  500     if (foldConvergenceDetectionIntoAllreduce_ && convTest_->getResNormType() == 
Belos::TwoNorm) {
 
  508         MVT::MvAddMv( one, *cur_soln_vec, alpha, *P_, *cur_soln_vec );
 
  512         MVT::MvAddMv( one, *R_, -alpha, *AP_, *R_ );
 
  516         if ( lp_->getLeftPrec() != Teuchos::null ) {
 
  517           lp_->applyLeftPrec( *R_, *Z_ );
 
  518           if ( lp_->getRightPrec() != Teuchos::null ) {
 
  520             lp_->applyRightPrec( *tmp, *Z_ );
 
  523         else if ( lp_->getRightPrec() != Teuchos::null ) {
 
  524           lp_->applyRightPrec( *R_, *Z_ );
 
  527           MVT::Assign( *R_, *Z_ );
 
  531         lp_->applyOp( *Z_, *AZ_ );
 
  534         MVT::MvTransMv( one, *S_, *T_, sHt );
 
  547         if (stest_->checkStatus(
this) == 
Passed) {
 
  551         beta = rHz_ / rHz_old;
 
  552         alpha = rHz_ / (delta - (beta*rHz_ / alpha));
 
  556                                     "Belos::CGSingleRedIter::iterate(): non-positive value for p^H*A*p encountered!" );
 
  563         MVT::MvAddMv( one, *U_, beta, *V_, *V_ );
 
  574         MVT::MvAddMv( one, *cur_soln_vec, alpha, *P_, *cur_soln_vec );
 
  578         MVT::MvAddMv( one, *R_, -alpha, *AP_, *R_ );
 
  585         if (stest_->checkStatus(
this) == 
Passed) {
 
  591         if ( lp_->getLeftPrec() != Teuchos::null ) {
 
  592           lp_->applyLeftPrec( *R_, *Z_ );
 
  593           if ( lp_->getRightPrec() != Teuchos::null ) {
 
  595             lp_->applyRightPrec( *tmp, *Z_ );
 
  598         else if ( lp_->getRightPrec() != Teuchos::null ) {
 
  599           lp_->applyRightPrec( *R_, *Z_ );
 
  602           MVT::Assign( *R_, *Z_ );
 
  606         lp_->applyOp( *Z_, *AZ_ );
 
  609         MVT::MvTransMv( one, *S_, *Z_, sHz );
 
  616         beta = rHz_ / rHz_old;
 
  617         alpha = rHz_ / (delta - (beta*rHz_ / alpha));
 
  621                                     "Belos::CGSingleRedIter::iterate(): non-positive value for p^H*A*p encountered!" );
 
  628         MVT::MvAddMv( one, *U_, beta, *V_, *V_ );
 
virtual ~CGSingleRedIterationState()=default
Collection of types and exceptions used within the Belos solvers. 
void setState(Teuchos::RCP< CGIterationStateBase< ScalarType, MV > > state)
int getBlockSize() const 
Get the blocksize to be used by the iterative solver in solving this linear problem. 
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Class which manages the output and verbosity of the Belos solvers. 
Teuchos::RCP< MV > getCurrentUpdate() const 
Get the current update to the linear system. 
int getNumIters() const 
Get the current iteration count. 
const LinearProblem< ScalarType, MV, OP > & getProblem() const 
Get a constant reference to the linear problem. 
void initialize(Teuchos::RCP< const MV > tmp, int _numVectors)
Pure virtual base class which augments the basic interface for a conjugate gradient linear solver ite...
T & get(const std::string &name, T def_value)
Structure to contain pointers to CGSingleRedIteration state variables. 
Pure virtual base class for defining the status testing capabilities of Belos. 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Declaration of basic traits for the multivector type. 
An implementation of StatusTestResNorm using a family of residual norms. 
void iterate()
This method performs CG iterations until the status test indicates the need to stop or an error occur...
A pure virtual class for defining the status tests for the Belos iterative solvers. 
Class which defines basic traits for the operator type. 
bool matches(Teuchos::RCP< const MV > tmp, int _numVectors=1) const 
CGIterateFailure is thrown when the CGIteration object is unable to compute the next iterate in the C...
CGSingleRedIterationState(Teuchos::RCP< const MV > tmp)
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *norms) const 
Get the norms of the residuals native to the solver. 
Teuchos::RCP< MV > P
The current decent direction vector. 
Traits class which defines basic operations on multivectors. 
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data. 
CGPositiveDefiniteFailure is thrown when the the CG 'alpha = p^H*A*P' value is less than zero...
typename SCT::magnitudeType MagnitudeType
Teuchos::ArrayView< MagnitudeType > getOffDiag()
Gets the off-diagonal for condition estimation (NOT_IMPLEMENTED) 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setBlockSize(int blockSize)
Set the blocksize to be used by the iterative solver in solving this linear problem. 
virtual void initialize(Teuchos::RCP< const MV > tmp, int _numVectors)
A linear system to solve, and its associated information. 
Class which describes the linear problem to be solved by the iterative solver. 
bool isInitialized()
States whether the solver has been initialized or not. 
CGSingleRedIterationState()=default
Teuchos::RCP< CGIterationStateBase< ScalarType, MV > > getState() const 
Get the current state of the linear solver. 
Structure to contain pointers to CGIteration state variables. 
Teuchos::RCP< MV > Z
The current preconditioned residual. 
Teuchos::RCP< MV > AP
The matrix A applied to current decent direction vector. 
CGSingleRedIter(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 ¶ms)
CGSingleRedIter constructor with linear problem, solver utilities, and parameter list of solver optio...
Belos::StatusTestResNorm for specifying general residual norm stopping criteria. 
Class which defines basic traits for the operator type. 
This class implements the preconditioned single-reduction Conjugate Gradient (CG) iteration...
#define TEUCHOS_ASSERT(assertion_test)
virtual ~CGSingleRedIter()=default
Destructor. 
Teuchos::RCP< MV > R
The current residual. 
Belos header file which uses auto-configuration information to include necessary C++ headers...
void resetNumIters(int iter=0)
Reset the iteration count. 
void initializeCG(Teuchos::RCP< CGIterationStateBase< ScalarType, MV > > newstate, Teuchos::RCP< MV > R_0)
Initialize the solver to an iterate, providing a complete state. 
void setDoCondEst(bool)
Sets whether or not to store the diagonal for condition estimation. 
Teuchos::ArrayView< MagnitudeType > getDiag()
Gets the diagonal for condition estimation (NOT_IMPLEMENTED)