From e5a128e865c989fcf2f153afa2da194e88f9572f Mon Sep 17 00:00:00 2001 From: Incardona Pietro <incardon@mpi-cbg.de> Date: Fri, 21 May 2021 10:37:17 +0200 Subject: [PATCH] Fixing grid_dist_id getPos --- openfpm_devices | 2 +- openfpm_io | 2 +- src/Grid/grid_dist_id.hpp | 2 +- src/Grid/tests/grid_dist_id_unit_test.cpp | 32 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/openfpm_devices b/openfpm_devices index a7c955b67..6a738ece9 160000 --- a/openfpm_devices +++ b/openfpm_devices @@ -1 +1 @@ -Subproject commit a7c955b6720dd482b2d2258b27dd4e6148230792 +Subproject commit 6a738ece9395c7dafbbf6ac244ac4ac99bf3ed64 diff --git a/openfpm_io b/openfpm_io index 29e9077f9..1a8e1bb01 160000 --- a/openfpm_io +++ b/openfpm_io @@ -1 +1 @@ -Subproject commit 29e9077f96e8f9a2945c0723b8fd47d54d310a0d +Subproject commit 1a8e1bb010f3562596263fea2c01e8b3514ef015 diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp index efa4a8155..8d4965bd2 100644 --- a/src/Grid/grid_dist_id.hpp +++ b/src/Grid/grid_dist_id.hpp @@ -2283,7 +2283,7 @@ public: for (int i = 0 ; i < dim ; i++) { - p.get(i) = (gdb_ext.get(v1.getSub()).origin.get(i) + v1.getKeyRef().get(i)) * this->spacing(i); + p.get(i) = (gdb_ext.get(v1.getSub()).origin.get(i) + v1.getKeyRef().get(i)) * this->spacing(i) + domain.getLow(i); } return p; diff --git a/src/Grid/tests/grid_dist_id_unit_test.cpp b/src/Grid/tests/grid_dist_id_unit_test.cpp index a6d4061e0..8d8186ea9 100644 --- a/src/Grid/tests/grid_dist_id_unit_test.cpp +++ b/src/Grid/tests/grid_dist_id_unit_test.cpp @@ -94,6 +94,38 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter3D_test) v_cl.execute(); BOOST_REQUIRE_EQUAL(vol,sz[0]*sz[1]*sz[2]); + + // Check getPos + + auto it = g_dist.getDomainIterator(); + + auto key = it.get(); + + auto pos = g_dist.getPos(key); + + BOOST_REQUIRE_CLOSE(pos.get(0),-0.3f,0.0001); + BOOST_REQUIRE_CLOSE(pos.get(1),-0.3f,0.0001); + BOOST_REQUIRE_CLOSE(pos.get(2),-0.3f,0.0001); + + bool check = false; + + while (it.isNext()) + { + auto key2 = it.get(); + + auto pos = g_dist.getPos(key2); + + if (pos[0] >= 0.99999 && pos[0] <= 1.00001 && + pos[1] >= 0.99999 && pos[1] <= 1.00001 && + pos[2] >= 0.99999 && pos[2] <= 1.00001) + { + check = true; + } + + ++it; + } + + BOOST_REQUIRE_EQUAL(check,true); } } -- GitLab