diff --git a/dune/solvers/iterationsteps/CMakeLists.txt b/dune/solvers/iterationsteps/CMakeLists.txt index 3b61c8511cdbff1ea89f9ba80766eb6967b90bca..5fde9a8fc16ff62b4d9efe5f674b834eed3e8750 100644 --- a/dune/solvers/iterationsteps/CMakeLists.txt +++ b/dune/solvers/iterationsteps/CMakeLists.txt @@ -6,6 +6,7 @@ install(FILES cgstep.cc cgstep.hh istlseqilu0step.hh + istlseqssorstep.hh iterationstep.hh lineariterationstep.hh linegsstep.cc diff --git a/dune/solvers/iterationsteps/Makefile.am b/dune/solvers/iterationsteps/Makefile.am index ed9466610ae4df557096415266b50b6d7bebc0be..e08f928bf294e169b104cb7aefc7bfdd4ef8f290 100644 --- a/dune/solvers/iterationsteps/Makefile.am +++ b/dune/solvers/iterationsteps/Makefile.am @@ -7,6 +7,7 @@ iterationsteps_HEADERS = amgstep.hh \ cgstep.hh \ cgstep.cc \ istlseqilu0step.hh \ + istlseqssorstep.hh \ iterationstep.hh \ lineariterationstep.hh \ linegsstep.hh \ diff --git a/dune/solvers/iterationsteps/istlseqssorstep.hh b/dune/solvers/iterationsteps/istlseqssorstep.hh new file mode 100644 index 0000000000000000000000000000000000000000..06f169f211fa9ae361d4f5be154d34c6e7b0e5ab --- /dev/null +++ b/dune/solvers/iterationsteps/istlseqssorstep.hh @@ -0,0 +1,57 @@ +// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=8 sw=4 sts=4: +#ifndef ISTL_SEQSSOR_STEP_HH +#define ISTL_SEQSSOR_STEP_HH + +/** \file + \brief A wrapper class for the ISTL SeqSSOR implementation + */ + +#include <memory> + +#include <dune/solvers/iterationsteps/lineariterationstep.hh> + +#include <dune/istl/preconditioners.hh> + +/** \brief A wrapper class for the ISTL SeqSSOR implementation + */ +template <class MatrixType, class VectorType> +class ISTLSeqSSORStep + // FIXME: ignoreNodes are not handled + : public LinearIterationStep<MatrixType, VectorType> +{ + typedef Dune::SeqSSOR<MatrixType,VectorType,VectorType> SeqSSOR; + +public: + ISTLSeqSSORStep (int iterations, double relaxationFactor) + : iterations_(iterations), relaxationFactor_(relaxationFactor) + {} + + /** \brief Sets up an algebraic hierarchy + */ + virtual void preprocess() override { + seqSSOR_ = std::make_unique<SeqSSOR>(*this->mat_, iterations_, + relaxationFactor_); + + // Note: as of now, pre() is a dummy + mutable_rhs = *this->rhs_; + seqSSOR_->pre(*this->x_, mutable_rhs); + } + + /** \brief Perform one iteration */ + virtual void iterate() override { + mutable_rhs = *this->rhs_; + seqSSOR_->apply(*this->x_, mutable_rhs); + } + +private: + + /** \brief The dune-istl sequential SSOR preconditioner */ + std::unique_ptr<SeqSSOR> seqSSOR_; + + VectorType mutable_rhs; + + int const iterations_; + double const relaxationFactor_; +}; +#endif