NoConvergence (const unsigned int last_step,
const double last_residual);
+ /**
+ * Standardized output for
+ * catch handlers.
+ */
+ virtual const char * what () const throw ();
+
/**
* Iteration number of the
* last step.
#include <lac/solver_control.h>
#include <cmath>
+#include <strstream>
/*----------------------- SolverControl ---------------------------------*/
{};
+const char *
+SolverControl::NoConvergence::what () const throw ()
+{
+ // have a place where to store the
+ // description of the exception as a char *
+ //
+ // this thing obviously is not multi-threading
+ // safe, but we don't care about that for now
+ //
+ // we need to make this object static, since
+ // we want to return the data stored in it
+ // and therefore need a liftime which is
+ // longer than the execution time of this
+ // function
+ static std::string description;
+ // convert the messages printed by the
+ // exceptions into a std::string
+ std::ostrstream out;
+
+ out << "Iterative method reported convergence failure in step "
+ << last_step << " with residual " << last_residual << std::ends;
+
+ description = out.str();
+ return description.c_str();
+}
+
+
SolverControl::SolverControl (const unsigned int maxiter,
const double tolerance,
deallog.push("sor");
check_method(rich,A,u,f,prec_sor);
+ try
+ {
+ check_method(cg,A,u,f,prec_sor);
+ }
+ catch (exception& e)
+ {
+ deallog << e.what() << endl;
+ }
+
check_method(bicgstab,A,u,f,prec_sor);
check_method(gmres,A,u,f,prec_sor);