|
Belos Package Browser (Single Doxygen Collection)
Development
|
Go to the documentation of this file.
42 #ifndef BELOS_FIXEDPOINT_ITER_HPP
43 #define BELOS_FIXEDPOINT_ITER_HPP
76 template<
class ScalarType,
class MV,
class OP>
252 template<
class ScalarType,
class MV,
class OP>
262 stateStorageInitialized_(false),
270 template <
class ScalarType,
class MV,
class OP>
273 if (!stateStorageInitialized_) {
277 if (lhsMV == Teuchos::null && rhsMV == Teuchos::null) {
278 stateStorageInitialized_ =
false;
285 if (R_ == Teuchos::null) {
289 "Belos::FixedPointIter::setStateSize(): linear problem does not specify multivectors to clone from.");
290 R_ = MVT::Clone( *tmp, numRHS_ );
291 Z_ = MVT::Clone( *tmp, numRHS_ );
295 stateStorageInitialized_ =
true;
302 template <
class ScalarType,
class MV,
class OP>
308 TEUCHOS_TEST_FOR_EXCEPTION(blockSize != MVT::GetNumberVecs(*lp_->getCurrRHSVec()), std::invalid_argument,
"Belos::FixedPointIter::setBlockSize size must match # RHS.");
310 TEUCHOS_TEST_FOR_EXCEPTION(blockSize <= 0, std::invalid_argument,
"Belos::FixedPointIter::setBlockSize was passed a non-positive argument.");
311 if (blockSize == numRHS_) {
316 if (blockSize!=numRHS_)
317 stateStorageInitialized_ =
false;
321 initialized_ =
false;
330 template <
class ScalarType,
class MV,
class OP>
334 if (!stateStorageInitialized_)
338 "Belos::FixedPointIter::initialize(): Cannot initialize state storage!");
342 std::string errstr(
"Belos::FixedPointIter::initialize(): Specified multivectors must have a consistent length and width.");
348 if (newstate.
R != Teuchos::null) {
350 std::invalid_argument, errstr );
353 std::invalid_argument, errstr );
355 std::invalid_argument, errstr );
358 if (newstate.
R != R_) {
360 MVT::MvAddMv( one, *newstate.
R, zero, *newstate.
R, *R_ );
366 "Belos::FixedPointIter::initialize(): FixedPointIterationState does not have initial residual.");
370 "Belos::FixedPointIter::initialize(): Does not work with right preconditioning");
379 template <
class ScalarType,
class MV,
class OP>
385 if (initialized_ ==
false) {
403 while (stest_->checkStatus(
this) !=
Passed) {
409 if ( lp_->getLeftPrec() != Teuchos::null ) {
410 lp_->applyLeftPrec( *R_, *Z_ );
417 MVT::Assign(*cur_soln_vec,*tmp);
418 MVT::MvAddMv(one,*tmp,one,*Z_,*cur_soln_vec);
419 lp_->updateSolution();
422 lp_->applyOp(*cur_soln_vec,*tmp);
423 MVT::MvAddMv(one,*rhs,-one,*tmp,*R_);
OperatorTraits< ScalarType, MV, OP > OPT
void setBlockSize(int blockSize)
Set the blocksize to be used by the iterative solver in solving this linear problem.
Belos header file which uses auto-configuration information to include necessary C++ headers.
void setStateSize()
Method for initalizing the state storage needed by FixedPoint.
Pure virtual base class which augments the basic interface for a fixed point linear solver iteration.
Class which defines basic traits for the operator type.
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Class which describes the linear problem to be solved by the iterative solver.
Pure virtual base class for defining the status testing capabilities of Belos.
MultiVecTraits< ScalarType, MV > MVT
void iterate()
This method performs Fixed Point iterations until the status test indicates the need to stop or an er...
const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > stest_
FixedPointIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
virtual ~FixedPointIter()
Destructor.
void resetNumIters(int iter=0)
Reset the iteration count.
Teuchos::ScalarTraits< ScalarType > SCT
Teuchos::RCP< const MV > R
The current residual.
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *norms) const
Get the norms of the residuals native to the solver.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
A linear system to solve, and its associated information.
void initializeFixedPoint(FixedPointIterationState< ScalarType, MV > &newstate)
Initialize the solver to an iterate, providing a complete state.
Class which manages the output and verbosity of the Belos solvers.
This class implements the preconditioned fixed point iteration.
T & get(ParameterList &l, const std::string &name)
int getNumIters() const
Get the current iteration count.
bool stateStorageInitialized_
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...
SCT::magnitudeType MagnitudeType
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get a constant reference to the linear problem.
Teuchos::RCP< const MV > Z
The current preconditioned residual.
Class which defines basic traits for the operator type.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
bool isInitialized()
States whether the solver has been initialized or not.
A pure virtual class for defining the status tests for the Belos iterative solvers.
Declaration of basic traits for the multivector type.
Collection of types and exceptions used within the Belos solvers.
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.
Structure to contain pointers to FixedPointIteration state variables.
const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > lp_
Traits class which defines basic operations on multivectors.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const Teuchos::RCP< OutputManager< ScalarType > > om_