diff --git a/src/core/p3m/fft.cpp b/src/core/p3m/fft.cpp index a14c9a2d00..bd6ad27e38 100644 --- a/src/core/p3m/fft.cpp +++ b/src/core/p3m/fft.cpp @@ -411,6 +411,7 @@ void back_grid_comm(fft_forw_plan plan_f, fft_back_plan plan_b, plan_f.element); } } +} // namespace /** Calculate 'best' mapping between a 2D and 3D grid. * Required for the communication from 3D regular domain @@ -461,7 +462,6 @@ int map_3don2d_grid(int const g3d[3], int g2d[3]) { } return row_dir; } -} // namespace /** Calculate most square 2D grid. */ static void calc_2d_grid(int n, int grid[3]) { diff --git a/src/core/p3m/fft.hpp b/src/core/p3m/fft.hpp index c87f11a14c..03dd4a0de6 100644 --- a/src/core/p3m/fft.hpp +++ b/src/core/p3m/fft.hpp @@ -232,4 +232,6 @@ void fft_pack_block(double const *in, double *out, int const start[3], void fft_unpack_block(double const *in, double *out, int const start[3], int const size[3], int const dim[3], int element); +int map_3don2d_grid(int const g3d[3], int g2d[3]); + #endif // defined(P3M) || defined(DP3M) diff --git a/src/core/p3m/math.hpp b/src/core/p3m/math.hpp index a9f2bdf7fd..2da9b38dd1 100644 --- a/src/core/p3m/math.hpp +++ b/src/core/p3m/math.hpp @@ -61,7 +61,7 @@ template DEVICE_QUALIFIER auto sinc(T x) { if (::math::abs(x) > epsilon) return sin(pix) / pix; - auto constexpr factorial = [](int n) { + auto constexpr factorial = [](int n) consteval { int acc{1}, c{1}; while (c < n) { acc *= ++c; diff --git a/src/core/unit_tests/fft_test.cpp b/src/core/unit_tests/fft_test.cpp index bb27335279..6e301a48da 100644 --- a/src/core/unit_tests/fft_test.cpp +++ b/src/core/unit_tests/fft_test.cpp @@ -67,6 +67,97 @@ BOOST_AUTO_TEST_CASE(fft_find_comm_groups_mismatch) { } } +BOOST_AUTO_TEST_CASE(fft_map_grid) { + { + auto g3d = Utils::Vector3i{{3, 2, 1}}; + auto g2d = Utils::Vector3i{{3, 2, 1}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 2); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{2, 1, 6}}; + auto g2d = Utils::Vector3i{{6, 2, 1}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 2); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{2, 6, 2}}; + auto g2d = Utils::Vector3i{{6, 2, 6}}; + auto ref = Utils::Vector3i{{6, 1, 2}}; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 1); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{3, 6, 6}}; + auto g2d = Utils::Vector3i{{6, 3, 6}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, -1); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{4, 1, 6}}; + auto g2d = Utils::Vector3i{{6, 4, 1}}; + auto ref = Utils::Vector3i{{4, 6, 1}}; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 2); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{5, 7, 7}}; + auto g2d = Utils::Vector3i{{7, 7, 5}}; + auto ref = Utils::Vector3i{{1, 7, 7}}; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 0); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{5, 7, 5}}; + auto g2d = Utils::Vector3i{{7, 7, 5}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, -1); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{4, 5, 6}}; + auto g2d = Utils::Vector3i{{6, 4, 5}}; + auto ref = Utils::Vector3i{{4, 1, 6}}; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 1); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{5, 4, 6}}; + auto g2d = Utils::Vector3i{{6, 4, 5}}; + auto ref = Utils::Vector3i{{1, 4, 6}}; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, 0); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{5, 6, 8}}; + auto g2d = Utils::Vector3i{{8, 7, 5}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, -1); + BOOST_CHECK_EQUAL(g2d, ref); + } + { + auto g3d = Utils::Vector3i{{5, 6, 9}}; + auto g2d = Utils::Vector3i{{8, 7, 5}}; + auto ref = g2d; + auto dir = map_3don2d_grid(g3d.data(), g2d.data()); + BOOST_CHECK_EQUAL(dir, -1); + BOOST_CHECK_EQUAL(g2d, ref); + } +} + BOOST_AUTO_TEST_CASE(fft_exceptions) { auto constexpr size_max = std::numeric_limits::max(); auto constexpr bad_size = size_max / sizeof(int) + 1ul; diff --git a/testsuite/scripts/tutorials/test_ferrofluid_1.py b/testsuite/scripts/tutorials/test_ferrofluid_1.py index f6ce5e78ca..7da0aa14ef 100644 --- a/testsuite/scripts/tutorials/test_ferrofluid_1.py +++ b/testsuite/scripts/tutorials/test_ferrofluid_1.py @@ -22,7 +22,7 @@ tutorial, skipIfMissingFeatures = importlib_wrapper.configure_and_import( "@TUTORIALS_DIR@/ferrofluid/ferrofluid_part1.py", - EQUIL_STEPS=200, EQUIL_ROUNDS=10, + EQUIL_STEPS=200, EQUIL_ROUNDS=20, CI_DP3M_PARAMS={'cao': 3, 'r_cut': 8.34, 'mesh': [8, 8, 8], 'alpha': 0.2115, 'tune': False}) @@ -33,7 +33,7 @@ class Tutorial(ut.TestCase): def test(self): self.assertEqual( int(np.sum(tutorial.n_clusters)), len(tutorial.cluster_sizes)) - for i in range(8): + for i in range(7): self.assertLess( tutorial.size_dist[0][i + 1], tutorial.size_dist[0][i])