libMesh
newton_solver.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #include "libmesh/diff_system.h"
20 #include "libmesh/dof_map.h"
21 #include "libmesh/libmesh_logging.h"
22 #include "libmesh/linear_solver.h"
23 #include "libmesh/newton_solver.h"
24 #include "libmesh/numeric_vector.h"
25 #include "libmesh/sparse_matrix.h"
26 
27 namespace libMesh
28 {
29 
30 // SIGN from Numerical Recipes
31 template <typename T>
32 inline
33 T SIGN(T a, T b)
34 {
35  return b >= 0 ? std::abs(a) : -std::abs(a);
36 }
37 
39  Real last_residual,
40  Real & current_residual,
41  NumericVector<Number> & newton_iterate,
42  const NumericVector<Number> & linear_solution)
43 {
44  // Take a full step if we got a residual reduction or if we
45  // aren't substepping
46  if ((current_residual < last_residual) ||
48  (!require_finite_residual || !libmesh_isnan(current_residual))))
49  return 1.;
50 
51  // The residual vector
53 
54  Real ax = 0.; // First abscissa, don't take negative steps
55  Real cx = 1.; // Second abscissa, don't extrapolate steps
56 
57  // Find bx, a step length that gives lower residual than ax or cx
58  Real bx = 1.;
59 
60  while (libmesh_isnan(current_residual) ||
61  (current_residual > last_residual &&
63  {
64  // Reduce step size to 1/2, 1/4, etc.
65  Real substepdivision;
66  if (brent_line_search && !libmesh_isnan(current_residual))
67  {
68  substepdivision = std::min(0.5, last_residual/current_residual);
69  substepdivision = std::max(substepdivision, tol*2.);
70  }
71  else
72  substepdivision = 0.5;
73 
74  newton_iterate.add (bx * (1.-substepdivision),
75  linear_solution);
76  newton_iterate.close();
77  bx *= substepdivision;
78  if (verbose)
79  libMesh::out << " Shrinking Newton step to "
80  << bx << std::endl;
81 
82  // We may need to localize a parallel solution
83  _system.update();
84 
85  // Check residual with fractional Newton step
86  _system.assembly (true, false);
87 
88  rhs.close();
89  current_residual = rhs.l2_norm();
90  if (verbose)
91  libMesh::out << " Current Residual: "
92  << current_residual << std::endl;
93 
94  if (bx/2. < minsteplength &&
95  (libmesh_isnan(current_residual) ||
96  (current_residual > last_residual)))
97  {
98  libMesh::out << "Inexact Newton step FAILED at step "
99  << _outer_iterations << std::endl;
100 
102  {
103  libmesh_convergence_failure();
104  }
105  else
106  {
107  libMesh::out << "Continuing anyway ..." << std::endl;
109  return bx;
110  }
111  }
112  } // end while (current_residual > last_residual)
113 
114  // Now return that reduced-residual step, or use Brent's method to
115  // find a more optimal step.
116 
117  if (!brent_line_search)
118  return bx;
119 
120  // Brent's method adapted from Numerical Recipes in C, ch. 10.2
121  Real e = 0.;
122 
123  Real x = bx, w = bx, v = bx;
124 
125  // Residuals at bx
126  Real fx = current_residual,
127  fw = current_residual,
128  fv = current_residual;
129 
130  // Max iterations for Brent's method loop
131  const unsigned int max_i = 20;
132 
133  // for golden ratio steps
134  const Real golden_ratio = 1.-(std::sqrt(5.)-1.)/2.;
135 
136  for (unsigned int i=1; i <= max_i; i++)
137  {
138  Real xm = (ax+cx)*0.5;
139  Real tol1 = tol * std::abs(x) + tol*tol;
140  Real tol2 = 2.0 * tol1;
141 
142  // Test if we're done
143  if (std::abs(x-xm) <= (tol2 - 0.5 * (cx - ax)))
144  return x;
145 
146  Real d;
147 
148  // Construct a parabolic fit
149  if (std::abs(e) > tol1)
150  {
151  Real r = (x-w)*(fx-fv);
152  Real q = (x-v)*(fx-fw);
153  Real p = (x-v)*q-(x-w)*r;
154  q = 2. * (q-r);
155  if (q > 0.)
156  p = -p;
157  else
158  q = std::abs(q);
159  if (std::abs(p) >= std::abs(0.5*q*e) ||
160  p <= q * (ax-x) ||
161  p >= q * (cx-x))
162  {
163  // Take a golden section step
164  e = x >= xm ? ax-x : cx-x;
165  d = golden_ratio * e;
166  }
167  else
168  {
169  // Take a parabolic fit step
170  d = p/q;
171  if (x+d-ax < tol2 || cx-(x+d) < tol2)
172  d = SIGN(tol1, xm - x);
173  }
174  }
175  else
176  {
177  // Take a golden section step
178  e = x >= xm ? ax-x : cx-x;
179  d = golden_ratio * e;
180  }
181 
182  Real u = std::abs(d) >= tol1 ? x+d : x + SIGN(tol1,d);
183 
184  // Assemble the residual at the new steplength u
185  newton_iterate.add (bx - u, linear_solution);
186  newton_iterate.close();
187  bx = u;
188  if (verbose)
189  libMesh::out << " Shrinking Newton step to "
190  << bx << std::endl;
191 
192  // We may need to localize a parallel solution
193  _system.update();
194  _system.assembly (true, false);
195 
196  rhs.close();
197  Real fu = current_residual = rhs.l2_norm();
198  if (verbose)
199  libMesh::out << " Current Residual: "
200  << fu << std::endl;
201 
202  if (fu <= fx)
203  {
204  if (u >= x)
205  ax = x;
206  else
207  cx = x;
208  v = w; w = x; x = u;
209  fv = fw; fw = fx; fx = fu;
210  }
211  else
212  {
213  if (u < x)
214  ax = u;
215  else
216  cx = u;
217  if (fu <= fw || w == x)
218  {
219  v = w; w = u;
220  fv = fw; fw = fu;
221  }
222  else if (fu <= fv || v == x || v == w)
223  {
224  v = u;
225  fv = fu;
226  }
227  }
228  }
229 
230  if (!quiet)
231  libMesh::out << "Warning! Too many iterations used in Brent line search!"
232  << std::endl;
233  return bx;
234 }
235 
236 
238  : Parent(s),
239  require_residual_reduction(true),
240  require_finite_residual(true),
241  brent_line_search(true),
242  track_linear_convergence(false),
243  minsteplength(1e-5),
244  linear_tolerance_multiplier(1e-3),
245  _linear_solver(LinearSolver<Number>::build(s.comm()))
246 {
247 }
248 
249 
250 
252 {
253 }
254 
255 
256 
258 {
259  Parent::init();
260 
261  if (libMesh::on_command_line("--solver-system-names"))
262  _linear_solver->init((_system.name()+"_").c_str());
263  else
264  _linear_solver->init();
265 
266  _linear_solver->init_names(_system);
267 }
268 
269 
270 
272 {
273  Parent::reinit();
274 
275  _linear_solver->clear();
276 
277  _linear_solver->init_names(_system);
278 }
279 
280 
281 
282 unsigned int NewtonSolver::solve()
283 {
284  LOG_SCOPE("solve()", "NewtonSolver");
285 
286  // Reset any prior solve result
288 
289  NumericVector<Number> & newton_iterate = *(_system.solution);
290 
291  std::unique_ptr<NumericVector<Number>> linear_solution_ptr = newton_iterate.zero_clone();
292  NumericVector<Number> & linear_solution = *linear_solution_ptr;
293  NumericVector<Number> & rhs = *(_system.rhs);
294 
295  newton_iterate.close();
296  linear_solution.close();
297  rhs.close();
298 
299 #ifdef LIBMESH_ENABLE_CONSTRAINTS
301 #endif
302 
303  SparseMatrix<Number> & matrix = *(_system.matrix);
304 
305  // Set starting linear tolerance
306  double current_linear_tolerance = initial_linear_tolerance;
307 
308  // Start counting our linear solver steps
309  _inner_iterations = 0;
310 
311  // Now we begin the nonlinear loop
314  {
315  // We may need to localize a parallel solution
316  _system.update();
317 
318  if (verbose)
319  libMesh::out << "Assembling the System" << std::endl;
320 
321  _system.assembly(true, true);
322  rhs.close();
323  Real current_residual = rhs.l2_norm();
324 
325  if (libmesh_isnan(current_residual))
326  {
327  libMesh::out << " Nonlinear solver DIVERGED at step "
329  << " with residual Not-a-Number"
330  << std::endl;
331  libmesh_convergence_failure();
332  continue;
333  }
334 
335  if (current_residual <= absolute_residual_tolerance)
336  {
337  if (verbose)
338  libMesh::out << "Linear solve unnecessary; residual "
339  << current_residual
340  << " meets absolute tolerance "
342  << std::endl;
343 
344  // We're not doing a solve, but other code may reuse this
345  // matrix.
346  matrix.close();
347 
349  if (current_residual == 0)
350  {
353  if (absolute_step_tolerance > 0)
355  if (relative_step_tolerance > 0)
357  }
358 
359  break;
360  }
361 
362  // Prepare to take incomplete steps
363  Real last_residual = current_residual;
364 
365  max_residual_norm = std::max (current_residual,
367 
368  // Compute the l2 norm of the whole solution
369  Real norm_total = newton_iterate.l2_norm();
370 
371  max_solution_norm = std::max(max_solution_norm, norm_total);
372 
373  if (verbose)
374  libMesh::out << "Nonlinear Residual: "
375  << current_residual << std::endl;
376 
377  // Make sure our linear tolerance is low enough
378  current_linear_tolerance =
379  double(std::min (current_linear_tolerance,
380  current_residual * linear_tolerance_multiplier));
381 
382  // But don't let it be too small
383  if (current_linear_tolerance < minimum_linear_tolerance)
384  {
385  current_linear_tolerance = minimum_linear_tolerance;
386  }
387 
388  // If starting the nonlinear solve with a really good initial guess, we dont want to set an absurd linear tolerance
389  current_linear_tolerance =
390  double(std::max(current_linear_tolerance,
391  absolute_residual_tolerance / current_residual
392  / 10.0));
393 
394  // At this point newton_iterate is the current guess, and
395  // linear_solution is now about to become the NEGATIVE of the next
396  // Newton step.
397 
398  // Our best initial guess for the linear_solution is zero!
399  linear_solution.zero();
400 
401  if (verbose)
402  libMesh::out << "Linear solve starting, tolerance "
403  << current_linear_tolerance << std::endl;
404 
405  // Solve the linear system.
406  const std::pair<unsigned int, Real> rval =
407  _linear_solver->solve (matrix, _system.request_matrix("Preconditioner"),
408  linear_solution, rhs, current_linear_tolerance,
410 
412  {
413  LinearConvergenceReason linear_c_reason = _linear_solver->get_converged_reason();
414 
415  // Check if something went wrong during the linear solve
416  if (linear_c_reason < 0)
417  {
418  // The linear solver failed somehow
420  // Print a message
421  libMesh::out << "Linear solver failed during Newton step, dropping out."
422  << std::endl;
423  break;
424  }
425  }
426 
427  // We may need to localize a parallel solution
428  _system.update ();
429  // The linear solver may not have fit our constraints exactly
430 #ifdef LIBMESH_ENABLE_CONSTRAINTS
432  (_system, &linear_solution, /* homogeneous = */ true);
433 #endif
434 
435  const unsigned int linear_steps = rval.first;
436  libmesh_assert_less_equal (linear_steps, max_linear_iterations);
437  _inner_iterations += linear_steps;
438 
439  const bool linear_solve_finished =
440  !(linear_steps == max_linear_iterations);
441 
442  if (verbose)
443  libMesh::out << "Linear solve finished, step " << linear_steps
444  << ", residual " << rval.second
445  << std::endl;
446 
447  // Compute the l2 norm of the nonlinear update
448  Real norm_delta = linear_solution.l2_norm();
449 
450  if (verbose)
451  libMesh::out << "Trying full Newton step" << std::endl;
452  // Take a full Newton step
453  newton_iterate.add (-1., linear_solution);
454  newton_iterate.close();
455 
456  if (this->linear_solution_monitor.get())
457  {
458  // Compute the l2 norm of the whole solution
459  norm_total = newton_iterate.l2_norm();
460  rhs.close();
461  (*this->linear_solution_monitor)(linear_solution, norm_delta,
462  newton_iterate, norm_total,
463  rhs, rhs.l2_norm(), _outer_iterations);
464  }
465 
466  // Check residual with full Newton step, if that's useful for determining
467  // whether to line search, whether to quit early, or whether to die after
468  // hitting our max iteration count
469  if (this->require_residual_reduction ||
470  this->require_finite_residual ||
471  _outer_iterations+1 < max_nonlinear_iterations ||
473  {
474  _system.update ();
475  _system.assembly(true, false);
476 
477  rhs.close();
478  current_residual = rhs.l2_norm();
479  if (verbose)
480  libMesh::out << " Current Residual: "
481  << current_residual << std::endl;
482 
483  // don't fiddle around if we've already converged
484  if (test_convergence(current_residual, norm_delta,
485  linear_solve_finished &&
486  current_residual <= last_residual))
487  {
488  if (!quiet)
489  print_convergence(_outer_iterations, current_residual,
490  norm_delta, linear_solve_finished &&
491  current_residual <= last_residual);
493  break; // out of _outer_iterations for loop
494  }
495  }
496 
497  // since we're not converged, backtrack if necessary
498  Real steplength =
500  last_residual, current_residual,
501  newton_iterate, linear_solution);
502  norm_delta *= steplength;
503 
504  // Check to see if backtracking failed,
505  // and break out of the nonlinear loop if so...
507  {
509  break; // out of _outer_iterations for loop
510  }
511 
513  {
514  libMesh::out << " Nonlinear solver reached maximum step "
515  << max_nonlinear_iterations << ", latest evaluated residual "
516  << current_residual << std::endl;
518  {
520  libMesh::out << " Continuing..." << std::endl;
521  }
522  else
523  {
524  libmesh_convergence_failure();
525  }
526  continue;
527  }
528 
529  // Compute the l2 norm of the whole solution
530  norm_total = newton_iterate.l2_norm();
531 
532  max_solution_norm = std::max(max_solution_norm, norm_total);
533 
534  // Print out information for the
535  // nonlinear iterations.
536  if (verbose)
537  libMesh::out << " Nonlinear step: |du|/|u| = "
538  << norm_delta / norm_total
539  << ", |du| = " << norm_delta
540  << std::endl;
541 
542  // Terminate the solution iteration if the difference between
543  // this iteration and the last is sufficiently small.
544  if (test_convergence(current_residual, norm_delta / steplength,
545  linear_solve_finished))
546  {
547  if (!quiet)
548  print_convergence(_outer_iterations, current_residual,
549  norm_delta / steplength,
550  linear_solve_finished);
552  break; // out of _outer_iterations for loop
553  }
554  } // end nonlinear loop
555 
556  // The linear solver may not have fit our constraints exactly
557 #ifdef LIBMESH_ENABLE_CONSTRAINTS
559 #endif
560 
561  // We may need to localize a parallel solution
562  _system.update ();
563 
564  // Make sure we are returning something sensible as the
565  // _solve_result, except in the edge case where we weren't really asked to
566  // solve.
569 
570  return _solve_result;
571 }
572 
573 
574 
575 bool NewtonSolver::test_convergence(Real current_residual,
576  Real step_norm,
577  bool linear_solve_finished)
578 {
579  // We haven't converged unless we pass a convergence test
580  bool has_converged = false;
581 
582  // Is our absolute residual low enough?
583  if (current_residual < absolute_residual_tolerance)
584  {
586  has_converged = true;
587  }
588 
589  // Is our relative residual low enough?
590  if ((current_residual / max_residual_norm) <
592  {
594  has_converged = true;
595  }
596 
597  // For incomplete linear solves, it's not safe to test step sizes
598  if (!linear_solve_finished)
599  {
600  return has_converged;
601  }
602 
603  // Is our absolute Newton step size small enough?
604  if (step_norm < absolute_step_tolerance)
605  {
607  has_converged = true;
608  }
609 
610  // Is our relative Newton step size small enough?
611  if (step_norm / max_solution_norm <
613  {
615  has_converged = true;
616  }
617 
618  return has_converged;
619 }
620 
621 
622 void NewtonSolver::print_convergence(unsigned int step_num,
623  Real current_residual,
624  Real step_norm,
625  bool linear_solve_finished)
626 {
627  // Is our absolute residual low enough?
628  if (current_residual < absolute_residual_tolerance)
629  {
630  libMesh::out << " Nonlinear solver converged, step " << step_num
631  << ", residual " << current_residual
632  << std::endl;
633  }
635  {
636  if (verbose)
637  libMesh::out << " Nonlinear solver current_residual "
638  << current_residual << " > "
639  << (absolute_residual_tolerance) << std::endl;
640  }
641 
642  // Is our relative residual low enough?
643  if ((current_residual / max_residual_norm) <
645  {
646  libMesh::out << " Nonlinear solver converged, step " << step_num
647  << ", residual reduction "
648  << current_residual / max_residual_norm
649  << " < " << relative_residual_tolerance
650  << std::endl;
651  }
653  {
654  if (verbose)
655  libMesh::out << " Nonlinear solver relative residual "
656  << (current_residual / max_residual_norm)
657  << " > " << relative_residual_tolerance
658  << std::endl;
659  }
660 
661  // For incomplete linear solves, it's not safe to test step sizes
662  if (!linear_solve_finished)
663  return;
664 
665  // Is our absolute Newton step size small enough?
666  if (step_norm < absolute_step_tolerance)
667  {
668  libMesh::out << " Nonlinear solver converged, step " << step_num
669  << ", absolute step size "
670  << step_norm
671  << " < " << absolute_step_tolerance
672  << std::endl;
673  }
674  else if (absolute_step_tolerance)
675  {
676  if (verbose)
677  libMesh::out << " Nonlinear solver absolute step size "
678  << step_norm
679  << " > " << absolute_step_tolerance
680  << std::endl;
681  }
682 
683  // Is our relative Newton step size small enough?
684  if (step_norm / max_solution_norm <
686  {
687  libMesh::out << " Nonlinear solver converged, step " << step_num
688  << ", relative step size "
689  << (step_norm / max_solution_norm)
690  << " < " << relative_step_tolerance
691  << std::endl;
692  }
693  else if (relative_step_tolerance)
694  {
695  if (verbose)
696  libMesh::out << " Nonlinear solver relative step size "
697  << (step_norm / max_solution_norm)
698  << " > " << relative_step_tolerance
699  << std::endl;
700  }
701 }
702 
703 } // namespace libMesh
libMesh::DiffSolver::reinit
virtual void reinit()
The reinitialization function.
Definition: diff_solver.C:60
libMesh::SparseMatrix::close
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
libMesh::DiffSolver::CONVERGED_ABSOLUTE_STEP
The DiffSolver achieved the desired absolute step size tolerance.
Definition: diff_solver.h:251
libMesh::ImplicitSystem::request_matrix
const SparseMatrix< Number > * request_matrix(const std::string &mat_name) const
Definition: implicit_system.C:236
libMesh::NumericVector::zero
virtual void zero()=0
Set all entries to zero.
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::NumericVector::add
virtual void add(const numeric_index_type i, const T value)=0
Adds value to each entry of the vector.
libMesh::ImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
Definition: implicit_system.h:57
libMesh::ExplicitSystem::rhs
NumericVector< Number > * rhs
The system matrix.
Definition: explicit_system.h:114
libMesh::NewtonSolver::track_linear_convergence
bool track_linear_convergence
If set to true, check for convergence of the linear solve.
Definition: newton_solver.h:129
libMesh::NewtonSolver::require_residual_reduction
bool require_residual_reduction
If this is set to true, the solver is forced to test the residual after each Newton step,...
Definition: newton_solver.h:98
libMesh::NewtonSolver::init
virtual void init() override
The initialization function.
Definition: newton_solver.C:257
libMesh::DiffSolver::CONVERGED_RELATIVE_STEP
The DiffSolver achieved the desired relative step size tolerance.
Definition: diff_solver.h:257
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DiffSolver::continue_after_backtrack_failure
bool continue_after_backtrack_failure
Defaults to false, telling the DiffSolver to throw an error when the backtracking scheme fails to fin...
Definition: diff_solver.h:180
libMesh::NumericVector::close
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
libMesh::DiffSolver::absolute_step_tolerance
Real absolute_step_tolerance
The DiffSolver should exit after the full nonlinear step norm is reduced to either less than absolute...
Definition: diff_solver.h:203
libMesh::NewtonSolver::_linear_solver
std::unique_ptr< LinearSolver< Number > > _linear_solver
The LinearSolver defines the interface used to solve the linear_implicit system.
Definition: newton_solver.h:153
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::DiffSolver::DIVERGED_LINEAR_SOLVER_FAILURE
The linear solver used by the DiffSolver failed to find a solution.
Definition: diff_solver.h:282
libMesh::DiffSolver
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Definition: diff_solver.h:70
libMesh::DiffSolver::DIVERGED_BACKTRACKING_FAILURE
The DiffSolver failed to find a descent direction by backtracking (See newton_solver....
Definition: diff_solver.h:276
libMesh::DiffSolver::CONVERGED_RELATIVE_RESIDUAL
The DiffSolver achieved the desired relative residual tolerance.
Definition: diff_solver.h:245
libMesh::DiffSolver::_solve_result
unsigned int _solve_result
Initialized to zero.
Definition: diff_solver.h:326
libMesh::NewtonSolver::linear_tolerance_multiplier
double linear_tolerance_multiplier
The tolerance for linear solves is kept below this multiplier (which defaults to 1e-3) times the norm...
Definition: newton_solver.h:143
libMesh::DiffSolver::_inner_iterations
unsigned int _inner_iterations
The number of inner iterations used by the last solve.
Definition: diff_solver.h:313
libMesh::DiffSolver::init
virtual void init()
The initialization function.
Definition: diff_solver.C:69
libMesh::SparseMatrix< Number >
libMesh::NewtonSolver::line_search
Real line_search(Real tol, Real last_residual, Real &current_residual, NumericVector< Number > &newton_iterate, const NumericVector< Number > &linear_solution)
This does a line search in the direction opposite linear_solution to try and minimize the residual of...
Definition: newton_solver.C:38
libMesh::NumericVector< Number >
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::SIGN
T SIGN(T a, T b)
Definition: newton_solver.C:33
libMesh::LinearConvergenceReason
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
Definition: enum_convergence_flags.h:33
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::DiffSolver::minimum_linear_tolerance
double minimum_linear_tolerance
The tolerance for linear solves is kept above this minimum.
Definition: diff_solver.h:215
libMesh::NewtonSolver::print_convergence
void print_convergence(unsigned int step_num, Real current_residual, Real step_norm, bool linear_solve_finished)
This prints output for the convergence criteria based on by the given residual and step size.
Definition: newton_solver.C:622
libMesh::DiffSolver::relative_step_tolerance
Real relative_step_tolerance
Definition: diff_solver.h:204
libMesh::DiffSolver::verbose
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
Definition: diff_solver.h:168
libMesh::libmesh_isnan
bool libmesh_isnan(T x)
Definition: libmesh_common.h:177
libMesh::ImplicitSystem::assembly
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
Definition: implicit_system.h:161
libMesh::DofMap::enforce_constraints_exactly
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh.
Definition: dof_map.h:2054
libMesh::DiffSolver::continue_after_max_iterations
bool continue_after_max_iterations
Defaults to true, telling the DiffSolver to continue rather than exit when a solve has reached its ma...
Definition: diff_solver.h:174
libMesh::ImplicitSystem::matrix
SparseMatrix< Number > * matrix
The system matrix.
Definition: implicit_system.h:393
libMesh::DiffSolver::CONVERGED_ABSOLUTE_RESIDUAL
The DiffSolver achieved the desired absolute residual tolerance.
Definition: diff_solver.h:239
libMesh::NewtonSolver::reinit
virtual void reinit() override
The reinitialization function.
Definition: newton_solver.C:271
libMesh::DiffSolver::DIVERGED_MAX_NONLINEAR_ITERATIONS
The DiffSolver reached the maximum allowed number of nonlinear iterations before satisfying any conve...
Definition: diff_solver.h:270
libMesh::DiffSolver::quiet
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
Definition: diff_solver.h:162
libMesh::DiffSolver::relative_residual_tolerance
Real relative_residual_tolerance
Definition: diff_solver.h:192
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
libMesh::DiffSolver::linear_solution_monitor
std::unique_ptr< LinearSolutionMonitor > linear_solution_monitor
Pointer to functor which is called right after each linear solve.
Definition: diff_solver.h:288
libMesh::DiffSolver::_outer_iterations
unsigned int _outer_iterations
The number of outer iterations used by the last solve.
Definition: diff_solver.h:308
libMesh::DiffSolver::absolute_residual_tolerance
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
Definition: diff_solver.h:191
libMesh::NewtonSolver::test_convergence
bool test_convergence(Real current_residual, Real step_norm, bool linear_solve_finished)
Definition: newton_solver.C:575
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::LinearSolver
This base class can be inherited from to provide interfaces to linear solvers from different packages...
Definition: linear_solver.h:69
libMesh::DiffSolver::max_linear_iterations
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
Definition: diff_solver.h:148
libMesh::NumericVector::l2_norm
virtual Real l2_norm() const =0
libMesh::on_command_line
bool on_command_line(std::string arg)
Definition: libmesh.C:898
libMesh::NewtonSolver::solve
virtual unsigned int solve() override
This method performs a solve, using an inexact Newton-Krylov method with line search.
Definition: newton_solver.C:282
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::DiffSolver::max_nonlinear_iterations
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
Definition: diff_solver.h:156
libMesh::NewtonSolver::NewtonSolver
NewtonSolver(sys_type &system)
Constructor.
Definition: newton_solver.C:237
libMesh::DiffSolver::max_solution_norm
Real max_solution_norm
The largest solution norm which the DiffSolver has yet seen will be stored here, to be used for stopp...
Definition: diff_solver.h:296
libMesh::NewtonSolver::~NewtonSolver
virtual ~NewtonSolver()
Destructor.
Definition: newton_solver.C:251
libMesh::NewtonSolver::require_finite_residual
bool require_finite_residual
If this is set to true, the solver is forced to test the residual after each Newton step,...
Definition: newton_solver.h:107
libMesh::NewtonSolver::minsteplength
Real minsteplength
If the quasi-Newton step length must be reduced to below this factor to give a residual reduction,...
Definition: newton_solver.h:137
libMesh::out
OStreamProxy out
libMesh::System::update
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:408
libMesh::NumericVector::zero_clone
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
libMesh::NewtonSolver::brent_line_search
bool brent_line_search
If require_residual_reduction is true, the solver may reduce step lengths when required.
Definition: newton_solver.h:120
libMesh::DiffSolver::max_residual_norm
Real max_residual_norm
The largest nonlinear residual which the DiffSolver has yet seen will be stored here,...
Definition: diff_solver.h:303
libMesh::DiffSolver::_system
sys_type & _system
A reference to the system we are solving.
Definition: diff_solver.h:318
libMesh::DiffSolver::INVALID_SOLVE_RESULT
A default or invalid solve result.
Definition: diff_solver.h:227
libMesh::DiffSolver::initial_linear_tolerance
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
Definition: diff_solver.h:210