diff --git a/openfpm_devices b/openfpm_devices index a7c955b6720dd482b2d2258b27dd4e6148230792..6a738ece9395c7dafbbf6ac244ac4ac99bf3ed64 160000 --- a/openfpm_devices +++ b/openfpm_devices @@ -1 +1 @@ -Subproject commit a7c955b6720dd482b2d2258b27dd4e6148230792 +Subproject commit 6a738ece9395c7dafbbf6ac244ac4ac99bf3ed64 diff --git a/openfpm_io b/openfpm_io index 29e9077f96e8f9a2945c0723b8fd47d54d310a0d..1a8e1bb010f3562596263fea2c01e8b3514ef015 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 efa4a81557ff2396372fef3fbe514c949c01610d..8d4965bd29b1626140afd1cae55cedc4bce99f64 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 a6d4061e0c2be72e30cb247cf2c761c23f508915..8d8186ea9b3ca4db3d5699d1fc16fd0350d38052 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); } }