From: maier Date: Sun, 20 Oct 2013 16:32:15 +0000 (+0000) Subject: Derive SolverControl::NoConvergence from dealii::ExceptionBase X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c341bb475333cfadcc3c1a3482dd26bbf44230d;p=dealii-svn.git Derive SolverControl::NoConvergence from dealii::ExceptionBase git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31341 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index c399798fed..bf0dde3a26 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -162,6 +162,13 @@ inconvenience this causes.

Specific improvements

    +
  1. + dealii::SolverControl::NoConvergence now inherits dealii::ExceptionBase and + is thrown via AssertThrow(false, ... ). +
    + (Matthias Maier, 2013/10/20) +
  2. +
  3. New: parallel::distributed::BlockVector has now methods update_ghost_values, compress, set_out_ghosts, and has_ghost_elements that do the respective diff --git a/deal.II/include/deal.II/algorithms/newton.templates.h b/deal.II/include/deal.II/algorithms/newton.templates.h index a57c34d233..b1380d6e4e 100644 --- a/deal.II/include/deal.II/algorithms/newton.templates.h +++ b/deal.II/include/deal.II/algorithms/newton.templates.h @@ -174,11 +174,10 @@ namespace Algorithms } deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (control.last_step(), - control.last_value()); + AssertThrow(false, SolverControl::NoConvergence (control.last_step(), + control.last_value())); // otherwise exit as normal } } diff --git a/deal.II/include/deal.II/lac/eigen.h b/deal.II/include/deal.II/lac/eigen.h index 4de7854975..133277f64f 100644 --- a/deal.II/include/deal.II/lac/eigen.h +++ b/deal.II/include/deal.II/lac/eigen.h @@ -316,11 +316,10 @@ EigenPower::solve (double &value, deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_bicgstab.h b/deal.II/include/deal.II/lac/solver_bicgstab.h index 98d65a7646..25a6eaa87d 100644 --- a/deal.II/include/deal.II/lac/solver_bicgstab.h +++ b/deal.II/include/deal.II/lac/solver_bicgstab.h @@ -436,8 +436,8 @@ SolverBicgstab::solve(const MATRIX &A, // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_cg.h b/deal.II/include/deal.II/lac/solver_cg.h index 3f31cdce72..4c01b49cc4 100644 --- a/deal.II/include/deal.II/lac/solver_cg.h +++ b/deal.II/include/deal.II/lac/solver_cg.h @@ -476,11 +476,10 @@ SolverCG::solve (const MATRIX &A, // Deallocate Memory cleanup(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_control.h b/deal.II/include/deal.II/lac/solver_control.h index 7116304470..f303cddcf8 100644 --- a/deal.II/include/deal.II/lac/solver_control.h +++ b/deal.II/include/deal.II/lac/solver_control.h @@ -68,11 +68,8 @@ class SolverControl : public Subscriptor public: /** - * Enum denoting the different - * states a solver can be in. See - * the general documentation of - * this class for more - * information. + * Enum denoting the different states a solver can be in. See the general + * documentation of this class for more information. */ enum State { @@ -84,42 +81,36 @@ public: 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. + * 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. + * 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 + + class NoConvergence : public dealii::ExceptionBase { public: - /** - * Constructor. - */ NoConvergence (const unsigned int last_step, - const double last_residual); + const double last_residual) + : last_step (last_step), last_residual(last_residual) + {} - /** - * Standardized output for - * catch handlers. - */ - virtual const char *what () const throw (); + virtual ~NoConvergence () throw () {} + + virtual void print_info (std::ostream &out) const + { + out << "Iterative method reported convergence failure in step " + << last_step << " with residual " << last_residual << std::endl; + } /** - * Iteration number of the - * last step. + * Iteration number of the last step. */ const unsigned int last_step; @@ -130,25 +121,17 @@ public: }; + /** - * Constructor. The parameters - * @p n and @p tol are the - * maximum number of iteration - * steps before failure and the - * tolerance to determine success + * Constructor. The parameters @p n and @p tol are the maximum number of + * iteration steps before failure and the tolerance to determine success * of the iteration. * - * @p log_history specifies - * whether the history (i.e. the - * value to be checked and the - * number of the iteration step) - * shall be printed to - * @p deallog stream. Default - * is: do not print. Similarly, - * @p log_result specifies the - * whether the final result is - * logged to @p deallog. Default - * is yes. + * @p log_history specifies whether the history (i.e. the value to be + * checked and the number of the iteration step) shall be printed to @p + * deallog stream. Default is: do not print. Similarly, @p log_result + * specifies the whether the final result is logged to @p deallog. + * Default is yes. */ SolverControl (const unsigned int n = 100, const double tol = 1.e-10, @@ -156,9 +139,8 @@ public: const bool log_result = true); /** - * Virtual destructor is needed - * as there are virtual functions - * in this class. + * Virtual destructor is needed as there are virtual functions in this + * class. */ virtual ~SolverControl(); @@ -173,48 +155,26 @@ public: void parse_parameters (ParameterHandler ¶m); /** - * Decide about success or failure - * of an iteration. This function - * gets the current iteration step - * to determine, whether the - * allowed number of steps has - * been exceeded and returns - * @p failure in this case. If - * @p check_value is below the - * prescribed tolerance, it - * returns @p success. In all - * other cases @p iterate is - * returned to suggest - * continuation of the iterative - * procedure. + * Decide about success or failure of an iteration. This function gets + * the current iteration step to determine, whether the allowed number of + * steps has been exceeded and returns @p failure in this case. If @p + * check_value is below the prescribed tolerance, it returns @p success. + * In all other cases @p iterate is returned to suggest continuation of + * the iterative procedure. * - * The iteration is also aborted - * if the residual becomes a - * denormalized value - * (@p NaN). Note, however, that - * this check is only performed - * if the @p isnan function is - * provided by the operating - * system, which is not always - * true. The @p configure - * scripts checks for this and - * sets the flag @p HAVE_ISNAN - * in the file - * Make.global_options if - * this function was found. + * The iteration is also aborted if the residual becomes a denormalized + * value (@p NaN). Note, however, that this check is only performed if + * the @p isnan function is provided by the operating system, which is + * not always true. The @p configure scripts checks for this and sets the + * flag @p HAVE_ISNAN in the file Make.global_options if this + * function was found. * - * check() additionally - * preserves @p step and - * @p check_value. These - * values are accessible by - * last_value() and + * check() additionally preserves @p step and @p check_value. + * These values are accessible by last_value() and * last_step(). * - * Derived classes may overload - * this function, e.g. to log the - * convergence indicators - * (@p check_value) or to do - * other computations. + * Derived classes may overload this function, e.g. to log the + * convergence indicators (@p check_value) or to do other computations. */ virtual State check (const unsigned int step, const double check_value); @@ -225,15 +185,13 @@ public: State last_check() const; /** - * Return the initial convergence - * criterion. + * Return the initial convergence criterion. */ double initial_value() const; /** - * Return the convergence value of last - * iteration step for which @p check was - * called by the solver. + * Return the convergence value of last iteration step for which @p check + * was called by the solver. */ double last_value() const; @@ -253,20 +211,15 @@ public: unsigned int set_max_steps (const unsigned int); /** - * Enables the failure - * check. Solving is stopped with - * @p ReturnState @p failure if - * residual>failure_residual with + * Enables the failure check. Solving is stopped with @p ReturnState @p + * failure if residual>failure_residual with * failure_residual:=rel_failure_residual*first_residual. */ void set_failure_criterion (const double rel_failure_residual); /** - * Disables failure check and - * resets - * @p relative_failure_residual - * and @p failure_residual to - * zero. + * Disables failure check and resets @p relative_failure_residual and @p + * failure_residual to zero. */ void clear_failure_criterion (); @@ -281,45 +234,34 @@ public: double set_tolerance (const double); /** - * Enables writing residuals of - * each step into a vector for - * later analysis. + * Enables writing residuals of each step into a vector for later + * analysis. */ void enable_history_data(); /** - * Average error reduction over - * all steps. + * Average error reduction over all steps. * - * Requires - * enable_history_data() + * Requires enable_history_data() */ double average_reduction() const; /** - * Error reduction of the last - * step; for stationary - * iterations, this approximates - * the norm of the iteration - * matrix. + * Error reduction of the last step; for stationary iterations, this + * approximates the norm of the iteration matrix. * - * Requires - * enable_history_data() + * Requires enable_history_data() */ double final_reduction() const; /** - * Error reduction of any - * iteration step. + * Error reduction of any iteration step. * - * Requires - * enable_history_data() + * Requires enable_history_data() */ double step_reduction(unsigned int step) const; /** - * Log each iteration step. Use - * @p log_frequency for skipping - * steps. + * Log each iteration step. Use @p log_frequency for skipping steps. */ void log_history (const bool); @@ -344,13 +286,9 @@ public: bool log_result () const; /** - * This exception is thrown if a - * function operating on the - * vector of history data of a - * SolverControl object id - * called, but storage of history - * data was not enabled by - * enable_history_data(). + * This exception is thrown if a function operating on the vector of + * history data of a SolverControl object id called, but storage of + * history data was not enabled by enable_history_data(). */ DeclException0(ExcHistoryDataRequired); @@ -386,33 +324,26 @@ protected: unsigned int lstep; /** - * Is set to @p true by - * @p set_failure_criterion and - * enables failure checking. + * Is set to @p true by @p set_failure_criterion and enables failure + * checking. */ bool check_failure; /** - * Stores the - * @p rel_failure_residual set by - * @p set_failure_criterion + * Stores the @p rel_failure_residual set by @p set_failure_criterion */ double relative_failure_residual; /** - * @p failure_residual equals the - * first residual multiplied by - * @p relative_crit set by - * @p set_failure_criterion (see there). + * @p failure_residual equals the first residual multiplied by @p + * relative_crit set by @p set_failure_criterion (see there). * - * Until the first residual is - * known it is 0. + * Until the first residual is known it is 0. */ double failure_residual; /** - * Log convergence history to - * @p deallog. + * Log convergence history to @p deallog. */ bool m_log_history; @@ -422,29 +353,23 @@ protected: unsigned int m_log_frequency; /** - * Log iteration result to - * @p deallog. If true, after - * finishing the iteration, a - * statement about failure or - * success together with @p lstep + * Log iteration result to @p deallog. If true, after finishing the + * iteration, a statement about failure or success together with @p lstep * and @p lvalue are logged. */ bool m_log_result; /** - * Control over the storage of - * history data. Set by + * Control over the storage of history data. Set by * enable_history_data(). */ bool history_data_enabled; /** - * Vector storing the result - * after each iteration step for - * later statistical analysis. + * Vector storing the result after each iteration step for later + * statistical analysis. * - * Use of this vector is enabled - * by enable_history_data(). + * Use of this vector is enabled by enable_history_data(). */ std::vector history_data; }; @@ -468,11 +393,8 @@ class ReductionControl : public SolverControl { public: /** - * Constructor. Provide the - * reduction factor in addition - * to arguments that have the - * same meaning as those of the - * constructor of the + * Constructor. Provide the reduction factor in addition to arguments + * that have the same meaning as those of the constructor of the * SolverControl constructor. */ ReductionControl (const unsigned int maxiter = 100, @@ -482,27 +404,20 @@ public: const bool log_result = true); /** - * Initialize with a - * SolverControl object. The - * result will emulate - * SolverControl by setting - * #reduce to zero. + * Initialize with a SolverControl object. The result will emulate + * SolverControl by setting #reduce to zero. */ ReductionControl (const SolverControl &c); /** - * Assign a SolverControl object - * to ReductionControl. The - * result of the assignment will - * emulate SolverControl by - * setting #reduce to zero. + * Assign a SolverControl object to ReductionControl. The result of the + * assignment will emulate SolverControl by setting #reduce to zero. */ ReductionControl &operator= (const SolverControl &c); /** - * Virtual destructor is needed - * as there are virtual functions - * in this class. + * Virtual destructor is needed as there are virtual functions in this + * class. */ virtual ~ReductionControl(); @@ -517,12 +432,9 @@ public: void parse_parameters (ParameterHandler ¶m); /** - * Decide about success or failure - * of an iteration. This function - * calls the one in the base - * class, but sets the tolerance - * to reduction * initial value - * upon the first iteration. + * Decide about success or failure of an iteration. This function calls + * the one in the base class, but sets the tolerance to reduction * + * initial value upon the first iteration. */ virtual State check (const unsigned int step, const double check_value); @@ -544,10 +456,8 @@ protected: double reduce; /** - * Reduced tolerance. Stop iterations - * if either this value is achieved - * or if the base class indicates - * success. + * Reduced tolerance. Stop iterations if either this value is achieved or + * if the base class indicates success. */ double reduced_tol; }; diff --git a/deal.II/include/deal.II/lac/solver_gmres.h b/deal.II/include/deal.II/lac/solver_gmres.h index 902b00493b..448244f6eb 100644 --- a/deal.II/include/deal.II/lac/solver_gmres.h +++ b/deal.II/include/deal.II/lac/solver_gmres.h @@ -824,8 +824,8 @@ SolverGMRES::solve (const MATRIX &A, deallog.pop(); // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } @@ -959,8 +959,8 @@ SolverFGMRES::solve ( deallog.pop(); // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); } #endif // DOXYGEN diff --git a/deal.II/include/deal.II/lac/solver_minres.h b/deal.II/include/deal.II/lac/solver_minres.h index 37934f4f04..5242f99d35 100644 --- a/deal.II/include/deal.II/lac/solver_minres.h +++ b/deal.II/include/deal.II/lac/solver_minres.h @@ -380,11 +380,10 @@ SolverMinRes::solve (const MATRIX &A, // Output deallog.pop (); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_qmrs.h b/deal.II/include/deal.II/lac/solver_qmrs.h index 1cce088b84..cf807c4c6c 100644 --- a/deal.II/include/deal.II/lac/solver_qmrs.h +++ b/deal.II/include/deal.II/lac/solver_qmrs.h @@ -301,11 +301,10 @@ SolverQMRS::solve (const MATRIX &A, // Output deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_relaxation.h b/deal.II/include/deal.II/lac/solver_relaxation.h index 6a78113b5e..62598b9dbe 100644 --- a/deal.II/include/deal.II/lac/solver_relaxation.h +++ b/deal.II/include/deal.II/lac/solver_relaxation.h @@ -150,11 +150,10 @@ SolverRelaxation::solve ( } deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (control.last_step(), + control.last_value())); // otherwise exit as normal } diff --git a/deal.II/include/deal.II/lac/solver_richardson.h b/deal.II/include/deal.II/lac/solver_richardson.h index fd881aeb6d..804a3a1162 100644 --- a/deal.II/include/deal.II/lac/solver_richardson.h +++ b/deal.II/include/deal.II/lac/solver_richardson.h @@ -285,11 +285,10 @@ SolverRichardson::solve (const MATRIX &A, this->memory.free(Vd); deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } @@ -345,11 +344,10 @@ SolverRichardson::Tsolve (const MATRIX &A, this->memory.free(Vr); this->memory.free(Vd); deallog.pop(); - // in case of failure: throw - // exception + // in case of failure: throw exception if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), + this->control().last_value())); // otherwise exit as normal } diff --git a/deal.II/source/lac/petsc_solver.cc b/deal.II/source/lac/petsc_solver.cc index 9da2aeef47..57c3bdb7c0 100644 --- a/deal.II/source/lac/petsc_solver.cc +++ b/deal.II/source/lac/petsc_solver.cc @@ -135,8 +135,8 @@ namespace PETScWrappers // in case of failure: throw // exception if (solver_control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step(), - solver_control.last_value()); + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); // otherwise exit as normal } @@ -822,8 +822,10 @@ namespace PETScWrappers * throw exception */ if (solver_control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step(), - solver_control.last_value()); + { + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); + } else { /** diff --git a/deal.II/source/lac/slepc_solver.cc b/deal.II/source/lac/slepc_solver.cc index 6ea1e27454..9f9ad41595 100644 --- a/deal.II/source/lac/slepc_solver.cc +++ b/deal.II/source/lac/slepc_solver.cc @@ -225,8 +225,8 @@ namespace SLEPcWrappers // and in case of failure: throw exception if (solver_control.last_check () != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step (), - solver_control.last_value ()); + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); } } diff --git a/deal.II/source/lac/solver_control.cc b/deal.II/source/lac/solver_control.cc index a6f1c61cb5..8f40d154a4 100644 --- a/deal.II/source/lac/solver_control.cc +++ b/deal.II/source/lac/solver_control.cc @@ -26,41 +26,6 @@ DEAL_II_NAMESPACE_OPEN /*----------------------- SolverControl ---------------------------------*/ -SolverControl::NoConvergence::NoConvergence (const unsigned int last_step, - const double last_residual) - : - last_step (last_step), - last_residual (last_residual) -{} - - -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 lifetime 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::ostringstream out; - out << "Iterative method reported convergence failure in step " - << last_step << " with residual " << last_residual; - - description = out.str(); - return description.c_str(); -} - - - SolverControl::SolverControl (const unsigned int maxiter, const double tolerance, const bool m_log_history, diff --git a/deal.II/source/lac/trilinos_solver.cc b/deal.II/source/lac/trilinos_solver.cc index 25edefb025..6eb7ae8567 100644 --- a/deal.II/source/lac/trilinos_solver.cc +++ b/deal.II/source/lac/trilinos_solver.cc @@ -264,8 +264,8 @@ namespace TrilinosWrappers solver_control.check (solver.NumIters(), solver.TrueResidual()); if (solver_control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step(), - solver_control.last_value()); + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); } @@ -458,8 +458,8 @@ namespace TrilinosWrappers solver_control.check (0, 0); if (solver_control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step(), - solver_control.last_value()); + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); } @@ -523,8 +523,8 @@ namespace TrilinosWrappers solver_control.check (0, 0); if (solver_control.last_check() != SolverControl::success) - throw SolverControl::NoConvergence (solver_control.last_step(), - solver_control.last_value()); + AssertThrow(false, SolverControl::NoConvergence (solver_control.last_step(), + solver_control.last_value())); } diff --git a/tests/lac/solver.cc b/tests/lac/solver.cc index 45e7d094d5..0bf7a98f4f 100644 --- a/tests/lac/solver.cc +++ b/tests/lac/solver.cc @@ -45,9 +45,9 @@ check_solve( SOLVER &solver, const MATRIX &A, { solver.solve(A,u,f,P); } - catch (std::exception &e) + catch (dealii::SolverControl::NoConvergence &e) { - deallog << e.what() << std::endl; + deallog << "Exception: " << e.get_exc_name() << std::endl; } } @@ -62,9 +62,9 @@ check_Tsolve(SOLVER &solver, const MATRIX &A, { solver.Tsolve(A,u,f,P); } - catch (std::exception &e) + catch (dealii::SolverControl::NoConvergence &e) { - deallog << e.what() << std::endl; + deallog << "Exception: " << e.get_exc_name() << std::endl; } } diff --git a/tests/lac/solver.output b/tests/lac/solver.output index 73f5d12b89..c5eda03ebd 100644 --- a/tests/lac/solver.output +++ b/tests/lac/solver.output @@ -55,7 +55,7 @@ DEAL:sor:Richardson::Starting value 3.000 DEAL:sor:Richardson::Convergence step 7 value 0.0004339 DEAL:sor:cg::Starting value 3.000 DEAL:sor:cg::Failure step 100 value 0.2585 -DEAL:sor::Iterative method reported convergence failure in step 100 with residual 0.258509 +DEAL:sor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:sor:Bicgstab::Starting value 3.000 DEAL:sor:Bicgstab::Convergence step 5 value 0 DEAL:sor:GMRES::Starting value 1.462 @@ -70,7 +70,7 @@ DEAL:psor:Richardson::Starting value 3.000 DEAL:psor:Richardson::Convergence step 8 value 0.0004237 DEAL:psor:cg::Starting value 3.000 DEAL:psor:cg::Failure step 100 value 0.1024 -DEAL:psor::Iterative method reported convergence failure in step 100 with residual 0.102391 +DEAL:psor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:psor:Bicgstab::Starting value 3.000 DEAL:psor:Bicgstab::Convergence step 4 value 0.0007969 DEAL:psor:GMRES::Starting value 1.467 @@ -81,23 +81,23 @@ DEAL::Size 12 Unknowns 121 DEAL::SOR-diff:0 DEAL:no-fail:cg::Starting value 11.00 DEAL:no-fail:cg::Failure step 10 value 0.1496 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.149566 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no-fail:Bicgstab::Starting value 11.00 DEAL:no-fail:Bicgstab::Failure step 10 value 0.002830 DEAL:no-fail:Bicgstab::Failure step 10 value 0.001961 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.00196051 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no-fail:GMRES::Starting value 11.00 DEAL:no-fail:GMRES::Failure step 10 value 0.8414 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.841354 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no-fail:GMRES::Starting value 11.00 DEAL:no-fail:GMRES::Failure step 10 value 0.8414 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.841354 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no-fail:QMRS::Starting value 11.00 DEAL:no-fail:QMRS::Failure step 10 value 0.4215 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.421504 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no:Richardson::Starting value 11.00 DEAL:no:Richardson::Failure step 100 value 0.3002 -DEAL:no::Iterative method reported convergence failure in step 100 with residual 0.300171 +DEAL:no::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no:cg::Starting value 11.00 DEAL:no:cg::Convergence step 15 value 0.0005794 DEAL:no:Bicgstab::Starting value 11.00 @@ -110,7 +110,7 @@ DEAL:no:QMRS::Starting value 11.00 DEAL:no:QMRS::Convergence step 16 value 0.0002583 DEAL:rich:Richardson::Starting value 11.00 DEAL:rich:Richardson::Failure step 100 value 1.219 -DEAL:rich::Iterative method reported convergence failure in step 100 with residual 1.2187 +DEAL:rich::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:rich:cg::Starting value 11.00 DEAL:rich:cg::Convergence step 15 value 0.0005794 DEAL:rich:Bicgstab::Starting value 11.00 @@ -141,7 +141,7 @@ DEAL:sor:Richardson::Starting value 11.00 DEAL:sor:Richardson::Convergence step 88 value 0.0009636 DEAL:sor:cg::Starting value 11.00 DEAL:sor:cg::Failure step 100 value 5.643 -DEAL:sor::Iterative method reported convergence failure in step 100 with residual 5.64329 +DEAL:sor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:sor:Bicgstab::Starting value 11.00 DEAL:sor:Bicgstab::Convergence step 14 value 0.0009987 DEAL:sor:GMRES::Starting value 7.322 @@ -154,7 +154,7 @@ DEAL:psor:Richardson::Starting value 11.00 DEAL:psor:Richardson::Convergence step 89 value 0.0009736 DEAL:psor:cg::Starting value 11.00 DEAL:psor:cg::Failure step 100 value 2.935 -DEAL:psor::Iterative method reported convergence failure in step 100 with residual 2.93488 +DEAL:psor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:psor:Bicgstab::Starting value 11.00 DEAL:psor:Bicgstab::Convergence step 11 value 0.0005151 DEAL:psor:GMRES::Starting value 7.345 diff --git a/tests/lapack/solver_cg.cc b/tests/lapack/solver_cg.cc index 3984e60207..246b801608 100644 --- a/tests/lapack/solver_cg.cc +++ b/tests/lapack/solver_cg.cc @@ -43,9 +43,9 @@ check_solve( SOLVER &solver, const MATRIX &A, { solver.solve(A,u,f,P); } - catch (std::exception &e) + catch (dealii::SolverControl::NoConvergence &e) { - deallog << e.what() << std::endl; + deallog << "Exception: " << e.get_exc_name() << std::endl; } } @@ -60,9 +60,9 @@ check_Tsolve(SOLVER &solver, const MATRIX &A, { solver.Tsolve(A,u,f,P); } - catch (std::exception &e) + catch (dealii::SolverControl::NoConvergence &e) { - deallog << e.what() << std::endl; + deallog << "Exception: " << e.get_exc_name() << std::endl; } } diff --git a/tests/lapack/solver_cg.output b/tests/lapack/solver_cg.output index 29c8953361..a407848c23 100644 --- a/tests/lapack/solver_cg.output +++ b/tests/lapack/solver_cg.output @@ -29,7 +29,7 @@ DEAL:no-fail:cg::Condition number estimate: 53.54 DEAL:no-fail:cg::Condition number estimate: 54.75 DEAL:no-fail:cg::Failure step 10 value 0.1496 DEAL:no-fail:cg:: 0.1363 0.6565 1.499 2.357 3.131 3.994 5.392 6.576 7.464 -DEAL:no-fail::Iterative method reported convergence failure in step 10 with residual 0.149566 +DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) DEAL:no:cg::Starting value 11.00 DEAL:no:cg::Condition number estimate: 11.01 DEAL:no:cg::Condition number estimate: 21.10 diff --git a/tests/petsc/solver_01.cc b/tests/petsc/solver_01.cc index 54c486a82f..5c68a79f41 100644 --- a/tests/petsc/solver_01.cc +++ b/tests/petsc/solver_01.cc @@ -45,12 +45,9 @@ check_solve( SOLVER &solver, const MATRIX &A, { solver.solve(A,u,f,P); } - catch (std::exception &e) + catch (dealii::SolverControl::NoConvergence &e) { - deallog << e.what() << std::endl; - // it needs to be expected for the - // richardson solver that we end up - // here, so don't abort + deallog << "Exception: " << e.get_exc_name() << std::endl; } deallog << "Solver stopped after " << solver.control().last_step() diff --git a/tests/petsc/solver_01.output b/tests/petsc/solver_01.output index 208bfd4911..dbab15846c 100644 --- a/tests/petsc/solver_01.output +++ b/tests/petsc/solver_01.output @@ -3,5 +3,5 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE DEAL::Starting value 7.750 DEAL::Failure step 100 value 4.004 -DEAL::Iterative method reported convergence failure in step 100 with residual 4.00437 +DEAL::Exception: SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) DEAL::Solver stopped after 100 iterations diff --git a/tests/petsc/solver_02.cc b/tests/petsc/solver_02.cc index 0a49a88c5c..baf08b9793 100644 --- a/tests/petsc/solver_02.cc +++ b/tests/petsc/solver_02.cc @@ -47,9 +47,7 @@ check_solve( SOLVER &solver, const MATRIX &A, } catch (dealii::SolverControl::NoConvergence &e) { - // just like for Richardson: expect to - // get here, don't abort the program - deallog << "Catched exception dealii::SolverControl::NoConvergence" << std::endl; + deallog << "Exception: " << e.get_exc_name() << std::endl; } deallog << "Solver stopped after " << solver.control().last_step() diff --git a/tests/petsc/solver_02.output b/tests/petsc/solver_02.output index 451d0391cc..00c1e2226c 100644 --- a/tests/petsc/solver_02.output +++ b/tests/petsc/solver_02.output @@ -3,5 +3,5 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE DEAL::Starting value 7.551 DEAL::Failure step 100 value 2.937 -DEAL::Catched exception dealii::SolverControl::NoConvergence +DEAL::Exception: SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) DEAL::Solver stopped after 100 iterations