From 8c5b07c3a3555d3eaf1c21a3f4dc92fa3738a85e Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 27 Jan 2018 15:39:32 -0500 Subject: [PATCH] Improve tolerances for errors near zero. Details in the floating point implementation (e.g., whether or not -ffast-math is used) can change the error by an order of magnitude or more. Get around this by, in each relevant case, bounding the error above. Since the errors are now checked in a different way the alternative output file has been removed. --- tests/grid/project_to_object_01.cc | 17 +- tests/grid/project_to_object_01.output | 24 +- .../grid/project_to_object_01.output.with_fma | 207 ------------------ 3 files changed, 20 insertions(+), 228 deletions(-) delete mode 100644 tests/grid/project_to_object_01.output.with_fma diff --git a/tests/grid/project_to_object_01.cc b/tests/grid/project_to_object_01.cc index 2dfca0427f..c0b01cf892 100644 --- a/tests/grid/project_to_object_01.cc +++ b/tests/grid/project_to_object_01.cc @@ -254,7 +254,6 @@ int main() // drops proportionally as the grid is refined for (unsigned int n_refinements = 4; n_refinements < 7; ++ n_refinements) { - deallog << "=====================================================" << std::endl << "Number of global refinements: " << n_refinements @@ -310,8 +309,8 @@ int main() << "true line midpoint: " << true_midpoint << std::endl - << "distance: " - << projected_point.distance(true_midpoint) + << "distance less than 5.0e-6: " + << (projected_point.distance(true_midpoint) < 5.0e-6) << std::endl; } @@ -418,8 +417,8 @@ int main() << "projected point distance from origin: " << projected_point.distance(Point<3>()) << std::endl - << "Error: " - << projected_point.distance(trial_point) + << "Error is less than 1.0e-3: " + << (projected_point.distance(trial_point) < 1.0e-3) << std::endl; } @@ -448,8 +447,8 @@ int main() << "projected point distance from origin: " << projected_point.distance(Point<3>()) << std::endl - << "Error (vs. going along the normal): " - << projected_point.distance(trial_point - normal_vector) + << "Error (vs. going along the normal) less than 0.01: " + << (projected_point.distance(trial_point - normal_vector) < 0.01) << std::endl; } @@ -480,8 +479,8 @@ int main() << "projected point distance from origin: " << projected_point.distance(Point<3>()) << std::endl - << "Error: " - << projected_point.distance(trial_point) + << "Error less than 1.0e-7: " + << (projected_point.distance(trial_point) < 1.0e-7) << std::endl; } } diff --git a/tests/grid/project_to_object_01.output b/tests/grid/project_to_object_01.output index 7cfc0d5bb0..fbbf17d434 100644 --- a/tests/grid/project_to_object_01.output +++ b/tests/grid/project_to_object_01.output @@ -48,7 +48,7 @@ DEAL::trial point distance from origin: 2.19657 DEAL::projected point distance from origin: 2.00000 DEAL::projected point: -1.12078 -1.12078 -1.21971 DEAL::true line midpoint: -1.12078 -1.12078 -1.21971 -DEAL::distance: 4.11779e-10 +DEAL::distance less than 5.0e-6: 1 DEAL:: DEAL::Check that projecting with spacedim == structdim is the identity map: DEAL:: @@ -77,13 +77,13 @@ DEAL::Project a weighed face point onto the same face in 3D: DEAL:: DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 9.62537e-12 +DEAL::Error is less than 1.0e-3: 1 DEAL:: DEAL::Project a point offset from the face onto the face in 3D: DEAL:: DEAL::trial point distance from origin: 2.20000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 4.27949e-07 +DEAL::Error (vs. going along the normal) less than 0.01: 1 DEAL:: DEAL::Project a weighed line point onto the same line in 3D: DEAL:: @@ -91,7 +91,7 @@ DEAL::trial point: -1.20701 -1.04224 -1.20701 DEAL::projected point: -1.20701 -1.04224 -1.20701 DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 8.09719e-13 +DEAL::Error less than 1.0e-7: 1 DEAL::===================================================== DEAL::Number of global refinements: 5 DEAL::===================================================== @@ -104,7 +104,7 @@ DEAL::trial point distance from origin: 2.19917 DEAL::projected point distance from origin: 2.00000 DEAL::projected point: -1.13838 -1.13838 -1.18668 DEAL::true line midpoint: -1.13837 -1.13837 -1.18668 -DEAL::distance: 3.93031e-06 +DEAL::distance less than 5.0e-6: 1 DEAL:: DEAL::Check that projecting with spacedim == structdim is the identity map: DEAL:: @@ -133,13 +133,13 @@ DEAL::Project a weighed face point onto the same face in 3D: DEAL:: DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 3.98368e-06 +DEAL::Error is less than 1.0e-3: 1 DEAL:: DEAL::Project a point offset from the face onto the face in 3D: DEAL:: DEAL::trial point distance from origin: 2.20000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 3.61016e-05 +DEAL::Error (vs. going along the normal) less than 0.01: 1 DEAL:: DEAL::Project a weighed line point onto the same line in 3D: DEAL:: @@ -147,7 +147,7 @@ DEAL::trial point: -1.18152 -1.09909 -1.18152 DEAL::projected point: -1.18152 -1.09909 -1.18152 DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 6.90400e-09 +DEAL::Error less than 1.0e-7: 1 DEAL::===================================================== DEAL::Number of global refinements: 6 DEAL::===================================================== @@ -160,7 +160,7 @@ DEAL::trial point distance from origin: 2.19979 DEAL::projected point distance from origin: 2.00000 DEAL::projected point: -1.14669 -1.14669 -1.17055 DEAL::true line midpoint: -1.14669 -1.14669 -1.17055 -DEAL::distance: 1.12263e-07 +DEAL::distance less than 5.0e-6: 1 DEAL:: DEAL::Check that projecting with spacedim == structdim is the identity map: DEAL:: @@ -189,13 +189,13 @@ DEAL::Project a weighed face point onto the same face in 3D: DEAL:: DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 0.000829874 +DEAL::Error is less than 1.0e-3: 1 DEAL:: DEAL::Project a point offset from the face onto the face in 3D: DEAL:: DEAL::trial point distance from origin: 2.20000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 0.00114084 +DEAL::Error (vs. going along the normal) less than 0.01: 1 DEAL:: DEAL::Project a weighed line point onto the same line in 3D: DEAL:: @@ -203,5 +203,5 @@ DEAL::trial point: -1.16828 -1.12706 -1.16828 DEAL::projected point: -1.16828 -1.12706 -1.16828 DEAL::trial point distance from origin: 2.00000 DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 4.18144e-08 +DEAL::Error less than 1.0e-7: 1 DEAL::OK diff --git a/tests/grid/project_to_object_01.output.with_fma b/tests/grid/project_to_object_01.output.with_fma deleted file mode 100644 index 2ac36b8566..0000000000 --- a/tests/grid/project_to_object_01.output.with_fma +++ /dev/null @@ -1,207 +0,0 @@ - -DEAL::testing cross derivative 0 -DEAL::slope is nearly 3: 1 -DEAL::testing cross derivative 1 -DEAL::slope is nearly 3: 1 -DEAL::testing cross derivative 2 -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: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::vertex 1 distance from origin: 2.00000 -DEAL::trial point distance from origin: 1.79445 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: 1.99383 0.156918 -DEAL::true geodesic midpoint: 1.99383 0.156918 -DEAL:: -DEAL::Project the convex combination of two vertices: -DEAL::projected point: 1.98114 0.274025 -DEAL::Convex combination point: 1.98114 0.274025 -DEAL::Distance: 5.55112e-17 -DEAL:: -DEAL::Check that projecting with spacedim == structdim -DEAL::is the identity map: -DEAL:: -DEAL::trial point: 0.417941 4.24242e+09 -DEAL::projected point: 0.417941 4.24242e+09 -DEAL:: -DEAL::Project a vertex onto the geodesic: -DEAL:: -DEAL::vertex distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: 2.00000 0.00000 -DEAL::actual vertex: 2.00000 0.00000 -DEAL::Test for robustness by projecting points with nonunique -DEAL::minimizers. The output here has been eyeballed as decent. -DEAL::===================================================== -DEAL::Number of global refinements: 4 -DEAL::===================================================== -DEAL:: -DEAL::Project a reweighed center onto a face in 3D: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::vertex 1 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.19658 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.12083 -1.12083 -1.21963 -DEAL::true line midpoint: -1.12083 -1.12083 -1.21963 -DEAL::distance: 3.53014e-07 -DEAL:: -DEAL::Check that projecting with spacedim == structdim is the identity map: -DEAL:: -DEAL::trial point: 0.417941 4.24242e+09 1.00000 -DEAL::projected point: 0.417941 4.24242e+09 1.00000 -DEAL:: -DEAL::Project a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15470 -1.15470 -1.15470 -DEAL::actual vertex: -1.15470 -1.15470 -1.15470 -DEAL::distance: 0.00000 -DEAL:: -DEAL::Project a point near a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15464 -1.15473 -1.15473 -DEAL::trial point: -1.15464 -1.15473 -1.15473 -DEAL::distance: 3.62779e-13 -DEAL:: -DEAL::Project a weighed face point onto the same face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 1.15559e-12 -DEAL:: -DEAL::Project a point offset from the face onto the face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.20000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 1.51134e-06 -DEAL:: -DEAL::Project a weighed line point onto the same line in 3D: -DEAL:: -DEAL::trial point: -1.20701 -1.04224 -1.20701 -DEAL::projected point: -1.20701 -1.04224 -1.20701 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 1.55488e-12 -DEAL::===================================================== -DEAL::Number of global refinements: 5 -DEAL::===================================================== -DEAL:: -DEAL::Project a reweighed center onto a face in 3D: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::vertex 1 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.19917 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.13839 -1.13839 -1.18665 -DEAL::true line midpoint: -1.13839 -1.13839 -1.18666 -DEAL::distance: 3.64048e-06 -DEAL:: -DEAL::Check that projecting with spacedim == structdim is the identity map: -DEAL:: -DEAL::trial point: 0.417941 4.24242e+09 1.00000 -DEAL::projected point: 0.417941 4.24242e+09 1.00000 -DEAL:: -DEAL::Project a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15470 -1.15470 -1.15470 -DEAL::actual vertex: -1.15470 -1.15470 -1.15470 -DEAL::distance: 0.00000 -DEAL:: -DEAL::Project a point near a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15467 -1.15472 -1.15472 -DEAL::trial point: -1.15467 -1.15472 -1.15472 -DEAL::distance: 7.44194e-10 -DEAL:: -DEAL::Project a weighed face point onto the same face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 3.98611e-06 -DEAL:: -DEAL::Project a point offset from the face onto the face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.20000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 2.33751e-05 -DEAL:: -DEAL::Project a weighed line point onto the same line in 3D: -DEAL:: -DEAL::trial point: -1.18152 -1.09909 -1.18152 -DEAL::projected point: -1.18152 -1.09909 -1.18152 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 5.86855e-09 -DEAL::===================================================== -DEAL::Number of global refinements: 6 -DEAL::===================================================== -DEAL:: -DEAL::Project a reweighed center onto a face in 3D: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::vertex 1 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.19979 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.14670 -1.14670 -1.17054 -DEAL::true line midpoint: -1.14670 -1.14670 -1.17054 -DEAL::distance: 1.04482e-07 -DEAL:: -DEAL::Check that projecting with spacedim == structdim is the identity map: -DEAL:: -DEAL::trial point: 0.417941 4.24242e+09 1.00000 -DEAL::projected point: 0.417941 4.24242e+09 1.00000 -DEAL:: -DEAL::Project a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15470 -1.15470 -1.15470 -DEAL::actual vertex: -1.15470 -1.15470 -1.15470 -DEAL::distance: 0.00000 -DEAL:: -DEAL::Project a point near a vertex: -DEAL:: -DEAL::vertex 0 distance from origin: 2.00000 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::projected point: -1.15469 -1.15471 -1.15471 -DEAL::trial point: -1.15469 -1.15471 -1.15471 -DEAL::distance: 1.53899e-10 -DEAL:: -DEAL::Project a weighed face point onto the same face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 0.000830164 -DEAL:: -DEAL::Project a point offset from the face onto the face in 3D: -DEAL:: -DEAL::trial point distance from origin: 2.20000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error (vs. going along the normal): 0.00114120 -DEAL:: -DEAL::Project a weighed line point onto the same line in 3D: -DEAL:: -DEAL::trial point: -1.16828 -1.12706 -1.16828 -DEAL::projected point: -1.16828 -1.12706 -1.16828 -DEAL::trial point distance from origin: 2.00000 -DEAL::projected point distance from origin: 2.00000 -DEAL::Error: 4.11270e-08 -DEAL::OK -- 2.39.5