libMesh
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
libMesh::PetscNonlinearSolver< T > Class Template Reference

This class provides an interface to PETSc iterative solvers that is compatible with the libMesh NonlinearSolver<> More...

#include <petsc_nonlinear_solver.h>

Inheritance diagram for libMesh::PetscNonlinearSolver< T >:
[legend]

Classes

class  ComputeLineSearchObject
 Abstract base class to be used to implement a custom line-search algorithm. More...
 

Public Types

typedef NonlinearImplicitSystem sys_type
 The type of system. More...
 

Public Member Functions

 PetscNonlinearSolver (sys_type &system)
 Constructor. More...
 
 ~PetscNonlinearSolver ()
 Destructor. More...
 
virtual void clear () override
 Release all memory and clear data structures. More...
 
virtual void init (const char *name=nullptr) override
 Initialize data structures if not done so already. More...
 
SNES snes ()
 
virtual std::pair< unsigned int, Realsolve (SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int) override
 Call the Petsc solver. More...
 
virtual void print_converged_reason () override
 Prints a useful message about why the latest nonlinear solve con(di)verged. More...
 
SNESConvergedReason get_converged_reason ()
 
virtual int get_total_linear_iterations () override
 Get the total number of linear iterations done in the last solve. More...
 
virtual unsigned get_current_nonlinear_iteration_number () const override
 
void set_residual_zero_out (bool state)
 Set if the residual should be zeroed out in the callback. More...
 
void set_jacobian_zero_out (bool state)
 Set if the jacobian should be zeroed out in the callback. More...
 
void use_default_monitor (bool state)
 Set to true to use the libMesh's default monitor, set to false to use your own. More...
 
void set_snesmf_reuse_base (bool state)
 Set to true to let PETSc reuse the base vector. More...
 
bool initialized () const
 
const sys_typesystem () const
 
sys_typesystem ()
 
void attach_preconditioner (Preconditioner< T > *preconditioner)
 Attaches a Preconditioner object to be used during the linear solves. More...
 
void set_solver_configuration (SolverConfiguration &solver_configuration)
 Set the solver configuration object. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::unique_ptr< NonlinearSolver< T > > build (sys_type &s, const SolverPackage solver_package=libMesh::default_solver_package())
 Builds a NonlinearSolver using the nonlinear solver package specified by solver_package. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

std::unique_ptr< ComputeLineSearchObjectlinesearch_object
 A callable object that can be used to specify a custom line-search. More...
 
void(* residual )(const NumericVector< Number > &X, NumericVector< Number > &R, sys_type &S)
 Function that computes the residual R(X) of the nonlinear system at the input iterate X. More...
 
NonlinearImplicitSystem::ComputeResidualresidual_object
 Object that computes the residual R(X) of the nonlinear system at the input iterate X. More...
 
NonlinearImplicitSystem::ComputeResidualfd_residual_object
 Object that computes the residual R(X) of the nonlinear system at the input iterate X for the purpose of forming a finite-differenced Jacobian. More...
 
NonlinearImplicitSystem::ComputeResidualmffd_residual_object
 Object that computes the residual R(X) of the nonlinear system at the input iterate X for the purpose of forming Jacobian-vector products via finite differencing. More...
 
void(* jacobian )(const NumericVector< Number > &X, SparseMatrix< Number > &J, sys_type &S)
 Function that computes the Jacobian J(X) of the nonlinear system at the input iterate X. More...
 
NonlinearImplicitSystem::ComputeJacobianjacobian_object
 Object that computes the Jacobian J(X) of the nonlinear system at the input iterate X. More...
 
void(* matvec )(const NumericVector< Number > &X, NumericVector< Number > *R, SparseMatrix< Number > *J, sys_type &S)
 Function that computes either the residual $ R(X) $ or the Jacobian $ J(X) $ of the nonlinear system at the input iterate $ X $. More...
 
NonlinearImplicitSystem::ComputeResidualandJacobianresidual_and_jacobian_object
 Object that computes either the residual $ R(X) $ or the Jacobian $ J(X) $ of the nonlinear system at the input iterate $ X $. More...
 
