From a675331dca89a32baff5ca264edc093e00708641 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 12 Jul 2016 15:51:41 +0200 Subject: [PATCH] fix exception catch --- tests/petsc_complex/solver_real_01.cc | 8 ++------ tests/petsc_complex/solver_real_01.output | 17 +--------------- tests/petsc_complex/solver_real_01.output.2 | 22 --------------------- tests/petsc_complex/solver_real_02.cc | 7 ++----- tests/petsc_complex/solver_real_02.output | 17 +--------------- tests/petsc_complex/solver_real_02.output.2 | 22 --------------------- 6 files changed, 6 insertions(+), 87 deletions(-) delete mode 100644 tests/petsc_complex/solver_real_01.output.2 delete mode 100644 tests/petsc_complex/solver_real_02.output.2 diff --git a/tests/petsc_complex/solver_real_01.cc b/tests/petsc_complex/solver_real_01.cc index c5126c999e..383e017417 100644 --- a/tests/petsc_complex/solver_real_01.cc +++ b/tests/petsc_complex/solver_real_01.cc @@ -46,12 +46,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() @@ -93,4 +90,3 @@ int main(int argc, char **argv) check_solve (solver, A,u,f, preconditioner); } } - diff --git a/tests/petsc_complex/solver_real_01.output b/tests/petsc_complex/solver_real_01.output index 79c6bb0409..dbab15846c 100644 --- a/tests/petsc_complex/solver_real_01.output +++ b/tests/petsc_complex/solver_real_01.output @@ -3,20 +3,5 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE DEAL::Starting value 7.750 DEAL::Failure step 100 value 4.004 -DEAL:: --------------------------------------------------------- -An error occurred in file in function - void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase &, dealii::PETScWrappers::VectorBase &, const dealii::PETScWrappers::VectorBase &, const dealii::PETScWrappers::PreconditionerBase &) -The violated condition was: - false -The name and call sequence of the exception was: - SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) -Additional Information: -Iterative method reported convergence failure in step 100. The residual in the last step was 4.00437. - -This error message can indicate that you have simply not allowed a sufficiently large number of iterations for your iterative solver to converge. This often happens when you increase the size of your problem. In such cases, the last residual will likely still be very small, and you can make the error go away by increasing the allowed number of iterations when setting up the SolverControl object that determines the maximal number of iterations you allow. - -The other situation where this error may occur is when your matrix is not invertible (e.g., your matrix has a null-space), or if you try to apply the wrong solver to a matrix (e.g., using CG for a matrix that is not symmetric or not positive definite). In these cases, the residual in the last iteration is likely going to be large. --------------------------------------------------------- - +DEAL::Exception: SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) DEAL::Solver stopped after 100 iterations diff --git a/tests/petsc_complex/solver_real_01.output.2 b/tests/petsc_complex/solver_real_01.output.2 deleted file mode 100644 index c82284093a..0000000000 --- a/tests/petsc_complex/solver_real_01.output.2 +++ /dev/null @@ -1,22 +0,0 @@ - -DEAL::Size 32 Unknowns 961 -DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE -DEAL::Starting value 7.750 -DEAL::Failure step 100 value 4.004 -DEAL:: --------------------------------------------------------- -An error occurred in file in function - void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase&, dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::PreconditionerBase&) -The violated condition was: - false -The name and call sequence of the exception was: - SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) -Additional Information: -Iterative method reported convergence failure in step 100. The residual in the last step was 4.00437. - -This error message can indicate that you have simply not allowed a sufficiently large number of iterations for your iterative solver to converge. This often happens when you increase the size of your problem. In such cases, the last residual will likely still be very small, and you can make the error go away by increasing the allowed number of iterations when setting up the SolverControl object that determines the maximal number of iterations you allow. - -The other situation where this error may occur is when your matrix is not invertible (e.g., your matrix has a null-space), or if you try to apply the wrong solver to a matrix (e.g., using CG for a matrix that is not symmetric or not positive definite). In these cases, the residual in the last iteration is likely going to be large. --------------------------------------------------------- - -DEAL::Solver stopped after 100 iterations diff --git a/tests/petsc_complex/solver_real_02.cc b/tests/petsc_complex/solver_real_02.cc index 8d952c9285..8536e318f1 100644 --- a/tests/petsc_complex/solver_real_02.cc +++ b/tests/petsc_complex/solver_real_02.cc @@ -45,11 +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; - // just like for Richardson: we end up - // here normally for this solver + deallog << "Exception: " << e.get_exc_name() << std::endl; } deallog << "Solver stopped after " << solver.control().last_step() @@ -92,4 +90,3 @@ int main(int argc, char **argv) } } - diff --git a/tests/petsc_complex/solver_real_02.output b/tests/petsc_complex/solver_real_02.output index 0dc47c2a6c..00c1e2226c 100644 --- a/tests/petsc_complex/solver_real_02.output +++ b/tests/petsc_complex/solver_real_02.output @@ -3,20 +3,5 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE DEAL::Starting value 7.551 DEAL::Failure step 100 value 2.937 -DEAL:: --------------------------------------------------------- -An error occurred in file in function - void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase &, dealii::PETScWrappers::VectorBase &, const dealii::PETScWrappers::VectorBase &, const dealii::PETScWrappers::PreconditionerBase &) -The violated condition was: - false -The name and call sequence of the exception was: - SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) -Additional Information: -Iterative method reported convergence failure in step 100. The residual in the last step was 2.9372. - -This error message can indicate that you have simply not allowed a sufficiently large number of iterations for your iterative solver to converge. This often happens when you increase the size of your problem. In such cases, the last residual will likely still be very small, and you can make the error go away by increasing the allowed number of iterations when setting up the SolverControl object that determines the maximal number of iterations you allow. - -The other situation where this error may occur is when your matrix is not invertible (e.g., your matrix has a null-space), or if you try to apply the wrong solver to a matrix (e.g., using CG for a matrix that is not symmetric or not positive definite). In these cases, the residual in the last iteration is likely going to be large. --------------------------------------------------------- - +DEAL::Exception: SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) DEAL::Solver stopped after 100 iterations diff --git a/tests/petsc_complex/solver_real_02.output.2 b/tests/petsc_complex/solver_real_02.output.2 deleted file mode 100644 index 66cb6eab06..0000000000 --- a/tests/petsc_complex/solver_real_02.output.2 +++ /dev/null @@ -1,22 +0,0 @@ - -DEAL::Size 32 Unknowns 961 -DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE -DEAL::Starting value 7.551 -DEAL::Failure step 100 value 2.937 -DEAL:: --------------------------------------------------------- -An error occurred in file in function - void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase&, dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::PreconditionerBase&) -The violated condition was: - false -The name and call sequence of the exception was: - SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value()) -Additional Information: -Iterative method reported convergence failure in step 100. The residual in the last step was 2.9372. - -This error message can indicate that you have simply not allowed a sufficiently large number of iterations for your iterative solver to converge. This often happens when you increase the size of your problem. In such cases, the last residual will likely still be very small, and you can make the error go away by increasing the allowed number of iterations when setting up the SolverControl object that determines the maximal number of iterations you allow. - -The other situation where this error may occur is when your matrix is not invertible (e.g., your matrix has a null-space), or if you try to apply the wrong solver to a matrix (e.g., using CG for a matrix that is not symmetric or not positive definite). In these cases, the residual in the last iteration is likely going to be large. --------------------------------------------------------- - -DEAL::Solver stopped after 100 iterations -- 2.39.5