50 #ifndef BELOS_TFQMR_ITER_HPP
51 #define BELOS_TFQMR_ITER_HPP
95 template <
class ScalarType,
class MV>
107 Rtilde(Teuchos::null),
D(Teuchos::null),
V(Teuchos::null)
143 template <
class ScalarType,
class MV,
class OP>
281 "Belos::TFQMRIter::setBlockSize(): Cannot use a block size that is not one.");
311 std::vector<MagnitudeType> tau_, cs_, theta_;
324 bool stateStorageInitialized_;
348 template <
class ScalarType,
class MV,
class OP>
364 stateStorageInitialized_(false),
371 template <
class ScalarType,
class MV,
class OP>
379 return Teuchos::null;
385 template <
class ScalarType,
class MV,
class OP>
388 if (!stateStorageInitialized_) {
393 if (lhsMV == Teuchos::null && rhsMV == Teuchos::null) {
394 stateStorageInitialized_ =
false;
401 if (R_ == Teuchos::null) {
405 "Belos::TFQMRIter::setStateSize(): linear problem does not specify multivectors to clone from.");
406 R_ = MVT::Clone( *tmp, 1 );
407 AU_ = MVT::Clone( *tmp, 1 );
408 D_ = MVT::Clone( *tmp, 1 );
409 V_ = MVT::Clone( *tmp, 1 );
413 stateStorageInitialized_ =
true;
420 template <
class ScalarType,
class MV,
class OP>
424 if (!stateStorageInitialized_)
428 "Belos::TFQMRIter::initialize(): Cannot initialize state storage!");
432 std::string errstr(
"Belos::TFQMRIter::initialize(): Specified multivectors must have a consistent length and width.");
439 if (newstate.
R != Teuchos::null) {
442 std::invalid_argument, errstr );
444 std::invalid_argument, errstr );
447 if (newstate.
R != R_) {
449 MVT::MvAddMv( one, *newstate.
R, STzero, *newstate.
R, *R_ );
455 W_ = MVT::CloneCopy( *R_ );
456 U_ = MVT::CloneCopy( *R_ );
457 Rtilde_ = MVT::CloneCopy( *R_ );
462 lp_->apply( *U_, *V_ );
463 AU_ = MVT::CloneCopy( *V_ );
468 MVT::MvNorm( *R_, tau_ );
469 MVT::MvTransMv( one, *Rtilde_, *R_, rho_old_ );
474 "Belos::TFQMRIter::initialize(): TFQMRIterState does not have initial residual.");
484 template <
class ScalarType,
class MV,
class OP>
490 if (initialized_ ==
false) {
498 ScalarType eta = STzero, beta = STzero;
507 "Belos::TFQMRIter::iterate(): current linear system has more than one vector!" );
513 while (stest_->checkStatus(
this) !=
Passed) {
521 MVT::MvTransMv( STone, *Rtilde_, *V_, alpha_ );
522 alpha_(0,0) = rho_old_(0,0)/alpha_(0,0);
530 MVT::MvAddMv( STone, *W_, -alpha_(0,0), *AU_, *W_ );
537 MVT::MvAddMv( STone, *U_, (theta_[0]*theta_[0]/alpha_(0,0))*eta, *D_, *D_ );
548 MVT::MvAddMv( STone, *U_, -alpha_(0,0), *V_, *U_ );
551 lp_->apply( *U_, *AU_ );
558 MVT::MvNorm( *W_, theta_ );
559 theta_[0] /= tau_[0];
562 tau_[0] *= theta_[0]*cs_[0];
563 eta = cs_[0]*cs_[0]*alpha_(0,0);
570 lp_->updateSolution( D_,
true, eta );
578 MVT::MvTransMv( STone, *Rtilde_, *W_, rho_ );
579 beta = rho_(0,0)/rho_old_(0,0);
580 rho_old_(0,0) = rho_(0,0);
587 MVT::MvAddMv( STone, *W_, beta, *U_, *U_ );
590 MVT::MvAddMv( STone, *AU_, beta, *V_, *V_ );
593 lp_->apply( *U_, *AU_ );
596 MVT::MvAddMv( STone, *AU_, beta, *V_, *V_ );
607 #endif // BELOS_TFQMR_ITER_HPP
Teuchos::RCP< const MV > V
Collection of types and exceptions used within the Belos solvers.
This class implements the preconditioned transpose-free QMR algorithm for solving non-Hermitian linea...
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Teuchos::ScalarTraits< ScalarType > SCT
SCT::magnitudeType MagnitudeType
void initializeTFQMR(TFQMRIterState< ScalarType, MV > newstate)
Initialize the solver to an iterate, providing a complete state.
OperatorTraits< ScalarType, MV, OP > OPT
TFQMRIterateFailure(const std::string &what_arg)
void setBlockSize(int blockSize)
Set the blocksize.
Class which manages the output and verbosity of the Belos solvers.
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.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
TFQMRIter(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &tester, Teuchos::ParameterList ¶ms)
Belos::TFQMRIter constructor.
virtual ~TFQMRIter()
Belos::TFQMRIter destructor.
An extension of the MultiVecTraits class that adds a new vector length method.
Teuchos::RCP< const MV > R
The current residual basis.
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *norms) const
Get the norms of the residuals native to the solver.
Teuchos::RCP< const MV > U
void resetNumIters(int iter=0)
Reset the iteration count.
Pure virtual base class which describes the basic interface to the linear solver iteration.
A pure virtual class for defining the status tests for the Belos iterative solvers.
Class which defines basic traits for the operator type.
Traits class which defines basic operations on multivectors.
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system.
Teuchos::RCP< const MV > Rtilde
void iterate()
This method performs block TFQMR iterations until the status test indicates the need to stop or an er...
bool isInitialized()
States whether the solver has been initialized or not.
Teuchos::RCP< const MV > W
A linear system to solve, and its associated information.
Structure to contain pointers to TFQMRIter state variables.
Class which describes the linear problem to be solved by the iterative solver.
TFQMRIterInitFailure(const std::string &what_arg)
int getNumIters() const
Get the current iteration count.
MultiVecTraitsExt< ScalarType, MV > MVText
TFQMRIterInitFailure is thrown when the TFQMRIter object is unable to generate an initial iterate in ...
MultiVecTraits< ScalarType, MV > MVT
TFQMRIterateFailure is thrown when the TFQMRIter object is unable to compute the next iterate in the ...
int getBlockSize() const
Get the blocksize to be used by the iterative solver in solving this linear problem.
Class which defines basic traits for the operator type.
Parent class to all Belos exceptions.
Teuchos::RCP< const MV > D
Belos header file which uses auto-configuration information to include necessary C++ headers...
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get a constant reference to the linear problem.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
TFQMRIterState< ScalarType, MV > getState() const
Get the current state of the linear solver.