All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Ewoms::NewtonMethod< TypeTag > Class Template Reference

The multi-dimensional Newton method. More...

#include <newtonmethod.hh>

Inheritance diagram for Ewoms::NewtonMethod< TypeTag >:
Ewoms::FvBaseNewtonMethod< TypeTag >

Public Member Functions

 NewtonMethod (Simulator &simulator)
 
bool converged () const
 Returns true if the error of the solution is below the tolerance.
 
Problem & problem ()
 Returns a reference to the object describing the current physical problem.
 
const Problem & problem () const
 Returns a reference to the object describing the current physical problem.
 
Model & model ()
 Returns a reference to the numeric model.
 
const Model & model () const
 Returns a reference to the numeric model.
 
int numIterations () const
 Returns the number of iterations done since the Newton method was invoked.
 
void setIterationIndex (int value)
 Set the index of current iteration. More...
 
Scalar tolerance () const
 Return the current tolerance at which the Newton method considers itself to be converged.
 
void setTolerance (Scalar value)
 Set the current tolerance at which the Newton method considers itself to be converged.
 
bool apply ()
 Run the Newton method. More...
 
Scalar suggestTimeStepSize (Scalar oldTimeStep) const
 Suggest a new time-step size based on the old time-step size. More...
 
std::ostringstream & endIterMsg ()
 Message that should be printed for the user after the end of an iteration.
 
void eraseMatrix ()
 Causes the solve() method to discared the structure of the linear system of equations the next time it is called.
 
LinearSolverBackend & linearSolver ()
 Returns the linear solver backend object for external use.
 
const LinearSolverBackend & linearSolver () const
 Returns the linear solver backend object for external use. More...
 
const Ewoms::TimerprePostProcessTimer () const
 
const Ewoms::TimerlinearizeTimer () const
 
const Ewoms::TimersolveTimer () const
 
const Ewoms::TimerupdateTimer () const
 

Static Public Member Functions

static void registerParameters ()
 Register all run-time parameters for the Newton method.
 

Protected Member Functions

bool verbose_ () const
 Returns true if the Newton method ought to be chatty.
 
void begin_ (const SolutionVector &u OPM_UNUSED)
 Called before the Newton method is applied to an non-linear system of equations. More...
 
void beginIteration_ ()
 Indicates the beginning of a Newton iteration.
 
void linearize_ ()
 Linearize the global non-linear system of equations.
 
void preSolve_ (const SolutionVector &currentSolution OPM_UNUSED, const GlobalEqVector &currentResidual)
 
void postSolve_ (const SolutionVector &nextSolution OPM_UNUSED, const SolutionVector &currentSolution OPM_UNUSED, const GlobalEqVector &currentResidual OPM_UNUSED, const GlobalEqVector &solutionUpdate OPM_UNUSED)
 Update the error of the solution given the previous iteration. More...
 
