libMesh

This class defines a solver which uses a PETSc SNES context to handle a DifferentiableSystem. More...
#include <petsc_diff_solver.h>
Public Types  
typedef DiffSolver  Parent 
enum  SolveResult { INVALID_SOLVE_RESULT = 0, CONVERGED_NO_REASON = 1, CONVERGED_ABSOLUTE_RESIDUAL = 2, CONVERGED_RELATIVE_RESIDUAL = 4, CONVERGED_ABSOLUTE_STEP = 8, CONVERGED_RELATIVE_STEP = 16, DIVERGED_NO_REASON = 32, DIVERGED_MAX_NONLINEAR_ITERATIONS = 64, DIVERGED_BACKTRACKING_FAILURE = 128, DIVERGED_LINEAR_SOLVER_FAILURE = 256 } 
Enumeration return type for the solve() function. More...  
typedef ImplicitSystem  sys_type 
The type of system. More...  
Public Member Functions  
PetscDiffSolver (sys_type &system)  
Constructor. More...  
virtual  ~PetscDiffSolver () 
Destructor. More...  
virtual void  reinit () override 
The reinitialization function. More...  
virtual void  init () override 
The initialization function. More...  
void  clear () 
The clear function. More...  
virtual unsigned int  solve () override 
This method performs a solve. More...  
unsigned int  total_outer_iterations () 
unsigned int  total_inner_iterations () 
unsigned int  solve_result () 
const sys_type &  system () const 
sys_type &  system () 
const Parallel::Communicator &  comm () const 
processor_id_type  n_processors () const 
processor_id_type  processor_id () const 
Static Public Member Functions  
static std::unique_ptr< DiffSolver >  build (sys_type &s) 
Factory method. 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  
unsigned int  max_linear_iterations 
Each linear solver step should exit after max_linear_iterations is exceeded. More...  
unsigned int  max_nonlinear_iterations 
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_iterations is false, or should end the nonlinear solve if max_nonlinear_iterations is exceeded and continue_after_max_iterations is true. More...  
bool  quiet 
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is true. More...  
bool  verbose 
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false. More...  
bool  continue_after_max_iterations 
Defaults to true, telling the DiffSolver to continue rather than exit when a solve has reached its maximum number of nonlinear iterations. More...  
bool  continue_after_backtrack_failure 
Defaults to false, telling the DiffSolver to throw an error when the backtracking scheme fails to find a descent direction. More...  
Real  absolute_residual_tolerance 
The DiffSolver 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 DiffSolver 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 
Real  initial_linear_tolerance 
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the tolerance for later solves. More...  
Real  minimum_linear_tolerance 
The tolerance for linear solves is kept above this minimum. More...  
std::unique_ptr< LinearSolutionMonitor >  linear_solution_monitor 
Pointer to functor which is called right after each linear solve. 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  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...  
PetscDMWrapper  _dm_wrapper 
Wrapper object for interacting with PetscDM. More...  
Real  max_solution_norm 
The largest solution norm which the DiffSolver has yet seen will be stored here, to be used for stopping criteria based on relative_step_tolerance. More...  
Real  max_residual_norm 
The largest nonlinear residual which the DiffSolver has yet seen will be stored here, to be used for stopping criteria based on relative_residual_tolerance. More...  
unsigned int  _outer_iterations 
The number of outer iterations used by the last solve. More...  
unsigned int  _inner_iterations 
The number of inner iterations used by the last solve. More...  
sys_type &  _system 
A reference to the system we are solving. More...  
unsigned int  _solve_result 
Initialized to zero. 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 threadsafe reference counting. More...  
static bool  _enable_print_counter 
Flag to control whether reference count information is printed when print_info is called. More...  
Private Member Functions  
void  setup_petsc_data () 
Common helper function to setup PETSc data structures. More...  
This class defines a solver which uses a PETSc SNES context to handle a DifferentiableSystem.
This class is part of the new DifferentiableSystem framework, which is still experimental. Users of this framework should beware of bugs and future API changes.
Definition at line 49 of file petsc_diff_solver.h.

protectedinherited 
Data structure to log the information.
The log is identified by the class name.
Definition at line 117 of file reference_counter.h.
Definition at line 64 of file petsc_diff_solver.h.

inherited 
The type of system.
Definition at line 78 of file diff_solver.h.

inherited 
Enumeration return type for the solve() function.
Multiple SolveResults may be combined (OR'd) in the single return. To test which ones are present, just AND the return value with any of the SolveResult flags defined below.
Enumerator  

INVALID_SOLVE_RESULT  A default or invalid solve result. This usually means no solve has occurred yet. 
CONVERGED_NO_REASON  The solver converged but no particular reason is specified. 
CONVERGED_ABSOLUTE_RESIDUAL  The DiffSolver achieved the desired absolute residual tolerance. 
CONVERGED_RELATIVE_RESIDUAL  The DiffSolver achieved the desired relative residual tolerance. 
CONVERGED_ABSOLUTE_STEP  The DiffSolver achieved the desired absolute step size tolerance. 
CONVERGED_RELATIVE_STEP  The DiffSolver achieved the desired relative step size tolerance. 
DIVERGED_NO_REASON  The DiffSolver diverged but no particular reason is specified. 
DIVERGED_MAX_NONLINEAR_ITERATIONS  The DiffSolver reached the maximum allowed number of nonlinear iterations before satisfying any convergence tests. 
DIVERGED_BACKTRACKING_FAILURE  The DiffSolver failed to find a descent direction by backtracking (See newton_solver.C) 
DIVERGED_LINEAR_SOLVER_FAILURE  The linear solver used by the DiffSolver failed to find a solution. 
Definition at line 223 of file diff_solver.h.

explicit 
Constructor.
Requires a reference to the system to be solved.

virtual 
Destructor.

staticinherited 
void libMesh::PetscDiffSolver::clear  (  ) 
The clear function.
Called if we reinit or when we destroy this object.

inherited 
Parallel::Communicator
object used by this mesh. Definition at line 87 of file parallel_object.h.
References libMesh::ParallelObject::_communicator.
Referenced by libMesh::EpetraVector< T >::EpetraVector(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), and libMesh::Parallel::sync_node_data_by_element_id_once().

staticinherited 

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

staticinherited 
Gets a string containing the reference information.

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().

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().

overridevirtual 
The initialization function.
Reimplemented from libMesh::DiffSolver.

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.

inherited 
Definition at line 93 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().
Referenced by libMesh::MeshBase::partition().

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

inherited 
Definition at line 99 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().
Referenced by libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::DofMap::last_dof(), libMesh::MeshBase::n_active_local_elem(), libMesh::DofMap::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), and libMesh::MeshTools::weight().

