Go to the documentation of this file.
   20 #ifndef LIBMESH_PETSC_NONLINEAR_SOLVER_H 
   21 #define LIBMESH_PETSC_NONLINEAR_SOLVER_H 
   23 #include "libmesh/libmesh_config.h" 
   26 #ifdef LIBMESH_HAVE_PETSC 
   29 #include "libmesh/nonlinear_solver.h" 
   30 #include "libmesh/petsc_macro.h" 
   34 # define LIBMESH_SAW_I 
   36 #include <petscsnes.h> 
   38 # undef I // Avoid complex.h contamination 
   43 class ResidualContext;
 
   54 #if PETSC_RELEASE_LESS_THAN(3,5,0) 
   61 #
if PETSC_VERSION_LESS_THAN(3,3,0)
 
   62                                                 SNES, Vec x, Vec y, Vec w, 
void * context, 
PetscBool * changed_y, 
PetscBool * changed_w
 
   64                                                 SNESLineSearch, Vec x, Vec y, Vec w, 
PetscBool * changed_y, 
PetscBool * changed_w, 
void * context
 
   69 #ifdef LIBMESH_ENABLE_DEPRECATED 
   74 #if PETSC_RELEASE_LESS_THAN(3,5,0) 
   81 #
if PETSC_VERSION_LESS_THAN(3,3,0)
 
   82                                                 SNES, Vec x, Vec y, Vec w, 
void * context, 
PetscBool * changed_y, 
PetscBool * changed_w
 
   84                                                 SNESLineSearch, Vec x, Vec y, Vec w, 
PetscBool * changed_y, 
PetscBool * changed_w, 
void * context
 
  121   virtual void clear () 
override;
 
  127   virtual void init (
const char * 
name = 
nullptr) 
override;
 
  138   virtual std::pair<unsigned int, Real>
 
  143          const unsigned int) 
override; 
 
  260 #if !PETSC_VERSION_LESS_THAN(3,3,0) 
  270 #if PETSC_RELEASE_LESS_THAN(3,5,0) 
  282 #endif // #ifdef LIBMESH_HAVE_PETSC 
  283 #endif // LIBMESH_PETSC_NONLINEAR_SOLVER_H 
  
Abstract base class to be used to implement a custom line-search algorithm.
 
virtual void clear() override
Release all memory and clear data structures.
 
NonlinearImplicitSystem sys_type
The type of system.
 
This class provides an interface to PETSc iterative solvers that is compatible with the libMesh Nonli...
 
PetscErrorCode libmesh_petsc_snes_residual(SNES, Vec x, Vec r, void *ctx)
 
virtual void print_converged_reason() override
Prints a useful message about why the latest nonlinear solve con(di)verged.
 
This base class can be inherited from to provide interfaces to nonlinear solvers from different packa...
 
PetscErrorCode __libmesh_petsc_snes_residual(SNES, Vec x, Vec r, void *ctx)
 
bool _zero_out_jacobian
true to zero out jacobian before going into application level call-back, otherwise false
 
friend PetscErrorCode libmesh_petsc_snes_residual(SNES snes, Vec x, Vec r, void *ctx)
 
friend PetscErrorCode libmesh_petsc_snes_fd_residual(SNES snes, Vec x, Vec r, void *ctx)
 
virtual std::pair< unsigned int, Real > solve(SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) override
Call the Petsc solver.
 
The libMesh namespace provides an interface to certain functionality in the library.
 
bool _snesmf_reuse_base
True, If we want the base vector to be used for differencing even if the function provided to SNESSet...
 
PetscErrorCode libmesh_petsc_snes_fd_residual(SNES, Vec x, Vec r, void *ctx)
 
unsigned _current_nonlinear_iteration_number
Stores the current nonlinear iteration number.
 
PetscNonlinearSolver(sys_type &system)
Constructor.
 
PetscErrorCode __libmesh_petsc_snes_monitor(SNES, PetscInt its, PetscReal fnorm, void *)
 
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
 
