]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use check_solver_within_range in Trilinos tests 4721/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 8 Aug 2017 06:10:51 +0000 (08:10 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 8 Aug 2017 06:18:59 +0000 (08:18 +0200)
24 files changed:
tests/tests.h
tests/trilinos/deal_solver_01.cc
tests/trilinos/deal_solver_01.output
tests/trilinos/deal_solver_02.cc
tests/trilinos/deal_solver_03.cc
tests/trilinos/deal_solver_03.output
tests/trilinos/deal_solver_04.cc
tests/trilinos/deal_solver_04.output
tests/trilinos/deal_solver_05.cc
tests/trilinos/deal_solver_05.output
tests/trilinos/deal_solver_06.cc
tests/trilinos/deal_solver_06.output
tests/trilinos/solver_03.cc
tests/trilinos/solver_03.output
tests/trilinos/solver_05.cc
tests/trilinos/solver_05.output
tests/trilinos/solver_07.cc
tests/trilinos/solver_07.output
tests/trilinos/solver_control_01.cc
tests/trilinos/solver_control_01.output
tests/trilinos/solver_control_02.cc
tests/trilinos/solver_control_02.output
tests/trilinos/solver_control_03.cc
tests/trilinos/solver_control_03.output

index 32189f1020ffa05f0abc48a923cfed549b740e69..b5aa51459565932261327bee018ace6b0fcd2a82 100644 (file)
@@ -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)                            \
index 984d355002708727124a84fc7a5123004ca6403e..30fd13cb38753310728679342045f2712c5f0496 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector> mem;
     SolverCG<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index 7e616e1e2f8c60a31618cf3ee85aa1da91186888..7963831f7aeacd655b7e6d3e2c49de98f2eddb26 100644 (file)
@@ -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
index 42adb4488dfe7b719cdc2c82f63d6befc07e3f12..5c1cacc58f332a85c8fef7f9324c638f96bd14b0 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector> mem;
     SolverBicgstab<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index 343486235a45e46af5c32f902801cf8baa68a5b8..46f94d336380f64c3294f3dec1bf78c6f4be22b1 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector> mem;
     SolverGMRES<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index 91ead34128d9576304ca36c1f2ae96f4aa273bef..5b6f34323b5067354d98a2ccde4355d5f9ce520d 100644 (file)
@@ -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
index bab2dee0dc6448240a9abc432ff04a90ccfc55bc..66333e3134f60be026950ad6dbbe2c200dd81720 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector> mem;
     SolverMinRes<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index 8b6c8b7ce699997d613b55a4e650a36b47c7b68d..97f2c1dbafec6b58748777611eb843e1627866c6 100644 (file)
@@ -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
index 6a32655016daf5f9b14289f200b35252e965065c..788477e391078649c00e4b6125bff1bbbe1a4d86 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector> mem;
     SolverQMRS<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index f79f420b327025cbb2a6ba27df15905e3e9f25c4..833c5cadbc3e0c33a932663fdcce2b8304cc349e 100644 (file)
@@ -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
index 7a3a7465686f4dd5f651152f5880f4f0db79b01f..02ee27eee7c0e754a874b29c0b7dbeddf7e145f1 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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<TrilinosWrappers::MPI::Vector>::AdditionalData data (/*omega=*/0.1);
     SolverRichardson<TrilinosWrappers::MPI::Vector> 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);
   }
 }
index ca294f124fe4003a3d512e77eb6f38e1371c030c..80b235bcec59f8a4afde8580fe157615bbb6a396 100644 (file)
@@ -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
index 3346578f522e760bf97c768bf915f17bffcd35af..80e908faddcabf076a23b96384a22c70e24a87bb 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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);
   }
 }
index 73845884ebd044466c196da773ab3fefbdf8a879..59e2d7da595bfb0f224c474fe79bf5b5c05e54a3 100644 (file)
@@ -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
index b97da29d194c0bf51211eaf891786484eb37ff69..5299c1f179582b6bc89cfaeb0417b4f0da43bf1d 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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);
   }
 }
index 6d09354e9043add53a64295397cd609f289df947..5dfcbb257799513010237638e607844dad6e64be 100644 (file)
@@ -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
index 12c27e921fe4af79ea5117502af9ed705d59c77e..6a49ffe6bcd924c585614f8141d0a237508fdc60 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-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);
   }
 
 }
index de22d3f1e77d498b9e048c2913989599f91f428d..5a2f484616781d09f6c7536dc4b6c99396cc9820 100644 (file)
@@ -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
index c7b337ff34fdb17e906567dd1aedc85381eb01e4..ba5f24bf62458e1171353bcf195a66bd8357f4e3 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-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();
   }
index 6b2f4fd7ab8b77f996a39cc31484c7d38b26e385..1611bacd1910f022f9537587ab7a3343d665532f 100644 (file)
@@ -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
index 83ddd3144b9b02ec14210d2186f030ac7230a5b8..36de9e3d90ce1b3b77436d0e1f84f25df375b6d4 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-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();
   }
index 8043d0642688e6c5c0c635c45856108a8ae966f6..6aa01e67acf8f8511e663dbfdccffb8111dd2c3c 100644 (file)
@@ -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
index 631aedc9efde2598157ed4db904ee58e86632409..5739b1d84869bc5078bc9e71e97a6d3a2a975a9d 100644 (file)
 #include <deal.II/lac/vector_memory.h>
 #include <typeinfo>
 
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-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();
   }
index 9ac7a926280dd83d83af876e073338343025ea10..d99e3b254681f650fc52a53f230a708e6713af77 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.