NewtonSolver.h

Note

The documentation on this page was automatically extracted from the DOLFIN C++ code and may need to be edited or expanded.

class NewtonSolver

Parent class(es)

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

explicit NewtonSolver(MPI_Comm comm = MPI_COMM_WORLD)

Create nonlinear solver

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.
std::pair<std::size_t, bool> solve(NonlinearProblem &nonlinear_function, GenericVector &x)

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)
std::size_t iteration() const

Return Newton iteration number

Returns
std::size_t
The iteration number.
double residual() const

Return current residual

Returns
double
Current residual.
double relative_residual() const

Return current relative residual

Returns
double
Current relative residual.
GenericLinearSolver &linear_solver() const

Return the linear solver

Returns
GenericLinearSolver
The linear solver.
static Parameters default_parameters()

Default parameter values

Returns
Parameters
Parameter values.
bool converged(const GenericVector &r, const NonlinearProblem &nonlinear_problem, std::size_t iteration)

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 occured.