16#include <petscsystypes.h>
21namespace dolfinx::nls::petsc
100 void set_F(std::function<
void(
const Vec x, Vec b)> F, Vec b_layout);
121 void set_J(std::function<
void(
const Vec x, Mat Jmat, Mat Pmat)> J,
122 Mat J_layout, Mat P_layout =
nullptr);
128 void set_update(std::function<
void(PetscInt step)> update);
145 "check the converged reason - positive on convergence, negative on "
146 "divergence")]] SNESConvergedReason
171 static PetscErrorCode residual(SNES
snes, Vec x, Vec b,
void* ctx);
172 static PetscErrorCode jacobian(SNES
snes, Vec x, Mat Jmat, Mat Pmat,
178 static PetscErrorCode update_step(SNES
snes, PetscInt step);
182 void set_callbacks();
185 std::function<void(
const Vec x, Vec b)> _fnF;
188 std::function<void(
const Vec x, Mat Jmat, Mat Pmat)> _fnJ;
191 std::function<void(PetscInt step)> _fnupdate;
194 std::exception_ptr _exception;
~SNESSolver()
Destructor.
Definition SNESSolver.cpp:88
std::string get_options_prefix() const
Get the prefix used by PETSc when searching the PETSc options database.
Definition SNESSolver.cpp:223
void set_F(std::function< void(const Vec x, Vec b)> F, Vec b_layout)
Set the function for computing the residual , and the vector that defines its layout.
Definition SNESSolver.cpp:118
SNESConvergedReason solve(Vec x)
Solve .
Definition SNESSolver.cpp:173
SNESSolver(MPI_Comm comm)
Create a nonlinear solver.
Definition SNESSolver.cpp:55
void set_J(std::function< void(const Vec x, Mat Jmat, Mat Pmat)> J, Mat J_layout, Mat P_layout=nullptr)
Set the function for computing the Jacobian , and the matrices that define its layout.
Definition SNESSolver.cpp:136
SNES snes() const
Get the wrapped PETSc SNES object, e.g. to configure the line search or the Krylov solver used for ea...
Definition SNESSolver.cpp:239
void set_update(std::function< void(PetscInt step)> update)
Set a function called before each nonlinear iteration, e.g. to update a time- or step-dependent term.
Definition SNESSolver.cpp:165
void set_options_prefix(std::string_view options_prefix)
Set the prefix used by PETSc when searching the PETSc options database.
Definition SNESSolver.cpp:215
void set_from_options() const
Set options from the PETSc options database.
Definition SNESSolver.cpp:233