Skip to content
Snippets Groups Projects
Commit c624daee authored by Elias Pipping's avatar Elias Pipping Committed by pipping
Browse files

LinearIterationSteps are now Preconditioners

[[Imported from SVN: r11959]]
parent 8c4c6813
No related branches found
No related tags found
No related merge requests found
......@@ -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_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment