Newton sover for coupled problems. More...
#include <dumux/multidomain/newtonsolver.hh>
Newton sover for coupled problems.
Public Types | |
using | Communication = Dune::Communication< Dune::MPIHelper::MPICommunicator > |
using | Assembler = Assembler |
export the assembler and linear solver types More... | |
using | LinearSolver = LinearSolver |
using | Variables = Detail::AssemblerVariables< Assembler > |
export the type of variables that represent a numerical solution More... | |
Public Member Functions | |
MultiDomainNewtonSolver (std::shared_ptr< Assembler > assembler, std::shared_ptr< LinearSolver > linearSolver, std::shared_ptr< CouplingManager > couplingManager, const Comm &comm=Dune::MPIHelper::getCommunication(), const std::string ¶mGroup="") | |
The constructor. More... | |
void | newtonBeginStep (const Variables &varsCurrentIter) override |
Indicates the beginning of a Newton iteration. More... | |
void | newtonBegin (Variables &vars) override |
Called before the Newton method is applied to an non-linear system of equations. More... | |
bool | newtonConverged () const override |
Returns true if the error of the solution is below the tolerance. More... | |
void | newtonEndStep (Variables &varsCurrentIter, const SolutionVector &uLastIter) override |
Indicates that one Newton iteration was finished. More... | |
const Communication & | comm () const |
the communicator for parallel runs More... | |
void | setMaxRelativeShift (Scalar tolerance) |
Set the maximum acceptable difference of any primary variable between two iterations for declaring convergence. More... | |
void | setMaxAbsoluteResidual (Scalar tolerance) |
Set the maximum acceptable absolute residual for declaring convergence. More... | |
void | setResidualReduction (Scalar tolerance) |
Set the maximum acceptable residual norm reduction. More... | |
void | setTargetSteps (int targetSteps) |
Set the number of iterations at which the Newton method should aim at. More... | |
void | setMinSteps (int minSteps) |
Set the number of minimum iterations for the Newton method. More... | |
void | setMaxSteps (int maxSteps) |
Set the number of iterations after which the Newton method gives up. More... | |
void | solve (Variables &vars, TimeLoop &timeLoop) override |
Run the Newton method to solve a non-linear system. Does time step control when the Newton fails to converge. More... | |
void | solve (Variables &vars) override |
Run the Newton method to solve a non-linear system. The solver is responsible for all the strategic decisions. More... | |
virtual bool | newtonProceed (const Variables &varsCurrentIter, bool converged) |
Returns true if another iteration should be done. More... | |
virtual void | assembleLinearSystem (const Variables &vars) |
Assemble the linear system of equations \(\mathbf{A}x - b = 0\). More... | |
void | solveLinearSystem (SolutionVector &deltaU) |
Solve the linear system of equations \(\mathbf{A}x - b = 0\). More... | |
void | newtonUpdate (Variables &vars, const SolutionVector &uLastIter, const SolutionVector &deltaU) |
Update the current solution with a delta vector. More... | |
virtual void | newtonEnd () |
Called if the Newton method ended (not known yet if we failed or succeeded) More... | |
virtual void | newtonFail (Variables &u) |
Called if the Newton method broke down. This method is called after newtonEnd() More... | |
virtual void | newtonSucceed () |
Called if the Newton method ended successfully This method is called after newtonEnd() More... | |
void | report (std::ostream &sout=std::cout) const |
output statistics / report More... | |
void | resetReport () |
reset the statistics More... | |
void | reportParams (std::ostream &sout=std::cout) const |
Report the options and parameters this Newton is configured with. More... | |
Scalar | suggestTimeStepSize (Scalar oldTimeStep) const |
Suggest a new time-step size based on the old time-step size. More... | |
void | setVerbosity (int val) |
Specifies the verbosity level. More... | |
int | verbosity () const |
Return the verbosity level. More... | |
const std::string & | paramGroup () const |
Returns the parameter group. More... | |
void | attachConvergenceWriter (std::shared_ptr< ConvergenceWriter > convWriter) |
Attach a convergence writer to write out intermediate results after each iteration. More... | |
void | detachConvergenceWriter () |
Detach the convergence writer to stop the output. More... | |
Scalar | retryTimeStepReductionFactor () const |
Return the factor for reducing the time step after a Newton iteration has failed. More... | |
void | setRetryTimeStepReductionFactor (const Scalar factor) |
Set the factor for reducing the time step after a Newton iteration has failed. More... | |
const Assembler & | assembler () const |
Access the assembler. More... | |
Assembler & | assembler () |
Access the assembler. More... | |
const LinearSolver & | linearSolver () const |
Access the linear solver. More... | |
Protected Member Functions | |
void | solutionChanged_ (Variables &vars, const SolutionVector &uCurrentIter) override |
Update solution-depended quantities like grid variables after the solution has changed. More... | |
void | computeResidualReduction_ (const Variables &vars) |
bool | enableResidualCriterion () const |
LinearSolver & | linearSolver () |
Access the linear solver. More... | |
bool | checkSizesOfSubMatrices (const Dune::MultiTypeBlockMatrix< FirstRow, Args... > &matrix) const |
Helper function to assure the MultiTypeBlockMatrix's sub-blocks have the correct sizes. More... | |
Protected Attributes | |
int | targetSteps_ |
optimal number of iterations we want to achieve More... | |
int | minSteps_ |
minimum number of iterations we do More... | |
int | maxSteps_ |
maximum number of iterations we do before giving up More... | |
int | numSteps_ |
actual number of steps done so far More... | |
Scalar | reduction_ |
Scalar | residualNorm_ |
Scalar | lastReduction_ |
Scalar | initialResidual_ |
Scalar | shift_ |
Scalar | lastShift_ |
std::ostringstream | endIterMsgStream_ |
message stream to be displayed at the end of iterations More... | |
|
inherited |
export the assembler and linear solver types
|
inherited |
|
inherited |
|
inherited |
export the type of variables that represent a numerical solution
|
inline |
The constructor.
|
inlinevirtualinherited |
Assemble the linear system of equations \(\mathbf{A}x - b = 0\).
vars | The current iteration's variables |
|
inlineinherited |
Access the assembler.
|
inlineinherited |
Access the assembler.
|
inlineinherited |
Attach a convergence writer to write out intermediate results after each iteration.
|
inlineprotectedinherited |
Helper function to assure the MultiTypeBlockMatrix's sub-blocks have the correct sizes.
|
inlineinherited |
the communicator for parallel runs
|
inlineprotectedinherited |
|
inlineinherited |
Detach the convergence writer to stop the output.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Access the linear solver.
|
inlineinherited |
Access the linear solver.
|
inlineoverridevirtual |
Called before the Newton method is applied to an non-linear system of equations.
vars | The variables representing the initial solution |
Reimplemented from Dumux::NewtonSolver< Assembler, LinearSolver, DefaultPartialReassembler, Dune::Communication< Dune::MPIHelper::MPICommunicator > >.
|
inlineoverridevirtual |
Indicates the beginning of a Newton iteration.
Reimplemented from Dumux::NewtonSolver< Assembler, LinearSolver, DefaultPartialReassembler, Dune::Communication< Dune::MPIHelper::MPICommunicator > >.
|
inlineoverridevirtual |
Returns true if the error of the solution is below the tolerance.
Reimplemented from Dumux::NewtonSolver< Assembler, LinearSolver, DefaultPartialReassembler, Dune::Communication< Dune::MPIHelper::MPICommunicator > >.
|
inlinevirtualinherited |
Called if the Newton method ended (not known yet if we failed or succeeded)
|
inlineoverridevirtual |
Indicates that one Newton iteration was finished.
varsCurrentIter | The variables after the current Newton iteration |
uLastIter | The solution at the beginning of the current Newton iteration |
Reimplemented from Dumux::NewtonSolver< Assembler, LinearSolver, DefaultPartialReassembler, Dune::Communication< Dune::MPIHelper::MPICommunicator > >.
|
inlinevirtualinherited |
Called if the Newton method broke down. This method is called after newtonEnd()
|
inlinevirtualinherited |
Returns true if another iteration should be done.
varsCurrentIter | The variables of the current Newton iteration |
converged | if the Newton method's convergence criterion was met in this step |
|
inlinevirtualinherited |
Called if the Newton method ended successfully This method is called after newtonEnd()
|
inlineinherited |
Update the current solution with a delta vector.
The error estimates required for the newtonConverged() and newtonProceed() methods should be updated inside this method.
Different update strategies, such as line search and chopped updates can be implemented. The default behavior is just to subtract deltaU from uLastIter, i.e.
\[ u^{k+1} = u^k - \Delta u^k \]
vars | The variables after the current iteration |
uLastIter | The solution vector after the last iteration |
deltaU | The delta as calculated from solving the linear system of equations. This parameter also stores the updated solution. |
|
inlineinherited |
Returns the parameter group.
|
inlineinherited |
output statistics / report
|
inlineinherited |
Report the options and parameters this Newton is configured with.
|
inlineinherited |
reset the statistics
|
inlineinherited |
Return the factor for reducing the time step after a Newton iteration has failed.
|
inlineinherited |
Set the maximum acceptable absolute residual for declaring convergence.
tolerance | The maximum absolute residual at which the scheme is considered finished |
|
inlineinherited |
Set the maximum acceptable difference of any primary variable between two iterations for declaring convergence.
tolerance | The maximum relative shift between two Newton iterations at which the scheme is considered finished |
|
inlineinherited |
Set the number of iterations after which the Newton method gives up.
maxSteps | Number of iterations after we give up |
|
inlineinherited |
Set the number of minimum iterations for the Newton method.
minSteps | Minimum number of iterations |
|
inlineinherited |
Set the maximum acceptable residual norm reduction.
tolerance | The maximum reduction of the residual norm at which the scheme is considered finished |
|
inlineinherited |
Set the factor for reducing the time step after a Newton iteration has failed.
|
inlineinherited |
Set the number of iterations at which the Newton method should aim at.
This is used to control the time-step size. The heuristic used is to scale the last time-step size by the deviation of the number of iterations used from the target steps.
targetSteps | Number of iterations which are considered "optimal" |
|
inlineinherited |
Specifies the verbosity level.
|
inlineoverrideprotectedvirtual |
Update solution-depended quantities like grid variables after the solution has changed.
Reimplemented from Dumux::NewtonSolver< Assembler, LinearSolver, DefaultPartialReassembler, Dune::Communication< Dune::MPIHelper::MPICommunicator > >.
|
inlineoverridevirtualinherited |
Run the Newton method to solve a non-linear system. The solver is responsible for all the strategic decisions.
vars | The variables object representing the current state of the numerical solution (primary and possibly secondary variables). |
Implements Dumux::PDESolver< Assembler, LinearSolver >.
|
inlineoverridevirtualinherited |
Run the Newton method to solve a non-linear system. Does time step control when the Newton fails to converge.
vars | The variables object representing the current state of the numerical solution (primary and possibly secondary variables). |
timeLoop | The time loop. |
Reimplemented from Dumux::PDESolver< Assembler, LinearSolver >.
|
inlineinherited |
Solve the linear system of equations \(\mathbf{A}x - b = 0\).
Throws Dumux::NumericalProblem if the linear solver didn't converge.
If the linear solver doesn't accept multitype matrices we copy the matrix into a 1x1 block BCRS matrix for solving.
deltaU | The difference between the current and the next solution |
|
inlineinherited |
Suggest a new time-step size based on the old time-step size.
The default behavior is to suggest the old time-step size scaled by the ratio between the target iterations and the iterations required to actually solve the last time-step.
|
inlineinherited |
Return the verbosity level.
|
protectedinherited |
message stream to be displayed at the end of iterations
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
maximum number of iterations we do before giving up
|
protectedinherited |
minimum number of iterations we do
|
protectedinherited |
actual number of steps done so far
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
optimal number of iterations we want to achieve