10#ifndef BELOS_FIXEDPOINT_ITER_HPP
11#define BELOS_FIXEDPOINT_ITER_HPP
27#include "Teuchos_ScalarTraits.hpp"
28#include "Teuchos_ParameterList.hpp"
29#include "Teuchos_TimeMonitor.hpp"
42template<
class ScalarType,
class MV,
class OP,
class DM>
52 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
66 Teuchos::ParameterList &
params );
179 const Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > lp_;
180 const Teuchos::RCP<OutputManager<ScalarType> > om_;
181 const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > stest_;
199 bool stateStorageInitialized_;
218 template<
class ScalarType,
class MV,
class OP,
class DM>
222 Teuchos::ParameterList &
params ):
228 stateStorageInitialized_(
false),
236 template<
class ScalarType,
class MV,
class OP,
class DM>
239 if (!stateStorageInitialized_) {
241 Teuchos::RCP<const MV>
lhsMV = lp_->getLHS();
242 Teuchos::RCP<const MV>
rhsMV = lp_->getRHS();
243 if (
lhsMV == Teuchos::null &&
rhsMV == Teuchos::null) {
244 stateStorageInitialized_ =
false;
251 if (R_ == Teuchos::null) {
255 "Belos::FixedPointIter::setStateSize(): linear problem does not specify multivectors to clone from.");
256 R_ = MVT::Clone( *
tmp, numRHS_ );
257 Z_ = MVT::Clone( *
tmp, numRHS_ );
261 stateStorageInitialized_ =
true;
268 template<
class ScalarType,
class MV,
class OP,
class DM>
283 stateStorageInitialized_ =
false;
287 initialized_ =
false;
296 template<
class ScalarType,
class MV,
class OP,
class DM>
300 if (!stateStorageInitialized_)
304 "Belos::FixedPointIter::initialize(): Cannot initialize state storage!");
308 std::string
errstr(
"Belos::FixedPointIter::initialize(): Specified multivectors must have a consistent length and width.");
312 std::invalid_argument,
errstr );
315 std::invalid_argument,
errstr );
317 std::invalid_argument,
errstr );
328 "Belos::FixedPointIter::initialize(): FixedPointIterationState does not have initial residual.");
338 template<
class ScalarType,
class MV,
class OP,
class DM>
344 if (initialized_ ==
false) {
349 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
356 Teuchos::RCP<MV>
tmp = MVT::Clone( *R_, numRHS_ );
358 if (lp_->getRightPrec() != Teuchos::null) {
360 Teuchos::RCP<MV>
rhs = MVT::CloneCopy( *R_ );
363 MVT::MvInit( *Z_,
zero );
368 while (stest_->checkStatus(
this) !=
Passed) {
374 lp_->applyRightPrec( *R_, *
tmp );
378 lp_->updateSolution();
381 MVT::MvAddMv(
one, *Z_,
one, *
tmp, *Z_ );
384 lp_->applyOp (*Z_, *
tmp );
390 Teuchos::RCP<const MV>
rhs = lp_->getCurrRHSVec();
395 while (stest_->checkStatus(
this) !=
Passed) {
401 if ( lp_->getLeftPrec() != Teuchos::null ) {
402 lp_->applyLeftPrec( *R_, *Z_ );
410 lp_->updateSolution();
Belos header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which augments the basic interface for a fixed point linear solver iteration.
Class which describes the linear problem to be solved by the iterative solver.
Declaration of basic traits for the multivector type.
Class which defines basic traits for the operator type.
Class which manages the output and verbosity of the Belos solvers.
Pure virtual base class for defining the status testing capabilities of Belos.
Collection of types and exceptions used within the Belos solvers.
This class implements the preconditioned fixed point iteration.
void resetNumIters(int iter=0)
Reset the iteration count.
Teuchos::ScalarTraits< ScalarType > SCT
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *) const
Get the norms of the residuals native to the solver.
FixedPointIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
void iterate()
This method performs Fixed Point iterations until the status test indicates the need to stop or an er...
int getNumIters() const
Get the current iteration count.
MultiVecTraits< ScalarType, MV, DM > MVT
FixedPointIter(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &tester, Teuchos::ParameterList ¶ms)
FixedPointIter constructor with linear problem, solver utilities, and parameter list of solver option...
OperatorTraits< ScalarType, MV, OP > OPT
SCT::magnitudeType MagnitudeType
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system.
int getBlockSize() const
Get the blocksize to be used by the iterative solver in solving this linear problem.
const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const
Get a constant reference to the linear problem.
bool isInitialized()
States whether the solver has been initialized or not.
void initializeFixedPoint(FixedPointIterationState< ScalarType, MV > &newstate)
Initialize the solver to an iterate, providing a complete state.
virtual ~FixedPointIter()
Destructor.
void setBlockSize(int blockSize)
Set the blocksize to be used by the iterative solver in solving this linear problem.
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).