void(* bounds )(NumericVector< Number > &XL, NumericVector< Number > &XU, sys_type &S)
 Function that computes the lower and upper bounds XL and XU on the solution of the nonlinear system. More...
 
NonlinearImplicitSystem::ComputeBoundsbounds_object
 Object that computes the bounds vectors $ XL $ and $ XU $. More...
 
void(* nullspace )(std::vector< NumericVector< Number > *> &sp, sys_type &S)
 Function that computes a basis for the Jacobian's nullspace – the kernel or the "zero energy modes" – that can be used in solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP). More...
 
NonlinearImplicitSystem::ComputeVectorSubspacenullspace_object
 A callable object that computes a basis for the Jacobian's nullspace – the kernel or the "zero energy modes" – that can be used in solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP). More...
 
void(* transpose_nullspace )(std::vector< NumericVector< Number > *> &sp, sys_type &S)
 Function that computes a basis for the transpose Jacobian's nullspace – when solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP), it is used to remove contributions outside of R(jac) More...
 
NonlinearImplicitSystem::ComputeVectorSubspacetranspose_nullspace_object
 A callable object that computes a basis for the transpose Jacobian's nullspace – when solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP), it is used to remove contributions outside of R(jac) More...
 
void(* nearnullspace )(std::vector< NumericVector< Number > *> &sp, sys_type &S)
 Function that computes a basis for the Jacobian's near nullspace – the set of "low energy modes" – that can be used for AMG coarsening, if the solver supports it (e.g., ML, PETSc's GAMG). More...
 
NonlinearImplicitSystem::ComputeVectorSubspacenearnullspace_object
 A callable object that computes a basis for the Jacobian's near nullspace – the set of "low energy modes" – that can be used for AMG coarsening, if the solver supports it (e.g., ML, PETSc's GAMG). More...
 
void(* user_presolve )(sys_type &S)
 Customizable function pointer which users can attach to the solver. More...
 
void(* postcheck )(const NumericVector< Number > &old_soln, NumericVector< Number > &search_direction, NumericVector< Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln, sys_type &S)
 Function that performs a "check" on the Newton search direction and solution after each nonlinear step. More...
 
NonlinearImplicitSystem::ComputePostCheckpostcheck_object
 A callable object that is executed after each nonlinear iteration. More...
 
unsigned int max_nonlinear_iterations
 Maximum number of non-linear iterations. More...
 
unsigned int max_function_evaluations
 Maximum number of function evaluations. More...
 
Real absolute_residual_tolerance
 The NonlinearSolver should exit after the residual is reduced to either less than absolute_residual_tolerance or less than relative_residual_tolerance times the initial residual. More...
 
Real relative_residual_tolerance
 
Real absolute_step_tolerance
 The NonlinearSolver should exit after the full nonlinear step norm is reduced to either less than absolute_step_tolerance or less than relative_step_tolerance times the largest nonlinear solution which has been seen so far. More...
 
Real relative_step_tolerance
 
unsigned int max_linear_iterations
 Each linear solver step should exit after max_linear_iterations is exceeded. More...
 
Real initial_linear_tolerance
 Any required linear solves will at first be done with this tolerance; the NonlinearSolver may tighten the tolerance for later solves. More...
 
Real minimum_linear_tolerance
 The tolerance for linear solves is kept above this minimum. More...
 
bool converged
 After a call to solve this will reflect whether or not the nonlinear solve was successful. More...
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

void build_mat_null_space (NonlinearImplicitSystem::ComputeVectorSubspace *computeSubspaceObject, void(*)(std::vector< NumericVector< Number > *> &, sys_type &), MatNullSpace *)
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

SNES _snes
 Nonlinear solver context. More...
 
SNESConvergedReason _reason
 Store the reason for SNES convergence/divergence for use even after the _snes has been cleared. More...
 
PetscInt _n_linear_iterations
 Stores the total number of linear iterations from the last solve. More...
 
unsigned _current_nonlinear_iteration_number
 Stores the current nonlinear iteration number. More...
 
bool _zero_out_residual
 true to zero out residual before going into application level call-back, otherwise false More...
 
bool _zero_out_jacobian
 true to zero out jacobian before going into application level call-back, otherwise false More...
 
bool _default_monitor
 true if we want the default monitor to be set, false for no monitor (i.e. More...
 
bool _snesmf_reuse_base
 True, If we want the base vector to be used for differencing even if the function provided to SNESSetFunction() is not the same as that provided to MatMFFDSetFunction(). More...
 
sys_type_system
 A reference to the system we are solving. More...
 
bool _is_initialized
 Flag indicating if the data structures have been initialized. More...
 
Preconditioner< T > * _preconditioner
 Holds the Preconditioner object to be used for the linear solves. More...
 
SolverConfiguration_solver_configuration
 Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits. More...
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter
 Flag to control whether reference count information is printed when print_info is called. More...
 

Friends

ResidualContext libmesh_petsc_snes_residual_helper (SNES snes, Vec x, void *ctx)
 
PetscErrorCode libmesh_petsc_snes_residual (SNES snes, Vec x, Vec r, void *ctx)
 
PetscErrorCode libmesh_petsc_snes_fd_residual (SNES snes, Vec x, Vec r, void *ctx)
 
PetscErrorCode libmesh_petsc_snes_mffd_residual (SNES snes, Vec x, Vec r, void *ctx)
 
PetscErrorCode libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat *jac, Mat *pc, MatStructure *msflag, void *ctx)
 
PetscErrorCode libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat jac, Mat pc, void *ctx)
 

Detailed Description

template<typename T>
class libMesh::PetscNonlinearSolver< T >

This class provides an interface to PETSc iterative solvers that is compatible with the libMesh NonlinearSolver<>

Author
Benjamin Kirk
Date
2002-2007

Definition at line 93 of file petsc_nonlinear_solver.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

◆ sys_type

template<typename T >
typedef NonlinearImplicitSystem libMesh::PetscNonlinearSolver< T >::sys_type

The type of system.

Definition at line 99 of file petsc_nonlinear_solver.h.

Constructor & Destructor Documentation

◆ PetscNonlinearSolver()

template<typename T >
libMesh::PetscNonlinearSolver< T >::PetscNonlinearSolver ( sys_type system)
explicit

Constructor.

Initializes Petsc data structures

◆ ~PetscNonlinearSolver()

template<typename T >
libMesh::PetscNonlinearSolver< T >::~PetscNonlinearSolver ( )

Destructor.

Member Function Documentation

◆ attach_preconditioner()

template<typename T >
void libMesh::NonlinearSolver< T >::attach_preconditioner ( Preconditioner< T > *  preconditioner)
inherited

Attaches a Preconditioner object to be used during the linear solves.

◆ build()

template<typename T >
static std::unique_ptr<NonlinearSolver<T> > libMesh::NonlinearSolver< T >::build ( sys_type s,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

Builds a NonlinearSolver using the nonlinear solver package specified by solver_package.

◆ build_mat_null_space()

template<typename T >
void libMesh::PetscNonlinearSolver< T >::build_mat_null_space ( NonlinearImplicitSystem::ComputeVectorSubspace computeSubspaceObject,
void(*)(std::vector< NumericVector< Number > * > &, sys_type &)  ,
MatNullSpace *   
)
protected

◆ clear()

template<typename T >
virtual void libMesh::PetscNonlinearSolver< T >::clear ( )
overridevirtual

Release all memory and clear data structures.

Reimplemented from libMesh::NonlinearSolver< T >.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ disable_print_counter_info()

static void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

◆ enable_print_counter_info()

static void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

◆ get_converged_reason()

template<typename T >
SNESConvergedReason libMesh::PetscNonlinearSolver< T >::get_converged_reason ( )
Returns
The currently-available (or most recently obtained, if the SNES object has been destroyed) convergence reason.

Refer to PETSc docs for the meaning of different SNESConvergedReasons.

◆ get_current_nonlinear_iteration_number()

template<typename T >
virtual unsigned libMesh::PetscNonlinearSolver< T >::get_current_nonlinear_iteration_number ( ) const
overridevirtual
Returns
The current nonlinear iteration number if called during the solve(), for example by the user-specified residual or Jacobian function.

Implements libMesh::NonlinearSolver< T >.

Definition at line 164 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_current_nonlinear_iteration_number.

unsigned _current_nonlinear_iteration_number
Stores the current nonlinear iteration number.

◆ get_info()

static std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

◆ get_total_linear_iterations()

template<typename T >
virtual int libMesh::PetscNonlinearSolver< T >::get_total_linear_iterations ( )
overridevirtual

Get the total number of linear iterations done in the last solve.

Implements libMesh::NonlinearSolver< T >.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 181 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 194 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }
std::string name(const ElemQuality q)
static Counts _counts
Actually holds the data.
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.

◆ init()

template<typename T >
virtual void libMesh::PetscNonlinearSolver< T >::init ( const char *  name = nullptr)
overridevirtual

Initialize data structures if not done so already.

May assign a name to the solver in some implementations

Implements libMesh::NonlinearSolver< T >.

Referenced by libMesh::PetscNonlinearSolver< T >::snes().

◆ initialized()

template<typename T >
bool libMesh::NonlinearSolver< T >::initialized ( ) const
inherited
Returns
true if the data structures are initialized, false otherwise.

Definition at line 92 of file nonlinear_solver.h.

References libMesh::NonlinearSolver< T >::_is_initialized.

92 { return _is_initialized; }
bool _is_initialized
Flag indicating if the data structures have been initialized.

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 83 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ print_converged_reason()

template<typename T >
virtual void libMesh::PetscNonlinearSolver< T >::print_converged_reason ( )
overridevirtual

Prints a useful message about why the latest nonlinear solve con(di)verged.

Reimplemented from libMesh::NonlinearSolver< T >.

◆ print_info()

static void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ set_jacobian_zero_out()

template<typename T >
void libMesh::PetscNonlinearSolver< T >::set_jacobian_zero_out ( bool  state)

Set if the jacobian should be zeroed out in the callback.

Definition at line 175 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_zero_out_jacobian.

175 { _zero_out_jacobian = state; }
bool _zero_out_jacobian
true to zero out jacobian before going into application level call-back, otherwise false ...

◆ set_residual_zero_out()

template<typename T >
void libMesh::PetscNonlinearSolver< T >::set_residual_zero_out ( bool  state)

Set if the residual should be zeroed out in the callback.

Definition at line 170 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_zero_out_residual.

170 { _zero_out_residual = state; }
bool _zero_out_residual
true to zero out residual before going into application level call-back, otherwise false ...

◆ set_snesmf_reuse_base()

template<typename T >
void libMesh::PetscNonlinearSolver< T >::set_snesmf_reuse_base ( bool  state)

Set to true to let PETSc reuse the base vector.

Definition at line 185 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_snesmf_reuse_base.

185 { _snesmf_reuse_base = state; }
bool _snesmf_reuse_base
True, If we want the base vector to be used for differencing even if the function provided to SNESSet...

◆ set_solver_configuration()

template<typename T >
void libMesh::NonlinearSolver< T >::set_solver_configuration ( SolverConfiguration solver_configuration)
inherited

Set the solver configuration object.

◆ snes()

template<typename T >
SNES libMesh::PetscNonlinearSolver< T >::snes ( )
Returns
The raw PETSc snes context pointer.

Definition at line 126 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_snes, and libMesh::PetscNonlinearSolver< T >::init().

126 { this->init(); return _snes; }
SNES _snes
Nonlinear solver context.
virtual void init(const char *name=nullptr) override
Initialize data structures if not done so already.

◆ solve()

template<typename T >
virtual std::pair<unsigned int, Real> libMesh::PetscNonlinearSolver< T >::solve ( SparseMatrix< T > &  ,
NumericVector< T > &  ,
NumericVector< T > &  ,
const double  ,
const unsigned  int 
)
overridevirtual

Call the Petsc solver.

It calls the method below, using the same matrix for the system and preconditioner matrices.

Implements libMesh::NonlinearSolver< T >.

◆ system() [1/2]

template<typename T >
const sys_type& libMesh::NonlinearSolver< T >::system ( ) const
inherited
Returns
A constant reference to the system we are solving.

Definition at line 280 of file nonlinear_solver.h.

References libMesh::NonlinearSolver< T >::_system.

280 { return _system; }
sys_type & _system
A reference to the system we are solving.

◆ system() [2/2]

template<typename T >
sys_type& libMesh::NonlinearSolver< T >::system ( )
inherited
Returns
A writable reference to the system we are solving.

Definition at line 285 of file nonlinear_solver.h.

References libMesh::NonlinearSolver< T >::_system.

285 { return _system; }
sys_type & _system
A reference to the system we are solving.

◆ use_default_monitor()

template<typename T >
void libMesh::PetscNonlinearSolver< T >::use_default_monitor ( bool  state)

Set to true to use the libMesh's default monitor, set to false to use your own.

Definition at line 180 of file petsc_nonlinear_solver.h.

References libMesh::PetscNonlinearSolver< T >::_default_monitor.

180 { _default_monitor = state; }
bool _default_monitor
true if we want the default monitor to be set, false for no monitor (i.e.

Friends And Related Function Documentation

◆ libmesh_petsc_snes_fd_residual

template<typename T >
PetscErrorCode libmesh_petsc_snes_fd_residual ( SNES  snes,
Vec  x,
Vec  r,
void *  ctx 
)
friend

◆ libmesh_petsc_snes_jacobian [1/2]

template<typename T >
PetscErrorCode libmesh_petsc_snes_jacobian ( SNES  snes,
Vec  x,
Mat *  jac,
Mat *  pc,
MatStructure *  msflag,
void *  ctx 
)
friend

◆ libmesh_petsc_snes_jacobian [2/2]

template<typename T >
PetscErrorCode libmesh_petsc_snes_jacobian ( SNES  snes,
Vec  x,
Mat  jac,
Mat  pc,
void *  ctx 
)
friend

◆ libmesh_petsc_snes_mffd_residual

template<typename T >
PetscErrorCode libmesh_petsc_snes_mffd_residual ( SNES  snes,
Vec  x,
Vec  r,
void *  ctx 
)
friend

◆ libmesh_petsc_snes_residual

template<typename T >
PetscErrorCode libmesh_petsc_snes_residual ( SNES  snes,
Vec  x,
Vec  r,
void *  ctx 
)
friend

◆ libmesh_petsc_snes_residual_helper

template<typename T >
ResidualContext libmesh_petsc_snes_residual_helper ( SNES  snes,
Vec  x,
void *  ctx 
)
friend

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _current_nonlinear_iteration_number

template<typename T >
unsigned libMesh::PetscNonlinearSolver< T >::_current_nonlinear_iteration_number
protected

Stores the current nonlinear iteration number.

Definition at line 230 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::get_current_nonlinear_iteration_number().

◆ _default_monitor

template<typename T >
bool libMesh::PetscNonlinearSolver< T >::_default_monitor
protected

true if we want the default monitor to be set, false for no monitor (i.e.

user code can use their own)

Definition at line 245 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::use_default_monitor().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

◆ _is_initialized

template<typename T >
bool libMesh::NonlinearSolver< T >::_is_initialized
protectedinherited

Flag indicating if the data structures have been initialized.

Definition at line 366 of file nonlinear_solver.h.

Referenced by libMesh::NonlinearSolver< T >::initialized().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_linear_iterations

template<typename T >
PetscInt libMesh::PetscNonlinearSolver< T >::_n_linear_iterations
protected

Stores the total number of linear iterations from the last solve.

Definition at line 225 of file petsc_nonlinear_solver.h.

◆ _n_objects

Threads::atomic<unsigned int> libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _preconditioner

template<typename T >
Preconditioner<T>* libMesh::NonlinearSolver< T >::_preconditioner
protectedinherited

Holds the Preconditioner object to be used for the linear solves.

Definition at line 371 of file nonlinear_solver.h.

◆ _reason

template<typename T >
SNESConvergedReason libMesh::PetscNonlinearSolver< T >::_reason
protected

Store the reason for SNES convergence/divergence for use even after the _snes has been cleared.

Note
print_converged_reason() will always try to get the current reason with SNESGetConvergedReason(), but if the SNES object has already been cleared, it will fall back on this stored value. This value is therefore necessarily not cleared by the clear() function.

Definition at line 220 of file petsc_nonlinear_solver.h.

◆ _snes

template<typename T >
SNES libMesh::PetscNonlinearSolver< T >::_snes
protected

Nonlinear solver context.

Definition at line 208 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::snes().

◆ _snesmf_reuse_base

template<typename T >
bool libMesh::PetscNonlinearSolver< T >::_snesmf_reuse_base
protected

True, If we want the base vector to be used for differencing even if the function provided to SNESSetFunction() is not the same as that provided to MatMFFDSetFunction().

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/MatSNESMFSetReuseBase.html

Definition at line 252 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::set_snesmf_reuse_base().

◆ _solver_configuration

template<typename T >
SolverConfiguration* libMesh::NonlinearSolver< T >::_solver_configuration
protectedinherited

Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits.

Definition at line 377 of file nonlinear_solver.h.

◆ _system

template<typename T >
sys_type& libMesh::NonlinearSolver< T >::_system
protectedinherited

A reference to the system we are solving.

Definition at line 361 of file nonlinear_solver.h.

Referenced by libMesh::NonlinearSolver< T >::system().

◆ _zero_out_jacobian

template<typename T >
bool libMesh::PetscNonlinearSolver< T >::_zero_out_jacobian
protected

true to zero out jacobian before going into application level call-back, otherwise false

Definition at line 240 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::set_jacobian_zero_out().

◆ _zero_out_residual

template<typename T >
bool libMesh::PetscNonlinearSolver< T >::_zero_out_residual
protected

true to zero out residual before going into application level call-back, otherwise false

Definition at line 235 of file petsc_nonlinear_solver.h.

Referenced by libMesh::PetscNonlinearSolver< T >::set_residual_zero_out().

◆ absolute_residual_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::absolute_residual_tolerance
inherited

The NonlinearSolver should exit after the residual is reduced to either less than absolute_residual_tolerance or less than relative_residual_tolerance times the initial residual.

Users should increase any of these tolerances that they want to use for a stopping condition.

Definition at line 312 of file nonlinear_solver.h.

◆ absolute_step_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::absolute_step_tolerance
inherited

The NonlinearSolver should exit after the full nonlinear step norm is reduced to either less than absolute_step_tolerance or less than relative_step_tolerance times the largest nonlinear solution which has been seen so far.

Users should increase any of these tolerances that they want to use for a stopping condition.

Note
Not all NonlinearSolvers support relative_step_tolerance!

Definition at line 326 of file nonlinear_solver.h.

◆ bounds

template<typename T >
void(* libMesh::NonlinearSolver< T >::bounds) (NumericVector< Number > &XL, NumericVector< Number > &XU, sys_type &S)
inherited

Function that computes the lower and upper bounds XL and XU on the solution of the nonlinear system.

Definition at line 199 of file nonlinear_solver.h.

◆ bounds_object

template<typename T >
NonlinearImplicitSystem::ComputeBounds* libMesh::NonlinearSolver< T >::bounds_object
inherited

Object that computes the bounds vectors $ XL $ and $ XU $.

Definition at line 205 of file nonlinear_solver.h.

◆ converged

template<typename T >
bool libMesh::NonlinearSolver< T >::converged
inherited

After a call to solve this will reflect whether or not the nonlinear solve was successful.

Definition at line 350 of file nonlinear_solver.h.

◆ fd_residual_object

template<typename T >
NonlinearImplicitSystem::ComputeResidual* libMesh::NonlinearSolver< T >::fd_residual_object
inherited

Object that computes the residual R(X) of the nonlinear system at the input iterate X for the purpose of forming a finite-differenced Jacobian.

Definition at line 152 of file nonlinear_solver.h.

◆ initial_linear_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::initial_linear_tolerance
inherited

Any required linear solves will at first be done with this tolerance; the NonlinearSolver may tighten the tolerance for later solves.

Definition at line 339 of file nonlinear_solver.h.

◆ jacobian

template<typename T >
void(* libMesh::NonlinearSolver< T >::jacobian) (const NumericVector< Number > &X, SparseMatrix< Number > &J, sys_type &S)
inherited

Function that computes the Jacobian J(X) of the nonlinear system at the input iterate X.

Definition at line 165 of file nonlinear_solver.h.

◆ jacobian_object

template<typename T >
NonlinearImplicitSystem::ComputeJacobian* libMesh::NonlinearSolver< T >::jacobian_object
inherited

Object that computes the Jacobian J(X) of the nonlinear system at the input iterate X.

Definition at line 173 of file nonlinear_solver.h.

◆ linesearch_object

template<typename T >
std::unique_ptr<ComputeLineSearchObject> libMesh::PetscNonlinearSolver< T >::linesearch_object

A callable object that can be used to specify a custom line-search.

Definition at line 201 of file petsc_nonlinear_solver.h.

◆ matvec

template<typename T >
void(* libMesh::NonlinearSolver< T >::matvec) (const NumericVector< Number > &X, NumericVector< Number > *R, SparseMatrix< Number > *J, sys_type &S)
inherited

Function that computes either the residual $ R(X) $ or the Jacobian $ J(X) $ of the nonlinear system at the input iterate $ X $.

Note
Either R or J could be nullptr.

Definition at line 182 of file nonlinear_solver.h.

◆ max_function_evaluations

template<typename T >
unsigned int libMesh::NonlinearSolver< T >::max_function_evaluations
inherited

Maximum number of function evaluations.

Definition at line 300 of file nonlinear_solver.h.

◆ max_linear_iterations

template<typename T >
unsigned int libMesh::NonlinearSolver< T >::max_linear_iterations
inherited

Each linear solver step should exit after max_linear_iterations is exceeded.

Definition at line 333 of file nonlinear_solver.h.

◆ max_nonlinear_iterations

template<typename T >
unsigned int libMesh::NonlinearSolver< T >::max_nonlinear_iterations
inherited

Maximum number of non-linear iterations.

Definition at line 295 of file nonlinear_solver.h.

◆ mffd_residual_object

template<typename T >
NonlinearImplicitSystem::ComputeResidual* libMesh::NonlinearSolver< T >::mffd_residual_object
inherited

Object that computes the residual R(X) of the nonlinear system at the input iterate X for the purpose of forming Jacobian-vector products via finite differencing.

Definition at line 159 of file nonlinear_solver.h.

◆ minimum_linear_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::minimum_linear_tolerance
inherited

The tolerance for linear solves is kept above this minimum.

Definition at line 344 of file nonlinear_solver.h.

◆ nearnullspace

template<typename T >
void(* libMesh::NonlinearSolver< T >::nearnullspace) (std::vector< NumericVector< Number > * > &sp, sys_type &S)
inherited

Function that computes a basis for the Jacobian's near nullspace – the set of "low energy modes" – that can be used for AMG coarsening, if the solver supports it (e.g., ML, PETSc's GAMG).

Definition at line 242 of file nonlinear_solver.h.

◆ nearnullspace_object

template<typename T >
NonlinearImplicitSystem::ComputeVectorSubspace* libMesh::NonlinearSolver< T >::nearnullspace_object
inherited

A callable object that computes a basis for the Jacobian's near nullspace – the set of "low energy modes" – that can be used for AMG coarsening, if the solver supports it (e.g., ML, PETSc's GAMG).

Definition at line 249 of file nonlinear_solver.h.

◆ nullspace

template<typename T >
void(* libMesh::NonlinearSolver< T >::nullspace) (std::vector< NumericVector< Number > * > &sp, sys_type &S)
inherited

Function that computes a basis for the Jacobian's nullspace – the kernel or the "zero energy modes" – that can be used in solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP).

Definition at line 213 of file nonlinear_solver.h.

◆ nullspace_object

template<typename T >
NonlinearImplicitSystem::ComputeVectorSubspace* libMesh::NonlinearSolver< T >::nullspace_object
inherited

A callable object that computes a basis for the Jacobian's nullspace – the kernel or the "zero energy modes" – that can be used in solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP).

Definition at line 221 of file nonlinear_solver.h.

◆ postcheck

template<typename T >
void(* libMesh::NonlinearSolver< T >::postcheck) (const NumericVector< Number > &old_soln, NumericVector< Number > &search_direction, NumericVector< Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln, sys_type &S)
inherited

