]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Resize defect vectors when changing multigrid levels
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 11 Aug 2016 12:06:24 +0000 (14:06 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 11 Aug 2016 14:10:53 +0000 (16:10 +0200)
include/deal.II/multigrid/multigrid.h
include/deal.II/multigrid/multigrid.templates.h

index 7f81b93a76db7da551bc149fd9387acb7c628311..b8b4fa788a60438ec0179b8bba18d3b3ffff0bc1 100644 (file)
@@ -99,9 +99,8 @@ public:
             Cycle                              cycle = v_cycle);
 
   /**
-   * Experimental constructor for cases in which no DoFHandler is available.
-   *
-   * @warning Not intended for general use.
+   * Constructor. Same as above but you can determine the multigrid
+   * levels to use yourself.
    */
   Multigrid(const unsigned int                 minlevel,
             const unsigned int                 maxlevel,
@@ -178,9 +177,8 @@ public:
 
   /**
    * Set the highest level for which the multilevel method is performed. By
-   * default, this is the finest level of the Triangulation; therefore, this
-   * function will only accept arguments smaller than the current #maxlevel
-   * and not smaller than the current #minlevel.
+   * default, this is the finest level of the Triangulation. Accepted are
+   * values not smaller than the current #minlevel.
    */
   void set_maxlevel (const unsigned int);
 
index e4f3befa504a8cd9637749d06fcdfcef3aecc9d4..5270febce77694a714c5bbb1e5b54425a4baf21d 100644 (file)
@@ -59,8 +59,11 @@ void
 Multigrid<VectorType>::reinit (const unsigned int min_level,
                                const unsigned int max_level)
 {
+  Assert (min_level <= max_level,
+          ExcLowerRangeType<unsigned int>(max_level, min_level));
   minlevel=min_level;
   maxlevel=max_level;
+  // solution, t and defect2 are resized in cycle()
   defect.resize(minlevel, maxlevel);
 }
 
@@ -69,9 +72,7 @@ template <typename VectorType>
 void
 Multigrid<VectorType>::set_maxlevel (const unsigned int l)
 {
-  Assert (l <= maxlevel, ExcIndexRange(l,minlevel,maxlevel+1));
-  Assert (l >= minlevel, ExcIndexRange(l,minlevel,maxlevel+1));
-  maxlevel = l;
+  reinit(minlevel, l);
 }
 
 
@@ -80,10 +81,10 @@ void
 Multigrid<VectorType>::set_minlevel (const unsigned int l,
                                      const bool relative)
 {
-  Assert (l <= maxlevel, ExcIndexRange(l,minlevel,maxlevel+1));
-  minlevel = (relative)
-             ? (maxlevel-l)
-             : l;
+  const unsigned int new_minlevel = (relative)
+                                    ? (maxlevel-l)
+                                    : l;
+  reinit(new_minlevel, maxlevel);
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.