From 25bdd0b853e8315f11e9ffd0ef26902089de9cea Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 11 Aug 2016 14:06:24 +0200 Subject: [PATCH] Resize defect vectors when changing multigrid levels --- include/deal.II/multigrid/multigrid.h | 10 ++++------ include/deal.II/multigrid/multigrid.templates.h | 15 ++++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/deal.II/multigrid/multigrid.h b/include/deal.II/multigrid/multigrid.h index 7f81b93a76..b8b4fa788a 100644 --- a/include/deal.II/multigrid/multigrid.h +++ b/include/deal.II/multigrid/multigrid.h @@ -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); diff --git a/include/deal.II/multigrid/multigrid.templates.h b/include/deal.II/multigrid/multigrid.templates.h index e4f3befa50..5270febce7 100644 --- a/include/deal.II/multigrid/multigrid.templates.h +++ b/include/deal.II/multigrid/multigrid.templates.h @@ -59,8 +59,11 @@ void Multigrid::reinit (const unsigned int min_level, const unsigned int max_level) { + Assert (min_level <= max_level, + ExcLowerRangeType(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 void Multigrid::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::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); } -- 2.39.5