memory.free(Vr);
deallog.pop();
- // Output
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
}
//----------------------------------------------------------------------//
deallog.pop();
- // Output
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
}
#endif
* Access to control object.
*/
SolverControl& control() const;
-
-//TODO: [WB] move this class to SolverControl to avoid forcing templatized class qualification when catching such exceptions
- DeclException2(ExcNoConvergence, int, double,
- << "Iteration did not converge after " << arg1
- << " steps. Final residual " << arg2);
protected:
deallog.pop();
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
}
// Output
deallog.pop();
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
};
enum State {
iterate = 0, success, failure
};
+
+ /**
+ * Class to be thrown upon
+ * failing convergence of an
+ * iterative solver, when either
+ * the number of iterations
+ * exceeds the limit or the
+ * residual fails to reach the
+ * desired limit, e.g. in the
+ * case of a break-down.
+ *
+ * The residual in the last
+ * iteration, as well as the
+ * iteration number of the last
+ * step are stored in this object
+ * and can be recovered upon
+ * catching an exception of this
+ * class.
+ */
+ class NoConvergence : public std::exception
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ NoConvergence (const unsigned int last_step,
+ const double last_residual);
+
+ /**
+ * Iteration number of the
+ * last step.
+ */
+ const unsigned int last_step;
+
+ /**
+ * Residual in the last step.
+ */
+ const double last_residual;
+ };
+
/**
* Constructor. The parameters
deallog.pop();
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
};
// Output
deallog.pop ();
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
};
}
while (state);
- // Deallocate Memory
-
+ // Deallocate Memory
memory.free(Vv);
memory.free(Vp);
memory.free(Vq);
memory.free(Vt);
memory.free(Vd);
- // Output
-
+ // Output
deallog.pop();
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
};
memory.free(Vd);
deallog.pop();
- // Output
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
}
memory.free(Vd);
deallog.pop();
- // Output
- AssertThrow(control().last_check() == SolverControl::success,
- typename Solver<VECTOR>::ExcNoConvergence(control().last_step(),
- control().last_value()));
+ // in case of failure: throw
+ // exception
+ if (control().last_check() != SolverControl::success)
+ throw SolverControl::NoConvergence (control().last_step(),
+ control().last_value());
+ // otherwise exit as normal
}
/*----------------------- SolverControl ---------------------------------*/
+SolverControl::NoConvergence::NoConvergence (const unsigned int last_step,
+ const double last_residual)
+ :
+ last_step (last_step),
+ last_residual (last_residual)
+{};
+
+
+
SolverControl::SolverControl (const unsigned int maxiter,
const double tolerance,
const bool _log_history,