Function that performs a "check" on the Newton search direction and solution after each nonlinear step.

See documentation for the NonlinearImplicitSystem::ComputePostCheck object for more information about the calling sequence.

Definition at line 263 of file nonlinear_solver.h.

◆ postcheck_object

template<typename T >
NonlinearImplicitSystem::ComputePostCheck* libMesh::NonlinearSolver< T >::postcheck_object
inherited

A callable object that is executed after each nonlinear iteration.

Allows the user to modify both the search direction and the solution vector in an application-specific way.

Definition at line 275 of file nonlinear_solver.h.

◆ relative_residual_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::relative_residual_tolerance
inherited

Definition at line 313 of file nonlinear_solver.h.

◆ relative_step_tolerance

template<typename T >
Real libMesh::NonlinearSolver< T >::relative_step_tolerance
inherited

Definition at line 327 of file nonlinear_solver.h.

◆ residual

template<typename T >
void(* libMesh::NonlinearSolver< T >::residual) (const NumericVector< Number > &X, NumericVector< Number > &R, sys_type &S)
inherited

Function that computes the residual R(X) of the nonlinear system at the input iterate X.

Definition at line 138 of file nonlinear_solver.h.

◆ residual_and_jacobian_object

template<typename T >
NonlinearImplicitSystem::ComputeResidualandJacobian* libMesh::NonlinearSolver< T >::residual_and_jacobian_object
inherited

