Skip to content

Commit

Permalink
step
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 14, 2024
1 parent 69151eb commit ec195f0
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/p3m/fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/p3m/fft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/core/p3m/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ template <typename T> 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;
Expand Down
91 changes: 91 additions & 0 deletions src/core/unit_tests/fft_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>::max();
auto constexpr bad_size = size_max / sizeof(int) + 1ul;
Expand Down
4 changes: 2 additions & 2 deletions testsuite/scripts/tutorials/test_ferrofluid_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand All @@ -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])
Expand Down

0 comments on commit ec195f0

Please sign in to comment.