diff --git a/dumux/assembly/fvassembler.hh b/dumux/assembly/fvassembler.hh index c60d14fff8cd37d56417d2574acf57b8daa5b87e..962e83a5332fe20ceba633e2795560a61bd72b62 100644 --- a/dumux/assembly/fvassembler.hh +++ b/dumux/assembly/fvassembler.hh @@ -154,9 +154,6 @@ public: { checkAssemblerState_(); - // update the grid variables for the case of active caching - gridVariables_->update(curSol); - assemble_([&](const Element& element) { LocalAssembler localAssembler(*this, element, curSol); diff --git a/dumux/nonlinear/newtonsolver.hh b/dumux/nonlinear/newtonsolver.hh index a5e34418f45e7692e4b1c29d1b803a05cbc78074..4ff3f1b2f2ec6b76b2c500c5084d976161dae1d3 100644 --- a/dumux/nonlinear/newtonsolver.hh +++ b/dumux/nonlinear/newtonsolver.hh @@ -541,17 +541,10 @@ public: { uCurrentIter = uLastIter; uCurrentIter -= deltaU; + solutionChanged_(uCurrentIter); if (enableResidualCriterion_) computeResidualReduction_(uCurrentIter); - - else - { - // If we get here, the convergence criterion does not require - // additional residual evaluations. Thus, the grid variables have - // not yet been updated to the new uCurrentIter. - this->assembler().updateGridVariables(uCurrentIter); - } } } @@ -782,6 +775,14 @@ public: protected: + /*! + * \brief Update solution-depended quantities like grid variables after the solution has changed. + */ + virtual void solutionChanged_(const SolutionVector &uCurrentIter) + { + this->assembler().updateGridVariables(uCurrentIter); + } + void computeResidualReduction_(const SolutionVector &uCurrentIter) { residualNorm_ = this->assembler().residualNorm(uCurrentIter); @@ -1048,6 +1049,7 @@ private: uCurrentIter = deltaU; uCurrentIter *= -lambda; uCurrentIter += uLastIter; + solutionChanged_(uCurrentIter); computeResidualReduction_(uCurrentIter); diff --git a/dumux/porousmediumflow/richards/newtonsolver.hh b/dumux/porousmediumflow/richards/newtonsolver.hh index bafc188d171595db8b09b5a411a1f5e1f59e518b..421f3783d80585572f42a2f4b5a1c87ffa462255 100644 --- a/dumux/porousmediumflow/richards/newtonsolver.hh +++ b/dumux/porousmediumflow/richards/newtonsolver.hh @@ -25,7 +25,7 @@ #ifndef DUMUX_RICHARDS_NEWTON_SOLVER_HH #define DUMUX_RICHARDS_NEWTON_SOLVER_HH -#include +#include #include #include @@ -37,8 +37,6 @@ namespace Dumux { * This solver 'knows' what a 'physically meaningful' solution is * and can thus do update smarter than the plain Newton solver. * - * \todo make this typetag independent by extracting anything model specific from assembler - * or from possible ModelTraits. */ template class RichardsNewtonSolver : public NewtonSolver @@ -96,28 +94,22 @@ private: const Scalar pcOld = pn - pw; const Scalar SwOld = max(0.0, MaterialLaw::sw(materialLawParams, pcOld)); - // convert into minimum and maximum wetting phase - // pressures + // convert into minimum and maximum wetting phase pressures const Scalar pwMin = pn - MaterialLaw::pc(materialLawParams, SwOld - 0.2); const Scalar pwMax = pn - MaterialLaw::pc(materialLawParams, SwOld + 0.2); // clamp the result - using std::min; using std::max; - uCurrentIter[dofIdxGlobal][pressureIdx] = max(pwMin, min(uCurrentIter[dofIdxGlobal][pressureIdx], pwMax)); + using std::clamp; + uCurrentIter[dofIdxGlobal][pressureIdx] = clamp(uCurrentIter[dofIdxGlobal][pressureIdx], pwMin, pwMax); } } } + // update the grid variables + this->solutionChanged_(uCurrentIter); + if (this->enableResidualCriterion()) this->computeResidualReduction_(uCurrentIter); - - 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. - this->assembler().updateGridVariables(uCurrentIter); - } } };