std::unique_ptr< ComputeLineSearchObject > linesearch_object
A callable object that can be used to specify a custom line-search.
 
PetscErrorCode libmesh_petsc_snes_mffd_residual(SNES snes, Vec x, Vec r, void *ctx)
 
SNESConvergedReason _reason
Store the reason for SNES convergence/divergence for use even after the _snes has been cleared.
 
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
 
void set_residual_zero_out(bool state)
Set if the residual should be zeroed out in the callback.
 
PetscErrorCode __libmesh_petsc_snes_mffd_interface(void *ctx, Vec x, Vec r)
 
void set_snesmf_reuse_base(bool state)
Set to true to let PETSc reuse the base vector.
 
PetscErrorCode libmesh_petsc_snes_jacobian(SNES, Vec x, Mat *jac, Mat *pc, MatStructure *msflag, void *ctx)
 
virtual void init(const char *name=nullptr) override
Initialize data structures if not done so already.
 
PetscErrorCode libmesh_petsc_snes_monitor(SNES, PetscInt its, PetscReal fnorm, void *)
 
friend PetscErrorCode libmesh_petsc_snes_mffd_residual(SNES snes, Vec x, Vec r, void *ctx)
 
PetscErrorCode libmesh_petsc_linesearch_shellfunc(SNESLineSearch linesearch, void *ctx)
 
Callable abstract base class to be used as a callback to provide the solver with a basis for the syst...
 
PetscErrorCode __libmesh_petsc_snes_postcheck(#if PETSC_VERSION_LESS_THAN(3, 3, 0) SNES, Vec x, Vec y, Vec w, void *context, PetscBool *changed_y, PetscBool *changed_w #else SNESLineSearch, Vec x, Vec y, Vec w, PetscBool *changed_y, PetscBool *changed_w, void *context #endif)
 
virtual ~ComputeLineSearchObject()
 
SNESConvergedReason get_converged_reason()
 
void set_jacobian_zero_out(bool state)
Set if the jacobian should be zeroed out in the callback.
 
~PetscNonlinearSolver()
Destructor.
 
PetscErrorCode __libmesh_petsc_snes_fd_residual(SNES, Vec x, Vec r, void *ctx)
 
PetscInt _n_linear_iterations
Stores the total number of linear iterations from the last solve.
 
PetscErrorCode __libmesh_petsc_snes_jacobian(SNES, Vec x, Mat *jac, Mat *pc, MatStructure *msflag, void *ctx)
 
virtual unsigned get_current_nonlinear_iteration_number() const override
 
bool _zero_out_residual
true to zero out residual before going into application level call-back, otherwise false
 
virtual int get_total_linear_iterations() override
Get the total number of linear iterations done in the last solve.
 
SNES _snes
Nonlinear solver context.
 
PetscErrorCode libmesh_petsc_snes_mffd_interface(void *ctx, Vec x, Vec r)
 
friend ResidualContext libmesh_petsc_snes_residual_helper(SNES snes, Vec x, void *ctx)
 
friend PetscErrorCode libmesh_petsc_snes_jacobian(SNES snes, Vec x, Mat *jac, Mat *pc, MatStructure *msflag, void *ctx)
 
virtual void linesearch(SNESLineSearch linesearch)=0
 
PetscErrorCode libmesh_petsc_snes_postcheck(#if PETSC_VERSION_LESS_THAN(3, 3, 0) SNES, Vec x, Vec y, Vec w, void *context, PetscBool *changed_y, PetscBool *changed_w #else SNESLineSearch, Vec x, Vec y, Vec w, PetscBool *changed_y, PetscBool *changed_w, void *context #endif)
 
const sys_type & system() const
 
bool _default_monitor
true if we want the default monitor to be set, false for no monitor (i.e.
 
void build_mat_null_space(NonlinearImplicitSystem::ComputeVectorSubspace *computeSubspaceObject, void(*)(std::vector< NumericVector< Number > * > &, sys_type &), MatNullSpace *)
 
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
 
void use_default_monitor(bool state)
Set to true to use the libMesh's default monitor, set to false to use your own.