From e014e665c965225de6ecb5d96cfc3a56c48cc3e7 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Fri, 6 Apr 2018 17:22:47 +0200 Subject: [PATCH] [test][richardsnc][implicit] Use NewtonSolver --- dumux/porousmediumflow/richardsnc/model.hh | 4 +++ .../richardsnc/volumevariables.hh | 2 ++ .../richardsnc/implicit/test_richardsnc_fv.cc | 35 ++++--------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/dumux/porousmediumflow/richardsnc/model.hh b/dumux/porousmediumflow/richardsnc/model.hh index 5dad8ad9cf..659a42feb0 100644 --- a/dumux/porousmediumflow/richardsnc/model.hh +++ b/dumux/porousmediumflow/richardsnc/model.hh @@ -148,6 +148,10 @@ SET_INT_PROP(RichardsNC, ReplaceCompEqIdx, 0); //! define the VolumeVariables SET_TYPE_PROP(RichardsNC, VolumeVariables, RichardsNCVolumeVariables<TypeTag>); +//! The default richardsnc model computes no diffusion in the air phase +//! Turning this on leads to the extended Richards equation (see e.g. Vanderborght et al. 2017) +SET_BOOL_PROP(RichardsNC, EnableWaterDiffusionInAir, false); + /*! *\brief The fluid system used by the model. * diff --git a/dumux/porousmediumflow/richardsnc/volumevariables.hh b/dumux/porousmediumflow/richardsnc/volumevariables.hh index 668e212a7a..cb12812843 100644 --- a/dumux/porousmediumflow/richardsnc/volumevariables.hh +++ b/dumux/porousmediumflow/richardsnc/volumevariables.hh @@ -319,6 +319,8 @@ class RichardsNCVolumeVariables : public RichardsBaseVolumeVariables<TypeTag> using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using Indices = typename GET_PROP_TYPE(TypeTag, Indices); + static_assert(!GET_PROP_VALUE(TypeTag, EnableWaterDiffusionInAir), "Water diffusion in air is not implement for RichardsNC"); + enum { wPhaseIdx = Indices::wPhaseIdx, diff --git a/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc index 8fcd51145e..22decb0f04 100644 --- a/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc +++ b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc @@ -41,9 +41,7 @@ #include <dumux/common/defaultusagemessage.hh> #include <dumux/linear/seqsolverbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> -#include <dumux/porousmediumflow/richards/newtoncontroller.hh> +#include <dumux/porousmediumflow/richards/newtonsolver.hh> #include <dumux/assembly/fvassembler.hh> @@ -130,7 +128,6 @@ int main(int argc, char** argv) try // get some time loop parameters using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); auto dt = getParam<Scalar>("TimeLoop.DtInitial"); @@ -158,10 +155,8 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared<LinearSolver>(); // the non-linear solver - using NewtonController = Dumux::RichardsNewtonController<TypeTag>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(timeLoop); - NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); + using NewtonSolver = Dumux::RichardsNewtonSolver<TypeTag, Assembler, LinearSolver>; + NewtonSolver nonLinearSolver(assembler, linearSolver); // time loop timeLoop->start(); do @@ -169,24 +164,8 @@ int main(int argc, char** argv) try // set previous solution for storage evaluations assembler->setPreviousSolution(xOld); - // try solving the non-linear system - for (int i = 0; i < maxDivisions; ++i) - { - // linearize & solve - auto converged = nonLinearSolver.solve(x); - - if (converged) - break; - - if (!converged && i == maxDivisions-1) - DUNE_THROW(Dune::MathError, - "Newton solver didn't converge after " - << maxDivisions - << " time-step divisions. dt=" - << timeLoop->timeStepSize() - << ".\nThe solutions of the current and the previous time steps " - << "have been saved to restart files."); - } + // solve the non-linear system with time step control + nonLinearSolver.solve(x, *timeLoop); // make the new solution the old solution xOld = x; @@ -202,8 +181,8 @@ int main(int argc, char** argv) try // report statistics of this time step timeLoop->reportTimeStep(); - // set new dt as suggested by newton controller - timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); + // set new dt as suggested by the newton solver + timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); } while (!timeLoop->finished()); -- GitLab