Skip to content
Snippets Groups Projects
Commit 59a2a1cc authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[test][2p1cni][implicit] Use NewtonSolver

parent 40dfa341
No related branches found
No related tags found
1 merge request!898Use NewtonSolver
...@@ -41,9 +41,8 @@ ...@@ -41,9 +41,8 @@
#include <dumux/common/dumuxmessage.hh> #include <dumux/common/dumuxmessage.hh>
#include <dumux/common/defaultusagemessage.hh> #include <dumux/common/defaultusagemessage.hh>
#include <dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh>
#include <dumux/linear/seqsolverbackend.hh> #include <dumux/linear/seqsolverbackend.hh>
#include <dumux/nonlinear/newtonmethod.hh> #include <dumux/nonlinear/privarswitchnewtonsolver.hh>
#include <dumux/assembly/fvassembler.hh> #include <dumux/assembly/fvassembler.hh>
...@@ -108,7 +107,6 @@ ...@@ -108,7 +107,6 @@
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
auto dt = getParam<Scalar>("TimeLoop.DtInitial"); auto dt = getParam<Scalar>("TimeLoop.DtInitial");
auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions");
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module // intialize the vtk output module
...@@ -130,9 +128,9 @@ ...@@ -130,9 +128,9 @@
auto linearSolver = std::make_shared<LinearSolver>(); auto linearSolver = std::make_shared<LinearSolver>();
// the non-linear solver // the non-linear solver
using NewtonController = Dumux::PriVarSwitchNewtonController<TypeTag>; using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch);
auto newtonController = std::make_shared<NewtonController>(timeLoop); using NewtonSolver = Dumux::PriVarSwitchNewtonSolver<Assembler, LinearSolver, PrimaryVariableSwitch>;
NewtonMethod<NewtonController, Assembler, LinearSolver> nonLinearSolver(newtonController, assembler, linearSolver); NewtonSolver nonLinearSolver(assembler, linearSolver);
// time loop // time loop
timeLoop->start(); do timeLoop->start(); do
...@@ -140,24 +138,8 @@ ...@@ -140,24 +138,8 @@
// set previous solution for storage evaluations // set previous solution for storage evaluations
assembler->setPreviousSolution(xOld); assembler->setPreviousSolution(xOld);
// try solving the non-linear system // solve the non-linear system with time step control
for (int i = 0; i < maxDivisions; ++i) nonLinearSolver.solve(x, *timeLoop);
{
// 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.");
}
// make the new solution the old solution // make the new solution the old solution
xOld = x; xOld = x;
...@@ -172,8 +154,8 @@ ...@@ -172,8 +154,8 @@
// report statistics of this time step // report statistics of this time step
timeLoop->reportTimeStep(); timeLoop->reportTimeStep();
// set new dt as suggested by newton controller // set new dt as suggested by the newton solver
timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
} while (!timeLoop->finished()); } while (!timeLoop->finished());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment