libMesh::NonlinearSolver< T > Class Template Reference
#include <nonlinear_solver.h>

Detailed Description
template<typename T>
class libMesh::NonlinearSolver< T >
This class provides a uniform interface for nonlinear solvers. This base class is overloaded to provide nonlinear solvers from different packages like PETSC.
Definition at line 54 of file nonlinear_solver.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 113 of file reference_counter.h.
| typedef NonlinearImplicitSystem libMesh::NonlinearSolver< T >::sys_type |
The type of system
Reimplemented in libMesh::PetscDMNonlinearSolver< T >, libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
Definition at line 60 of file nonlinear_solver.h.
Constructor & Destructor Documentation
| libMesh::NonlinearSolver< T >::NonlinearSolver | ( | sys_type & | s | ) | [inline, explicit] |
Constructor. Initializes Solver data structures
Definition at line 312 of file nonlinear_solver.h.
00312 : 00313 residual (NULL), 00314 residual_object (NULL), 00315 jacobian (NULL), 00316 jacobian_object (NULL), 00317 matvec (NULL), 00318 residual_and_jacobian_object (NULL), 00319 bounds (NULL), 00320 bounds_object (NULL), 00321 nullspace (NULL), 00322 nullspace_object (NULL), 00323 nearnullspace (NULL), 00324 nearnullspace_object (NULL), 00325 user_presolve (NULL), 00326 max_nonlinear_iterations(0), 00327 max_function_evaluations(0), 00328 absolute_residual_tolerance(0), 00329 relative_residual_tolerance(0), 00330 absolute_step_tolerance(0), 00331 relative_step_tolerance(0), 00332 max_linear_iterations(0), 00333 initial_linear_tolerance(0), 00334 minimum_linear_tolerance(0), 00335 _system(s), 00336 _is_initialized (false), 00337 _preconditioner (NULL) 00338 { 00339 }
| libMesh::NonlinearSolver< T >::~NonlinearSolver | ( | ) | [inline, virtual] |
Destructor.
Definition at line 345 of file nonlinear_solver.h.
References libMesh::NonlinearSolver< T >::clear().
00346 { 00347 this->clear (); 00348 }
Member Function Documentation
| void libMesh::NonlinearSolver< T >::attach_preconditioner | ( | Preconditioner< T > * | preconditioner | ) | [inline] |
Attaches a Preconditioner object to be used during the linear solves.
Definition at line 91 of file nonlinear_solver.C.
References libMesh::NonlinearSolver< T >::_is_initialized, libMesh::NonlinearSolver< T >::_preconditioner, and libMesh::err.
00092 { 00093 if(this->_is_initialized) 00094 { 00095 libMesh::err << "Preconditioner must be attached before the solver is initialized!"<<std::endl; 00096 libmesh_error(); 00097 } 00098 00099 _preconditioner = preconditioner; 00100 }
| AutoPtr< NonlinearSolver< T > > libMesh::NonlinearSolver< T >::build | ( | sys_type & | s, | |
| const SolverPackage | solver_package = libMesh::default_solver_package() | |||
| ) | [inline, static] |
Builds a NonlinearSolver using the nonlinear solver package specified by solver_package
Definition at line 38 of file nonlinear_solver.C.
References libMesh::err, libMesh::on_command_line(), libMeshEnums::PETSC_SOLVERS, libMesh::AutoPtr< Tp >::reset(), and libMesh::TRILINOS_SOLVERS.
00039 { 00040 AutoPtr<NonlinearSolver<T> > ap; 00041 00042 // Build the appropriate solver 00043 switch (solver_package) 00044 { 00045 00046 #ifdef LIBMESH_HAVE_PETSC 00047 case PETSC_SOLVERS: 00048 #if PETSC_VERSION_LESS_THAN(3,3,0) 00049 ap.reset(new PetscNonlinearSolver<T>(s)); 00050 break; 00051 #else 00052 if (libMesh::on_command_line ("--use-petsc-dm")){ 00053 ap.reset(new PetscDMNonlinearSolver<T>(s)); 00054 } 00055 else { 00056 ap.reset(new PetscNonlinearSolver<T>(s)); 00057 } 00058 break; 00059 #endif 00060 #endif // LIBMESH_HAVE_PETSC 00061 00062 #ifdef LIBMESH_HAVE_NOX 00063 case TRILINOS_SOLVERS: 00064 ap.reset(new NoxNonlinearSolver<T>(s)); 00065 break; 00066 #endif 00067 00068 default: 00069 libMesh::err << "ERROR: Unrecognized solver package: " 00070 << solver_package 00071 << std::endl; 00072 libmesh_error(); 00073 } 00074 00075 return ap; 00076 }
| virtual void libMesh::NonlinearSolver< T >::clear | ( | ) | [inline, virtual] |
Release all memory and clear data structures.
Reimplemented in libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
Definition at line 89 of file nonlinear_solver.h.
Referenced by libMesh::NonlinearSolver< T >::~NonlinearSolver().
| void libMesh::ReferenceCounter::disable_print_counter_info | ( | ) | [static, inherited] |
Definition at line 106 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00107 { 00108 _enable_print_counter = false; 00109 return; 00110 }
| void libMesh::ReferenceCounter::enable_print_counter_info | ( | ) | [static, inherited] |
Methods to enable/disable the reference counter output from print_info()
Definition at line 100 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00101 { 00102 _enable_print_counter = true; 00103 return; 00104 }
| virtual unsigned libMesh::NonlinearSolver< T >::get_current_nonlinear_iteration_number | ( | ) | const [pure virtual] |
If called *during* the solve(), for example by the user-specified residual or Jacobian function, returns the current nonlinear iteration number. Must be redefined in derived classes.
Implemented in libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
| std::string libMesh::ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 47 of file reference_counter.C.
References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().
Referenced by libMesh::ReferenceCounter::print_info().
00048 { 00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00050 00051 std::ostringstream oss; 00052 00053 oss << '\n' 00054 << " ---------------------------------------------------------------------------- \n" 00055 << "| Reference count information |\n" 00056 << " ---------------------------------------------------------------------------- \n"; 00057 00058 for (Counts::iterator it = _counts.begin(); 00059 it != _counts.end(); ++it) 00060 { 00061 const std::string name(it->first); 00062 const unsigned int creations = it->second.first; 00063 const unsigned int destructions = it->second.second; 00064 00065 oss << "| " << name << " reference count information:\n" 00066 << "| Creations: " << creations << '\n' 00067 << "| Destructions: " << destructions << '\n'; 00068 } 00069 00070 oss << " ---------------------------------------------------------------------------- \n"; 00071 00072 return oss.str(); 00073 00074 #else 00075 00076 return ""; 00077 00078 #endif 00079 }
| virtual int libMesh::NonlinearSolver< T >::get_total_linear_iterations | ( | ) | [pure virtual] |
Get the total number of linear iterations done in the last solve
Implemented in libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
| void libMesh::ReferenceCounter::increment_constructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 163 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
00164 { 00165 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00166 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00167 00168 p.first++; 00169 }
| void libMesh::ReferenceCounter::increment_destructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 176 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
00177 { 00178 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00179 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00180 00181 p.second++; 00182 }
| virtual void libMesh::NonlinearSolver< T >::init | ( | ) | [pure virtual] |
Initialize data structures if not done so already.
Implemented in libMesh::PetscDMNonlinearSolver< T >, libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
| bool libMesh::NonlinearSolver< T >::initialized | ( | ) | const [inline] |
- Returns:
- true if the data structures are initialized, false otherwise.
Definition at line 84 of file nonlinear_solver.h.
Referenced by libMesh::PetscNonlinearSolver< T >::clear(), libMesh::PetscNonlinearSolver< T >::get_converged_reason(), libMesh::NoxNonlinearSolver< T >::init(), and libMesh::PetscNonlinearSolver< T >::init().
00084 { return _is_initialized; }
| static unsigned int libMesh::ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 79 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
00080 { return _n_objects; }
| virtual void libMesh::NonlinearSolver< T >::print_converged_reason | ( | ) | [inline, virtual] |
Prints a useful message about why the latest nonlinear solve con(di)verged.
Reimplemented in libMesh::PetscNonlinearSolver< T >.
Definition at line 109 of file nonlinear_solver.h.
| void libMesh::ReferenceCounter::print_info | ( | std::ostream & | out = libMesh::out |
) | [static, inherited] |
Prints the reference information, by default to libMesh::out.
Definition at line 88 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().
00089 { 00090 if( _enable_print_counter ) out_stream << ReferenceCounter::get_info(); 00091 }
| virtual std::pair<unsigned int, Real> libMesh::NonlinearSolver< T >::solve | ( | SparseMatrix< T > & | , | |
| NumericVector< T > & | , | |||
| NumericVector< T > & | , | |||
| const | double, | |||
| const unsigned | int | |||
| ) | [pure virtual] |
Solves the nonlinear system.
Implemented in libMesh::PetscDMNonlinearSolver< T >, libMesh::PetscNonlinearSolver< T >, libMesh::NoxNonlinearSolver< T >, and libMesh::NoxNonlinearSolver< Number >.
| sys_type& libMesh::NonlinearSolver< T >::system | ( | ) | [inline] |
- Returns:
- a writeable reference to the system we are solving.
Definition at line 222 of file nonlinear_solver.h.
00222 { return _system; }
| const sys_type& libMesh::NonlinearSolver< T >::system | ( | ) | const [inline] |
- Returns:
- a constant reference to the system we are solving.
Definition at line 217 of file nonlinear_solver.h.
Referenced by libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), libMesh::PetscNonlinearSolver< T >::solve(), and libMesh::PetscDMNonlinearSolver< T >::solve().
00217 { return _system; }
Member Data Documentation
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 118 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::get_info(), libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().
bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited] |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 137 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().
bool libMesh::NonlinearSolver< T >::_is_initialized [protected] |
Flag indicating if the data structures have been initialized.
Definition at line 298 of file nonlinear_solver.h.
Referenced by libMesh::NonlinearSolver< T >::attach_preconditioner(), libMesh::PetscNonlinearSolver< T >::clear(), libMesh::PetscNonlinearSolver< T >::init(), and libMesh::NonlinearSolver< Number >::initialized().
Threads::spin_mutex libMesh::ReferenceCounter::_mutex [static, protected, inherited] |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 131 of file reference_counter.h.
Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited] |
The number of objects. Print the reference count information when the number returns to 0.
Definition at line 126 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
Preconditioner<T>* libMesh::NonlinearSolver< T >::_preconditioner [protected] |
Holds the Preconditioner object to be used for the linear solves.
Definition at line 303 of file nonlinear_solver.h.
Referenced by libMesh::NonlinearSolver< T >::attach_preconditioner(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), libMesh::PetscNonlinearSolver< T >::solve(), and libMesh::PetscDMNonlinearSolver< T >::solve().
sys_type& libMesh::NonlinearSolver< T >::_system [protected] |
A reference to the system we are solving.
Definition at line 293 of file nonlinear_solver.h.
Referenced by libMesh::NonlinearSolver< Number >::system().
| Real libMesh::NonlinearSolver< T >::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.
Users should increase any of these tolerances that they want to use for a stopping condition.
Definition at line 249 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| Real libMesh::NonlinearSolver< T >::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.
Users should increase any of these tolerances that they want to use for a stopping condition.
Note that not all NonlinearSolvers support relative_step_tolerance!
Definition at line 263 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), and libMesh::NoxNonlinearSolver< T >::solve().
| void(* libMesh::NonlinearSolver< T >::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.
| NonlinearImplicitSystem::ComputeBounds* libMesh::NonlinearSolver< T >::bounds_object |
Object that computes the bounds vectors
and
.
Definition at line 179 of file nonlinear_solver.h.
| bool libMesh::NonlinearSolver< T >::converged |
After a call to solve this will reflect whether or not the nonlinear solve was successful.
Definition at line 287 of file nonlinear_solver.h.
Referenced by libMesh::NoxNonlinearSolver< T >::solve(), libMesh::PetscNonlinearSolver< T >::solve(), and libMesh::PetscDMNonlinearSolver< T >::solve().
| Real libMesh::NonlinearSolver< T >::initial_linear_tolerance |
Any required linear solves will at first be done with this tolerance; the NonlinearSolver may tighten the tolerance for later solves.
Definition at line 276 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| void(* libMesh::NonlinearSolver< T >::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.
Referenced by libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| NonlinearImplicitSystem::ComputeJacobian* libMesh::NonlinearSolver< T >::jacobian_object |
Object that computes the Jacobian J(X) of the nonlinear system at the input iterate X.
Definition at line 149 of file nonlinear_solver.h.
Referenced by libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| void(* libMesh::NonlinearSolver< T >::matvec)(const NumericVector< Number > &X, NumericVector< Number > *R, SparseMatrix< Number > *J, sys_type &S) |
Function that computes either the residual
or the Jacobian
of the nonlinear system at the input iterate
. Note that either R or J could be XSNULL.
Referenced by libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), and libMesh::Problem_Interface::computePreconditioner().
| unsigned int libMesh::NonlinearSolver< T >::max_function_evaluations |
Maximum number of function evaluations.
Definition at line 237 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), and libMesh::PetscNonlinearSolver< T >::solve().
| unsigned int libMesh::NonlinearSolver< T >::max_linear_iterations |
Each linear solver step should exit after max_linear_iterations is exceeded.
Definition at line 270 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| unsigned int libMesh::NonlinearSolver< T >::max_nonlinear_iterations |
Maximum number of non-linear iterations.
Definition at line 232 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| Real libMesh::NonlinearSolver< T >::minimum_linear_tolerance |
The tolerance for linear solves is kept above this minimum
Definition at line 281 of file nonlinear_solver.h.
| void(* libMesh::NonlinearSolver< T >::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).
Referenced by libMesh::PetscNonlinearSolver< T >::solve().
| NonlinearImplicitSystem::ComputeVectorSubspace* libMesh::NonlinearSolver< T >::nearnullspace_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).
Definition at line 209 of file nonlinear_solver.h.
Referenced by libMesh::PetscNonlinearSolver< T >::solve().
| void(* libMesh::NonlinearSolver< T >::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).
Referenced by libMesh::PetscNonlinearSolver< T >::solve().
| NonlinearImplicitSystem::ComputeVectorSubspace* libMesh::NonlinearSolver< T >::nullspace_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).
Definition at line 195 of file nonlinear_solver.h.
Referenced by libMesh::PetscNonlinearSolver< T >::solve().
| Real libMesh::NonlinearSolver< T >::relative_residual_tolerance |
Definition at line 250 of file nonlinear_solver.h.
Referenced by libMesh::PetscDMNonlinearSolver< T >::init(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| Real libMesh::NonlinearSolver< T >::relative_step_tolerance |
Definition at line 264 of file nonlinear_solver.h.
Referenced by libMesh::PetscNonlinearSolver< T >::solve().
| void(* libMesh::NonlinearSolver< T >::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.
Referenced by libMesh::Problem_Interface::computeF().
| NonlinearImplicitSystem::ComputeResidualandJacobian* libMesh::NonlinearSolver< T >::residual_and_jacobian_object |
Object that computes either the residual
or the Jacobian
of the nonlinear system at the input iterate
. Note that either R or J could be XSNULL.
Definition at line 168 of file nonlinear_solver.h.
Referenced by libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::NoxNonlinearSolver< T >::solve(), and libMesh::PetscNonlinearSolver< T >::solve().
| NonlinearImplicitSystem::ComputeResidual* libMesh::NonlinearSolver< T >::residual_object |
Object that computes the residual R(X) of the nonlinear system at the input iterate X.
Definition at line 135 of file nonlinear_solver.h.
Referenced by libMesh::Problem_Interface::computeF().
| void(* libMesh::NonlinearSolver< T >::user_presolve)(sys_type &S) |
The documentation for this class was generated from the following files:
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:32 UTC
Hosted By: