From: Martin Kronbichler Date: Thu, 14 Dec 2017 06:46:19 +0000 (+0100) Subject: Fix corner case in comparison. Add test. X-Git-Tag: v9.0.0-rc1~659^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2696c47d839e9cdc28b7df63f8e6be9b8efbca36;p=dealii.git Fix corner case in comparison. Add test. --- diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 727a99eb4c..17d51850a3 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -60,9 +60,13 @@ namespace DoFTools * std::map. * * Comparison is done through an artificial downstream direction that - * tells directions apart through a factor of 1e-5. The final comparison - * is done without an epsilon, so points need to have identical floating - * point components to be considered equal. + * tells directions apart through a factor of 1e-5. Once we got the + * direction, we check for its value. In case the distance is exactly zero + * (without an epsilon), we might still have the case that two points + * combine in a particular way, e.g. the points (1.0, 1.0) and (1.0+1e-5, + * 0.0). Thus, compare the points component by component in the second + * step. Thus, points need to have identical floating point components to + * be considered equal. */ template struct ComparisonHelper @@ -79,10 +83,23 @@ namespace DoFTools double weight = 1.; for (unsigned int d=0; d 0) + return true; + else + { + for (unsigned int d=0; d + +void +test (const double epsilon) +{ + constexpr unsigned int dim = 2; + Point p1(1.0, 1.0); + Point p2(1.0+epsilon, 0.0); + + std::map > support_points; + support_points[0] = p1; + support_points[1] = p2; + + DoFTools::write_gnuplot_dof_support_point_info(deallog.get_file_stream(), + support_points); + deallog << std::endl; +} + + + +int main() +{ + initlog(); + test(1e-4); + test(1e-5); + test(1e-6); +} diff --git a/tests/dofs/dof_tools_write_gnuplot_dof_support_point_info_04.output b/tests/dofs/dof_tools_write_gnuplot_dof_support_point_info_04.output new file mode 100644 index 0000000000..c591160267 --- /dev/null +++ b/tests/dofs/dof_tools_write_gnuplot_dof_support_point_info_04.output @@ -0,0 +1,10 @@ + +1.00000 1.00000 "0" +1.00010 0.00000 "1" +DEAL:: +1.00000 1.00000 "0" +1.00001 0.00000 "1" +DEAL:: +1.00000 0.00000 "1" +1.00000 1.00000 "0" +DEAL::