]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add tests for HSFC with degenerate input
authorDenis Davydov <davydden@gmail.com>
Tue, 7 May 2019 17:34:19 +0000 (19:34 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 7 May 2019 18:30:45 +0000 (20:30 +0200)
tests/base/utilities_17.cc [new file with mode: 0644]
tests/base/utilities_17.output [new file with mode: 0644]
tests/base/utilities_18.cc [new file with mode: 0644]
tests/base/utilities_18.output [new file with mode: 0644]
tests/base/utilities_19.cc [new file with mode: 0644]
tests/base/utilities_19.output [new file with mode: 0644]

diff --git a/tests/base/utilities_17.cc b/tests/base/utilities_17.cc
new file mode 100644 (file)
index 0000000..9506284
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+// similar to utilities_14, test
+// Utilities::inverse_Hilbert_space_filling_curve in 3D for point on the planes
+// with bits=2.
+// the test output is made to be exactly the same as utilities_14
+
+//      3 |    5---6   9---10
+//        |    |   |   |   |
+//      2 |    4   7---8   11
+//        |    |           |
+//      1 |    3---2   13--12
+//        |        |   |
+//      0 |    0---1   14--15
+//        |
+//         ------------------
+//             0   1   2   3
+
+#include <deal.II/base/utilities.h>
+
+#include "../tests.h"
+
+
+void
+test(const unsigned int plane = 1)
+{
+  Assert(plane < 3, ExcInternalError());
+  const std::vector<Point<2>> points = {Point<2>(0, 0),
+                                        Point<2>(1, 0),
+                                        Point<2>(1, 1),
+                                        Point<2>(0, 1),
+                                        Point<2>(0, 2),
+                                        Point<2>(0, 3),
+                                        Point<2>(1, 3),
+                                        Point<2>(1, 2),
+                                        Point<2>(2, 2),
+                                        Point<2>(2, 3),
+                                        Point<2>(3, 3),
+                                        Point<2>(3, 2),
+                                        Point<2>(3, 1),
+                                        Point<2>(2, 1),
+                                        Point<2>(2, 0),
+                                        Point<2>(3, 0)};
+
+  std::vector<Point<3>> points_degenerate(points.size());
+  for (unsigned int i = 0; i < points.size(); ++i)
+    {
+      unsigned int eff_d = 0;
+      for (unsigned int d = 0; d < 3; ++d)
+        if (d != plane)
+          {
+            points_degenerate[i][d] = points[i][eff_d];
+            ++eff_d;
+          }
+    }
+
+
+  const int  bit_depth = 2;
+  const auto res =
+    Utilities::inverse_Hilbert_space_filling_curve(points_degenerate,
+                                                   bit_depth);
+
+  deallog << plane << ":" << std::endl;
+  for (const auto &p : res)
+    {
+      AssertThrow(p[0] == 0, ExcInternalError());
+      deallog << p[1] << " " << p[2] << " "
+              << Utilities::pack_integers<3>(p, bit_depth) << std::endl;
+    }
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test(0);
+  test(1);
+  test(2);
+}
diff --git a/tests/base/utilities_17.output b/tests/base/utilities_17.output
new file mode 100644 (file)
index 0000000..7470d56
--- /dev/null
@@ -0,0 +1,55 @@
+
+DEAL::0:
+DEAL::0 0 0
+DEAL::0 1 1
+DEAL::0 2 2
+DEAL::0 3 3
+DEAL::1 0 4
+DEAL::1 1 5
+DEAL::1 2 6
+DEAL::1 3 7
+DEAL::2 0 8
+DEAL::2 1 9
+DEAL::2 2 10
+DEAL::2 3 11
+DEAL::3 0 12
+DEAL::3 1 13
+DEAL::3 2 14
+DEAL::3 3 15
+DEAL::
+DEAL::1:
+DEAL::0 0 0
+DEAL::0 1 1
+DEAL::0 2 2
+DEAL::0 3 3
+DEAL::1 0 4
+DEAL::1 1 5
+DEAL::1 2 6
+DEAL::1 3 7
+DEAL::2 0 8
+DEAL::2 1 9
+DEAL::2 2 10
+DEAL::2 3 11
+DEAL::3 0 12
+DEAL::3 1 13
+DEAL::3 2 14
+DEAL::3 3 15
+DEAL::
+DEAL::2:
+DEAL::0 0 0
+DEAL::0 1 1
+DEAL::0 2 2
+DEAL::0 3 3
+DEAL::1 0 4
+DEAL::1 1 5
+DEAL::1 2 6
+DEAL::1 3 7
+DEAL::2 0 8
+DEAL::2 1 9
+DEAL::2 2 10
+DEAL::2 3 11
+DEAL::3 0 12
+DEAL::3 1 13
+DEAL::3 2 14
+DEAL::3 3 15
+DEAL::
diff --git a/tests/base/utilities_18.cc b/tests/base/utilities_18.cc
new file mode 100644 (file)
index 0000000..71d7ade
--- /dev/null
@@ -0,0 +1,75 @@
+// ---------------------------------------------------------------------
+//
+// 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 (effectively) 1D
+// take utilities_16 input and put on a coordinate line in 3D.
+// output is made exactly the same as in utilities_16
+
+#include <deal.II/base/utilities.h>
+
+#include "../tests.h"
+
+
+void
+test(unsigned int plane = 1)
+{
+  Assert(plane < 3, ExcInternalError());
+  const std::vector<Point<1>> points = {
+    Point<1>(1), Point<1>(0), Point<1>(13), Point<1>(-2), Point<1>(22)};
+
+  std::vector<Point<3>> points_degenerate(points.size());
+  for (unsigned int i = 0; i < points.size(); ++i)
+    points_degenerate[i][plane] = points[i][0];
+
+  const int  bit_depth = 5;
+  const auto res =
+    Utilities::inverse_Hilbert_space_filling_curve(points_degenerate,
+                                                   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());
+            });
+
+  deallog << plane << ":" << std::endl;
+  for (const auto ind : index)
+    {
+      AssertThrow(res[ind][0] == 0, ExcInternalError());
+      AssertThrow(res[ind][1] == 0, ExcInternalError());
+      deallog << points[ind][0] << std::endl;
+    }
+  deallog << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test(0);
+  test(1);
+  test(2);
+}
diff --git a/tests/base/utilities_18.output b/tests/base/utilities_18.output
new file mode 100644 (file)
index 0000000..71438d4
--- /dev/null
@@ -0,0 +1,22 @@
+
+DEAL::0:
+DEAL::-2.00000
+DEAL::0.00000
+DEAL::1.00000
+DEAL::13.0000
+DEAL::22.0000
+DEAL::
+DEAL::1:
+DEAL::-2.00000
+DEAL::0.00000
+DEAL::1.00000
+DEAL::13.0000
+DEAL::22.0000
+DEAL::
+DEAL::2:
+DEAL::-2.00000
+DEAL::0.00000
+DEAL::1.00000
+DEAL::13.0000
+DEAL::22.0000
+DEAL::
diff --git a/tests/base/utilities_19.cc b/tests/base/utilities_19.cc
new file mode 100644 (file)
index 0000000..6ea8035
--- /dev/null
@@ -0,0 +1,56 @@
+// ---------------------------------------------------------------------
+//
+// 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 with
+// effective dimension == 0
+
+#include <deal.II/base/utilities.h>
+
+#include "../tests.h"
+
+
+template <int dim>
+void
+test()
+{
+  deallog << "dim=" << dim << std::endl;
+  const std::vector<Point<dim>> points_degenerate = {Point<dim>(),
+                                                     Point<dim>(),
+                                                     Point<dim>()};
+
+  const int  bit_depth = 5;
+  const auto res =
+    Utilities::inverse_Hilbert_space_filling_curve(points_degenerate,
+                                                   bit_depth);
+
+  for (unsigned int i = 0; i < res.size(); ++i)
+    {
+      for (unsigned int d = 0; d < dim; ++d)
+        deallog << " " << res[i][d];
+
+      deallog << std::endl;
+    }
+}
+
+int
+main()
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/base/utilities_19.output b/tests/base/utilities_19.output
new file mode 100644 (file)
index 0000000..39e7a65
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::dim=1
+DEAL:: 0
+DEAL:: 1
+DEAL:: 2
+DEAL::dim=2
+DEAL:: 0 0
+DEAL:: 0 1
+DEAL:: 0 2
+DEAL::dim=3
+DEAL:: 0 0 0
+DEAL:: 0 0 1
+DEAL:: 0 0 2

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.