DOLFIN
DOLFIN C++ interface
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
dolfin::NewtonSolver Class Reference

#include <NewtonSolver.h>

Inheritance diagram for dolfin::NewtonSolver:
Inheritance graph
[legend]
Collaboration diagram for dolfin::NewtonSolver:
Collaboration graph
[legend]

Public Member Functions

 NewtonSolver (MPI_Comm comm=MPI_COMM_WORLD)
 Create nonlinear solver.
 
 NewtonSolver (MPI_Comm comm, std::shared_ptr< GenericLinearSolver > solver, GenericLinearAlgebraFactory &factory)
 
virtual ~NewtonSolver ()
 Destructor.
 
std::pair< std::size_t, bool > solve (NonlinearProblem &nonlinear_function, GenericVector &x)
 
std::size_t iteration () const
 
std::size_t krylov_iterations () const
 
double residual () const
 
double residual0 () const
 
double relative_residual () const
 
GenericLinearSolverlinear_solver () const
 
void set_relaxation_parameter (double relaxation_parameter)
 
double get_relaxation_parameter ()
 
- Public Member Functions inherited from dolfin::Variable
 Variable ()
 Create unnamed variable.
 
 Variable (const std::string name, const std::string label)
 Create variable with given name and label.
 
 Variable (const Variable &variable)
 Copy constructor.
 
virtual ~Variable ()
 Destructor.
 
const Variableoperator= (const Variable &variable)
 Assignment operator.
 
void rename (const std::string name, const std::string label)
 Rename variable.
 
std::string name () const
 Return name.
 
std::string label () const
 Return label (description)
 
std::size_t id () const
 
virtual std::string str (bool verbose) const
 Return informal string representation (pretty-print)
 

Static Public Member Functions

static Parameters default_parameters ()
 

Protected Member Functions

virtual bool converged (const GenericVector &r, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
 
virtual void solver_setup (std::shared_ptr< const GenericMatrix > A, std::shared_ptr< const GenericMatrix > P, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
 
virtual void update_solution (GenericVector &x, const GenericVector &dx, double relaxation_parameter, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
 

Additional Inherited Members

- Public Attributes inherited from dolfin::Variable
Parameters parameters
 Parameters.
 

Detailed Description

This class defines a Newton solver for nonlinear systems of equations of the form :math:F(x) = 0.

Constructor & Destructor Documentation

NewtonSolver::NewtonSolver ( MPI_Comm  comm,
std::shared_ptr< GenericLinearSolver solver,
GenericLinearAlgebraFactory factory 
)

Create nonlinear solver using provided linear solver

Arguments comm (MPI_Ccmm) The MPI communicator. solver (GenericLinearSolver) The linear solver. factory (GenericLinearAlgebraFactory) The factory.

Member Function Documentation

bool NewtonSolver::converged ( const GenericVector r,
const NonlinearProblem nonlinear_problem,
std::size_t  iteration 
)
protectedvirtual

Convergence test. It may be overloaded using virtual inheritance and this base criterion may be called from derived, both in C++ and Python.

Arguments r (GenericVector) Residual for criterion evaluation. nonlinear_problem (NonlinearProblem) The nonlinear problem. iteration (std::size_t) Newton iteration number.

Returns bool Whether convergence occurred.

Parameters NewtonSolver::default_parameters ( )
static

Default parameter values

Returns Parameters Parameter values.

double dolfin::NewtonSolver::get_relaxation_parameter ( )
inline

Get relaxation parameter

Returns double Relaxation parameter value.

std::size_t NewtonSolver::iteration ( ) const

Return current Newton iteration number

Returns std::size_t The iteration number.

std::size_t NewtonSolver::krylov_iterations ( ) const

Return number of Krylov iterations elapsed since solve started

Returns std::size_t The number of iterations.

GenericLinearSolver & NewtonSolver::linear_solver ( ) const

Return the linear solver

Returns GenericLinearSolver The linear solver.

double NewtonSolver::relative_residual ( ) const

Return current relative residual

Returns double Current relative residual.

double NewtonSolver::residual ( ) const

Return current residual

Returns double Current residual.

double NewtonSolver::residual0 ( ) const

Return initial residual

Returns double Initial residual.

void dolfin::NewtonSolver::set_relaxation_parameter ( double  relaxation_parameter)
inline

Set relaxation parameter. Default value 1.0 means full Newton method, value smaller than 1.0 relaxes the method by shrinking effective Newton step size by the given factor.

Arguments relaxation_parameter(double) Relaxation parameter value.

std::pair< std::size_t, bool > NewtonSolver::solve ( NonlinearProblem nonlinear_function,
GenericVector x 
)

Solve abstract nonlinear problem :math:F(x) = 0 for given :math:F and Jacobian :math:\dfrac{\partial F}{\partial x}.

Arguments nonlinear_function (NonlinearProblem) The nonlinear problem. x (GenericVector) The vector.

Returns std::pair<std::size_t, bool> Pair of number of Newton iterations, and whether iteration converged)

void NewtonSolver::solver_setup ( std::shared_ptr< const GenericMatrix A,
std::shared_ptr< const GenericMatrix P,
const NonlinearProblem nonlinear_problem,
std::size_t  iteration 
)
protectedvirtual

Setup solver to be used with system matrix A and preconditioner matrix P. It may be overloaded to get finer control over linear solver setup, various linesearch tricks, etc. Note that minimal implementation should call set_operators method of the linear solver.

Arguments A (std::shared_ptr<const GenericMatrix>) System Jacobian matrix. J (std::shared_ptr<const GenericMatrix>) System preconditioner matrix. nonlinear_problem (NonlinearProblem) The nonlinear problem. iteration (std::size_t) Newton iteration number.

void NewtonSolver::update_solution ( GenericVector x,
const GenericVector dx,
double  relaxation_parameter,
const NonlinearProblem nonlinear_problem,
std::size_t  iteration 
)
protectedvirtual

Update solution vector by computed Newton step. Default update is given by formula::

x -= relaxation_parameter*dx

Arguments x (GenericVector>) The solution vector to be updated. dx (GenericVector>) The update vector computed by Newton step. relaxation_parameter (double) Newton relaxation parameter. nonlinear_problem (NonlinearProblem) The nonlinear problem. iteration (std::size_t) Newton iteration number.


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