25#ifndef DUMUX_RICHARDS_NEWTON_SOLVER_HH
26#define DUMUX_RICHARDS_NEWTON_SOLVER_HH
43template <
class Assembler,
class LinearSolver>
46 using Scalar =
typename Assembler::Scalar;
48 using Indices =
typename Assembler::GridVariables::VolumeVariables::Indices;
49 enum { pressureIdx = Indices::pressureIdx };
55 using ParentType::ParentType;
68 void choppedUpdate_(
Variables &varsCurrentIter,
69 const SolutionVector &uLastIter,
70 const SolutionVector &deltaU)
final
72 auto uCurrentIter = uLastIter;
73 uCurrentIter -= deltaU;
79 const auto& gridGeometry = this->
assembler().gridGeometry();
80 for (
const auto& element : elements(gridGeometry.gridView()))
82 auto fvGeometry =
localView(gridGeometry);
83 fvGeometry.bindElement(element);
85 for (
auto&& scv : scvs(fvGeometry))
87 auto dofIdxGlobal = scv.dofIndex();
90 const auto& spatialParams = this->
assembler().problem().spatialParams();
91 const auto elemSol =
elementSolution(element, uCurrentIter, gridGeometry);
93 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
94 const Scalar pcMin = fluidMatrixInteraction.pc(1.0);
95 const Scalar pw = uLastIter[dofIdxGlobal][pressureIdx];
97 const Scalar pn = max(this->
assembler().problem().nonwettingReferencePressure(), pw + pcMin);
98 const Scalar pcOld = pn - pw;
99 const Scalar SwOld = max(0.0, fluidMatrixInteraction.sw(pcOld));
102 const Scalar pwMin = pn - fluidMatrixInteraction.pc(SwOld - 0.2);
103 const Scalar pwMax = pn - fluidMatrixInteraction.pc(SwOld + 0.2);
107 uCurrentIter[dofIdxGlobal][pressureIdx] = clamp(uCurrentIter[dofIdxGlobal][pressureIdx], pwMin, pwMax);
Element solution classes and factory functions.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition box/elementsolution.hh:118
Detail::AssemblerVariables< Assembler > Variables
Definition common/pdesolver.hh:82
const Assembler & assembler() const
Definition common/pdesolver.hh:121
int numSteps_
actual number of steps done so far
Definition nonlinear/newtonsolver.hh:916
bool enableResidualCriterion() const
Definition nonlinear/newtonsolver.hh:906
virtual void solutionChanged_(Variables &vars, const SolutionVector &uCurrentIter)
Update solution-dependent quantities like grid variables after the solution has changed.
Definition nonlinear/newtonsolver.hh:874
NewtonSolver(std::shared_ptr< Assembler > assembler, std::shared_ptr< LinearSolver > linearSolver, const Communication &comm=Dune::MPIHelper::getCollectiveCommunication(), const std::string ¶mGroup="")
The Constructor.
Definition nonlinear/newtonsolver.hh:244
typename Backend::DofVector SolutionVector
Definition nonlinear/newtonsolver.hh:221
VariablesBackend< typename ParentType::Variables > Backend
Definition nonlinear/newtonsolver.hh:220
void computeResidualReduction_(const Variables &vars)
Definition nonlinear/newtonsolver.hh:882
A Richards model specific Newton solver.
Definition porousmediumflow/richards/newtonsolver.hh:45
Declares all properties used in Dumux.
Reference implementation of a Newton solver.