Object that computes either the residual $ R(X) $ or the Jacobian $ J(X) $ of the nonlinear system at the input iterate $ X $.

Note
Either R or J could be nullptr.

Definition at line 194 of file nonlinear_solver.h.

◆ residual_object

template<typename T >
NonlinearImplicitSystem::ComputeResidual* libMesh::NonlinearSolver< T >::residual_object
inherited

Object that computes the residual R(X) of the nonlinear system at the input iterate X.

Definition at line 146 of file nonlinear_solver.h.

◆ transpose_nullspace

template<typename T >
void(* libMesh::NonlinearSolver< T >::transpose_nullspace) (std::vector< NumericVector< Number > * > &sp, sys_type &S)
inherited

Function that computes a basis for the transpose Jacobian's nullspace – when solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP), it is used to remove contributions outside of R(jac)

Definition at line 228 of file nonlinear_solver.h.

◆ transpose_nullspace_object

template<typename T >
NonlinearImplicitSystem::ComputeVectorSubspace* libMesh::NonlinearSolver< T >::transpose_nullspace_object
inherited

A callable object that computes a basis for the transpose Jacobian's nullspace – when solving a degenerate problem iteratively, if the solver supports it (e.g., PETSc's KSP), it is used to remove contributions outside of R(jac)

Definition at line 235 of file nonlinear_solver.h.

◆ user_presolve

template<typename T >
void(* libMesh::NonlinearSolver< T >::user_presolve) (sys_type &S)
inherited

Customizable function pointer which users can attach to the solver.

Gets called prior to every call to solve().

Definition at line 255 of file nonlinear_solver.h.


The documentation for this class was generated from the following file: