From ca89ccfedf9665d921e8526dd582c68f598bbc2d Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 8 Aug 2017 08:10:51 +0200 Subject: [PATCH] Use check_solver_within_range in Trilinos tests --- tests/tests.h | 7 +++- tests/trilinos/deal_solver_01.cc | 33 +++------------- tests/trilinos/deal_solver_01.output | 4 +- tests/trilinos/deal_solver_02.cc | 32 +++------------ tests/trilinos/deal_solver_03.cc | 33 +++------------- tests/trilinos/deal_solver_03.output | 4 +- tests/trilinos/deal_solver_04.cc | 33 +++------------- tests/trilinos/deal_solver_04.output | 2 - tests/trilinos/deal_solver_05.cc | 32 ++------------- tests/trilinos/deal_solver_05.output | 4 +- tests/trilinos/deal_solver_06.cc | 31 ++------------- tests/trilinos/deal_solver_06.output | 4 +- tests/trilinos/solver_03.cc | 33 +++------------- tests/trilinos/solver_03.output | 3 +- tests/trilinos/solver_05.cc | 33 +++------------- tests/trilinos/solver_05.output | 3 +- tests/trilinos/solver_07.cc | 33 +++------------- tests/trilinos/solver_07.output | 3 +- tests/trilinos/solver_control_01.cc | 44 +++++---------------- tests/trilinos/solver_control_01.output | 6 +-- tests/trilinos/solver_control_02.cc | 52 ++++++++----------------- tests/trilinos/solver_control_02.output | 12 ++---- tests/trilinos/solver_control_03.cc | 44 +++++---------------- tests/trilinos/solver_control_03.output | 6 +-- 24 files changed, 99 insertions(+), 392 deletions(-) diff --git a/tests/tests.h b/tests/tests.h index 32189f1020..b5aa514595 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -239,7 +239,12 @@ std::string unify_pretty_function (const std::string &text) #define check_solver_within_range(SolverType_COMMAND, CONTROL_COMMAND, MIN_ALLOWED, MAX_ALLOWED) \ { \ const unsigned int previous_depth = deallog.depth_file(0); \ - SolverType_COMMAND; \ + try \ + { \ + SolverType_COMMAND; \ + } \ + catch (SolverControl::NoConvergence &exc) \ + {} \ deallog.depth_file(previous_depth); \ const unsigned int steps = CONTROL_COMMAND; \ if (steps >= MIN_ALLOWED && steps <= MAX_ALLOWED) \ diff --git a/tests/trilinos/deal_solver_01.cc b/tests/trilinos/deal_solver_01.cc index 984d355002..30fd13cb38 100644 --- a/tests/trilinos/deal_solver_01.cc +++ b/tests/trilinos/deal_solver_01.cc @@ -37,33 +37,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -103,6 +76,10 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverCG solver(control, mem); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 42, 44); } } diff --git a/tests/trilinos/deal_solver_01.output b/tests/trilinos/deal_solver_01.output index 7e616e1e2f..7963831f7a 100644 --- a/tests/trilinos/deal_solver_01.output +++ b/tests/trilinos/deal_solver_01.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii8SolverCGINS_16TrilinosWrappers3MPI6VectorEEE -DEAL:cg::Starting value 31.0000 -DEAL:cg::Convergence step 43 value 0.000818932 -DEAL::Solver stopped after 43 iterations +DEAL::Solver stopped within 42 - 44 iterations diff --git a/tests/trilinos/deal_solver_02.cc b/tests/trilinos/deal_solver_02.cc index 42adb4488d..5c1cacc58f 100644 --- a/tests/trilinos/deal_solver_02.cc +++ b/tests/trilinos/deal_solver_02.cc @@ -39,32 +39,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - check_solver_within_range( - solver.solve(A,u,f,P), - solver_control.last_step(), 49, 51); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } -} - int main(int argc, char **argv) { @@ -103,6 +77,10 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverBicgstab solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 49, 51); } } diff --git a/tests/trilinos/deal_solver_03.cc b/tests/trilinos/deal_solver_03.cc index 343486235a..46f94d3363 100644 --- a/tests/trilinos/deal_solver_03.cc +++ b/tests/trilinos/deal_solver_03.cc @@ -39,33 +39,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -105,6 +78,10 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverGMRES solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 74, 76); } } diff --git a/tests/trilinos/deal_solver_03.output b/tests/trilinos/deal_solver_03.output index 91ead34128..5b6f34323b 100644 --- a/tests/trilinos/deal_solver_03.output +++ b/tests/trilinos/deal_solver_03.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii11SolverGMRESINS_16TrilinosWrappers3MPI6VectorEEE -DEAL:GMRES::Starting value 31.0000 -DEAL:GMRES::Convergence step 75 value 0.000809583 -DEAL::Solver stopped after 75 iterations +DEAL::Solver stopped within 74 - 76 iterations diff --git a/tests/trilinos/deal_solver_04.cc b/tests/trilinos/deal_solver_04.cc index bab2dee0dc..66333e3134 100644 --- a/tests/trilinos/deal_solver_04.cc +++ b/tests/trilinos/deal_solver_04.cc @@ -38,33 +38,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -104,6 +77,10 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverMinRes solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 0, 42); } } diff --git a/tests/trilinos/deal_solver_04.output b/tests/trilinos/deal_solver_04.output index 8b6c8b7ce6..97f2c1dbaf 100644 --- a/tests/trilinos/deal_solver_04.output +++ b/tests/trilinos/deal_solver_04.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii12SolverMinResINS_16TrilinosWrappers3MPI6VectorEEE -DEAL:minres::Starting value 31.0000 -DEAL:minres::Convergence step 43 value 0.000691560 DEAL::Solver stopped after 43 iterations diff --git a/tests/trilinos/deal_solver_05.cc b/tests/trilinos/deal_solver_05.cc index 6a32655016..788477e391 100644 --- a/tests/trilinos/deal_solver_05.cc +++ b/tests/trilinos/deal_solver_05.cc @@ -37,33 +37,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -103,6 +76,9 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverQMRS solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 45, 47); } } diff --git a/tests/trilinos/deal_solver_05.output b/tests/trilinos/deal_solver_05.output index f79f420b32..833c5cadbc 100644 --- a/tests/trilinos/deal_solver_05.output +++ b/tests/trilinos/deal_solver_05.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii10SolverQMRSINS_16TrilinosWrappers3MPI6VectorEEE -DEAL:QMRS::Starting value 31.0000 -DEAL:QMRS::Convergence step 46 value 0.000906349 -DEAL::Solver stopped after 46 iterations +DEAL::Solver stopped within 45 - 47 iterations diff --git a/tests/trilinos/deal_solver_06.cc b/tests/trilinos/deal_solver_06.cc index 7a3a746568..02ee27eee7 100644 --- a/tests/trilinos/deal_solver_06.cc +++ b/tests/trilinos/deal_solver_06.cc @@ -37,32 +37,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -101,6 +75,9 @@ int main(int argc, char **argv) SolverRichardson::AdditionalData data (/*omega=*/0.1); SolverRichardson solver(control, mem, data); PreconditionIdentity preconditioner; - check_solve (solver, control, A,u,f, preconditioner); + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 5269, 5271); } } diff --git a/tests/trilinos/deal_solver_06.output b/tests/trilinos/deal_solver_06.output index ca294f124f..80b235bcec 100644 --- a/tests/trilinos/deal_solver_06.output +++ b/tests/trilinos/deal_solver_06.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii16SolverRichardsonINS_16TrilinosWrappers3MPI6VectorEEE -DEAL:Richardson::Starting value 31.00 -DEAL:Richardson::Convergence step 5271 value 0.0009996 -DEAL::Solver stopped after 5271 iterations +DEAL::Solver stopped within 5269 - 5271 iterations diff --git a/tests/trilinos/solver_03.cc b/tests/trilinos/solver_03.cc index 3346578f52..80e908fadd 100644 --- a/tests/trilinos/solver_03.cc +++ b/tests/trilinos/solver_03.cc @@ -32,33 +32,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -98,6 +71,10 @@ int main(int argc, char **argv) TrilinosWrappers::SolverCG solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 42, 44); } } diff --git a/tests/trilinos/solver_03.output b/tests/trilinos/solver_03.output index 73845884eb..59e2d7da59 100644 --- a/tests/trilinos/solver_03.output +++ b/tests/trilinos/solver_03.output @@ -1,5 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii16TrilinosWrappers8SolverCGE -DEAL::Convergence step 43 value 0.000818932 -DEAL::Solver stopped after 43 iterations +DEAL::Solver stopped within 42 - 44 iterations diff --git a/tests/trilinos/solver_05.cc b/tests/trilinos/solver_05.cc index b97da29d19..5299c1f179 100644 --- a/tests/trilinos/solver_05.cc +++ b/tests/trilinos/solver_05.cc @@ -32,33 +32,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -98,6 +71,10 @@ int main(int argc, char **argv) TrilinosWrappers::SolverGMRES solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 70, 72); } } diff --git a/tests/trilinos/solver_05.output b/tests/trilinos/solver_05.output index 6d09354e90..5dfcbb2577 100644 --- a/tests/trilinos/solver_05.output +++ b/tests/trilinos/solver_05.output @@ -1,5 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii16TrilinosWrappers11SolverGMRESE -DEAL::Convergence step 71 value 0.000916839 -DEAL::Solver stopped after 71 iterations +DEAL::Solver stopped within 70 - 72 iterations diff --git a/tests/trilinos/solver_07.cc b/tests/trilinos/solver_07.cc index 12c27e921f..6a49ffe6bc 100644 --- a/tests/trilinos/solver_07.cc +++ b/tests/trilinos/solver_07.cc @@ -32,33 +32,6 @@ #include #include -template -void -check_solve (SolverType &solver, - const SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P) -{ - deallog << "Solver type: " << typeid(solver).name() << std::endl; - - u = 0.; - f = 1.; - try - { - solver.solve(A,u,f,P); - } - catch (std::exception &e) - { - deallog << e.what() << std::endl; - abort (); - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; -} - int main(int argc, char **argv) { @@ -97,7 +70,11 @@ int main(int argc, char **argv) TrilinosWrappers::SolverCGS solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, control, A,u,f, preconditioner); + + deallog << "Solver type: " << typeid(solver).name() << std::endl; + + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 40, 42); } } diff --git a/tests/trilinos/solver_07.output b/tests/trilinos/solver_07.output index de22d3f1e7..5a2f484616 100644 --- a/tests/trilinos/solver_07.output +++ b/tests/trilinos/solver_07.output @@ -1,5 +1,4 @@ DEAL::Size 32 Unknowns 961 DEAL::Solver type: N6dealii16TrilinosWrappers9SolverCGSE -DEAL::Convergence step 41 value 0.000549330 -DEAL::Solver stopped after 41 iterations +DEAL::Solver stopped within 40 - 42 iterations diff --git a/tests/trilinos/solver_control_01.cc b/tests/trilinos/solver_control_01.cc index c7b337ff34..ba5f24bf62 100644 --- a/tests/trilinos/solver_control_01.cc +++ b/tests/trilinos/solver_control_01.cc @@ -33,36 +33,6 @@ #include #include -template -void -check_solve (SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P, - const bool expected_result) -{ - TrilinosWrappers::SolverCG solver(solver_control); - - u = 0.; - f = 1.; - bool success = false; - try - { - solver.solve(A,u,f,P); - deallog << "Success. "; - success = true; - } - catch (std::exception &e) - { - deallog << "Failure. "; - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; - Assert(success == expected_result, ExcMessage("Incorrect result.")); -} - int main(int argc, char **argv) { @@ -103,15 +73,21 @@ int main(int argc, char **argv) deallog.push("Abs tol"); { // Expects success - SolverControl solver_control(2000, 1.e-3); - check_solve (solver_control, A,u,f, preconditioner, true); + SolverControl control(2000, 1.e-3); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 42, 44); } deallog.pop(); + + u = 0.; deallog.push("Iterations"); { // Expects failure - SolverControl solver_control(20, 1.e-3); - check_solve (solver_control, A,u,f, preconditioner, false); + SolverControl control(20, 1.e-3); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 0, 19); } deallog.pop(); } diff --git a/tests/trilinos/solver_control_01.output b/tests/trilinos/solver_control_01.output index 6b2f4fd7ab..1611bacd19 100644 --- a/tests/trilinos/solver_control_01.output +++ b/tests/trilinos/solver_control_01.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 -DEAL:Abs tol::Convergence step 43 value 0.000818932 -DEAL:Abs tol::Success. Solver stopped after 43 iterations -DEAL:Iterations::Failure step 20 value 6.00198 -DEAL:Iterations::Failure. Solver stopped after 20 iterations +DEAL:Abs tol::Solver stopped within 42 - 44 iterations +DEAL:Iterations::Solver stopped after 20 iterations diff --git a/tests/trilinos/solver_control_02.cc b/tests/trilinos/solver_control_02.cc index 83ddd3144b..36de9e3d90 100644 --- a/tests/trilinos/solver_control_02.cc +++ b/tests/trilinos/solver_control_02.cc @@ -33,36 +33,6 @@ #include #include -template -void -check_solve (SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P, - const bool expected_result) -{ - TrilinosWrappers::SolverCG solver(solver_control); - - u = 0.; - f = 1.; - bool success = false; - try - { - solver.solve(A,u,f,P); - deallog << "Success. "; - success = true; - } - catch (std::exception &e) - { - deallog << "Failure. "; - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; - Assert(success == expected_result, ExcMessage("Incorrect result.")); -} - int main(int argc, char **argv) { @@ -103,22 +73,32 @@ int main(int argc, char **argv) deallog.push("Rel tol"); { // Expects success - ReductionControl solver_control(2000, 1.e-30, 1e-6); - check_solve (solver_control, A,u,f, preconditioner, true); + ReductionControl control(2000, 1.e-30, 1e-6); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 49, 51); } deallog.pop(); + + u = 0.; deallog.push("Abs tol"); { // Expects success - ReductionControl solver_control(2000, 1.e-3, 1e-9); - check_solve (solver_control, A,u,f, preconditioner, true); + ReductionControl control(2000, 1.e-3, 1e-9); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 42, 44); } deallog.pop(); + + u = 0.; deallog.push("Iterations"); { // Expects failure - ReductionControl solver_control(20, 1.e-30, 1e-6); - check_solve (solver_control, A,u,f, preconditioner, false); + ReductionControl control(20, 1.e-30, 1e-6); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 0, 19); } deallog.pop(); } diff --git a/tests/trilinos/solver_control_02.output b/tests/trilinos/solver_control_02.output index 8043d06426..6aa01e67ac 100644 --- a/tests/trilinos/solver_control_02.output +++ b/tests/trilinos/solver_control_02.output @@ -1,11 +1,5 @@ DEAL::Size 32 Unknowns 961 -DEAL:Rel tol::Starting value 31.0000 -DEAL:Rel tol::Convergence step 50 value 2.11364e-05 -DEAL:Rel tol::Success. Solver stopped after 50 iterations -DEAL:Abs tol::Starting value 31.0000 -DEAL:Abs tol::Convergence step 43 value 0.000818932 -DEAL:Abs tol::Success. Solver stopped after 43 iterations -DEAL:Iterations::Starting value 31.0000 -DEAL:Iterations::Failure step 20 value 6.00198 -DEAL:Iterations::Failure. Solver stopped after 20 iterations +DEAL:Rel tol::Solver stopped within 49 - 51 iterations +DEAL:Abs tol::Solver stopped within 42 - 44 iterations +DEAL:Iterations::Solver stopped after 20 iterations diff --git a/tests/trilinos/solver_control_03.cc b/tests/trilinos/solver_control_03.cc index 631aedc9ef..5739b1d848 100644 --- a/tests/trilinos/solver_control_03.cc +++ b/tests/trilinos/solver_control_03.cc @@ -33,36 +33,6 @@ #include #include -template -void -check_solve (SolverControl &solver_control, - const MatrixType &A, - VectorType &u, - VectorType &f, - const PRECONDITION &P, - const bool expected_result) -{ - TrilinosWrappers::SolverCG solver(solver_control); - - u = 0.; - f = 1.; - bool success = false; - try - { - solver.solve(A,u,f,P); - deallog << "Success. "; - success = true; - } - catch (std::exception &e) - { - deallog << "Failure. "; - } - - deallog << "Solver stopped after " << solver_control.last_step() - << " iterations" << std::endl; - Assert(success == expected_result, ExcMessage("Incorrect result.")); -} - int main(int argc, char **argv) { @@ -103,15 +73,21 @@ int main(int argc, char **argv) deallog.push("Abs tol"); { // Expects success - IterationNumberControl solver_control(2000, 1.e-3); - check_solve (solver_control, A,u,f, preconditioner, true); + IterationNumberControl control(2000, 1.e-3); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 42, 44); } deallog.pop(); + + u = 0.; deallog.push("Iterations"); { // Expects success - IterationNumberControl solver_control(20, 1.e-3); - check_solve (solver_control, A,u,f, preconditioner, true); + IterationNumberControl control(20, 1.e-3); + TrilinosWrappers::SolverCG solver(control); + check_solver_within_range(solver.solve(A,u,f,preconditioner), + control.last_step(), 19, 21); } deallog.pop(); } diff --git a/tests/trilinos/solver_control_03.output b/tests/trilinos/solver_control_03.output index 9ac7a92628..d99e3b2546 100644 --- a/tests/trilinos/solver_control_03.output +++ b/tests/trilinos/solver_control_03.output @@ -1,6 +1,4 @@ DEAL::Size 32 Unknowns 961 -DEAL:Abs tol::Convergence step 43 value 0.000818932 -DEAL:Abs tol::Success. Solver stopped after 43 iterations -DEAL:Iterations::Convergence step 20 value 6.00198 -DEAL:Iterations::Success. Solver stopped after 20 iterations +DEAL:Abs tol::Solver stopped within 42 - 44 iterations +DEAL:Iterations::Solver stopped within 19 - 21 iterations -- 2.39.5