libMesh

This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearImplicitSystem and DifferentiableSystem A user can define a solver by deriving from this class and implementing certain functions. More...
#include <diff_solver.h>
Public Types  
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  
DiffSolver (sys_type &s)  
Constructor. More...  
virtual  ~DiffSolver () 
Destructor. More...  
virtual void  init () 
The initialization function. More...  
virtual void  reinit () 
The reinitialization function. More...  
virtual unsigned int  solve ()=0 
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  
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...  
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearImplicitSystem and DifferentiableSystem A user can define a solver by deriving from this class and implementing certain functions.
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 71 of file 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.
The type of system.
Definition at line 78 of file diff_solver.h.
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.
libMesh::DiffSolver::DiffSolver  (  sys_type &  s  ) 
Constructor.
Requires a reference to the system to be solved.

virtual 

static 

inherited 
Parallel::Communicator
object used by this mesh. Definition at line 89 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().

virtual 
The initialization function.
This method is used to initialize internal data structures before a simulation begins.
Reimplemented in libMesh::PetscDiffSolver, and libMesh::NewtonSolver.

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

virtual 
The reinitialization function.
This method is used after changes in the mesh.
Reimplemented in libMesh::NewtonSolver, and libMesh::PetscDiffSolver.

pure virtual 
This method performs a solve.
What occurs in this method will depend on the type of solver. See the subclasses for more details.
Implemented in libMesh::PetscDiffSolver, and libMesh::NewtonSolver.
unsigned int libMesh::DiffSolver::solve_result  (  ) 
Definition at line 133 of file diff_solver.h.
References _solve_result.
const sys_type& libMesh::DiffSolver::system  (  )  const 
Definition at line 138 of file diff_solver.h.
References _system.
sys_type& libMesh::DiffSolver::system  (  ) 
Definition at line 143 of file diff_solver.h.
References _system.
unsigned int libMesh::DiffSolver::total_inner_iterations  (  ) 
Definition at line 128 of file diff_solver.h.
References _inner_iterations.
unsigned int libMesh::DiffSolver::total_outer_iterations  (  ) 
Definition at line 122 of file diff_solver.h.
References _outer_iterations.

protectedinherited 
Definition at line 107 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().

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

protected 
The number of inner iterations used by the last solve.
Definition at line 314 of file diff_solver.h.
Referenced by 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().

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

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

protected 
A reference to the system we are solving.
Definition at line 319 of file diff_solver.h.
Referenced by system().
Real libMesh::DiffSolver::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.
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().
Real libMesh::DiffSolver::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.
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.
bool libMesh::DiffSolver::continue_after_backtrack_failure 
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.
bool libMesh::DiffSolver::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.
Definition at line 175 of file diff_solver.h.
Real libMesh::DiffSolver::initial_linear_tolerance 
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.
std::unique_ptr<LinearSolutionMonitor> libMesh::DiffSolver::linear_solution_monitor 
Pointer to functor which is called right after each linear solve.
Definition at line 289 of file diff_solver.h.
unsigned int libMesh::DiffSolver::max_linear_iterations 
Each linear solver step should exit after max_linear_iterations
is exceeded.
Definition at line 149 of file diff_solver.h.
unsigned int libMesh::DiffSolver::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.
Definition at line 157 of file diff_solver.h.

protected 
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.

protected 
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.
Real libMesh::DiffSolver::minimum_linear_tolerance 
The tolerance for linear solves is kept above this minimum.
Definition at line 216 of file diff_solver.h.
bool libMesh::DiffSolver::quiet 
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.
Real libMesh::DiffSolver::relative_residual_tolerance 
Definition at line 193 of file diff_solver.h.
Referenced by TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln().
Real libMesh::DiffSolver::relative_step_tolerance 
Definition at line 205 of file diff_solver.h.
Referenced by TimeSolverTestImplementation< TimeSolverType >::run_test_with_exact_soln().
bool libMesh::DiffSolver::verbose 
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.