From faff379fed7ec642ba94eb6330bccc5ebcae9880 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Mon, 9 Apr 2018 06:38:22 +0200 Subject: [PATCH] [test][tracer][implicit] Use NewtonSolver --- .../tracer/1ptracer/test_cctracer.cc | 3 +- .../tracer/constvel/test_tracer.cc | 3 +- .../multicomp/test_tracer_maxwellstefan.cc | 34 ++++--------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc b/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc index 9187fa0257..010fa97380 100644 --- a/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc +++ b/test/porousmediumflow/tracer/1ptracer/test_cctracer.cc @@ -39,7 +39,6 @@ #include <dumux/common/dumuxmessage.hh> #include <dumux/linear/seqsolverbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> #include <dumux/assembly/fvassembler.hh> #include <dumux/assembly/diffmethod.hh> @@ -286,7 +285,7 @@ int main(int argc, char** argv) try // report statistics of this time step timeLoop->reportTimeStep(); - // set new dt as suggested by newton controller + // set new dt timeLoop->setTimeStepSize(dt); } while (!timeLoop->finished()); diff --git a/test/porousmediumflow/tracer/constvel/test_tracer.cc b/test/porousmediumflow/tracer/constvel/test_tracer.cc index f75e2b5a3a..b710725758 100644 --- a/test/porousmediumflow/tracer/constvel/test_tracer.cc +++ b/test/porousmediumflow/tracer/constvel/test_tracer.cc @@ -37,7 +37,6 @@ #include <dumux/common/defaultusagemessage.hh> #include <dumux/linear/seqsolverbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> #include <dumux/assembly/fvassembler.hh> #include <dumux/io/vtkoutputmodule.hh> @@ -183,7 +182,7 @@ int main(int argc, char** argv) try if (timeLoop->isCheckPoint() || timeLoop->finished()) vtkWriter.write(timeLoop->time()); - // set new dt as suggested by newton controller + // set new dt timeLoop->setTimeStepSize(dt); } diff --git a/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc b/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc index 07d3eb609d..a03b1a28a8 100644 --- a/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc +++ b/test/porousmediumflow/tracer/multicomp/test_tracer_maxwellstefan.cc @@ -41,8 +41,7 @@ #include <dumux/common/defaultusagemessage.hh> #include <dumux/linear/amgbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> +#include <dumux/nonlinear/newtonsolver.hh> #include <dumux/assembly/fvassembler.hh> #include <dumux/assembly/diffmethod.hh> @@ -135,7 +134,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"); @@ -163,10 +161,8 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared<LinearSolver>(leafGridView, fvGridGeometry->dofMapper()); // the non-linear solver - using NewtonController = Dumux::NewtonController<Scalar>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(timeLoop); - NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); + using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>; + NewtonSolver nonLinearSolver(assembler, linearSolver); // time loop timeLoop->start(); do @@ -174,24 +170,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; @@ -207,8 +187,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