From 5bb31f99b13d2ef7c3a0d817b4f03016f8e28096 Mon Sep 17 00:00:00 2001
From: Uli Sack <usack@math.fu-berlin.de>
Date: Mon, 12 Nov 2012 07:51:54 +0000
Subject: [PATCH] empty setNumberOfLevels; tweak destructor such that it won't
 produce a segfault for a MultigridStep that never called preprocess; remove
 dysfunct newline marks in deprecation warnings

[[Imported from SVN: r7399]]
---
 dune/solvers/iterationsteps/multigridstep.hh | 38 ++++++--------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/dune/solvers/iterationsteps/multigridstep.hh b/dune/solvers/iterationsteps/multigridstep.hh
index f3c7fdb6..6605cf1d 100644
--- a/dune/solvers/iterationsteps/multigridstep.hh
+++ b/dune/solvers/iterationsteps/multigridstep.hh
@@ -39,7 +39,7 @@
                       LinearIterationStep<MatrixType, VectorType>* postSmoother,
                       Solver* baseSolver,
                       const BitVectorType* ignoreNodes)
-        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators.\n Just erase the number of levels from the argument list in your constructor call.") :
+        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators. Just erase the number of levels from the argument list in your constructor call.") :
             LinearIterationStep<MatrixType, VectorType>(mat, x, rhs),
             presmoother_(numLevels), postsmoother_(numLevels),
             matrixHierarchy_(numLevels),
@@ -88,7 +88,7 @@
         MultigridStep(const MatrixType& mat, 
                       VectorType& x, 
                       VectorType& rhs, int numLevels)
-        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators.\n Just erase the number of levels from the argument list in your constructor call.") :
+        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators. Just erase the number of levels from the argument list in your constructor call.") :
             LinearIterationStep<MatrixType, VectorType>(mat, x, rhs),
             presmoother_(numLevels),postsmoother_(numLevels),
             basesolver_(0),
@@ -112,43 +112,25 @@
 
         virtual ~MultigridStep()
         {
-            for (size_t i=0; i<matrixHierarchy_.size()-1; i++)
-                delete(ignoreNodesHierarchy_[i]);
+            for (int i=0; i<int(ignoreNodesHierarchy_.size()-1); i++)
+            {
+                if (ignoreNodesHierarchy_[i])
+                    delete(ignoreNodesHierarchy_[i]);
+            }
         }
 
         virtual void setProblem(const MatrixType& mat, 
                                 VectorType& x, 
                                 VectorType& rhs,
                                 int numLevels)
-        DUNE_DEPRECATED_MSG("Use setProblem(const MatrixType& mat,VectorType& x,const VectorType& rhs).\n The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators.")
+        DUNE_DEPRECATED_MSG("Use setProblem(const MatrixType& mat,VectorType& x,const VectorType& rhs). The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators.")
         {
             setProblem(mat, x, rhs);
         }
 
         virtual void setNumberOfLevels(int numLevels)
-        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators.\n The functionality of this function is now performed in preprocess().")
-        {
-            numLevels_ = numLevels;
-
-            for (int i=0; i<int(ignoreNodesHierarchy_.size())-1; i++)
-                if (ignoreNodesHierarchy_[i])
-                    delete(ignoreNodesHierarchy_[i]);
-
-            matrixHierarchy_.resize(numLevels);
-            ignoreNodesHierarchy_.resize(numLevels);
-
-            for (int i=0; i<int(matrixHierarchy_.size())-1; i++)
-            {
-                matrixHierarchy_[i].reset();
-                ignoreNodesHierarchy_[i] = NULL;
-            }
-
-            presmoother_.resize(numLevels);
-            postsmoother_.resize(numLevels);
-
-            xHierarchy_.resize(numLevels);
-            rhsHierarchy_.resize(numLevels);
-        }
+        DUNE_DEPRECATED_MSG("The number of levels is no longer set explicitely, but instead inferred from the number of transfer operators. The functionality of this function is now performed in preprocess().")
+        {}
 
         virtual void setProblem(const MatrixType& mat,
                                 VectorType& x,
-- 
GitLab