]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use FloatingPointComparator in TriangulationDescription 14307/head
authorPeter Munch <peterrmuench@gmail.com>
Sat, 24 Sep 2022 09:08:39 +0000 (11:08 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 25 Sep 2022 13:34:05 +0000 (15:34 +0200)
source/grid/tria_description.cc

index 4de96bb5039c1e819d077aa8acea361552bceec9..ed35ad410d905219680115645361e5c55f6ebce1 100644 (file)
@@ -13,6 +13,7 @@
 //
 // ---------------------------------------------------------------------
 
+#include <deal.II/base/floating_point_comparator.h>
 #include <deal.II/base/geometry_info.h>
 #include <deal.II/base/mpi.h>
 #include <deal.II/base/mpi_consensus_algorithms.h>
@@ -153,20 +154,12 @@ namespace TriangulationDescription
 
           if (vertices_have_unique_ids == false) // need to compare points
             {
-              // comparator of points
-              const auto comp = [](const auto &a, const auto &b) {
-                const double tolerance = 1e-10;
-
-                for (unsigned int i = 0; i < spacedim; ++i)
-                  if (std::abs(a[i] - b[i]) > tolerance)
-                    return a[i] < b[i];
-
-                return false;
-              };
-
               // map point to local vertex index
-              std::map<Point<spacedim>, unsigned int, decltype(comp)>
-                map_point_to_local_vertex_index(comp);
+              std::map<Point<spacedim>,
+                       unsigned int,
+                       FloatingPointComparator<double>>
+                map_point_to_local_vertex_index(
+                  FloatingPointComparator<double>(1e-10));
 
               // ... initialize map with existing points
               for (unsigned int i = 0; i < this->coarse_cell_vertices.size();

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.