diff --git a/example/Vector/4_multiphase_celllist/Makefile b/example/Vector/4_multiphase_celllist_verlet/Makefile similarity index 100% rename from example/Vector/4_multiphase_celllist/Makefile rename to example/Vector/4_multiphase_celllist_verlet/Makefile diff --git a/example/Vector/4_multiphase_celllist/config.cfg b/example/Vector/4_multiphase_celllist_verlet/config.cfg similarity index 100% rename from example/Vector/4_multiphase_celllist/config.cfg rename to example/Vector/4_multiphase_celllist_verlet/config.cfg diff --git a/example/Vector/4_multiphase_celllist/main.cpp b/example/Vector/4_multiphase_celllist_verlet/main.cpp similarity index 99% rename from example/Vector/4_multiphase_celllist/main.cpp rename to example/Vector/4_multiphase_celllist_verlet/main.cpp index 60a2007c24246f1e0a369ad75bde9c0c980743fd..c353f0d8d9897554c23b7059eae67e5350e17ff5 100644 --- a/example/Vector/4_multiphase_celllist/main.cpp +++ b/example/Vector/4_multiphase_celllist_verlet/main.cpp @@ -14,7 +14,6 @@ * * This example show multi-phase cell lists for the distributed vector * - * \warning BETA version * */ @@ -136,6 +135,8 @@ int main(int argc, char* argv[]) CellListM<3,float,2> NN; NN.Initialize(box_cl,div); + + // for all the phases i for (size_t i = 0; i < phases.size() ; i++) { diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp index e9d457fda9f9dfe4d9988e1ecf100e3651770c5a..64d85b55379a9734fe09c55227645c2b171017e5 100644 --- a/src/Vector/vector_dist.hpp +++ b/src/Vector/vector_dist.hpp @@ -359,26 +359,10 @@ public: { // Cell list CellL cell_list; - size_t div[dim]; - - // Calculate the Cell list division for this CellList - CellDecomposer_sm<dim,St,shift<dim,St>> cd_sm; - - for (size_t i = 0 ; i < dim ; i++) - div[i] = (getDecomposition().getDomain().getHigh(i) - getDecomposition().getDomain().getLow(i)) / r_cut; size_t pad = 0; - Ghost<dim,St> g = getDecomposition().getGhost(); - g.magnify(1.013); - - // Calculate the maximum padding - for (size_t i = 0 ; i < dim ; i++) - { - size_t tmp = std::ceil(fabs(g.getLow(i)) / r_cut); - pad = (pad > tmp)?pad:tmp; - } - - cd_sm.setDimensions(getDecomposition().getDomain(),div,pad); + CellDecomposer_sm<dim,St,shift<dim,St>> cd_sm; + cl_param_calculateSym(getDecomposition().getDomain(),cd_sm,getDecomposition().getGhost(),r_cut,pad); // Processor bounding box Box<dim, St> pbox = getDecomposition().getProcessorBounds(); @@ -568,6 +552,8 @@ public: * * \param r_cut cut-off radius * + * \return the verlet list + * */ VerletList<dim,St,FAST,shift<dim,St> > getVerletSym(St r_cut) { @@ -585,6 +571,8 @@ public: * * \param r_cut cut-off radius * + * \return a VerletList object + * */ VerletList<dim,St,FAST,shift<dim,St> > getVerlet(St r_cut) { @@ -1137,6 +1125,9 @@ public: pbox.enlarge(g); cl_param_calculate(pbox, div,r_cut,enlarge); + + // output the fixed domain + box = pbox; } /*! \brief It return the id of structure in the allocation list diff --git a/src/Vector/vector_dist_comm.hpp b/src/Vector/vector_dist_comm.hpp index 8283f30c53add880daf3656a38eb42ea86a73f89..87f1fcd4a2041e2c0deb1c3999359df5deb5d617 100644 --- a/src/Vector/vector_dist_comm.hpp +++ b/src/Vector/vector_dist_comm.hpp @@ -248,8 +248,7 @@ class vector_dist_comm // add this particle shifting its position v_pos.add(p); - v_prp.add(); - v_prp.last() = v_prp.get(key); + v_prp.get(lg_m+i) = v_prp.get(key); } } @@ -366,7 +365,11 @@ class vector_dist_comm // Create the shift boxes createShiftBox(); - lg_m = v_prp.size(); + if (opt != SKIP_LABELLING) + lg_m = v_prp.size(); + +// v_pos.resize(lg_m); +// v_prp.resize(lg_m); if (box_f.size() == 0) return; @@ -818,10 +821,13 @@ public: // send vector for each processor typedef openfpm::vector<prp_object> send_vector; + v_pos.resize(g_m); + // reset the ghost part - if (opt != NO_POSITION) - v_pos.resize(g_m); - v_prp.resize(g_m); + if (opt != SKIP_LABELLING) + { + v_prp.resize(g_m); + } // Label all the particles if ((opt & SKIP_LABELLING) == false) @@ -837,7 +843,15 @@ public: prc_recv_get.clear(); recv_sz_get.clear(); - v_cl.SSendRecvP<send_vector,decltype(v_prp),prp...>(g_send_prp,v_prp,prc_g_opart,prc_recv_get,recv_sz_get); + + if (opt == SKIP_LABELLING) + { + op_ssend_gg_recv_merge opm(g_m); +// v_cl.SSendRecvP_op<op_ssend_recv_merge<op> + v_cl.SSendRecvP_op<op_ssend_gg_recv_merge,send_vector,decltype(v_prp),prp...>(g_send_prp,v_prp,prc_g_opart,opm,prc_recv_get,recv_sz_get); + } + else + v_cl.SSendRecvP<send_vector,decltype(v_prp),prp...>(g_send_prp,v_prp,prc_g_opart,prc_recv_get,recv_sz_get); if (opt != NO_POSITION) { diff --git a/src/Vector/vector_dist_unit_test.hpp b/src/Vector/vector_dist_unit_test.hpp index ac68bea2e6b050157910d9a0a5fdc9cbeee92033..8c3c800e3d974914dfa011fed44c492824116f37 100644 --- a/src/Vector/vector_dist_unit_test.hpp +++ b/src/Vector/vector_dist_unit_test.hpp @@ -1435,12 +1435,12 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions - size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; + size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC}; // ghost Ghost<3,float> ghost(0.1); - typedef aggregate<float> part_prop; + typedef aggregate<float,float,float> part_prop; // Distributed vector vector_dist<3,float, part_prop > vd(k,box,bc,ghost); @@ -1458,6 +1458,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) // Fill some properties randomly vd.getProp<0>(key) = 0.0; + vd.getProp<1>(key) = vd.getPos(key)[0]; + vd.getProp<2>(key) = vd.getPos(key)[0]*vd.getPos(key)[0]; ++it; } @@ -1465,22 +1467,21 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) vd.map(); // sync the ghost - vd.ghost_get<0>(); - - openfpm::vector<size_t> list_idx; - openfpm::vector<size_t> list_idx2; + vd.ghost_get<0,1,2>(); - auto it3 = vd.getGhostIterator(); - while (it3.isNext()) + bool ret = true; + auto it2 = vd.getGhostIterator(); + while (it2.isNext()) { - auto key = it3.get(); + auto key = it2.get(); - list_idx.add(key.getKey()); + ret &= vd.getProp<1>(key) == vd.getPos(key)[0]; + ret &= vd.getProp<2>(key) == vd.getPos(key)[0] * vd.getPos(key)[0]; - ++it3; + ++it2; } - list_idx.sort(); + BOOST_REQUIRE_EQUAL(ret,true); for (size_t i = 0 ; i < 10 ; i++) { @@ -1490,7 +1491,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) { auto key = it.get(); - vd.getPos(key)[0] = ud(eg); vd.getPos(key)[1] = ud(eg); vd.getPos(key)[2] = ud(eg); @@ -1503,7 +1503,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) vd.ghost_get<0>(SKIP_LABELLING); - list_idx2.clear(); auto it2 = vd.getGhostIterator(); bool ret = true; @@ -1511,40 +1510,18 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) { auto key = it2.get(); - list_idx2.add(key.getKey()); ret &= vd.getProp<0>(key) == i; + ret &= vd.getProp<1>(key) == vd.getPos(key)[0]; + ret &= vd.getProp<2>(key) == vd.getPos(key)[0] * vd.getPos(key)[0]; ++it2; } - BOOST_REQUIRE_EQUAL(ret,true); - BOOST_REQUIRE_EQUAL(list_idx.size(),list_idx2.size()); - - list_idx2.sort(); - - ret = true; - for (size_t i = 0 ; i < list_idx.size() ; i++) - ret &= list_idx.get(i) == list_idx2.get(i); - BOOST_REQUIRE_EQUAL(ret,true); } vd.map(); - vd.ghost_get<0>(); - - list_idx.clear(); - - auto it4 = vd.getGhostIterator(); - while (it4.isNext()) - { - auto key = it4.get(); - - list_idx.add(key.getKey()); - - ++it4; - } - - list_idx.sort(); + vd.ghost_get<0,1,2>(); for (size_t i = 0 ; i < 10 ; i++) { @@ -1554,20 +1531,20 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) { auto key = it.get(); - vd.getPos(key)[0] = ud(eg); vd.getPos(key)[1] = ud(eg); vd.getPos(key)[2] = ud(eg); // Fill some properties randomly vd.getProp<0>(key) = i; + vd.getProp<1>(key) = vd.getPos(key)[0]; + vd.getProp<2>(key) = vd.getPos(key)[0]*vd.getPos(key)[0]; ++it; } vd.ghost_get<0>(SKIP_LABELLING); - list_idx2.clear(); auto it2 = vd.getGhostIterator(); bool ret = true; @@ -1575,21 +1552,14 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering ) { auto key = it2.get(); - list_idx2.add(key.getKey()); ret &= vd.getProp<0>(key) == i; + ret &= vd.getProp<1>(key) == vd.getPos(key)[0]; + ret &= vd.getProp<2>(key) == vd.getPos(key)[0] * vd.getPos(key)[0]; + ++it2; } - BOOST_REQUIRE_EQUAL(ret,true); - BOOST_REQUIRE_EQUAL(list_idx.size(),list_idx2.size()); - - list_idx2.sort(); - - ret = true; - for (size_t i = 0 ; i < list_idx.size() ; i++) - ret &= list_idx.get(i) == list_idx2.get(i); - BOOST_REQUIRE_EQUAL(ret,true); } } diff --git a/src/main.cpp b/src/main.cpp index d82bfd852c95a5a8526c338fe9e33cc3130a572a..c60b455f760aa5c64e8c240c5e273acc34046d6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,4 +49,5 @@ int main(int argc, char* argv[]) #include "Graph/DistGraphFactory.hpp" #include "Decomposition/nn_processor_unit_test.hpp" #include "Grid/staggered_grid_dist_unit_test.hpp" +#include "Vector/vector_dist_MP_unit_tests.hpp" //#include "antoniol_test_isolation.hpp"