From 23c05d29c8b382301b9732b65531a15d14937b92 Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 7 Dec 2017 19:48:55 -0500 Subject: [PATCH] Check a convergence rate, not errors, in a test. --- tests/grid/project_to_object_01.cc | 28 ++++++++++++++++--- tests/grid/project_to_object_01.output | 18 ++---------- .../grid/project_to_object_01.output.with_fma | 18 ++---------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/tests/grid/project_to_object_01.cc b/tests/grid/project_to_object_01.cc index 08c1515647..2dfca0427f 100644 --- a/tests/grid/project_to_object_01.cc +++ b/tests/grid/project_to_object_01.cc @@ -25,6 +25,7 @@ #include #include +#include #include "../tests.h" @@ -64,14 +65,33 @@ int main() deallog << "testing cross derivative " << cross_derivative_n << std::endl; + std::vector steps; + std::vector errors; for (unsigned int step_n = 5; step_n < 10; ++step_n) { - deallog << cross_stencil(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 + (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; } } diff --git a/tests/grid/project_to_object_01.output b/tests/grid/project_to_object_01.output index 142e6cc04f..ace096ef83 100644 --- a/tests/grid/project_to_object_01.output +++ b/tests/grid/project_to_object_01.output @@ -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: diff --git a/tests/grid/project_to_object_01.output.with_fma b/tests/grid/project_to_object_01.output.with_fma index 3ba034bd4b..2ac36b8566 100644 --- a/tests/grid/project_to_object_01.output.with_fma +++ b/tests/grid/project_to_object_01.output.with_fma @@ -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: -- 2.39.5