]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added quicktest for nanoflann. 5028/head
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 5 Sep 2017 14:50:06 +0000 (16:50 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 5 Sep 2017 14:50:06 +0000 (16:50 +0200)
tests/quick_tests/CMakeLists.txt
tests/quick_tests/nanoflann.cc [new file with mode: 0644]

index 6d0e3acb43843a59d70de410f876660e5196f432..e6a3529a024e6c2bc91a39b1c5877f171661c9be 100644 (file)
@@ -136,6 +136,11 @@ IF (DEAL_II_WITH_GSL)
   make_quicktest("gsl" ${_mybuild} "")
 ENDIF()
 
+# Test Nanoflann
+IF (DEAL_II_WITH_NANOFLANN)
+  make_quicktest("nanoflann" ${_mybuild} "")
+ENDIF()
+
 # Test Arpack
 IF (DEAL_II_WITH_ARPACK AND DEAL_II_WITH_UMFPACK)
   make_quicktest("arpack" ${_mybuild} "")
diff --git a/tests/quick_tests/nanoflann.cc b/tests/quick_tests/nanoflann.cc
new file mode 100644 (file)
index 0000000..d233500
--- /dev/null
@@ -0,0 +1,57 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+//---------------------------------------------------------------------
+
+// Create a list of points, and compute the minimum distance from some other points
+// to this set, using a kdtree library
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/numerics/kdtree.h>
+
+
+int main ()
+{
+  KDTree<2> kdtree;
+
+  std::vector<Point<2> > points;
+
+  // Add four points
+  points.push_back(Point<2>(0,0));
+  points.push_back(Point<2>(0,1));
+  points.push_back(Point<2>(1,0));
+  points.push_back(Point<2>(1,1));
+
+  deallog << "Distance from unit square:" << std::endl;
+
+  std::vector<Point<2> > test_points;
+  test_points.push_back(Point<2>(.5, .5));
+  test_points.push_back(Point<2>(2, 0));
+  test_points.push_back(Point<2>(2, 2));
+
+  kdtree.set_points(points);
+
+  for (auto &p : test_points)
+    {
+      auto res = kdtree.get_closest_points(p,1)[0];
+      deallog << "P: " << p << ", distance: " << res.second << ", index: " << res.first << std::endl;
+    }
+
+  deallog << "Consistency checking: the following are all the points in the set." << std::endl;
+  for (auto &p : points)
+    {
+      auto res = kdtree.get_closest_points(p,1)[0];
+      deallog << "P: " << p << ", distance: " << res.second << ", index: " << res.first << std::endl;
+      Assert(res.second < 1e-10, ExcMessage("Should be zero!"));
+    }
+}

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.