From 5e965d93459761a74e61420a26d84a98be9fdd08 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 7 May 2019 16:40:14 +0200 Subject: [PATCH] test Utilities::inverse_Hilbert_space_filling_curve in 1D --- tests/base/utilities_16.cc | 59 ++++++++++++++++++++++++++++++++++ tests/base/utilities_16.output | 6 ++++ 2 files changed, 65 insertions(+) create mode 100644 tests/base/utilities_16.cc create mode 100644 tests/base/utilities_16.output diff --git a/tests/base/utilities_16.cc b/tests/base/utilities_16.cc new file mode 100644 index 0000000000..5c37d14d10 --- /dev/null +++ b/tests/base/utilities_16.cc @@ -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 + +#include "../tests.h" + + +void +test() +{ + const std::vector> 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 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 index 0000000000..d8520a73a9 --- /dev/null +++ b/tests/base/utilities_16.output @@ -0,0 +1,6 @@ + +DEAL::-2.00000 +DEAL::0.00000 +DEAL::1.00000 +DEAL::13.0000 +DEAL::22.0000 -- 2.39.5