From: Martin Kronbichler Date: Tue, 24 Nov 2020 16:50:56 +0000 (+0100) Subject: Multigrid: Only call MGLevelObject::resize() if necessary X-Git-Tag: v9.3.0-rc1~852^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3745799974cab80ff95a09958477456e1b93f24;p=dealii.git Multigrid: Only call MGLevelObject::resize() if necessary --- diff --git a/include/deal.II/multigrid/multigrid.templates.h b/include/deal.II/multigrid/multigrid.templates.h index 5459468171..b8a7f3ba6e 100644 --- a/include/deal.II/multigrid/multigrid.templates.h +++ b/include/deal.II/multigrid/multigrid.templates.h @@ -251,12 +251,17 @@ void Multigrid::cycle() { // The defect vector has been initialized by copy_to_mg. Now adjust the - // other vectors. - solution.resize(minlevel, maxlevel); - t.resize(minlevel, maxlevel); - if (cycle_type != v_cycle) + // other vectors. First out a check if we have the right number of levels. + if (solution.min_level() != minlevel || solution.max_level() != maxlevel) + { + solution.resize(minlevel, maxlevel); + t.resize(minlevel, maxlevel); + } + if (cycle_type != v_cycle && + (defect2.min_level() != minlevel || defect2.max_level() != maxlevel)) defect2.resize(minlevel, maxlevel); + // And now we go and reinit the vectors on the levels. for (unsigned int level = minlevel; level <= maxlevel; ++level) { // the vectors for level>minlevel will be overwritten by the apply() @@ -280,10 +285,14 @@ void Multigrid::vcycle() { // The defect vector has been initialized by copy_to_mg. Now adjust the - // other vectors. - solution.resize(minlevel, maxlevel); - t.resize(minlevel, maxlevel); + // other vectors. First out a check if we have the right number of levels. + if (solution.min_level() != minlevel || solution.max_level() != maxlevel) + { + solution.resize(minlevel, maxlevel); + t.resize(minlevel, maxlevel); + } + // And now we go and reinit the vectors on the levels. for (unsigned int level = minlevel; level <= maxlevel; ++level) { solution[level].reinit(defect[level], level > minlevel);