10#ifndef BELOS_FIXEDPOINT_ITER_HPP
11#define BELOS_FIXEDPOINT_ITER_HPP
27#include "Teuchos_SerialDenseMatrix.hpp"
28#include "Teuchos_SerialDenseVector.hpp"
29#include "Teuchos_ScalarTraits.hpp"
30#include "Teuchos_ParameterList.hpp"
31#include "Teuchos_TimeMonitor.hpp"
44template<
class ScalarType,
class MV,
class OP>
54 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
68 Teuchos::ParameterList &
params );
181 const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > lp_;
182 const Teuchos::RCP<OutputManager<ScalarType> > om_;
183 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > stest_;
201 bool stateStorageInitialized_;
220 template<
class ScalarType,
class MV,
class OP>
224 Teuchos::ParameterList &
params ):
230 stateStorageInitialized_(
false),
238 template <
class ScalarType,
class MV,
class OP>
241 if (!stateStorageInitialized_) {
243 Teuchos::RCP<const MV>
lhsMV = lp_->getLHS();
244 Teuchos::RCP<const MV>
rhsMV = lp_->getRHS();
245 if (
lhsMV == Teuchos::null &&
rhsMV == Teuchos::null) {
246 stateStorageInitialized_ =
false;
253 if (R_ == Teuchos::null) {
257 "Belos::FixedPointIter::setStateSize(): linear problem does not specify multivectors to clone from.");
258 R_ = MVT::Clone( *
tmp, numRHS_ );
259 Z_ = MVT::Clone( *
tmp, numRHS_ );
263 stateStorageInitialized_ =
true;
270 template <
class ScalarType,
class MV,
class OP>
285 stateStorageInitialized_ =
false;
289 initialized_ =
false;
298 template <
class ScalarType,
class MV,
class OP>
302 if (!stateStorageInitialized_)
306 "Belos::FixedPointIter::initialize(): Cannot initialize state storage!");
310 std::string
errstr(
"Belos::FixedPointIter::initialize(): Specified multivectors must have a consistent length and width.");
313 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
314 const ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
318 std::invalid_argument,
errstr );
321 std::invalid_argument,
errstr );
323 std::invalid_argument,
errstr );
334 "Belos::FixedPointIter::initialize(): FixedPointIterationState does not have initial residual.");
344 template <
class ScalarType,
class MV,
class OP>
350 if (initialized_ ==
false) {
355 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
362 Teuchos::RCP<MV>
tmp = MVT::Clone( *R_, numRHS_ );
364 if (lp_->getRightPrec() != Teuchos::null) {
366 Teuchos::RCP<MV>
rhs = MVT::CloneCopy( *R_ );
369 MVT::MvInit( *Z_,
zero );
374 while (stest_->checkStatus(
this) !=
Passed) {
380 lp_->applyRightPrec( *R_, *
tmp );
384 lp_->updateSolution();
387 MVT::MvAddMv(
one, *Z_,
one, *
tmp, *Z_ );
390 lp_->applyOp (*Z_, *
tmp );
396 Teuchos::RCP<const MV>
rhs = lp_->getCurrRHSVec();
401 while (stest_->checkStatus(
this) !=
Passed) {
407 if ( lp_->getLeftPrec() != Teuchos::null ) {
408 lp_->applyLeftPrec( *R_, *Z_ );
416 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.
Teuchos::ScalarTraits< ScalarType > SCT
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get a constant reference to the linear problem.
void setBlockSize(int blockSize)
Set the blocksize to be used by the iterative solver in solving this linear problem.
SCT::magnitudeType MagnitudeType
void resetNumIters(int iter=0)
Reset the iteration count.
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *) const
Get the norms of the residuals native to the solver.
virtual ~FixedPointIter()
Destructor.
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
int getBlockSize() const
Get the blocksize to be used by the iterative solver in solving this linear problem.
bool isInitialized()
States whether the solver has been initialized or not.
int getNumIters() const
Get the current iteration count.
FixedPointIter(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)
FixedPointIter constructor with linear problem, solver utilities, and parameter list of solver option...
void initializeFixedPoint(FixedPointIterationState< ScalarType, MV > &newstate)
Initialize the solver to an iterate, providing a complete state.
OperatorTraits< ScalarType, MV, OP > OPT
void iterate()
This method performs Fixed Point iterations until the status test indicates the need to stop or an er...
MultiVecTraits< ScalarType, MV > MVT
FixedPointIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).