This is a generic class that defines a solver to handle DifferentiableSystems 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.
Author:
Roy H. Stogner 2006
Definition at line 50 of file diff_solver.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
Definition at line 105 of file reference_counter.h.
typedef DifferentiableSystemDiffSolver::sys_typeThe type of system
Definition at line 56 of file diff_solver.h.
Member Enumeration Documentation
enum DiffSolver::SolveResultEnumeration 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)
virtual unsigned int DiffSolver::adjoint_solve () [pure virtual]This method performs a solve on the adjoint system. What occurs in this method will depend on the type of solver. See the subclasses for more details.
Implemented in NewtonSolver, and PetscDiffSolver.
AutoPtr< DiffSolver > DiffSolver::build (sys_type &s) [static]Factory. Requires a reference to the system to be solved. Returns a NewtonSolver by default
Definition at line 47 of file diff_solver.C.
Referenced by PetscDiffSolver::adjoint_solve(), and TimeSolver::init().
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and Quality::name().
Referenced by ReferenceCounter::print_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::ostringstream out;
out << '
<< ' ----------------------------------------------------------------------------
<< '| Reference count information |
<< ' ---------------------------------------------------------------------------- ;
for (Counts::iterator it = _counts.begin();
it != _counts.end(); ++it)
{
const std::string name(it->first);
const unsigned int creations = it->second.first;
const unsigned int destructions = it->second.second;
out << '| ' << name << ' reference count information:
<< '| Creations: ' << creations << '
<< '| Destructions: ' << destructions << ';
}
out << ' ---------------------------------------------------------------------------- ;
return out.str();
#else
return '';
#endif
}
void 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 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
void 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 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
void DiffSolver::init () [virtual]The initialization function. This method is used to initialize internal data structures before a simulation begins.
Reimplemented in PetscDiffSolver.
Definition at line 63 of file diff_solver.C.
References max_residual_norm, and max_solution_norm.
Referenced by PetscDiffSolver::init().
{
// Reset the max_step_size and max_residual_norm for a new problem
max_solution_norm = 0.;
max_residual_norm = 0.;
}
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().
{ return _n_objects; }
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
Definition at line 83 of file reference_counter.C.
void DiffSolver::reinit () [virtual]The reinitialization function. This method is used after changes in the mesh.
Reimplemented in NewtonSolver, and PetscDiffSolver.
Definition at line 54 of file diff_solver.C.
References max_residual_norm, and max_solution_norm.
Referenced by PetscDiffSolver::reinit(), and NewtonSolver::reinit().
{
// Reset the max_step_size and max_residual_norm for a new mesh
max_solution_norm = 0.;
max_residual_norm = 0.;
}
virtual unsigned int DiffSolver::solve () [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 NewtonSolver, and PetscDiffSolver.
unsigned int DiffSolver::solve_result () [inline]Returns:
the value of the SolveResult from the last solve.
Definition at line 116 of file diff_solver.h.
References _solve_result.
{ return _solve_result; }
sys_type& DiffSolver::system () [inline]Returns:
a writeable reference to the system we are solving.
Definition at line 123 of file reference_counter.h.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
unsigned int DiffSolver::_outer_iterations [protected]The number of outer iterations used by the last solve
Definition at line 275 of file diff_solver.h.
Referenced by NewtonSolver::line_search(), PetscDiffSolver::solve(), NewtonSolver::solve(), and total_outer_iterations().
unsigned int DiffSolver::_solve_result [protected]Initialized to zero. solve_result is typically set internally in the solve() function before it returns. When non-zero, solve_result tells the result of the latest solve. See enum definition for description.
Definition at line 293 of file diff_solver.h.
Referenced by NewtonSolver::line_search(), NewtonSolver::solve(), solve_result(), and NewtonSolver::test_convergence().
sys_type& DiffSolver::_system [protected]A reference to the system we are solving.
Definition at line 285 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), NewtonSolver::line_search(), PetscDiffSolver::solve(), NewtonSolver::solve(), and system().
RealDiffSolver::absolute_residual_toleranceThe 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 169 of file diff_solver.h.
Referenced by NewtonSolver::print_convergence(), and NewtonSolver::test_convergence().
RealDiffSolver::absolute_step_toleranceThe 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 181 of file diff_solver.h.
Referenced by NewtonSolver::print_convergence(), and NewtonSolver::test_convergence().
bool DiffSolver::continue_after_backtrack_failureDefaults to false, telling the DiffSolver to throw a libmesh_error() when the backtracking scheme fails to find a descent direction.
Definition at line 158 of file diff_solver.h.
Referenced by NewtonSolver::line_search().
bool DiffSolver::continue_after_max_iterationsDefaults to true, telling the DiffSolver to continue rather than exit when a solve has reached its maximum number of nonlinear iterations.
Definition at line 152 of file diff_solver.h.
Referenced by NewtonSolver::solve().
RealDiffSolver::initial_linear_toleranceAny required linear solves will at first be done with this tolerance; the DiffSolver may tighten the tolerance for later solves.
Definition at line 188 of file diff_solver.h.
Referenced by NewtonSolver::solve().
unsigned int DiffSolver::max_linear_iterationsEach linear solver step should exit after max_linear_iterations is exceeded.
Definition at line 132 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), ContinuationSystem::continuation_solve(), NewtonSolver::solve(), and ContinuationSystem::solve_tangent().
unsigned int DiffSolver::max_nonlinear_iterationsThe 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 140 of file diff_solver.h.
Referenced by ContinuationSystem::continuation_solve(), NewtonSolver::solve(), and ContinuationSystem::update_solution().
RealDiffSolver::max_residual_norm [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 270 of file diff_solver.h.
Referenced by init(), NewtonSolver::print_convergence(), reinit(), NewtonSolver::solve(), and NewtonSolver::test_convergence().
RealDiffSolver::max_solution_norm [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 263 of file diff_solver.h.
Referenced by init(), NewtonSolver::print_convergence(), reinit(), NewtonSolver::solve(), and NewtonSolver::test_convergence().
RealDiffSolver::minimum_linear_toleranceThe tolerance for linear solves is kept above this minimum
Definition at line 193 of file diff_solver.h.
Referenced by NewtonSolver::solve().
bool DiffSolver::quietThe DiffSolver should not print anything to std::cout unless quiet is set to false
Definition at line 146 of file diff_solver.h.
Referenced by NewtonSolver::adjoint_solve(), NewtonSolver::line_search(), NewtonSolver::print_convergence(), and NewtonSolver::solve().
RealDiffSolver::relative_residual_tolerance
Definition at line 170 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), NewtonSolver::print_convergence(), and NewtonSolver::test_convergence().
RealDiffSolver::relative_step_tolerance
Definition at line 182 of file diff_solver.h.
Referenced by NewtonSolver::print_convergence(), and NewtonSolver::test_convergence().
Author
Generated automatically by Doxygen for libMesh from the source code.