11#include <dolfinx/common/MPI.h>
12#include <dolfinx/la/petsc.h>
41 explicit NewtonSolver(MPI_Comm comm);
44 NewtonSolver(NewtonSolver&& solver) =
default;
47 NewtonSolver(
const NewtonSolver& solver) =
delete;
50 NewtonSolver& operator=(NewtonSolver&& solver) =
default;
53 NewtonSolver& operator=(
const NewtonSolver& solver) =
delete;
64 void setF(std::function<
void(
const Vec, Vec)> F, Vec b);
72 void setJ(std::function<
void(
const Vec, Mat)> J, Mat Jmat);
83 void setP(std::function<
void(
const Vec, Mat)> P, Mat Pmat);
91 const la::petsc::KrylovSolver& get_krylov_solver()
const;
99 la::petsc::KrylovSolver& get_krylov_solver();
106 void set_form(std::function<
void(Vec)> form);
111 void set_convergence_check(
112 std::function<std::pair<double, bool>(
const NewtonSolver&,
const Vec)> c);
124 std::function<
void(
const NewtonSolver& solver,
const Vec, Vec)> update);
131 std::pair<int, bool> solve(Vec x);
136 int iteration()
const;
140 int krylov_iterations()
const;
144 double residual()
const;
148 double residual0()
const;
151 MPI_Comm comm()
const;
164 std::string convergence_criterion =
"residual";
170 bool error_on_nonconvergence =
true;
173 double relaxation_parameter = 1.0;
179 std::function<void(
const Vec x, Vec b)> _fnF;
184 std::function<void(
const Vec x, Mat J)> _fnJ;
189 std::function<void(
const Vec x, Mat P)> _fnP;
193 std::function<void(
const Vec x)> _system;
199 Mat _matJ =
nullptr, _matP =
nullptr;
202 std::function<std::pair<double, bool>(
const NewtonSolver& solver,
207 std::function<void(
const NewtonSolver& solver,
const Vec dx, Vec x)>
211 int _krylov_iterations;
217 double _residual, _residual0;
220 la::petsc::KrylovSolver _solver;
A duplicate MPI communicator and manage lifetime of the communicator.
Definition MPI.h:44
Top-level namespace.
Definition defines.h:12