From a656b05f524834675c506f31bf4ce09e7bea9b03 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Mon, 13 Dec 2010 08:47:41 +0000
Subject: [PATCH] a preconditioned Richardson step

[[Imported from SVN: r3601]]
---
 dune/solvers/iterationsteps/Makefile.am       |  4 +-
 dune/solvers/iterationsteps/richardsonstep.hh | 58 +++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 dune/solvers/iterationsteps/richardsonstep.hh

diff --git a/dune/solvers/iterationsteps/Makefile.am b/dune/solvers/iterationsteps/Makefile.am
index f4372b65..b18e7f47 100644
--- a/dune/solvers/iterationsteps/Makefile.am
+++ b/dune/solvers/iterationsteps/Makefile.am
@@ -4,7 +4,9 @@ iterationstepsdir = $(includedir)/dune/dune-solvers/iterationsteps
 iterationsteps_HEADERS = amgstep.hh blockgsstep.hh blockgsstep.cc iterationstep.hh \
           lineariterationstep.hh linegsstep.hh linegsstep.cc mmgstep.hh mmgstep.cc \
           multigridstep.hh  multigridstep.cc \
-          projectedblockgsstep.hh projectedblockgsstep.cc projectedlinegsstep.cc projectedlinegsstep.hh truncatedblockgsstep.hh \
+          projectedblockgsstep.hh projectedblockgsstep.cc projectedlinegsstep.cc projectedlinegsstep.hh \
+                         richardsonstep.hh \
+                         truncatedblockgsstep.hh \
            truncatedsaddlepointgsstep.hh  trustregiongsstep.cc  trustregiongsstep.hh
 
 include $(top_srcdir)/am/global-rules
diff --git a/dune/solvers/iterationsteps/richardsonstep.hh b/dune/solvers/iterationsteps/richardsonstep.hh
new file mode 100644
index 00000000..4ae49b4f
--- /dev/null
+++ b/dune/solvers/iterationsteps/richardsonstep.hh
@@ -0,0 +1,58 @@
+#ifndef DUNE_RICHARDSON_STEP_HH
+#define DUNE_RICHARDSON_STEP_HH
+
+#include <dune/common/bitsetvector.hh>
+
+#include <dune/solvers/common/preconditioner.hh>
+#include <dune/solvers/iterationsteps/iterationstep.hh>
+
+/** \brief A single preconditioned and damped Richardson step
+*/
+template<class VectorType,
+         class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> >
+         class RichardsonStep 
+         : public IterationStep<VectorType, BitVectorType>
+{
+
+public:
+        
+    /** \brief Constructor */
+    RichardsonStep(const Preconditioner<VectorType>* preconditioner,
+                   double damping
+    ) 
+        : preconditioner_(preconditioner),
+          damping_(damping)
+    {}
+
+    //! Perform one iteration
+    virtual void iterate();
+
+    /** \brief Retrieve the solution */
+    virtual VectorType getSol();
+    
+    const Preconditioner<VectorType>* preconditioner_;
+
+    double damping_;
+    
+};
+
+template<class VectorType, class BitVectorType>
+inline
+VectorType RichardsonStep<VectorType, BitVectorType>::getSol()
+{
+    return *(this->x_);
+}
+
+template<class VectorType, class BitVectorType>
+inline
+void RichardsonStep<VectorType, BitVectorType>::iterate()
+{
+    VectorType residual;
+    
+    preconditioner_->apply(*this->x_, residual);
+    
+    this->x_->axpy(damping_, residual);
+    
+}
+
+#endif
-- 
GitLab