# NewtonSolver¶

class dolfin.cpp.la.NewtonSolver(*args)

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

Create nonlinear solver using provided linear solver Arguments comm (MPI_Ccmm) The MPI communicator. solver (GenericLinearSolver ) The linear solver. factory (GenericLinearAlgebraFactory ) The factory.

Parameters: comm (MPI_Comm) – GenericLinearSolver > solver (std::shared_ptr<) – & factory (GenericLinearAlgebraFactory) –
converged()

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: GenericVector & r (const) – NonlinearProblem & nonlinear_problem (const) – iteration (std::size_t) – bool
static default_parameters()
get_relaxation_parameter()

Get relaxation parameter Returns double Relaxation parameter value.

Return type: double
iteration()

Return current Newton iteration number Returns std::size_t The iteration number.

Return type: std::size_t
krylov_iterations()

Return number of Krylov iterations elapsed since solve started Returns std::size_t The number of iterations.

Return type: std::size_t
linear_solver()

Return the linear solver Returns:cpp:any:GenericLinearSolver The linear solver.

Return type: GenericLinearSolver &
relative_residual()

Return current relative residual Returns double Current relative residual.

Return type: double
residual()

Return current residual Returns double Current residual.

Return type: double
residual0()

Return initial residual Returns double Initial residual.

Return type: double
set_relaxation_parameter()

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.

Parameters: relaxation_parameter (double) – void
solve()

Solve abstract nonlinear problem $$F(x) = 0$$ for given $$F$$ and Jacobian $$\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)

Parameters: & nonlinear_function (NonlinearProblem) – & x (GenericVector) – std::pair< std::size_t, bool >
solver_setup()

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.

Parameters: const GenericMatrix > A (std::shared_ptr<) – const GenericMatrix > P (std::shared_ptr<) – NonlinearProblem & nonlinear_problem (const) – iteration (std::size_t) – void
thisown

The membership flag

update_solution()

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.

Parameters: & x (GenericVector) – GenericVector & dx (const) – relaxation_parameter (double) – NonlinearProblem & nonlinear_problem (const) – iteration (std::size_t) – void