diff --git a/dune/solvers/iterationsteps/lineariterationstep.hh b/dune/solvers/iterationsteps/lineariterationstep.hh index 65d40593b04d1857a7d30d3db59ee7c234ca3fcb..f3a2170c758fac212806e7b4abae1364b878b349 100644 --- a/dune/solvers/iterationsteps/lineariterationstep.hh +++ b/dune/solvers/iterationsteps/lineariterationstep.hh @@ -6,11 +6,16 @@ #include <dune/common/bitsetvector.hh> #include <dune/common/shared_ptr.hh> +#include <dune/solvers/common/preconditioner.hh> + #include "iterationstep.hh" //! Base class for iteration steps being called by an iterative linear solver template<class MatrixType, class VectorType, class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> > -class LinearIterationStep : public IterationStep<VectorType, BitVectorType> +class LinearIterationStep : public IterationStep<VectorType, BitVectorType>, + public Dune::Solvers::Preconditioner<MatrixType, + VectorType, + BitVectorType> { public: @@ -33,6 +38,11 @@ public: rhs_ = &rhs; mat_ = Dune::stackobject_to_shared_ptr(mat); } + + //! Set linear operator + virtual void setMatrix(const MatrixType& mat) { + mat_ = Dune::stackobject_to_shared_ptr(mat); + } //! Do the actual iteration virtual void iterate() = 0; @@ -59,6 +69,15 @@ public: DUNE_THROW(SolverError, "Iteration step has no matrix"); #endif } + + virtual void apply(VectorType& x, const VectorType& r) + { + x = 0; + this->x_ = &x; + rhs_ = &r; + iterate(); + x = getSol(); + } //! The container for the right hand side const VectorType* rhs_;