]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test Utilities::inverse_Hilbert_space_filling_curve in 1D
authorDenis Davydov <davydden@gmail.com>
Tue, 7 May 2019 14:40:14 +0000 (16:40 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 7 May 2019 17:40:30 +0000 (19:40 +0200)
tests/base/utilities_16.cc [new file with mode: 0644]
tests/base/utilities_16.output [new file with mode: 0644]

diff --git a/tests/base/utilities_16.cc b/tests/base/utilities_16.cc
new file mode 100644 (file)
index 0000000..5c37d14
--- /dev/null
@@ -0,0 +1,59 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test Utilities::inverse_Hilbert_space_filling_curve in 1D
+
+#include <deal.II/base/utilities.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  const std::vector<Point<1>> points = {
+    Point<1>(1), Point<1>(0), Point<1>(13), Point<1>(-2), Point<1>(22)};
+
+  const int  bit_depth = 5;
+  const auto res =
+    Utilities::inverse_Hilbert_space_filling_curve(points, bit_depth);
+
+  std::vector<unsigned int> index(points.size());
+  for (unsigned int i = 0; i < index.size(); ++i)
+    index[i] = i;
+
+  std::sort(index.begin(),
+            index.end(),
+            [&](const unsigned int &a, const unsigned int &b) {
+              AssertIndexRange(a, res.size());
+              AssertIndexRange(b, res.size());
+              return std::lexicographical_compare(res[a].begin(),
+                                                  res[a].end(),
+                                                  res[b].begin(),
+                                                  res[b].end());
+            });
+
+  for (const auto ind : index)
+    deallog << points[ind][0] << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test();
+}
diff --git a/tests/base/utilities_16.output b/tests/base/utilities_16.output
new file mode 100644 (file)
index 0000000..d8520a7
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::-2.00000
+DEAL::0.00000
+DEAL::1.00000
+DEAL::13.0000
+DEAL::22.0000

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.