From 28ce472adc7deba6899d68b0a40a35dfb369c44a Mon Sep 17 00:00:00 2001
From: Uli Sack <usack@math.fu-berlin.de>
Date: Fri, 20 Jan 2012 16:04:35 +0000
Subject: [PATCH] added specialization for MatrixType=SumOperator<...,...>

[[Imported from SVN: r5408]]
---
 .../truncatedcompressedmgtransfer.hh          | 65 ++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/dune/solvers/transferoperators/truncatedcompressedmgtransfer.hh b/dune/solvers/transferoperators/truncatedcompressedmgtransfer.hh
index 8fc17d55..f36cf33a 100644
--- a/dune/solvers/transferoperators/truncatedcompressedmgtransfer.hh
+++ b/dune/solvers/transferoperators/truncatedcompressedmgtransfer.hh
@@ -5,6 +5,8 @@
 #include <dune/common/fmatrix.hh>
 #include <dune/common/bitsetvector.hh>
 
+#include <dune/solvers/operators/sumoperator.hh>
+
 #include "truncatedmgtransfer.hh"
 #include "compressedmultigridtransfer.hh"
 
@@ -38,7 +40,7 @@ class TruncatedCompressedMGTransfer :
 public:
 
     typedef typename CompressedMultigridTransfer<VectorType, BitVectorType, MatrixType>::TransferOperatorType TransferOperatorType;
-    
+
 
     /** \brief Default constructor */
     TruncatedCompressedMGTransfer()
@@ -77,6 +79,67 @@ public:
 };
 
 
+template<class VectorType, class BitVectorType, class SparseMatrixType, class LowRankMatrixType>
+class TruncatedCompressedMGTransfer<VectorType, BitVectorType, SumOperator<SparseMatrixType, LowRankMatrixType> > :
+    public CompressedMultigridTransfer<VectorType, BitVectorType, SparseMatrixType>,
+    public TruncatedMGTransfer<VectorType, BitVectorType, SparseMatrixType>
+{
+
+    enum {blocksize = VectorType::block_type::dimension};
+
+    typedef typename VectorType::field_type field_type;
+
+public:
+    typedef SumOperator<SparseMatrixType,LowRankMatrixType> OperatorType;
+    typedef typename CompressedMultigridTransfer<VectorType, BitVectorType, SparseMatrixType>::TransferOperatorType TransferOperatorType;
+
+
+    /** \brief Default constructor */
+    TruncatedCompressedMGTransfer()
+    {}
+
+    /** \brief Restrict level fL of f and store the result in level cL of t
+     *
+     * \param critical Has to contain an entry for each degree of freedom.
+     *        Those dofs with a set bit are treated as critical.
+     */
+    void restrict(const VectorType& f, VectorType &t, const BitVectorType& critical) const;
+
+    /** \brief Restriction of  MultiGridTransfer*/
+    using CompressedMultigridTransfer< VectorType, BitVectorType, SparseMatrixType >::restrict;
+
+    /** \brief Prolong level cL of f and store the result in level fL of t
+     * 
+     * \param critical Has to contain an entry for each degree of freedom.
+     *        Those dofs with a set bit are treated as critical.
+     */
+    void prolong(const VectorType& f, VectorType &t, const BitVectorType& critical) const;
+
+    /** \brief Prolongation of  MultiGridTransfer*/
+    using CompressedMultigridTransfer< VectorType, BitVectorType, SparseMatrixType >::prolong;
+
+    /** \brief Galerkin assemble a coarse stiffness matrix
+     *
+     * \param critical Has to contain an entry for each degree of freedom.
+     *        Those dofs with a set bit are treated as critical.
+     */
+    void galerkinRestrict(const OperatorType& fineMat, OperatorType& coarseMat, const BitVectorType& critical) const;
+
+    /** \brief forward noncritical Galerkin restriction of sparse Matrix to CompressedMultiGridTransfer and do the rest here */
+    void galerkinRestrict(const OperatorType& fineMat, OperatorType& coarseMat) const
+    {
+        CompressedMultigridTransfer< VectorType, BitVectorType, SparseMatrixType >::galerkinRestrict(fineMat.sparseMatrix(), coarseMat.sparseMatrix());
+
+        // \todo do the thing to the lowRankTerm
+    }
+
+    /** \brief forward to baseclass */
+    virtual void galerkinRestrictSetOccupation(const OperatorType& fineMat, OperatorType& coarseMat) const
+    {
+        CompressedMultigridTransfer<VectorType,BitVectorType,SparseMatrixType>::galerkinRestrictSetOccupation(fineMat.sparseMatrix(),coarseMat.sparseMatrix());
+    }
+
+};
 #include "truncatedcompressedmgtransfer.cc"
 
 #endif
-- 
GitLab