void update_ (SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
 Update the current solution with a delta vector. More...
 
void updateConstraintDof_ (unsigned globalDofIdx OPM_UNUSED, PrimaryVariables &nextValue, const Constraints &constraints)
 Update the primary variables for a degree of freedom which is constraint.
 
void updatePrimaryVariables_ (unsigned globalDofIdx OPM_UNUSED, PrimaryVariables &nextValue, const PrimaryVariables &currentValue, const EqVector &update, const EqVector &currentResidual OPM_UNUSED)
 Update a single primary variables object.
 
void writeConvergence_ (const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate)
 Write the convergence behaviour of the newton method to disk. More...
 
void endIteration_ (const SolutionVector &nextSolution OPM_UNUSED, const SolutionVector &currentSolution OPM_UNUSED)
 Indicates that one Newton iteration was finished. More...
 
bool proceed_ () const
 Returns true iff another Newton iteration should be done.
 
void end_ ()
 Indicates that we're done solving the non-linear system of equations.
 
void failed_ ()
 Called if the Newton method broke down. More...
 
void succeeded_ ()
 Called if the Newton method was successful. More...
 
int targetIterations_ () const
 
int maxIterations_ () const
 

Static Protected Member Functions

static bool enableConstraints_ ()
 

Protected Attributes

Simulatorsimulator_
 
Ewoms::Timer prePostProcessTimer_
 
Ewoms::Timer linearizeTimer_
 
Ewoms::Timer solveTimer_
 
Ewoms::Timer updateTimer_
 
std::ostringstream endIterMsgStream_
 
Scalar error_
 
Scalar lastError_
 
Scalar tolerance_
 
int numIterations_
 
LinearSolverBackend linearSolver_
 
CollectiveCommunication comm_
 
ConvergenceWriter convergenceWriter_
 

Detailed Description

template<class TypeTag>
class Ewoms::NewtonMethod< TypeTag >

The multi-dimensional Newton method.

This class uses static polymorphism to allow implementations to implement different update/convergence strategies.

Member Function Documentation

template<class TypeTag >
bool Ewoms::NewtonMethod< TypeTag >::apply ( )
inline

Run the Newton method.

The actual implementation can influence all the strategic decisions via callbacks using static polymorphism.

template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::begin_ ( const SolutionVector &u  OPM_UNUSED)
inlineprotected

Called before the Newton method is applied to an non-linear system of equations.

Parameters
uThe initial solution
template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::endIteration_ ( const SolutionVector &nextSolution  OPM_UNUSED,
const SolutionVector &currentSolution  OPM_UNUSED 
)
inlineprotected

Indicates that one Newton iteration was finished.

Parameters
nextSolutionThe solution after the current Newton iteration
currentSolutionThe solution at the beginning of the current Newton iteration
template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::failed_ ( )
inlineprotected

Called if the Newton method broke down.

This method is called after end_()

template<class TypeTag >
const LinearSolverBackend& Ewoms::NewtonMethod< TypeTag >::linearSolver ( ) const
inline

Returns the linear solver backend object for external use.

template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::postSolve_ ( const SolutionVector &nextSolution  OPM_UNUSED,
const SolutionVector &currentSolution  OPM_UNUSED,
const GlobalEqVector &currentResidual  OPM_UNUSED,
const GlobalEqVector &solutionUpdate  OPM_UNUSED 
)
inlineprotected

Update the error of the solution given the previous iteration.

For our purposes, the error of a solution is defined as the maximum of the weighted residual of a given solution.

Parameters
nextSolutionThe solution after the current iteration
currentSolutionThe solution at the beginning the current iteration
currentResidualThe residual (i.e., right-hand-side) of the current iteration's solution.
solutionUpdateThe difference between the current and the next solution
template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::setIterationIndex ( int  value)
inline

Set the index of current iteration.

Normally this does not need to be called, but if the non-linear solver is implemented externally, it needs to be set in order for the model to do the Right Thing (TM) while linearizing.

template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::succeeded_ ( )
inlineprotected

Called if the Newton method was successful.

This method is called after end_()

template<class TypeTag >
Scalar Ewoms::NewtonMethod< TypeTag >::suggestTimeStepSize ( Scalar  oldTimeStep) const
inline

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.

template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::update_ ( SolutionVector &  nextSolution,
const SolutionVector &  currentSolution,
const GlobalEqVector &  solutionUpdate,
const GlobalEqVector &  currentResidual 
)
inlineprotected

Update the current solution with a delta vector.

Different update strategies, such as chopped updates can be implemented by overriding this method. The default behavior is use the standard Newton-Raphson update strategy, i.e.

\[ u^{k+1} = u^k - \Delta u^k \]

Parameters
nextSolutionThe solution vector after the current iteration
currentSolutionThe solution vector after the last iteration
solutionUpdateThe delta vector as calculated by solving the linear system of equations
currentResidualThe residual vector of the current Newton-Raphson iteraton
template<class TypeTag >
void Ewoms::NewtonMethod< TypeTag >::writeConvergence_ ( const SolutionVector &  currentSolution,
const GlobalEqVector &  solutionUpdate 
)
inlineprotected

Write the convergence behaviour of the newton method to disk.

This method is called as part of the update proceedure.


The documentation for this class was generated from the following file: