]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test umfpack/umfpack_04: Avoid printing exact number of iterations
authorMatthias Maier <tamiko@kyomu.43-1.org>
Fri, 19 Dec 2014 11:33:45 +0000 (12:33 +0100)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Fri, 19 Dec 2014 11:55:35 +0000 (12:55 +0100)
This commit introduces a new macro for tests to test an iterative solve to
convergence within a given number of iteration steps. Due to roundoff
errors the exact number doesn't have to be stable...

tests/tests.h
tests/umfpack/umfpack_04.cc
tests/umfpack/umfpack_04.compiler=Intel=yes.release.output [deleted file]
tests/umfpack/umfpack_04.debug.output [deleted file]
tests/umfpack/umfpack_04.output [moved from tests/umfpack/umfpack_04.compiler=Intel=no.release.output with 63% similarity]

index 10cc76eb77761c85e6cec9d45864cf63d2340852..fe7ecbd81df7c588b145bbca41cd712a75992b83 100644 (file)
@@ -144,6 +144,34 @@ void unify_pretty_function (const std::string &filename)
 }
 
 
+/*
+ * Test that a solver converged within a certain range of iteration steps.
+ *
+ * SOLVER_COMMAND is the command to issue, CONTROL_COMMAND a function call
+ * that returns the number of iterations (castable to unsigned int), and
+ * MIN_ALLOWED, MAX_ALLOWED is the inclusive range of allowed iteration
+ * steps.
+ */
+
+#define check_solver_within_range(SOLVER_COMMAND, CONTROL_COMMAND, MIN_ALLOWED, MAX_ALLOWED) \
+{                                                                              \
+  const unsigned int previous_depth = deallog.depth_file(0);                   \
+  SOLVER_COMMAND;                                                              \
+  deallog.depth_file(previous_depth);                                          \
+  const unsigned int steps = CONTROL_COMMAND;                                  \
+  if (steps >= MIN_ALLOWED && steps <= MAX_ALLOWED)                            \
+    {                                                                          \
+      deallog << "Solver stopped within " << MIN_ALLOWED << " - "              \
+              << MAX_ALLOWED << " iterations" << std::endl;                    \
+    }                                                                          \
+  else                                                                         \
+    {                                                                          \
+      deallog << "Solver stopped after " << steps << " iterations"             \
+              << std::endl;                                                    \
+    }                                                                          \
+}
+
+
 // ------------------------------ Functions used in initializing subsystems -------------------
 
 
index 177d94a40f5e29bdcd65924a294e237a406f9945..d20df2b930c8933b2fbb2f3453a1c222855d4397 100644 (file)
@@ -174,12 +174,51 @@ void test ()
   ubb = bb;
 
   SolverControl control (1000, 1e-13);
-
   SolverCG<BlockVector<double> > bcg(control, SolverCG<BlockVector<double> >::AdditionalData());
-  bcg.solve(Bb, bx, bb, PreconditionIdentity());
+
+  switch (dim)
+    {
+    case 1:
+      check_solver_within_range(
+        bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+        control.last_step(), 112, 114);
+      break;
+    case 2:
+      check_solver_within_range(
+        bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+        control.last_step(), 60, 62);
+      break;
+    case 3:
+      check_solver_within_range(
+        bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+        control.last_step(), 24, 26);
+      break;
+    default:
+      Assert(false, ExcNotImplemented());
+    }
 
   SolverCG<Vector<double> > cg(control, SolverCG<Vector<double> >::AdditionalData());
-  cg.solve(B, x, b, PreconditionIdentity());
+
+  switch (dim)
+    {
+    case 1:
+      check_solver_within_range(
+        cg.solve(B, x, b, PreconditionIdentity()),
+        control.last_step(), 112, 114);
+      break;
+    case 2:
+      check_solver_within_range(
+        cg.solve(B, x, b, PreconditionIdentity()),
+        control.last_step(), 60, 62);
+      break;
+    case 3:
+      check_solver_within_range(
+        cg.solve(B, x, b, PreconditionIdentity()),
+        control.last_step(), 24, 26);
+      break;
+    default:
+      Assert(false, ExcNotImplemented());
+    }
 
   deallog << "Sparse Factorization" << std::endl;
   SparseDirectUMFPACK umfpack, umfpackb;
diff --git a/tests/umfpack/umfpack_04.compiler=Intel=yes.release.output b/tests/umfpack/umfpack_04.compiler=Intel=yes.release.output
deleted file mode 100644 (file)
index 221e282..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-
-DEAL::1d
-DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 112 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 112 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::2d
-DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::3d
-DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
diff --git a/tests/umfpack/umfpack_04.debug.output b/tests/umfpack/umfpack_04.debug.output
deleted file mode 100644 (file)
index 8a04a69..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-
-DEAL::1d
-DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::2d
-DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::3d
-DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
similarity index 63%
rename from tests/umfpack/umfpack_04.compiler=Intel=no.release.output
rename to tests/umfpack/umfpack_04.output
index 8a04a69361b8a72327912bf776e444ad25b979b0..de6c549d1952f2454a8af61fe44dc0ea520b64e9 100644 (file)
@@ -1,10 +1,8 @@
 
 DEAL::1d
 DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
+DEAL::Solver stopped within 112 - 114 iterations
+DEAL::Solver stopped within 112 - 114 iterations
 DEAL::Sparse Factorization
 DEAL::absolute norms = 6.45748 6.45748
 DEAL::relative norm distance = 0
@@ -13,10 +11,8 @@ DEAL::absolute norms = 6.45748 6.45748
 DEAL::relative norm distance = 0
 DEAL::2d
 DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
+DEAL::Solver stopped within 60 - 62 iterations
+DEAL::Solver stopped within 60 - 62 iterations
 DEAL::Sparse Factorization
 DEAL::absolute norms = 10.0596 10.0596
 DEAL::relative norm distance = 0
@@ -25,10 +21,8 @@ DEAL::absolute norms = 10.0596 10.0596
 DEAL::relative norm distance = 0
 DEAL::3d
 DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
+DEAL::Solver stopped within 24 - 26 iterations
+DEAL::Solver stopped within 24 - 26 iterations
 DEAL::Sparse Factorization
 DEAL::absolute norms = 13.7931 13.7931
 DEAL::relative norm distance = 0

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.