13#ifndef DUMUX_RICHARDS_NEWTON_SOLVER_HH
14#define DUMUX_RICHARDS_NEWTON_SOLVER_HH
18#include <dune/common/parallel/communication.hh>
19#include <dune/common/parallel/mpihelper.hh>
35template <
class Assembler,
class LinearSolver,
36 class Reassembler = PartialReassembler<Assembler>,
37 class Comm = Dune::Communication<Dune::MPIHelper::MPICommunicator> >
40 using Scalar =
typename Assembler::Scalar;
42 using Indices =
typename Assembler::GridVariables::VolumeVariables::Indices;
43 enum { pressureIdx = Indices::pressureIdx };
63 void choppedUpdate_(
Variables &varsCurrentIter,
64 const SolutionVector &uLastIter,
65 const ResidualVector &deltaU)
final
67 auto uCurrentIter = uLastIter;
68 Backend::axpy(-1.0, deltaU, uCurrentIter);
74 const auto& gridGeometry = this->
assembler().gridGeometry();
75 auto fvGeometry =
localView(gridGeometry);
76 for (
const auto& element : elements(gridGeometry.gridView()))
78 fvGeometry.bindElement(element);
80 for (
auto&& scv : scvs(fvGeometry))
82 auto dofIdxGlobal = scv.dofIndex();
85 const auto& spatialParams = this->
assembler().problem().spatialParams();
86 const auto elemSol =
elementSolution(element, uCurrentIter, gridGeometry);
88 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
89 const Scalar pcMin = fluidMatrixInteraction.pc(1.0);
90 const Scalar pw = uLastIter[dofIdxGlobal][pressureIdx];
92 const Scalar pn = max(this->
assembler().problem().nonwettingReferencePressure(), pw + pcMin);
93 const Scalar pcOld = pn - pw;
94 const Scalar SwOld = max(0.0, fluidMatrixInteraction.sw(pcOld));
97 const Scalar pwMin = pn - fluidMatrixInteraction.pc(SwOld - 0.2);
98 const Scalar pwMax = pn - fluidMatrixInteraction.pc(SwOld + 0.2);
102 uCurrentIter[dofIdxGlobal][pressureIdx] = clamp(uCurrentIter[dofIdxGlobal][pressureIdx], pwMin, pwMax);
An implementation of a Newton solver.
Definition: nonlinear/newtonsolver.hh:181
typename Assembler::ResidualType ResidualVector
Definition: nonlinear/newtonsolver.hh:187
int numSteps_
actual number of steps done so far
Definition: nonlinear/newtonsolver.hh:887
bool enableResidualCriterion() const
Definition: nonlinear/newtonsolver.hh:877
virtual void solutionChanged_(Variables &vars, const SolutionVector &uCurrentIter)
Update solution-dependent quantities like grid variables after the solution has changed.
Definition: nonlinear/newtonsolver.hh:855
typename Backend::DofVector SolutionVector
Definition: nonlinear/newtonsolver.hh:186
VariablesBackend< typename ParentType::Variables > Backend
Definition: nonlinear/newtonsolver.hh:185
void computeResidualReduction_(const Variables &vars)
Definition: nonlinear/newtonsolver.hh:863
const Assembler & assembler() const
Access the assembler.
Definition: common/pdesolver.hh:121
Detail::PDESolver::AssemblerVariables< Assembler > Variables
export the type of variables that represent a numerical solution
Definition: common/pdesolver.hh:71
A Richards model specific Newton solver.
Definition: porousmediumflow/richards/newtonsolver.hh:39
Defines all properties used in Dumux.
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:26
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition: cellcentered/elementsolution.hh:101
Reference implementation of a Newton solver.
Detects which entries in the Jacobian have to be recomputed.