Skip to content

Make Newton only throw NewtonError

Lukas Riedel requested to merge homogenize-newton-errors into master

What does this MR do?

This MR makes the exceptions thrown by the new Newton solver interfaces (LineSearch and Terminate) derived from NewtonError.

Why was this MR needed?

Although there is an exception class NewtonError, the errors thrown by DefaultLineSearch and DefaultTerminate are not derived from it. This causes some surprising behavior from a user perspective, as not all errors thrown by the NewtonMethod are derived from NewtonError:

try {
  Dune::PDELab::NewtonMethod<GO, LS> newton(go, ls);
  newton.apply(u);
}
catch (Dune::PDELab::NewtonError&) {
  std::cout << "Error in Newton solver!" << std::endl;
  // BUT: LineSearchError and TerminateError not catched!
}
catch (...) {
  // LineSearchError and TerminateError end up here!
  // But one would expect that ...
  std::cout << "Error unrelated to Newton solver!" << std::endl;
}
Edited by Lukas Riedel

Merge request reports