From b06fcec748502af4d7a212d8a2ae93dd296a729a Mon Sep 17 00:00:00 2001 From: DennisGlaeser Date: Thu, 9 Nov 2017 19:45:26 +0100 Subject: [PATCH] [fvassembler] update grid variables before computing the residual If the residual is to be computed for a given solution, the grid variables have to be updated in case global caching is enabled. If doing so, an additional update in the newtonEndStep() method is only necessary if the criterion does not require additional residual evaluations. --- dumux/assembly/fvassembler.hh | 3 +++ dumux/nonlinear/newtoncontroller.hh | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dumux/assembly/fvassembler.hh b/dumux/assembly/fvassembler.hh index ec217894f2..79a947932b 100644 --- a/dumux/assembly/fvassembler.hh +++ b/dumux/assembly/fvassembler.hh @@ -204,6 +204,9 @@ public: if (!stationary_ && localResidual_.isStationary()) DUNE_THROW(Dune::InvalidStateException, "Assembling instationary problem but previous solution was not set!"); + // update the grid variables for the case of active caching + gridVariables_->update(curSol); + // let the local assembler add the element contributions for (const auto element : elements(gridView())) LocalAssembler::assemble(*this, r, element, curSol); diff --git a/dumux/nonlinear/newtoncontroller.hh b/dumux/nonlinear/newtoncontroller.hh index 8bcf3903b0..087b512826 100644 --- a/dumux/nonlinear/newtoncontroller.hh +++ b/dumux/nonlinear/newtoncontroller.hh @@ -392,10 +392,14 @@ public: reduction_ = residualNorm_; reduction_ /= initialResidual_; } + else + { + // If we get here, the convergence criterion does not require + // additional residual evalutions. Thus, the grid variables have + // not yet been updated to the new uCurrentIter. + assembler.gridVariables().update(uCurrentIter); + } } - - // update the variables class to the new solution - assembler.gridVariables().update(uCurrentIter); } /*! -- GitLab