-
Oliver Sander authored
[[Imported from SVN: r2356]]
Oliver Sander authored[[Imported from SVN: r2356]]
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
lineariterationstep.hh 1.87 KiB
#ifndef LINEAR_ITERATIONSTEP_HH
#define LINEAR_ITERATIONSTEP_HH
#include <vector>
#include <dune/common/bitsetvector.hh>
#include "iterationstep.hh"
//! Base class for iteration steps being called by a iterative linear solver
template<class MatrixType, class VectorType, class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> >
class LinearIterationStep : public IterationStep<VectorType, BitVectorType>
{
public:
//! Default constructor
LinearIterationStep() {}
/** \brief Destructor */
virtual ~LinearIterationStep() {}
//! Constructor being given linear operator, solution and right hand side
LinearIterationStep(const MatrixType& mat, VectorType& x, VectorType& rhs) {
mat_ = &mat;
this->x_ = &x;
rhs_ = &rhs;
}
//! Set linear operator, solution and right hand side
virtual void setProblem(const MatrixType& mat, VectorType& x, VectorType& rhs) {
this->x_ = &x;
rhs_ = &rhs;
mat_ = &mat;
}
//! Do the actual iteration
virtual void iterate() = 0;
//! Return solution object
virtual VectorType getSol() = 0;
//! Return linear operator
virtual const MatrixType* getMatrix() {return mat_;}
/** \brief Checks whether all relevant member variables are set
* \exception SolverError if the iteration step is not set up properly
*/
virtual void check() const {
#if 0
if (!x_)
DUNE_THROW(SolverError, "Iteration step has no solution vector");
if (!rhs_)
DUNE_THROW(SolverError, "Iteration step has no right hand side");
if (!mat_)
DUNE_THROW(SolverError, "Iteration step has no matrix");
#endif
}
//! The container for the right hand side
VectorType* rhs_;
//! The linear operator
const MatrixType* mat_;
};
#endif