]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Check a convergence rate, not errors, in a test. 5599/head
authorDavid Wells <wellsd2@rpi.edu>
Fri, 8 Dec 2017 00:48:55 +0000 (19:48 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Fri, 8 Dec 2017 00:48:55 +0000 (19:48 -0500)
tests/grid/project_to_object_01.cc
tests/grid/project_to_object_01.output
tests/grid/project_to_object_01.output.with_fma

index 08c1515647e6b00ec76cb0321f6657ad5ce4bb1a..2dfca0427fc7b6b644fe5ad0bbb9d46591f1c50b 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <array>
 #include <cmath>
+#include <numeric>
 
 #include "../tests.h"
 
@@ -64,14 +65,33 @@ int main()
         deallog << "testing cross derivative "
                 << cross_derivative_n
                 << std::endl;
+        std::vector<double> steps;
+        std::vector<double> errors;
         for (unsigned int step_n = 5; step_n < 10; ++step_n)
           {
-            deallog << cross_stencil<structdim>(cross_derivatives[cross_derivative_n],
+            const double current_step = std::pow(0.5, double(step_n));
+            steps.push_back(std::log(current_step));
+            errors.push_back(std::log(std::abs(cross_stencil<structdim>
+                                               (cross_derivatives[cross_derivative_n],
                                                 c0,
-                                                std::pow(0.5, double(step_n)),
-                                                objective) - exact[cross_derivative_n]
-                    << std::endl;
+                                                current_step,
+                                                objective)
+                                               - exact[cross_derivative_n])));
           }
+
+        const double mean_step = std::accumulate(steps.begin(), steps.end(), 0.0)/steps.size();
+        const double mean_error = std::accumulate(errors.begin(), errors.end(), 0.0)/errors.size();
+
+        double numerator = 0.0;
+        double denominator = 0.0;
+        for (std::size_t i = 0; i < steps.size(); ++i)
+          {
+            numerator += (steps[i] - mean_step)*(errors[i] - mean_error);
+            denominator += Utilities::fixed_power<2>(steps[i] - mean_step);
+          }
+        deallog << "slope is nearly 3: "
+                << (std::abs(numerator/denominator - 3.0) < 0.05)
+                << std::endl;
       }
   }
 
index 142e6cc04f57c8b419de265f97ba9e21c64f0851..ace096ef8348d83ca98bf6fe3678018261900306 100644 (file)
@@ -1,22 +1,10 @@
 
 DEAL::testing cross derivative 0
-DEAL::2.08262e-05
-DEAL::2.61032e-06
-DEAL::3.26714e-07
-DEAL::4.08654e-08
-DEAL::5.10984e-09
+DEAL::slope is nearly 3: 1
 DEAL::testing cross derivative 1
-DEAL::2.10357e-05
-DEAL::2.62342e-06
-DEAL::3.27533e-07
-DEAL::4.09167e-08
-DEAL::5.11266e-09
+DEAL::slope is nearly 3: 1
 DEAL::testing cross derivative 2
-DEAL::5.75514e-06
-DEAL::7.19207e-07
-DEAL::8.98876e-08
-DEAL::1.12350e-08
-DEAL::1.40439e-09
+DEAL::slope is nearly 3: 1
 DEAL::
 DEAL::Project the arithmetic mean of two vertices on a circular
 DEAL::arc. The result should be the geodesic midpoint:
index 3ba034bd4bdeb17bfba1861676d9685b56e60079..2ac36b85668cf198bd694130112adb3ae9a7db34 100644 (file)
@@ -1,22 +1,10 @@
 
 DEAL::testing cross derivative 0
-DEAL::2.08262e-05
-DEAL::2.61032e-06
-DEAL::3.26714e-07
-DEAL::4.08653e-08
-DEAL::5.10978e-09
+DEAL::slope is nearly 3: 1
 DEAL::testing cross derivative 1
-DEAL::2.10357e-05
-DEAL::2.62342e-06
-DEAL::3.27533e-07
-DEAL::4.09166e-08
-DEAL::5.11283e-09
+DEAL::slope is nearly 3: 1
 DEAL::testing cross derivative 2
-DEAL::5.75514e-06
-DEAL::7.19207e-07
-DEAL::8.98876e-08
-DEAL::1.12351e-08
-DEAL::1.40411e-09
+DEAL::slope is nearly 3: 1
 DEAL::
 DEAL::Project the arithmetic mean of two vertices on a circular
 DEAL::arc. The result should be the geodesic midpoint:

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.