overridevirtual 
The reinitialization function.
This method is used after changes in the mesh.
Reimplemented from libMesh::DiffSolver.

private 
Common helper function to setup PETSc data structures.

overridevirtual 
This method performs a solve.
What occurs in this method will depend on the PETSc SNES settings. See the PETSc documentation for more details.
Implements libMesh::DiffSolver.

inherited 
Definition at line 133 of file diff_solver.h.
References libMesh::DiffSolver::_solve_result.

inherited 
Definition at line 138 of file diff_solver.h.
References libMesh::DiffSolver::_system.

inherited 
Definition at line 143 of file diff_solver.h.
References libMesh::DiffSolver::_system.

inherited 
Definition at line 128 of file diff_solver.h.
References libMesh::DiffSolver::_inner_iterations.

inherited 
Definition at line 122 of file diff_solver.h.
References libMesh::DiffSolver::_outer_iterations.

protectedinherited 
Definition at line 105 of file parallel_object.h.
Referenced by libMesh::ParallelObject::comm(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::operator=(), and libMesh::ParallelObject::processor_id().

staticprotectedinherited 
Actually holds the data.
Definition at line 122 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().

protected 
Wrapper object for interacting with PetscDM.
Definition at line 99 of file petsc_diff_solver.h.

staticprotectedinherited 
Flag to control whether reference count information is printed when print_info is called.
Definition at line 141 of file reference_counter.h.

protectedinherited 
The number of inner iterations used by the last solve.
Definition at line 314 of file diff_solver.h.
Referenced by libMesh::DiffSolver::total_inner_iterations().

staticprotectedinherited 
Mutual exclusion object to enable threadsafe reference counting.
Definition at line 135 of file reference_counter.h.

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().

protectedinherited 
The number of outer iterations used by the last solve.
Definition at line 309 of file diff_solver.h.
Referenced by libMesh::DiffSolver::total_outer_iterations().

protected 
Nonlinear solver context.
Definition at line 94 of file petsc_diff_solver.h.

protectedinherited 
Initialized to zero.
solve_result is typically set internally in the solve() function before it returns. When nonzero, solve_result tells the result of the latest solve. See enum definition for description.
Definition at line 327 of file diff_solver.h.
Referenced by libMesh::DiffSolver::solve_result().

protectedinherited 
A reference to the system we are solving.
Definition at line 319 of file diff_solver.h.
Referenced by libMesh::DiffSolver::system().

inherited 
The DiffSolver 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 192 of file diff_solver.h.
Referenced by TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln().

inherited 
The DiffSolver 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.
Definition at line 204 of file diff_solver.h.

inherited 
Defaults to false, telling the DiffSolver to throw an error when the backtracking scheme fails to find a descent direction.
Definition at line 181 of file diff_solver.h.

inherited 
Defaults to true, telling the DiffSolver to continue rather than exit when a solve has reached its maximum number of nonlinear iterations.
Definition at line 175 of file diff_solver.h.

inherited 
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the tolerance for later solves.
Definition at line 211 of file diff_solver.h.

inherited 
Pointer to functor which is called right after each linear solve.
Definition at line 289 of file diff_solver.h.

inherited 
Each linear solver step should exit after max_linear_iterations
is exceeded.
Definition at line 149 of file diff_solver.h.

inherited 
The DiffSolver should exit in failure if max_nonlinear_iterations
is exceeded and continue_after_max_iterations
is false, or should end the nonlinear solve if max_nonlinear_iterations
is exceeded and continue_after_max_iterations
is true.
Definition at line 157 of file diff_solver.h.

protectedinherited 
The largest nonlinear residual which the DiffSolver has yet seen will be stored here, to be used for stopping criteria based on relative_residual_tolerance.
Definition at line 304 of file diff_solver.h.

protectedinherited 
The largest solution norm which the DiffSolver has yet seen will be stored here, to be used for stopping criteria based on relative_step_tolerance.
Definition at line 297 of file diff_solver.h.

inherited 
The tolerance for linear solves is kept above this minimum.
Definition at line 216 of file diff_solver.h.

inherited 
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is true.
Definition at line 163 of file diff_solver.h.

inherited 
Definition at line 193 of file diff_solver.h.
Referenced by TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln().

inherited 
Definition at line 205 of file diff_solver.h.
Referenced by TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln().

inherited 
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
Definition at line 169 of file diff_solver.h.