From c624daee33f09176e9e9d9803c32d71fd8eae4df Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Fri, 30 Aug 2013 13:04:15 +0000 Subject: [PATCH] LinearIterationSteps are now Preconditioners [[Imported from SVN: r11959]] --- .../iterationsteps/lineariterationstep.hh | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dune/solvers/iterationsteps/lineariterationstep.hh b/dune/solvers/iterationsteps/lineariterationstep.hh index 65d40593..f3a2170c 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_; -- GitLab