diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp index 8b951df32b2e5c4d31c1bd3a820f4857c4b6aedb..9b109c73ab1e249cdb5cb965c8cf98f00242d596 100644 --- a/src/Grid/grid_dist_id.hpp +++ b/src/Grid/grid_dist_id.hpp @@ -1693,15 +1693,39 @@ public: getGlobalGridsInfo(gdb_ext_global); std::cout << "Global size: " << gdb_ext_global.size() << std::endl; - +/* for (size_t i = 0; i < gdb_ext_global.size(); i++) { - std::cout << "(" << gdb_ext_global.get(i).Dbox.getLow(0) << "; " << gdb_ext_global.get(i).Dbox.getHigh(0) << ")" << std::endl; + std::cout << "(" << gdb_ext_global.get(i).Dbox.getLow(0) << "; " << gdb_ext_global.get(i).Dbox.getLow(1) << "); (" << gdb_ext_global.get(i).Dbox.getHigh(0) << "; " << gdb_ext_global.get(i).Dbox.getHigh(1) << ")" << std::endl; std::cout << "I = " << i << ", Origin is (" << gdb_ext_global.get(i).origin.get(0) << "; " << gdb_ext_global.get(i).origin.get(1) << ")" << std::endl; } +*/ + for (size_t i = 0; i < gdb_ext.size(); i++) + { + Box<dim,long int> box = gdb_ext.get(i).Dbox; + box += gdb_ext.get(i).origin; + std::cout << "(" << box.getLow(0) << "; " << box.getLow(1) << "); (" << box.getHigh(0) << "; " << box.getHigh(1) << ")" << std::endl; + } + this->template map_(domain,dec,cd_sm,loc_grid,loc_grid_old,gdb_ext,gdb_ext_old,gdb_ext_global); } + void gdb_ext_info() + { + for (size_t i = 0; i < gdb_ext.size(); i++) + { + Box<dim,long int> box = gdb_ext.get(i).Dbox; + box += gdb_ext.get(i).origin; + std::cout << "(" << box.getLow(0) << "; " << box.getLow(1) << "); (" << box.getHigh(0) << "; " << box.getHigh(1) << ")" << std::endl; + } + std::cout << "--------------" << std::endl; + for (size_t i = 0; i < dec.getNSubDomain(); i++) + { + std::cout << "(" << dec.getSubDomain(i).getLow(0) << "; " << dec.getSubDomain(i).getLow(1) << "); (" << dec.getSubDomain(i).getHigh(0) << "; " << dec.getSubDomain(i).getHigh(1) << ")" << std::endl; + } + std::cout << "******************" << std::endl; + } + inline void save(const std::string & filename) const { diff --git a/src/Grid/grid_dist_id_HDF5_chckpnt_restart_test.hpp b/src/Grid/grid_dist_id_HDF5_chckpnt_restart_test.hpp index e5b2a7ffe084241b243895cd9ddf88205eea61e7..67379b07fa76a395da76d1745aba85e8ef56f77b 100644 --- a/src/Grid/grid_dist_id_HDF5_chckpnt_restart_test.hpp +++ b/src/Grid/grid_dist_id_HDF5_chckpnt_restart_test.hpp @@ -125,6 +125,39 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_load_test ) BOOST_REQUIRE_EQUAL(sum, (size_t)k*k); } +BOOST_AUTO_TEST_CASE( grid_gdb_test ) +{ + // Input data + size_t k = 10; + + size_t ghost_part = 0.2; + + // Domain + Box<2,float> domain({0.0,0.0},{1.0,1.0}); + + Vcluster & v_cl = create_vcluster(); + + // Skip this test on big scale + if (v_cl.getProcessingUnits() >= 32) + return; + + if (v_cl.getProcessUnitID() == 0) + std::cout << "Testing gdb_ext grid info..." << std::endl; + + // grid size + size_t sz[2]; + sz[0] = k; + sz[1] = k; + + // Ghost + Ghost<2,float> g(ghost_part); + + // Distributed grid with id decomposition + grid_dist_id<2, float, scalar<float>, CartDecomposition<2,float>> g_dist(sz,domain,g); + + g_dist.gdb_ext_info(); +} + BOOST_AUTO_TEST_SUITE_END() #endif /* SRC_GRID_GRID_DIST_ID_HDF5_CHCKPNT_RESTART_TEST_HPP_ */ diff --git a/src/Grid/grid_dist_id_comm.hpp b/src/Grid/grid_dist_id_comm.hpp index 11019ba088620e50ffd41bdda9d4c3f97affe1f8..fedb9d0ab5850ae5e93f71216091694927aed3e3 100644 --- a/src/Grid/grid_dist_id_comm.hpp +++ b/src/Grid/grid_dist_id_comm.hpp @@ -60,7 +60,7 @@ public: /*! \brief Label intersection grids for mappings * - * \param prc_sz For each processor the number of grids to send + * \param prc_sz For each processor the number of grids to send to */ inline void labelIntersectionGridsProcessor(Box<dim,St> domain, Decomposition & dec, CellDecomposer_sm<dim,St,shift<dim,St>> & cd_sm, openfpm::vector<device_grid> & loc_grid_old, openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext, openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext_old, openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext_global, openfpm::vector<openfpm::vector<device_grid>> & lbl_b, openfpm::vector<size_t> & prc_sz) { @@ -72,22 +72,27 @@ public: for (size_t i = 0; i < gdb_ext_old.size(); i++) { // Local old sub-domain - SpaceBox<dim,St> sub_dom = gdb_ext_old.get(i).Dbox; + SpaceBox<dim,long int> sub_dom = gdb_ext_old.get(i).Dbox; + sub_dom += gdb_ext_old.get(i).origin; for (size_t j = 0; j < gdb_ext_global.size(); j++) { size_t p_id = 0; // Intersection box - SpaceBox<dim,St> inte_box; + SpaceBox<dim,long int> inte_box; // Global new sub-domain - SpaceBox<dim,St> sub_dom_new = gdb_ext_global.get(j).Dbox; + SpaceBox<dim,long int> sub_dom_new = gdb_ext_global.get(j).Dbox; + sub_dom_new += gdb_ext_global.get(j).origin; bool intersect = sub_dom.Intersect(sub_dom_new, inte_box); if (intersect == true) { + + //std::cout << "Inte_box: (" << inte_box.getLow(0) << "; " << inte_box.getLow(1) << "); (" << inte_box.getHigh(0) << "; " << inte_box.getHigh(1) << ")" << std::endl; + /* // Grid to send size size_t sz1[dim]; @@ -101,30 +106,40 @@ public: Point<dim,St> p; for (size_t i = 0; i < dim; i++) p.get(i) = (inte_box.getHigh(i) + inte_box.getLow(i))/2; + + //std::cout << "Point: (" << p.get(0) << "; " << p.get(1) << ")" << std::endl; + p_id = dec.processorID(p); prc_sz.get(p_id)++; - std::cout << "P_id: " << p_id << std::endl; + //std::cout << "P_id: " << p_id << std::endl; // Convert intersection box from contiguous to discrete - SpaceBox<dim,long int> inte_box_discr = cd_sm.convertDomainSpaceIntoGridUnits(inte_box,dec.periodicity()); + //SpaceBox<dim,long int> inte_box_discr = cd_sm.convertDomainSpaceIntoGridUnits(inte_box,dec.periodicity()); - std::cout << "Beg:" << inte_box_discr.getHigh(0) << "; " << inte_box.getHigh(1) << std::endl; - std::cout << "End:" << inte_box_discr.getLow(0) << "; " << inte_box.getLow(1) << std::endl; + //std::cout << "Beg:" << inte_box_discr.getHigh(0) << "; " << inte_box.getHigh(1) << std::endl; + //std::cout << "End:" << inte_box_discr.getLow(0) << "; " << inte_box.getLow(1) << std::endl; // Transform coordinates to local - inte_box_discr -= gdb_ext.get(i).origin; + auto inte_box_local = inte_box; + + inte_box_local -= gdb_ext_global.get(j).origin; + + //std::cout << "Inte_box_local: (" << inte_box_local.getLow(0) << "; " << inte_box_local.getLow(1) << "); (" << inte_box_local.getHigh(0) << "; " << inte_box_local.getHigh(1) << ")" << std::endl; // Grid corresponding for gdb_ext_old.get(i) box device_grid gr = loc_grid_old.get(i); + for (size_t l = 0; l < dim; l++) + std::cout << "GR Size on " << l << " dimension: " << gr.getGrid().size(l) << std::endl; + // Size of the grid to send size_t sz[dim]; for (size_t l = 0; l < dim; l++) { - sz[l] = inte_box_discr.getHigh(l) - inte_box_discr.getLow(l); - //std::cout << " Size on " << l << " dimension: " << sz[l] << std::endl; + sz[l] = inte_box_local.getHigh(l) - inte_box_local.getLow(l); + std::cout << "GR_send size on " << l << " dimension: " << sz[l] << std::endl; } // Grid to send @@ -132,32 +147,34 @@ public: gr_send.setMemory(); // Sub iterator across intersection box inside local grid - grid_key_dx<dim> start = inte_box_discr.getKP1(); - grid_key_dx<dim> stop = inte_box_discr.getKP2(); + grid_key_dx<dim> start = inte_box_local.getKP1(); + grid_key_dx<dim> stop = inte_box_local.getKP2(); //std::string start2 = start.to_string(); //std::string stop2 = stop.to_string(); - auto key_it = gr.getSubIterator(start,stop); + auto it = gr.getSubIterator(start,stop); // Copy selected elements into a new sub-grid - while (key_it.isNext()) + while (it.isNext()) { - grid_key_dx<dim> key = key_it.get(); - //std::string str = key.to_string(); - //std::cout << "Key: " << str << std::endl; + auto key = it.get(); + std::string str = key.to_string(); + std::cout << "Key: " << str << std::endl; gr_send.get_o(key) = gr.get_o(key); + + //gr_send.template get<0>(key) = gr.template get<0>(key); //gr.template get<0>(key) - std::cout << "8" << std::endl; + //gr_send.set(key,gr,key); - ++key_it; + ++it; } - // Add to the labeling vector - lbl_b.get(p_id).add(gr_send); + //lbl_b.get(p_id).add(gr_send); //std::cout << "9" << std::endl; + } } }