DUNE PDELab (2.8)

Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ > Class Template Reference

Newton solver for solving non-linear problems. More...

#include <dune/pdelab/solver/newton.hh>

Public Types

using GridOperator = GridOperator_
 Type of the grid operator.
 
using LinearSolver = LinearSolver_
 Type of the linear solver.
 
using Domain = typename GridOperator::Traits::Domain
 Type of the domain (solution)
 
using Range = typename GridOperator::Traits::Range
 Type of the range (residual)
 
using Jacobian = typename GridOperator::Traits::Jacobian
 Type of the Jacobian matrix.
 
using Real = typename Dune::FieldTraits< typename Domain::ElementType >::real_type
 Number type.
 
using Result = PDESolverResult< Real >
 Type of results.
 
using LineSearch = LineSearchInterface< Domain >
 Type of line search interface.
 

Public Member Functions

Resultresult ()
 Return results.
 
virtual void apply (Domain &solution)
 Solve the nonlinear problem using solution as initial guess and for storing the result.
 
virtual void updateDefect (Domain &solution)
 Update _residual and defect in _result.
 
void setVerbosityLevel (unsigned int verbosity)
 Set how much output you get.
 
unsigned int getVerbosityLevel () const
 Get verbosity level.
 
void setReduction (Real reduction)
 Set reduction Newton needs to achieve.
 
Real getReduction () const
 Get reduction.
 
void setAbsoluteLimit (Real absoluteLimit)
 Set absolute convergence limit.
 
void setKeepMatrix (bool b)
 Set whether the jacobian matrix should be kept across calls to apply().
 
void setUseMaxNorm (bool b)
 Set whether to use the maximum norm for stopping criteria.
 
void setHangingNodeModifications (bool b)
 Does the problem have hanging nodes.
 
bool keepMatrix () const
 Return whether the jacobian matrix is kept across calls to apply().
 
void discardMatrix ()
 Discard the stored Jacobian matrix.
 
void setMinLinearReduction (Real minLinearReduction)
 Set the minimal reduction in the linear solver. More...
 
void setFixedLinearReduction (bool fixedLinearReduction)
 Set wether to use a fixed reduction in the linear solver. More...
 
void setReassembleThreshold (Real reassembleThreshold)
 Set a threshold, when the linear operator is reassembled. More...
 
void setParameters (const ParameterTree &parameterTree)
 Interpret a parameter tree as a set of options for the newton solver. More...
 
void setTerminate (std::shared_ptr< TerminateInterface > terminate)
 Set the termination criterion.
 
std::shared_ptr< TerminateInterface > getTerminate () const
 Return a pointer to the stored termination criterion.
 
void setLineSearch (std::shared_ptr< LineSearch > lineSearch)
 Set the line search. More...
 
std::shared_ptr< LineSearchgetLineSearch () const
 Return a pointer to the stored line search.
 
void printParameters (const std::string &_name="NewtonMethod") const
 Output NewtonMethod parameters. More...
 
 NewtonMethod (const GridOperator &gridOperator, LinearSolver &linearSolver)
 Construct Newton using default parameters with default parameters. More...
 
 NewtonMethod (const GridOperator &gridOperator, LinearSolver &linearSolver, const ParameterTree &parameterTree)
 Construct Newton passing a parameter tree.
 

Detailed Description

template<typename GridOperator_, typename LinearSolver_>
class Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >

Newton solver for solving non-linear problems.

  • The line search and the termination criterion can be changed at runtime by the setTerminate() and the setLineSearch() methods.
  • If Newton is created using the default parameters it is an inexact Newton since the default reduction for the linear systems is quite low. You can change this through setMinLinearReduction()
Template Parameters
GridOperator_Grid operator for evaluation of residual and Jacobian
LinearSolver_Solver backend for solving linear system of equations
Examples
recipe-operator-splitting.cc.

Constructor & Destructor Documentation

◆ NewtonMethod()

template<typename GridOperator_ , typename LinearSolver_ >
Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::NewtonMethod ( const GridOperator gridOperator,
LinearSolver linearSolver 
)
inline

Construct Newton using default parameters with default parameters.

in p

Member Function Documentation

◆ printParameters()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::printParameters ( const std::string &  _name = "NewtonMethod< GridOperator_, LinearSolver_ >") const
inline

Output NewtonMethod parameters.

Setting parameters using ParameterTree is quite error prone. Checking parameters without setting up the debugger can be useful.

◆ setFixedLinearReduction()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::setFixedLinearReduction ( bool  fixedLinearReduction)
inline

Set wether to use a fixed reduction in the linear solver.

Note
If fixedLinearReduction is true, the linear reduction rate will always be fixed to minLinearReduction.

◆ setLineSearch()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::setLineSearch ( std::shared_ptr< LineSearch lineSearch)
inline

Set the line search.

See getLineSearch() for already implemented line searches

◆ setMinLinearReduction()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::setMinLinearReduction ( Real  minLinearReduction)
inline

Set the minimal reduction in the linear solver.

Note
with minLinearReduction > 0, the linear reduction will be determined as mininum of the minLinearReduction and the linear reduction needed to achieve second order Newton convergence. (As long as you are not using a fixed linear reduction)

◆ setParameters()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::setParameters ( const ParameterTree parameterTree)
inline

Interpret a parameter tree as a set of options for the newton solver.

Possible parameters:

example configuration:

[newton_parameters]
ReassembleThreshold = 0.1
AbsoluteLimit = 1e-6
Reduction = 1e-4
MinLinearReduction = 1e-3
MaxIterations = 15
LineSearchDampingFactor = 0.7

and invocation in the code:

newton.setParameters(param.sub("NewtonParameters"));

This can also be used to set single parameters like this

ptree["verbosity"] = "4";
newton.setParameters(ptree);
Hierarchical structure of string parameters.
Definition: parametertree.hh:35

References Dune::ParameterTree::get(), Dune::ParameterTree::hasSub(), and Dune::ParameterTree::sub().

Referenced by Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::NewtonMethod().

◆ setReassembleThreshold()

template<typename GridOperator_ , typename LinearSolver_ >
void Dune::PDELab::NewtonMethod< GridOperator_, LinearSolver_ >::setReassembleThreshold ( Real  reassembleThreshold)
inline

Set a threshold, when the linear operator is reassembled.

We allow to keep the linear operator over several newton iterations. If the reduction in the newton drops below a given threshold the linear operator is reassembled to ensure convergence.


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)