20 #ifndef __PETSC_SNES_SOLVER_H 21 #define __PETSC_SNES_SOLVER_H 27 #include <petscsnes.h> 29 #include <dolfin/common/MPI.h> 30 #include <dolfin/la/PETScObject.h> 31 #include <dolfin/la/PETScMatrix.h> 32 #include <dolfin/nls/NewtonSolver.h> 33 #include <dolfin/parameter/Parameters.h> 50 explicit PETScSNESSolver(MPI_Comm comm, std::string nls_type=
"default");
114 static std::vector<std::pair<std::string, std::string>>
methods();
131 snes_ctx_t() : nonlinear_problem(NULL), x(NULL), f_tmp(NULL), xl(NULL),
152 void set_linear_solver_parameters();
155 static const std::map<std::string,
156 std::pair<std::string, const SNESType>> _methods;
159 static PetscErrorCode FormFunction(SNES
snes, Vec x, Vec f,
void* ctx);
162 static PetscErrorCode FormJacobian(SNES snes, Vec x, Mat A, Mat B,
165 static PetscErrorCode FormObjective(SNES snes, Vec x, PetscReal* out,
184 std::shared_ptr<const PETScVector> lb;
185 std::shared_ptr<const PETScVector> ub;
188 bool _has_explicit_bounds;
191 struct snes_ctx_t _snes_ctx;
Definition: PETScVector.h:60
void set_options_prefix(std::string options_prefix)
Definition: PETScSNESSolver.cpp:291
void set_from_options() const
Set options from the PETSc options database.
Definition: PETScSNESSolver.cpp:308
MPI_Comm mpi_comm() const
Return the MPI communicator.
Definition: PETScSNESSolver.cpp:315
std::pair< std::size_t, bool > solve(NonlinearProblem &nonlinear_problem, GenericVector &x, const GenericVector &lb, const GenericVector &ub)
Definition: PETScSNESSolver.cpp:142
Definition: PETScMatrix.h:58
Definition: NonlinearProblem.h:36
virtual ~PETScSNESSolver()
Destructor.
Definition: PETScSNESSolver.cpp:135
std::string get_options_prefix() const
Definition: PETScSNESSolver.cpp:299
PETScSNESSolver(MPI_Comm comm, std::string nls_type="default")
Create SNES solver.
Definition: PETScSNESSolver.cpp:98
Definition: Parameters.h:94
Definition: PETScSNESSolver.h:45
Parameters parameters
Parameters.
Definition: PETScSNESSolver.h:120
static std::vector< std::pair< std::string, std::string > > methods()
Return a list of available solver methods.
Definition: PETScSNESSolver.cpp:75
SNES snes() const
Return PETSc SNES pointer.
Definition: PETScSNESSolver.h:123
void init(NonlinearProblem &nonlinear_problem, GenericVector &x)
Definition: PETScSNESSolver.cpp:173
Definition: PETScObject.h:33
static Parameters default_parameters()
Default parameter values.
Definition: PETScSNESSolver.cpp:83
This class defines a common interface for vectors.
Definition: GenericVector.h:47