#include <newton_solver.h>
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 }
typedef DifferentiableSystem sys_type
NewtonSolver (sys_type &system)
virtual ~NewtonSolver ()
virtual void reinit ()
virtual unsigned int solve ()
virtual unsigned int adjoint_solve ()
virtual void init ()
unsigned int total_outer_iterations ()
unsigned int total_inner_iterations ()
unsigned int solve_result ()
const sys_type & system () const
sys_type & system ()
static AutoPtr< DiffSolver > build (sys_type &s)
static std::string get_info ()
static void print_info ()
static unsigned int n_objects ()
bool require_residual_reduction
bool brent_line_search
Real minsteplength
Real linear_tolerance_multiplier
unsigned int max_linear_iterations
unsigned int max_nonlinear_iterations
bool quiet
bool continue_after_max_iterations
bool continue_after_backtrack_failure
Real absolute_residual_tolerance
Real relative_residual_tolerance
Real absolute_step_tolerance
Real relative_step_tolerance
Real initial_linear_tolerance
Real minimum_linear_tolerance
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
Real line_search (Real tol, Real last_residual, Real ¤t_residual, NumericVector< Number > &newton_iterate, const NumericVector< Number > &linear_solution)
void print_convergence (unsigned int step_num, Real current_residual, Real step_norm, bool linear_solve_finished)
bool test_convergence (Real current_residual, Real step_norm, bool linear_solve_finished)
void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)
AutoPtr< LinearSolver< Number > > linear_solver
Real max_solution_norm
Real max_residual_norm
unsigned int _outer_iterations
unsigned int _inner_iterations
sys_type & _system
unsigned int _solve_result
static Counts _counts
static Threads::atomic< unsigned int > _n_objects
static Threads::spin_mutex _mutex
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method 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.
Author:
Definition at line 47 of file newton_solver.h.
Definition at line 105 of file reference_counter.h.
Definition at line 61 of file newton_solver.h.
Definition at line 56 of file diff_solver.h.
Enumerator:
Definition at line 200 of file diff_solver.h.
{
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
};
Definition at line 228 of file newton_solver.C.
: Parent(s),
require_residual_reduction(true),
brent_line_search(true),
minsteplength(1e-5),
linear_tolerance_multiplier(1e-3),
linear_solver(LinearSolver<Number>::build())
{
}
Definition at line 240 of file newton_solver.C.
{
}
Implements DiffSolver.
Definition at line 496 of file newton_solver.C.
References DiffSolver::_system, System::add_vector(), ExplicitSystem::assemble_qoi_derivative(), DifferentiableSystem::assembly(), SparseMatrix< T >::close(), DiffSolver::CONVERGED_RELATIVE_RESIDUAL, DofMap::enforce_constraints_exactly(), System::get_dof_map(), ImplicitSystem::get_matrix(), SparseMatrix< T >::get_transpose(), ImplicitSystem::have_matrix(), linear_solver, ImplicitSystem::matrix, DiffSolver::max_linear_iterations, DiffSolver::quiet, DiffSolver::relative_residual_tolerance, ExplicitSystem::rhs, and System::update().
{
// The adjoint_solve API (and all APIs using it) are about to see a
// series of non-backwards-compatible changes, primarily to add
// multiple-QoI support
libmesh_experimental();
START_LOG('adjoint_solve()', 'NewtonSolver');
if (!quiet)
std::cout << 'Assembling the Adjoint System' << std::endl;
// Adding an adjoint_solution vector, allocate an adjoint_solution if it doesn't already exist
NumericVector<Number> & adjoint_solution = _system.add_vector('adjoint_solution');
// Do DiffSystem assembly
_system.assembly(false, true);
_system.matrix->close();
// But take the adjoint
_system.matrix->get_transpose(*_system.matrix);
if (_system.have_matrix('Preconditioner'))
{
SparseMatrix<Number> &pre = _system.get_matrix('Preconditioner');
pre.get_transpose(pre);
}
// And set the right hand side to the quantity of interest's
// derivative
_system.assemble_qoi_derivative();
if (!quiet)
std::cout << 'Linear solve of Adjoint System starting, tolerance '
<< relative_residual_tolerance << ', max iterations '
<< max_linear_iterations << std::endl;
// Solve the linear system. Two cases:
const std::pair<unsigned int, Real> rval =
(_system.have_matrix('Preconditioner')) ?
// 1.) User-supplied preconditioner
linear_solver->solve (*_system.matrix,
_system.get_matrix('Preconditioner'),
adjoint_solution, *_system.rhs,
relative_residual_tolerance,
max_linear_iterations) :
// 2.) Use system matrix for the preconditioner
linear_solver->solve (*_system.matrix,
adjoint_solution, *_system.rhs,
relative_residual_tolerance,
max_linear_iterations);
// We may need to localize a parallel solution
_system.update ();
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_AMR
_system.get_dof_map().enforce_constraints_exactly(_system, &adjoint_solution);
#endif
const unsigned int linear_steps = rval.first;
libmesh_assert(linear_steps <= max_linear_iterations);
if (!quiet)
std::cout << 'Linear solve of Adjoint System finished, step ' << linear_steps
<< ', residual ' << rval.second
<< std::endl;
STOP_LOG('adjoint_solve()', 'NewtonSolver');
// FIXME - We'll worry about getting the solve result right later...
return DiffSolver::CONVERGED_RELATIVE_RESIDUAL;
}
Definition at line 47 of file diff_solver.C.
Referenced by PetscDiffSolver::adjoint_solve(), and TimeSolver::init().
{
return AutoPtr<DiffSolver>(new NewtonSolver(s));
}
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
}
Definition at line 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.first++;
}
Definition at line 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.second++;
}
Reimplemented in PetscDiffSolver.
Definition at line 63 of file diff_solver.C.
References DiffSolver::max_residual_norm, and DiffSolver::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.;
}
Definition at line 40 of file newton_solver.C.
References DiffSolver::_outer_iterations, DiffSolver::_solve_result, DiffSolver::_system, NumericVector< T >::add(), DifferentiableSystem::assembly(), brent_line_search, NumericVector< T >::close(), DiffSolver::continue_after_backtrack_failure, DiffSolver::DIVERGED_BACKTRACKING_FAILURE, NumericVector< T >::l2_norm(), std::max(), std::min(), minsteplength, DiffSolver::quiet, require_residual_reduction, ExplicitSystem::rhs, and SIGN().
Referenced by solve().
{
// Take a full step if we got a residual reduction or if we
// aren't substepping
if (current_residual < last_residual ||
!require_residual_reduction)
return 1.;
// The residual vector
NumericVector<Number> &rhs = *(_system.rhs);
Real ax = 0.; // First abscissa, don't take negative steps
Real cx = 1.; // Second abscissa, don't extrapolate steps
// Find bx, a step length that gives lower residual than ax or cx
Real bx = 1.;
while (current_residual > last_residual)
{
// Reduce step size to 1/2, 1/4, etc.
Real substepdivision;
if (brent_line_search)
{
substepdivision = std::min(0.5, last_residual/current_residual);
substepdivision = std::max(substepdivision, tol*2.);
}
else
substepdivision = 0.5;
newton_iterate.add (bx * (1.-substepdivision),
linear_solution);
newton_iterate.close();
bx *= substepdivision;
if (!quiet)
std::cout << ' Shrinking Newton step to '
<< bx << std::endl;
// Check residual with fractional Newton step
_system.assembly (true, false);
rhs.close();
current_residual = rhs.l2_norm();
if (!quiet)
std::cout << ' Current Residual: '
<< current_residual << std::endl;
if (bx/2. < minsteplength &&
current_residual > last_residual)
{
std::cout << 'Inexact Newton step FAILED at step '
<< _outer_iterations << std::endl;
if (!continue_after_backtrack_failure)
{
libmesh_convergence_failure();
}
else
{
std::cout << 'Continuing anyway ...' << std::endl;
_solve_result = DiffSolver::DIVERGED_BACKTRACKING_FAILURE;
return bx;
}
}
} // end while (current_residual > last_residual)
// Now return that reduced-residual step, or use Brent's method to
// find a more optimal step.
if (!brent_line_search)
return bx;
// Brent's method adapted from Numerical Recipes in C, ch. 10.2
Real e = 0.;
Real x = bx, w = bx, v = bx;
// Residuals at bx
Real fx = current_residual,
fw = current_residual,
fv = current_residual;
// Max iterations for Brent's method loop
const unsigned int max_i = 20;
// for golden ratio steps
const Real golden_ratio = 1.-(std::sqrt(5.)-1.)/2.;
for (unsigned int i=1; i <= max_i; i++)
{
Real xm = (ax+cx)*0.5;
Real tol1 = tol * std::abs(x) + tol*tol;
Real tol2 = 2.0 * tol1;
// Test if we're done
if (std::abs(x-xm) <= (tol2 - 0.5 * (cx - ax)))
return x;
Real d;
// Construct a parabolic fit
if (std::abs(e) > tol1)
{
Real r = (x-w)*(fx-fv);
Real q = (x-v)*(fx-fw);
Real p = (x-v)*q-(x-w)*r;
q = 2. * (q-r);
if (q > 0.)
p = -p;
else
q = std::abs(q);
if (std::abs(p) >= std::abs(0.5*q*e) ||
p <= q * (ax-x) ||
p >= q * (cx-x))
{
// Take a golden section step
e = x >= xm ? ax-x : cx-x;
d = golden_ratio * e;
}
else
{
// Take a parabolic fit step
d = p/q;
if (x+d-ax < tol2 || cx-(x+d) < tol2)
d = SIGN(tol1, xm - x);
}
}
else
{
// Take a golden section step
e = x >= xm ? ax-x : cx-x;
d = golden_ratio * e;
}
Real u = std::abs(d) >= tol1 ? x+d : x + SIGN(tol1,d);
// Assemble the residual at the new steplength u
newton_iterate.add (bx - u, linear_solution);
newton_iterate.close();
bx = u;
if (!quiet)
std::cout << ' Shrinking Newton step to '
<< bx << std::endl;
_system.assembly (true, false);
rhs.close();
Real fu = current_residual = rhs.l2_norm();
if (!quiet)
std::cout << ' Current Residual: '
<< fu << std::endl;
if (fu <= fx)
{
if (u >= x)
ax = x;
else
cx = x;
v = w; w = x; x = u;
fv = fw; fw = fx; fx = fu;
}
else
{
if (u < x)
ax = u;
else
cx = u;
if (fu <= fw || w == x)
{
v = w; w = u;
fv = fw; fw = fu;
}
else if (fu <= fv || v == x || v == w)
{
v = u;
fv = fu;
}
}
}
std::cout << 'Warning! Too many iterations used in Brent line search!'
<< std::endl;
return bx;
}
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; }
Definition at line 621 of file newton_solver.C.
References DiffSolver::absolute_residual_tolerance, DiffSolver::absolute_step_tolerance, DiffSolver::max_residual_norm, DiffSolver::max_solution_norm, DiffSolver::quiet, DiffSolver::relative_residual_tolerance, and DiffSolver::relative_step_tolerance.
Referenced by solve().
{
// Is our absolute residual low enough?
if (current_residual < absolute_residual_tolerance)
{
std::cout << ' Nonlinear solver converged, step ' << step_num
<< ', residual ' << current_residual
<< std::endl;
}
else if (absolute_residual_tolerance)
{
std::cout << ' Nonlinear solver current_residual '
<< current_residual << ' > '
<< (absolute_residual_tolerance) << std::endl;
}
// Is our relative residual low enough?
if ((current_residual / max_residual_norm) <
relative_residual_tolerance)
{
std::cout << ' Nonlinear solver converged, step ' << step_num
<< ', residual reduction '
<< current_residual / max_residual_norm
<< ' < ' << relative_residual_tolerance
<< std::endl;
}
else if (relative_residual_tolerance)
{
if (!quiet)
std::cout << ' Nonlinear solver relative residual '
<< (current_residual / max_residual_norm)
<< ' > ' << relative_residual_tolerance
<< std::endl;
}
// For incomplete linear solves, it's not safe to test step sizes
if (!linear_solve_finished)
return;
// Is our absolute Newton step size small enough?
if (step_norm < absolute_step_tolerance)
{
std::cout << ' Nonlinear solver converged, step ' << step_num
<< ', absolute step size '
<< step_norm
<< ' < ' << absolute_step_tolerance
<< std::endl;
}
else if (absolute_step_tolerance)
{
std::cout << ' Nonlinear solver absolute step size '
<< step_norm
<< ' > ' << absolute_step_tolerance
<< std::endl;
}
// Is our relative Newton step size small enough?
if (step_norm / max_solution_norm <
relative_step_tolerance)
{
std::cout << ' Nonlinear solver converged, step ' << step_num
<< ', relative step size '
<< (step_norm / max_solution_norm)
<< ' < ' << relative_step_tolerance
<< std::endl;
}
else if (relative_step_tolerance)
{
std::cout << ' Nonlinear solver relative step size '
<< (step_norm / max_solution_norm)
<< ' > ' << relative_step_tolerance
<< std::endl;
}
}
Definition at line 83 of file reference_counter.C.
References ReferenceCounter::get_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::cout << ReferenceCounter::get_info();
#endif
}
Reimplemented from DiffSolver.
Definition at line 246 of file newton_solver.C.
References linear_solver, and DiffSolver::reinit().
{
Parent::reinit();
linear_solver->clear();
}
Implements DiffSolver.
Definition at line 255 of file newton_solver.C.
References DiffSolver::_inner_iterations, DiffSolver::_outer_iterations, DiffSolver::_solve_result, DiffSolver::_system, NumericVector< T >::add(), DifferentiableSystem::assembly(), NumericVector< T >::clone(), NumericVector< T >::close(), DiffSolver::continue_after_max_iterations, DiffSolver::DIVERGED_BACKTRACKING_FAILURE, DiffSolver::DIVERGED_MAX_NONLINEAR_ITERATIONS, DofMap::enforce_constraints_exactly(), System::get_dof_map(), ImplicitSystem::get_matrix(), ImplicitSystem::have_matrix(), DiffSolver::initial_linear_tolerance, DiffSolver::INVALID_SOLVE_RESULT, NumericVector< T >::l2_norm(), line_search(), linear_solver, linear_tolerance_multiplier, ImplicitSystem::matrix, std::max(), DiffSolver::max_linear_iterations, DiffSolver::max_nonlinear_iterations, DiffSolver::max_residual_norm, DiffSolver::max_solution_norm, std::min(), DiffSolver::minimum_linear_tolerance, print_convergence(), DiffSolver::quiet, ExplicitSystem::rhs, System::solution, test_convergence(), System::update(), and NumericVector< T >::zero().
{
START_LOG('solve()', 'NewtonSolver');
// Reset any prior solve result
_solve_result = INVALID_SOLVE_RESULT;
NumericVector<Number> &newton_iterate = *(_system.solution);
AutoPtr<NumericVector<Number> > linear_solution_ptr = newton_iterate.clone();
NumericVector<Number> &linear_solution = *linear_solution_ptr;
NumericVector<Number> &rhs = *(_system.rhs);
newton_iterate.close();
linear_solution.close();
rhs.close();
#ifdef LIBMESH_ENABLE_AMR
_system.get_dof_map().enforce_constraints_exactly(_system);
#endif
SparseMatrix<Number> &matrix = *(_system.matrix);
// Prepare to take incomplete steps
Real last_residual=0.;
// Set starting linear tolerance
Real current_linear_tolerance = initial_linear_tolerance;
// Start counting our linear solver steps
_inner_iterations = 0;
// Now we begin the nonlinear loop
for (_outer_iterations=0; _outer_iterations<max_nonlinear_iterations;
++_outer_iterations)
{
if (!quiet)
std::cout << 'Assembling the System' << std::endl;
_system.assembly(true, true);
rhs.close();
Real current_residual = rhs.l2_norm();
last_residual = current_residual;
// isnan() isn't standard C++ yet
#ifdef isnan
if (isnan(current_residual))
{
std::cout << ' Nonlinear solver DIVERGED at step ' << last_residual
<< ' with norm Not-a-Number'
<< std::endl;
libmesh_convergence_failure();
continue;
}
#endif // isnan
max_residual_norm = std::max (current_residual,
max_residual_norm);
// Compute the l2 norm of the whole solution
Real norm_total = newton_iterate.l2_norm();
max_solution_norm = std::max(max_solution_norm, norm_total);
if (!quiet)
std::cout << 'Nonlinear Residual: '
<< current_residual << std::endl;
// Make sure our linear tolerance is low enough
current_linear_tolerance = std::min (current_linear_tolerance,
current_residual * linear_tolerance_multiplier);
// But don't let it be too small
if (current_linear_tolerance < minimum_linear_tolerance)
{
current_linear_tolerance = minimum_linear_tolerance;
}
// At this point newton_iterate is the current guess, and
// linear_solution is now about to become the NEGATIVE of the next
// Newton step.
// Our best initial guess for the linear_solution is zero!
linear_solution.zero();
if (!quiet)
std::cout << 'Linear solve starting, tolerance '
<< current_linear_tolerance << std::endl;
// Solve the linear system. Two cases:
const std::pair<unsigned int, Real> rval =
(_system.have_matrix('Preconditioner')) ?
// 1.) User-supplied preconditioner
linear_solver->solve (matrix, _system.get_matrix('Preconditioner'),
linear_solution, rhs, current_linear_tolerance,
max_linear_iterations) :
// 2.) Use system matrix for the preconditioner
linear_solver->solve (matrix, linear_solution, rhs,
current_linear_tolerance,
max_linear_iterations);
// We may need to localize a parallel solution
_system.update ();
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_AMR
_system.get_dof_map().enforce_constraints_exactly(_system, &linear_solution);
#endif
const unsigned int linear_steps = rval.first;
libmesh_assert(linear_steps <= max_linear_iterations);
_inner_iterations += linear_steps;
const bool linear_solve_finished =
!(linear_steps == max_linear_iterations);
if (!quiet)
std::cout << 'Linear solve finished, step ' << linear_steps
<< ', residual ' << rval.second
<< std::endl;
// Compute the l2 norm of the nonlinear update
Real norm_delta = linear_solution.l2_norm();
if (!quiet)
std::cout << 'Trying full Newton step' << std::endl;
// Take a full Newton step
newton_iterate.add (-1., linear_solution);
newton_iterate.close();
// Check residual with full Newton step
_system.assembly(true, false);
rhs.close();
current_residual = rhs.l2_norm();
if (!quiet)
std::cout << ' Current Residual: '
<< current_residual << std::endl;
// A potential method for avoiding oversolving?
/*
Real predicted_absolute_error =
current_residual * norm_delta / last_residual;
Real predicted_relative_error =
predicted_absolute_error / max_solution_norm;
std::cout << 'Predicted absolute error = ' <<
predicted_absolute_error << std::endl;
std::cout << 'Predicted relative error = ' <<
predicted_relative_error << std::endl;
*/
// don't fiddle around if we've already converged
if (test_convergence(current_residual, norm_delta,
linear_solve_finished))
{
if (!quiet)
print_convergence(_outer_iterations, current_residual,
norm_delta, linear_solve_finished);
_outer_iterations++;
break; // out of _outer_iterations for loop
}
// otherwise, backtrack if necessary
Real steplength =
this->line_search(std::sqrt(TOLERANCE),
last_residual, current_residual,
newton_iterate, linear_solution);
norm_delta *= steplength;
// Check to see if backtracking failed,
// and break out of the nonlinear loop if so...
if (_solve_result == DiffSolver::DIVERGED_BACKTRACKING_FAILURE)
{
_outer_iterations++;
break; // out of _outer_iterations for loop
}
// Compute the l2 norm of the whole solution
norm_total = newton_iterate.l2_norm();
max_solution_norm = std::max(max_solution_norm, norm_total);
// Print out information for the
// nonlinear iterations.
if (!quiet)
std::cout << ' Nonlinear step: |du|/|u| = '
<< norm_delta / norm_total
<< ', |du| = ' << norm_delta
<< std::endl;
// Terminate the solution iteration if the difference between
// this iteration and the last is sufficiently small.
if (!quiet)
print_convergence(_outer_iterations, current_residual,
norm_delta / steplength,
linear_solve_finished);
if (test_convergence(current_residual, norm_delta / steplength,
linear_solve_finished))
{
_outer_iterations++;
break; // out of _outer_iterations for loop
}
if (_outer_iterations >= max_nonlinear_iterations - 1)
{
std::cout << ' Nonlinear solver FAILED TO CONVERGE by step '
<< _outer_iterations << ' with norm '
<< norm_total << std::endl;
if (continue_after_max_iterations)
{
_solve_result = DiffSolver::DIVERGED_MAX_NONLINEAR_ITERATIONS;
std::cout << ' Continuing anyway...' << std::endl;
}
else
{
libmesh_convergence_failure();
}
continue;
}
} // end nonlinear loop
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_AMR
_system.get_dof_map().enforce_constraints_exactly(_system);
#endif
// We may need to localize a parallel solution
_system.update ();
STOP_LOG('solve()', 'NewtonSolver');
// Make sure we are returning something sensible as the
// _solve_result.
libmesh_assert (_solve_result != DiffSolver::INVALID_SOLVE_RESULT);
return _solve_result;
}
Definition at line 116 of file diff_solver.h.
References DiffSolver::_solve_result.
{ return _solve_result; }
Definition at line 126 of file diff_solver.h.
References DiffSolver::_system.
{ return _system; }
Definition at line 121 of file diff_solver.h.
References DiffSolver::_system.
Referenced by __libmesh_petsc_diff_solver_jacobian(), and __libmesh_petsc_diff_solver_residual().
{ return _system; }
Definition at line 574 of file newton_solver.C.
References DiffSolver::_solve_result, DiffSolver::absolute_residual_tolerance, DiffSolver::absolute_step_tolerance, DiffSolver::CONVERGED_ABSOLUTE_RESIDUAL, DiffSolver::CONVERGED_ABSOLUTE_STEP, DiffSolver::CONVERGED_RELATIVE_RESIDUAL, DiffSolver::CONVERGED_RELATIVE_STEP, DiffSolver::max_residual_norm, DiffSolver::max_solution_norm, DiffSolver::relative_residual_tolerance, and DiffSolver::relative_step_tolerance.
Referenced by solve().
{
// We haven't converged unless we pass a convergence test
bool has_converged = false;
// Is our absolute residual low enough?
if (current_residual < absolute_residual_tolerance)
{
_solve_result |= CONVERGED_ABSOLUTE_RESIDUAL;
has_converged = true;
}
// Is our relative residual low enough?
if ((current_residual / max_residual_norm) <
relative_residual_tolerance)
{
_solve_result |= CONVERGED_RELATIVE_RESIDUAL;
has_converged = true;
}
// For incomplete linear solves, it's not safe to test step sizes
if (!linear_solve_finished)
{
return has_converged;
}
// Is our absolute Newton step size small enough?
if (step_norm < absolute_step_tolerance)
{
_solve_result |= CONVERGED_ABSOLUTE_STEP;
has_converged = true;
}
// Is our relative Newton step size small enough?
if (step_norm / max_solution_norm <
relative_step_tolerance)
{
_solve_result |= CONVERGED_RELATIVE_STEP;
has_converged = true;
}
return has_converged;
}
Definition at line 111 of file diff_solver.h.
References DiffSolver::_inner_iterations.
{ return _inner_iterations; }
Definition at line 105 of file diff_solver.h.
References DiffSolver::_outer_iterations.
{ return _outer_iterations; }
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
Definition at line 280 of file diff_solver.h.
Referenced by solve(), and DiffSolver::total_inner_iterations().
Definition at line 123 of file reference_counter.h.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
Definition at line 275 of file diff_solver.h.
Referenced by line_search(), PetscDiffSolver::solve(), solve(), and DiffSolver::total_outer_iterations().
Definition at line 293 of file diff_solver.h.
Referenced by line_search(), solve(), DiffSolver::solve_result(), and test_convergence().
Definition at line 285 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), adjoint_solve(), line_search(), PetscDiffSolver::solve(), solve(), and DiffSolver::system().
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 print_convergence(), and test_convergence().
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 print_convergence(), and test_convergence().
brent_line_search is currently set to true by default.
Definition at line 100 of file newton_solver.h.
Definition at line 158 of file diff_solver.h.
Definition at line 152 of file diff_solver.h.
Definition at line 188 of file diff_solver.h.
Definition at line 124 of file newton_solver.h.
Referenced by adjoint_solve(), reinit(), and solve().
Definition at line 114 of file newton_solver.h.
Definition at line 132 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), adjoint_solve(), ContinuationSystem::continuation_solve(), solve(), and ContinuationSystem::solve_tangent().
Definition at line 140 of file diff_solver.h.
Referenced by ContinuationSystem::continuation_solve(), solve(), and ContinuationSystem::update_solution().
Definition at line 270 of file diff_solver.h.
Referenced by DiffSolver::init(), print_convergence(), DiffSolver::reinit(), solve(), and test_convergence().
Definition at line 263 of file diff_solver.h.
Referenced by DiffSolver::init(), print_convergence(), DiffSolver::reinit(), solve(), and test_convergence().
Definition at line 193 of file diff_solver.h.
Definition at line 108 of file newton_solver.h.
Definition at line 146 of file diff_solver.h.
Referenced by adjoint_solve(), line_search(), print_convergence(), and solve().
Definition at line 170 of file diff_solver.h.
Referenced by PetscDiffSolver::adjoint_solve(), adjoint_solve(), print_convergence(), and test_convergence().
Definition at line 182 of file diff_solver.h.
Referenced by print_convergence(), and test_convergence().
Definition at line 87 of file newton_solver.h.
Referenced by line_search().
Generated automatically by Doxygen for libMesh from the source code.