5 #include <unordered_map> 6 #include "Grid/map_grid.hpp" 7 #include "VCluster/VCluster.hpp" 8 #include "Space/SpaceBox.hpp" 9 #include "util/mathutil.hpp" 10 #include "VTKWriter/VTKWriter.hpp" 12 #include "SparseGridGpu/SparseGridGpu.hpp" 14 #include "Iterators/grid_dist_id_iterator_dec.hpp" 15 #include "Iterators/grid_dist_id_iterator.hpp" 16 #include "Iterators/grid_dist_id_iterator_sub.hpp" 17 #include "grid_dist_key.hpp" 18 #include "NN/CellList/CellDecomposer.hpp" 19 #include "util/object_util.hpp" 20 #include "memory/ExtPreAlloc.hpp" 21 #include "Packer_Unpacker/Packer.hpp" 22 #include "Packer_Unpacker/Unpacker.hpp" 23 #include "Decomposition/CartDecomposition.hpp" 24 #include "data_type/aggregate.hpp" 26 #include "grid_dist_id_comm.hpp" 27 #include "HDF5_wr/HDF5_wr.hpp" 28 #include "SparseGrid/SparseGrid.hpp" 29 #include "lib/pdata.hpp" 31 #include "cuda/grid_dist_id_kernels.cuh" 32 #include "Grid/cuda/grid_dist_id_iterator_gpu.cuh" 38 template<
unsigned int dim>
49 template<
unsigned int dim>
62 #define NO_GDB_EXT_SWITCH 0x1000 90 template<
unsigned int dim,
142 CellDecomposer_sm<dim,St,shift<dim,St>>
cd_sm;
292 grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> * g =
static_cast<grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> *
>(ptr);
298 size_t lc_id = g->
dec.ProctoID(i);
332 sub_domain =
gdb_ext.get(sub_id).Dbox;
333 sub_domain +=
gdb_ext.get(sub_id).origin;
340 for (
size_t i = 0 ; i < dim ; i++)
347 else if (cmb.
c[i] == -1)
354 sub_domain_other_exp.
enlarge(g);
355 if (sub_domain_other_exp.
Intersect(sub_domain,ib) ==
false)
357 for (
size_t i = 0 ; i < dim ; i++)
375 auto g =
cd_sm.getGrid();
380 for (
size_t i = 0 ; i <
dec.getNNProcessors() ; i++)
383 auto&& pib =
ig_box.last();
385 pib.prc =
dec.IDtoProc(i);
386 for (
size_t j = 0 ; j <
dec.getProcessorNIGhost(i) ; j++)
392 size_t sub_id =
dec.getProcessorIGhostSub(i,j);
393 size_t r_sub =
dec.getProcessorIGhostSSub(i,j);
395 auto & n_box =
dec.getNearSubdomains(
dec.IDtoProc(i));
398 n_box.get(r_sub),
dec.getProcessorIGhostPos(i,j),
407 for (
size_t k = 0 ; k < ibv.
size() ; k++)
410 if (ibv.get(k).bx.isValid() ==
false)
418 bid_t.
g_id =
dec.getProcessorIGhostId(i,j) | (k) << 52;
420 bid_t.
sub = convert_to_gdb_ext(
dec.getProcessorIGhostSub(i,j),
425 bid_t.
cmb =
dec.getProcessorIGhostPos(i,j);
426 bid_t.
r_sub =
dec.getProcessorIGhostSSub(i,j);
444 auto g =
cd_sm.getGrid();
456 for(
size_t i = 0 ; i <
dec.getNNProcessors() ; i++)
458 for (
size_t j = 0 ; j <
ig_box.get(i).bid.
size() ; j++)
460 box_int_send.get(i).add();
461 box_int_send.get(i).last().bx =
ig_box.get(i).bid.get(j).box;
462 box_int_send.get(i).last().g_id =
ig_box.get(i).bid.get(j).g_id;
463 box_int_send.get(i).last().r_sub =
ig_box.get(i).bid.get(j).r_sub;
464 box_int_send.get(i).last().cmb =
ig_box.get(i).bid.get(j).cmb;
466 prc.add(
dec.IDtoProc(i));
469 v_cl.
SSendRecv(box_int_send,box_int_recv,prc,prc_recv,sz_recv);
476 for (
size_t i = 0 ; i < box_int_recv.
size() ; i++)
479 size_t p_id =
dec.ProctoID(prc_recv.get(i));
480 auto&& pib =
eg_box.get(p_id);
481 pib.prc = prc_recv.get(i);
483 eg_box.get(p_id).recv_pnt = 0;
484 eg_box.get(p_id).n_r_box = box_int_recv.get(i).
size();
487 for (
size_t j = 0 ; j < box_int_recv.get(i).
size() ; j++)
489 size_t vol_recv = box_int_recv.get(i).get(j).bx.getVolumeKey();
491 eg_box.get(p_id).recv_pnt += vol_recv;
492 size_t send_list_id = box_int_recv.get(i).get(j).r_sub;
518 size_t g_id = box_int_recv.get(i).get(j).g_id;
519 add_eg_box<dim>(k,box_int_recv.get(i).get(j).cmb,output,
522 box_int_recv.get(i).get(j).bx.getP1(),
525 eb_gid_list.last().eb_list.add(pib.bid.size() - 1);
534 bool no_match =
true;
539 if (pib.bid.get(eb_id).g_e_box == box_int_recv.get(i).get(j).bx)
553 if (no_match ==
true)
558 for (
size_t s = 0 ; s < dim ; s++)
559 {sz[s] = box_int_recv.get(i).get(j).bx.getHigh(s) - box_int_recv.get(i).get(j).bx.getLow(s) + 1;}
567 tmp.
GDbox = box_int_recv.get(i).get(j).bx;
568 tmp.GDbox -= tmp.GDbox.getP1();
569 tmp.origin = output.
getP1();
570 for (
size_t s = 0 ; s < dim ; s++)
573 tmp.Dbox.setLow(s,0);
574 tmp.Dbox.setHigh(s,-1);
586 size_t g_id = box_int_recv.get(i).get(j).g_id;
587 add_eg_box<dim>(
gdb_ext.
size()-1,box_int_recv.get(i).get(j).cmb,output,
590 box_int_recv.get(i).get(j).bx.getP1(),
596 eb_gid_list.last().eb_list.add(pib.bid.size() - 1);
603 size_t sub_id = pib.bid.get(fm).sub;
605 for ( ; pib_cnt < pib.bid.size() ; pib_cnt++)
607 pib.bid.get(pib_cnt).lr_e_box -=
gdb_ext.get(sub_id).origin;
618 size_t sub_id = s_sub.get(send_list_id);
622 bid_t.
cmb = box_int_recv.get(i).get(j).cmb;
623 bid_t.
cmb.sign_flip();
626 bid_t.
g_id = box_int_recv.get(i).get(j).g_id;
629 tb -=
gdb_ext.get(sub_id).origin;
654 auto g =
cd_sm.getGrid();
659 for (
size_t i = 0 ; i <
dec.getNSubDomain() ; i++)
664 for (
size_t j = 0 ; j <
dec.getLocalNIGhost(i) ; j++)
678 for (
size_t k = 0 ; k < ibv.
size() ; k++)
681 if (ibv.get(k).bx.isValid() ==
false)
685 pib.bid.last().box = ibv.get(k).bx;
687 pib.bid.last().sub_gdb_ext = convert_to_gdb_ext(i,
692 pib.bid.last().sub =
dec.getLocalIGhostSub(i,j);
695 pib.bid.last().cmb =
dec.getLocalIGhostPos(i,j);
709 size_t r_sub =
dec.getLocalIGhostSub(i,j);
719 pib.bid.last().box = ib;
720 pib.bid.last().sub =
dec.getLocalIGhostSub(i,j);
721 pib.bid.last().k.add(
dec.getLocalIGhostE(i,j));
722 pib.bid.last().cmb =
dec.getLocalIGhostPos(i,j);
723 pib.bid.last().sub_gdb_ext = i;
738 if (j == k) {
continue;}
751 pib.bid.last().box = output;
753 pib.bid.last().sub_gdb_ext = j;
754 pib.bid.last().sub = i;
757 pib.bid.last().cmb.
zero();
776 auto g =
cd_sm.getGrid();
783 for (
size_t i = 0 ; i <
dec.getNSubDomain() ; i++)
787 long int volume_linked = 0;
789 size_t le_sub =
loc_ig_box.get(i).bid.get(j).sub;
808 bool intersect_domain = bx.
Intersect(flp_i,output);
809 bool intersect_gdomain = gbx.
Intersect(flp_i,output);
812 if (intersect_domain ==
false && intersect_gdomain ==
true)
815 loc_ig_box.get(i).bid.get(j).k.add(pib.bid.size());
816 size_t s =
loc_ig_box.get(i).bid.get(j).k.last();
821 add_loc_eg_box(le_sub,
830 volume_linked += pib.bid.last().ebox.getVolumeKey();
839 size_t s =
loc_ig_box.get(i).bid.get(j).k.get(0);
840 pib.bid.resize(
dec.getLocalNEGhost(k));
843 pib.bid.get(s).sub =
dec.getLocalEGhostSub(k,s);
844 pib.bid.get(s).cmb =
loc_ig_box.get(i).bid.get(j).cmb;
845 pib.bid.get(s).cmb.sign_flip();
846 pib.bid.get(s).k = j;
847 pib.bid.get(s).initialized =
true;
848 pib.bid.get(s).sub_gdb_ext = k;
864 for (
size_t i = 0 ; i < dim ; i++)
867 {std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" distributed grids with size smaller than 2 are not supported\n";}
878 for (
size_t i = 0 ; i < dim ; i++)
881 {std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" error the simulation domain is invalid\n";}
907 for (
size_t i = 0 ; i < n_grid ; i++)
916 for (
size_t j = 0 ; j < dim ; j++)
934 cd_sm.setDimensions(cd_old,ext);
950 getCellDecomposerPar<dim>(c_g,
g_sz,bc);
965 for (
size_t i = 0 ; i < dim ; i++) {this->g_sz[i] =
g_sz[i];}
975 for (
size_t i = 0 ; i < dim ; i++)
976 {div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));}
978 if (g_dist.size(0) != 0)
980 for (
size_t i = 0 ; i < dim ; i++)
981 {div[i] = g_dist.size(i);}
986 dec.decompose(dec_options::DEC_SKIP_ICELL);
1018 for (
size_t i = 0 ; i < dim ; i++) {this->g_sz[i] =
g_sz[i];}
1060 for (
size_t i = 0 ; i < dim ; i++)
1076 this->v_sub_unit_factor = n_sub;
1079 void reset_ghost_structures()
1117 static const unsigned int dims = dim;
1150 return cd_sm.getCellBox().getHigh(i);
1172 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop>>(func);
1181 template<
unsigned int p>
1185 {
loc_grid.get(i).template setBackgroundValue<p>(bv);}
1201 {lins +=
loc_grid.get(i).size_inserted();}
1246 check_new(
this,8,GRID_DIST_EVENT,4);
1249 for (
size_t i = 0 ; i < dim ; i++)
1263 template<
typename H>
1270 check_new(
this,8,GRID_DIST_EVENT,4);
1273 size_t ext_dim[dim];
1274 for (
size_t i = 0 ; i < dim ; i++) {ext_dim[i] = g.getGridInfoVoid().size(i) + ext.
getKP1().
get(i) + ext.
getKP2().
get(i);}
1286 for (
size_t i = 0 ; i < dim ; i++)
1290 if (g.getDecomposition().periodicity(i) == NON_PERIODIC)
1292 this->domain.
setLow(i,g.getDomain().getLow(i) - ext.
getLow(i) * g.spacing(i) - g.spacing(i) / 2.0);
1293 this->domain.
setHigh(i,g.getDomain().getHigh(i) + ext.
getHigh(i) * g.spacing(i) + g.spacing(i) / 2.0);
1297 this->domain.
setLow(i,g.getDomain().getLow(i) - ext.
getLow(i) * g.spacing(i));
1298 this->domain.
setHigh(i,g.getDomain().getHigh(i) + ext.
getHigh(i) * g.spacing(i));
1317 template<
typename Decomposition2>
1319 const size_t (&
g_sz)[dim],
1325 check_new(
this,8,GRID_DIST_EVENT,4);
1348 check_new(
this,8,GRID_DIST_EVENT,4);
1393 template<
typename Decomposition2>
1426 check_new(
this,8,GRID_DIST_EVENT,4);
1482 check_new(
this,8,GRID_DIST_EVENT,4);
1509 check_new(
this,8,GRID_DIST_EVENT,4);
1552 check_new(
this,8,GRID_DIST_EVENT,4);
1563 this->use_bx_def =
true;
1574 check_valid(
this,8);
1587 check_valid(
this,8);
1600 check_valid(
this,8);
1613 check_valid(
this,8);
1626 check_valid(
this,8);
1641 check_valid(
this,8);
1643 for (
size_t i = 0 ; i < dim ; i++)
1660 check_valid(
this,8);
1666 total +=
gdb_ext.get(i).Dbox.getVolumeKey();
1680 check_valid(
this,8);
1686 total +=
gdb_ext.get(i).GDbox.getVolumeKey();
1701 check_valid(
this,8);
1714 check_valid(
this,8);
1732 v_cl.
recv(0,0,&size_r,
sizeof(
size_t));
1757 decltype(device_grid::type_of_subiterator()),
1762 check_valid(
this,8);
1771 decltype(device_grid::type_of_subiterator()),
1799 template<
typename lambda_t2>
1800 void setPoints(lambda_t2 f2)
1802 auto it = getGridIteratorGPU();
1813 template<
typename lambda_t2>
1816 auto it = getGridIteratorGPU(k1,k2);
1826 template<
typename lambda_t1,
typename lambda_t2>
1827 void addPoints(lambda_t1 f1, lambda_t2 f2)
1829 auto it = getGridIteratorGPU();
1830 it.setGPUInsertBuffer(1);
1842 template<
typename lambda_t1,
typename lambda_t2>
1845 auto it = getGridIteratorGPU(k1,k2);
1846 it.setGPUInsertBuffer(1);
1882 getGridIteratorGPU()
1920 for (
size_t i = 0; i < dim; i++)
1936 decltype(device_grid::type_of_subiterator()),FREE>
1940 check_valid(
this,8);
1949 decltype(device_grid::type_of_subiterator()),
1962 template<
unsigned int Np>
1970 check_valid(
this,8);
1992 decltype(device_grid::type_of_iterator()),
1997 check_valid(
this,8);
2000 for (
size_t i = 0 ; i < dim ; i++)
2004 decltype(device_grid::type_of_iterator()),
2027 check_valid(
this,8);
2070 check_valid(
this,8);
2083 loc_grid.get(i).removeUnusedBuffers();
2110 check_valid(
this,8);
2128 check_valid(
this,8);
2134 template<
typename ... v_reduce>
2135 void flush(flush_type
opt = flush_type::FLUSH_ON_HOST)
2156 check_valid(
this,8);
2176 -> decltype(
loc_grid.get(v1.getSub()).
template insert<p>(v1.getKey()))
2179 check_valid(
this,8);
2182 return loc_grid.get(v1.getSub()).
template insert<p>(v1.getKey());
2203 -> decltype(
loc_grid.get(v1.getSub()).
template insertFlush<p>(v1.getKey()))
2206 check_valid(
this,8);
2209 return loc_grid.get(v1.getSub()).
template insertFlush<p>(v1.getKey());
2220 template <
unsigned int p,
typename bg_key>
2222 ->
typename std::add_lvalue_reference<decltype(
loc_grid.get(v1.getSub()).
template get<p>(v1.getKey()))>::type
2225 check_valid(
this,8);
2227 return loc_grid.get(v1.getSub()).
template get<p>(v1.getKey());
2239 template <
unsigned int p,
typename bg_key>
2241 -> decltype(
loc_grid.get(v1.getSub()).
template get<p>(v1.getKey()))
2244 check_valid(
this,8);
2246 return loc_grid.get(v1.getSub()).
template get<p>(v1.getKey());
2257 template <
unsigned int p = 0>
2259 -> decltype(v1.getSub()->template get<p>(v1.getKey()))
2262 check_valid(
this,8);
2264 return v1.getSub()->template get<p>(v1.getKey());
2275 template <
unsigned int p = 0>
2279 check_valid(
this,8);
2281 return v1.getSub()->template get<p>(v1.getKey());
2292 template <
unsigned int p = 0>
2296 check_valid(
this,8);
2298 return loc_grid.get(v1.getSub()).
template get<p>(v1.getKey());
2309 template <
unsigned int p = 0>
2313 check_valid(
this,8);
2315 return loc_grid.get(v1.getSub()).
template get<p>(v1.getKey());
2326 template <
typename bg_key>
2330 check_valid(
this,8);
2334 for (
int i = 0 ; i < dim ; i++)
2349 template<
typename bg_key>
2363 template <
unsigned int p = 0,
typename bgkey>
2366 return this->
template get<p>(v1);
2377 template <
unsigned int p = 0,
typename bgkey>
2380 return this->
template get<p>(v1);
2391 check_valid(
this,8);
2424 template<
template<
typename,
typename>
class op,
int... prp>
void ghost_put()
2427 check_valid(
this,8);
2465 grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> &
copy(
grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> & g,
bool use_memcpy =
true)
2467 if (T::noPointers() ==
true && use_memcpy)
2473 long int start = gs_src.LinId(
gdb_ext.get(i).Dbox.getKP1());
2474 long int stop = gs_src.LinId(
gdb_ext.get(i).Dbox.getKP2());
2476 if (stop < start) {
continue;}
2478 void * dst = static_cast<void *>(static_cast<char *>(this->
get_loc_grid(i).getPointer()) + start*
sizeof(T));
2479 void * src = static_cast<void *>(static_cast<char *>(g.
get_loc_grid(i).getPointer()) + start*
sizeof(T));
2481 memcpy(dst,src,
sizeof(T) * (stop + 1 - start));
2499 auto Cp = it.template getStencil<0>();
2501 dst.insert_o(Cp) = src.get_o(Cp);
2523 grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> &
copy_sparse(
grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> & g,
bool use_memcpy =
true)
2545 return cd_sm.getCellBox().getP2();
2561 check_valid(
this,8);
2564 size_t sub_id = k.getSub();
2569 k_glob = k_glob +
gdb_ext.get(sub_id).origin;
2584 CellDecomposer_sm<dim, St, shift<dim,St>> cdsm;
2589 cdsm.setDimensions(
dec.getDomain(),
dec.getDistGrid().getSize(), 0);
2594 for (
size_t i = 0; i < dist.getNOwnerSubSubDomains() ; i++)
2596 dist.getSubSubDomainPos(i,p);
2597 dec.setSubSubDomainComputationCost(dist.getOwnerSubSubDomain(i) , 1 + md.resolution(p));
2600 dec.computeCommunicationAndMigrationCosts(ts);
2602 dist.setDistTol(md.distributionTol());
2609 template<
unsigned int prop_src,
unsigned int prop_dst,
unsigned int stencil_size,
unsigned int N,
typename lambda_f,
typename ... ArgsT >
2617 for (
int j = 0 ; j < dim ; j++)
2625 bool overlap = dom.
Intersect(base,inte);
2627 if (overlap ==
true)
2629 loc_grid.get(i).template conv<prop_src,prop_dst,stencil_size>(stencil,inte.
getKP1(),inte.
getKP2(),func,args...);
2638 template<
unsigned int prop_src,
unsigned int prop_dst,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2646 for (
int j = 0 ; j < dim ; j++)
2654 bool overlap = dom.
Intersect(base,inte);
2656 if (overlap ==
true)
2658 loc_grid.get(i).template conv_cross<prop_src,prop_dst,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2667 template<
unsigned int prop_src,
unsigned int prop_dst,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2675 for (
int j = 0 ; j < dim ; j++)
2683 bool overlap = dom.
Intersect(base,inte);
2685 if (overlap ==
true)
2687 loc_grid.get(i).template conv_cross_b<prop_src,prop_dst,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2696 template<
unsigned int stencil_size,
typename v_type,
typename lambda_f,
typename ... ArgsT >
2704 for (
int j = 0 ; j < dim ; j++)
2712 bool overlap = dom.
Intersect(base,inte);
2714 if (overlap ==
true)
2716 loc_grid.get(i).template conv_cross_ids<stencil_size,v_type>(inte.
getKP1(),inte.
getKP2(),func,args...);
2725 template<
unsigned int prop_src1,
unsigned int prop_src2,
unsigned int prop_dst1,
unsigned int prop_dst2,
unsigned int stencil_size,
unsigned int N,
typename lambda_f,
typename ... ArgsT >
2733 for (
int j = 0 ; j < dim ; j++)
2741 bool overlap = dom.
Intersect(base,inte);
2743 if (overlap ==
true)
2745 loc_grid.get(i).template conv2<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(stencil,inte.
getKP1(),inte.
getKP2(),func,create_vcluster().rank(),args...);
2754 template<
unsigned int prop_src1,
unsigned int prop_src2,
unsigned int prop_dst1,
unsigned int prop_dst2,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2762 for (
int j = 0 ; j < dim ; j++)
2770 bool overlap = dom.
Intersect(base,inte);
2772 if (overlap ==
true)
2774 loc_grid.get(i).template conv2<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2783 template<
unsigned int prop_src1,
unsigned int prop_dst1,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2791 for (
int j = 0 ; j < dim ; j++)
2799 bool overlap = dom.
Intersect(base,inte);
2801 if (overlap ==
true)
2803 loc_grid.get(i).template conv<prop_src1,prop_dst1,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2812 template<
unsigned int prop_src1,
unsigned int prop_src2,
unsigned int prop_dst1,
unsigned int prop_dst2,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2820 for (
int j = 0 ; j < dim ; j++)
2828 bool overlap = dom.
Intersect(base,inte);
2830 if (overlap ==
true)
2832 loc_grid.get(i).template conv2_b<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2837 template<
typename NNtype>
2838 void findNeighbours()
2850 template<
unsigned int prop_src1,
unsigned int prop_src2,
unsigned int prop_dst1,
unsigned int prop_dst2,
unsigned int stencil_size,
typename lambda_f,
typename ... ArgsT >
2858 for (
int j = 0 ; j < dim ; j++)
2866 bool overlap = dom.
Intersect(base,inte);
2868 if (overlap ==
true)
2870 loc_grid.get(i).template conv_cross2<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
2886 bool write(std::string output,
size_t opt = VTK_WRITER | FORMAT_BINARY )
2889 check_valid(
this,8);
2892 file_type ft = file_type::ASCII;
2894 if (
opt & FORMAT_BINARY)
2895 {ft = file_type::BINARY;}
2903 if (
opt & PRINT_GHOST)
2925 for (
int j = 0 ; j < dim ; j++)
2928 offset =
gdb_ext.get(i).origin;
2948 bool write_frame(std::string output,
size_t i,
size_t opt = VTK_WRITER | FORMAT_ASCII)
2951 check_valid(
this,8);
2953 file_type ft = file_type::ASCII;
2955 if (
opt & FORMAT_BINARY)
2956 ft = file_type::BINARY;
2995 gdb_ext.get(i).Dbox.getKP2());
3005 template<
unsigned int Np>
3036 return check_whoami(
this,8);
3048 size_t tot_volume = 0;
3050 std::cout <<
"-------- External Ghost boxes ---------- " << std::endl;
3054 std::cout <<
"Processor: " <<
eg_box.get(i).prc <<
" Boxes:" << std::endl;
3056 for (
size_t j = 0; j <
eg_box.get(i).bid.
size() ; j++)
3058 std::cout <<
" Box: " <<
eg_box.get(i).bid.get(j).g_e_box.toString() <<
" Id: " <<
eg_box.get(i).bid.get(j).g_id << std::endl;
3059 tot_volume +=
eg_box.get(i).bid.get(j).g_e_box.getVolumeKey();
3063 std::cout <<
"TOT volume external ghost " << tot_volume << std::endl;
3065 std::cout <<
"-------- Internal Ghost boxes ---------- " << std::endl;
3070 std::cout <<
"Processor: " <<
ig_box.get(i).prc <<
" Boxes:" << std::endl;
3072 for (
size_t j = 0 ; j <
ig_box.get(i).bid.
size() ; j++)
3074 std::cout <<
" Box: " <<
ig_box.get(i).bid.get(j).box.toString() <<
" Id: " <<
ig_box.get(i).bid.get(j).g_id << std::endl;
3075 tot_volume +=
ig_box.get(i).bid.get(j).box.getVolumeKey();
3079 std::cout <<
"TOT volume internal ghost " << tot_volume << std::endl;
3143 for(
int j = 0 ; j < dim ; j++)
3144 {p_dw.
get(j) = mvof.get(i).dw.get(j);}
3161 for(
int j = 0 ; j < dim ; j++)
3162 {p_up.
get(j) = mvof.get(i).up.get(j);}
3174 template<
typename stencil_type>
3197 T> ca(
loc_grid.get(0).getBackgroundValue(),bv);
3199 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(ca);
3201 if (!(
opt & NO_GDB_EXT_SWITCH))
3218 reset_ghost_structures();
3229 inline void save(
const std::string & filename)
const 3241 inline void load(
const std::string & filename)
3250 map(NO_GDB_EXT_SWITCH);
3262 for (
int j = 0 ; j < dim ; j++)
3267 while (it_src.isNext())
3269 auto key = it_src.get();
3272 for (
int j = 0 ; j < dim ; j++)
3273 {key_dst.
set_d(j,key.get(j) + orig.
get(j) + kp1.
get(j));}
3275 dg.insert_o(key_dst) = lg.get_o(key);
3288 template <
typename stencil = no_stencil>
3316 std::cout <<
"-- REPORT --" << std::endl;
3317 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 3318 std::cout <<
"Processor: " <<
v_cl.
rank() <<
" Time spent in packing data: " << tot_pack << std::endl;
3319 std::cout <<
"Processor: " <<
v_cl.
rank() <<
" Time spent in sending and receving data: " << tot_sendrecv << std::endl;
3320 std::cout <<
"Processor: " <<
v_cl.
rank() <<
" Time spent in merging: " << tot_merge << std::endl;
3321 std::cout <<
"Processor: " <<
v_cl.
rank() <<
" Time spent in local merging: " << tot_loc_merge << std::endl;
3324 std::cout <<
"Enable ENABLE_GRID_DIST_ID_PERF_STATS if you want to activate this feature" << std::endl;
3331 #ifdef ENABLE_GRID_DIST_ID_PERF_STATS 3337 std::cout <<
"Enable ENABLE_GRID_DIST_ID_PERF_STATS if you want to activate this feature" << std::endl;
3349 void setNumberOfInsertPerThread(
size_t n_ins)
3354 template<
typename func_t,
typename it_t,
typename ... args_t>
3355 void iterateGridGPU(it_t & it, args_t ... args)
3360 {
loc_grid.get(i).setGPUInsertBuffer(0ul,1ul);}
3362 while(it.isNextGrid())
3366 size_t i = it.getGridId();
3368 auto ite =
loc_grid.get(i).getGridGPUIterator(b.getKP1int(),b.getKP2int());
3370 loc_grid.get(i).setGPUInsertBuffer(ite.nblocks(),ite.nthrs());
3371 loc_grid.get(i).initializeGPUInsertBuffer();
3373 ite_gpu_dist<dim> itd = ite;
3375 for (
int j = 0 ; j < dim ; j++)
3377 itd.origin.set_d(j,
gdb_ext.get(i).origin.get(j));
3378 itd.start_base.set_d(j,0);
3381 CUDA_LAUNCH((grid_apply_functor),ite,
loc_grid.get(i).toKernel(),itd,func_t(),args...);
3402 bout -=
gdb_ext.get(i).origin;
3416 template<
unsigned int ... prp>
void deviceToHost()
3420 loc_grid.get(i).template deviceToHost<prp ...>();
3427 template<
unsigned int ... prp>
void hostToDevice()
3431 loc_grid.get(i).template hostToDevice<prp ...>();
3445 template<
unsigned int dim,
typename St,
typename T,
typename Memory = HeapMemory,
typename Decomposition = CartDecomposition<dim,St> >
3448 template<
unsigned int dim,
typename St,
typename T,
typename Memory = HeapMemory,
typename Decomposition = CartDecomposition<dim,St>>
3451 template<
unsigned int dim,
typename St,
typename T,
typename devg,
typename Memory = HeapMemory,
typename Decomposition = CartDecomposition<dim,St>>
3455 template<
unsigned int dim,
typename St,
typename T,
typename Memory = CudaMemory,
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
3458 template<
unsigned int dim,
typename St,
typename T,
typename Memory = CudaMemory,
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
3461 template<
unsigned int dim,
typename St,
typename T,
typename Memory = CudaMemory,
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
bool init_e_g_box
Flag that indicate if the external ghost box has been initialized.
size_t g_id
Global id of the internal ghost box.
std::unordered_map< size_t, size_t > g_id_to_external_ghost_box
auto insertFlush(const grid_dist_key_dx< dim, bg_key > &v1) -> decltype(loc_grid.get(v1.getSub()).template insertFlush< p >(v1.getKey()))
insert an element in the grid
Decomposition decomposition
Decomposition used.
openfpm::vector< size_t > recv_sz
Receiving size.
size_t g_sz[dim]
Size of the grid on each dimension.
Vcluster & v_cl
Communicator class.
openfpm::vector< Box< dim, long int > > bx_def
Set of boxes that define where the grid is defined.
void magnify_fix_P1(T mg)
Magnify the box by a factor keeping fix the point P1.
openfpm::vector< e_lbox_grid< dim > > loc_eg_box
Local external ghost boxes in grid units.
This class represent an N-dimensional box.
grid_key_dx_iterator_sub< dim, stencil_offset_compute< dim, Np >, typename device_grid::linearizer_type > get_loc_grid_iterator_stencil(size_t i, const grid_key_dx< dim >(&stencil_pnt)[Np])
Get the i sub-domain grid.
void conv2_b(grid_key_dx< dim > start, grid_key_dx< dim > stop, lambda_f func, ArgsT ... args)
apply a convolution on 2 property on GPU
bool write(std::string output, size_t opt=VTK_WRITER|FORMAT_BINARY)
Write the distributed grid information.
comb< dim > cmb
In which sector live the box.
bool use_bx_def
Indicate if we have to use bx_def to define the grid.
Point< dim, St > getSpacing()
Get the spacing on each dimension.
base_key & getKeyRef()
Get the reference key.
void construct_link_dw(self &grid_dw, openfpm::vector< offset_mv< dim >> &mvof)
construct link between current and the level down
Point< dim, long int > dw
offset to move on the lower grid (finer)
bool is_staggered() const
Indicate that this grid is not staggered.
void getGlobalGridsInfo(openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global) const
It gathers the information about local grids for all of the processors.
comb< dim > cmb
Sector position of the external ghost.
grid_dist_id(const Decomposition &dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
size_t getProcessUnitID()
Get the process unit id.
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext
Extension of each grid: Domain and ghost + domain.
const openfpm::vector< i_lbox_grid< dim > > & get_ig_box()
Get the internal ghost box.
Decomposition dec
Space Decomposition.
grid_dist_id_iterator_dec< Decomposition, true > getGridGhostIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop)
bool write_frame(std::string output, size_t i, size_t opt=VTK_WRITER|FORMAT_ASCII)
Write the distributed grid information.
static const unsigned int dims
Number of dimensions.
This class is an helper for the communication of grid_dist_id.
auto get(const grid_dist_lin_dx &v1) const -> decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))
Get the reference of the selected element.
Position of the element of dimension d in the hyper-cube of dimension dim.
void addComputationCosts(Model md=Model(), size_t ts=1)
Add the computation cost on the decomposition using a resolution function.
Distributed linearized key.
Ghost< dim, St > ghost
Ghost expansion.
void ghost_put_(Decomposition &dec, const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, openfpm::vector< std::unordered_map< size_t, size_t >> &g_id_to_internal_ghost_box)
It merge the information in the ghost with the real information.
void remove(const grid_dist_key_dx< dim, bg_key > &v1)
remove an element in the grid
size_t size() const
Return the total number of points in the grid.
__device__ __host__ size_t size() const
Return the size of the grid.
size_t sub
sub_id in which sub-domain this box live
const openfpm::vector< i_lbox_grid< dim > > & get_loc_ig_box()
Get the internal local ghost box.
bool init_local_i_g_box
Indicate if the local internal ghost box has been initialized.
void construct_link(self &grid_up, self &grid_dw)
construct link between levels
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
void removeUnusedBuffers()
Eliminate many internal temporary buffer you can use this between flushes if you get some out of memo...
openfpm::vector< device_grid > loc_grid_old
Old local grids.
grid_key_dx< dim > getGKey(const grid_dist_key_dx< dim > &k) const
Convert a g_dist_key_dx into a global key.
grid_dist_id(const grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g)
Copy constructor.
size_t opt
Receiving option.
grid_sm< dim, T > ginfo
Grid informations object.
void set_for_adjustment(size_t sub_id, const Box< dim, St > &sub_domain_other, const comb< dim > &cmb, Box< dim, long int > &ib, Ghost< dim, long int > &g)
this function is for optimization of the ghost size
grid_dist_id(const grid_dist_id< dim, St, H, typename Decomposition::base_type, Memory, grid_cpu< dim, H >> &g, const Ghost< dim, long int > &gh, Box< dim, size_t > ext)
This constructor is special, it construct an expanded grid that perfectly overlap with the previous.
base_key getKey() const
Get the key.
size_t gpu_n_insert_thread
number of insert each GPU thread does
const grid_sm< dim, void > & getGridInfoVoid() const
Get an object containing the grid informations without type.
void create_eg_box()
Create per-processor internal ghost box list in grid units.
device_grid device_grid_type
Type of device grid.
void create_local_eg_box()
Create per-processor external ghost boxes list in grid units.
void conv_cross2(grid_key_dx< 3 > start, grid_key_dx< 3 > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
Box< dim, size_t > bx
Box in global unit.
void sign_flip()
Flip the sign of the combination.
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext_global
Global gdb_ext.
auto get(const grid_dist_key_dx< dim, bg_key > &v1) const -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
Get the reference of the selected element.
__device__ __host__ index_type get(index_type i) const
Get the i index.
auto get(const grid_dist_g_dx< device_grid > &v1) -> decltype(v1.getSub() ->template get< p >(v1.getKey()))
Get the reference of the selected element.
Grid key for a distributed grid.
void check_size(const size_t(&g_sz)[dim])
Check the grid has a valid size.
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g, const periodicity< dim > &p, openfpm::vector< Box< dim, long int >> &bx_def)
It construct a grid on the full domain restricted to the set of boxes specified.
Point< dim, St > getPos(const grid_dist_key_dx< dim, bg_key > &v1)
Get the reference of the selected element.
::Box< dim, long int > box
Box.
auto insert(const grid_dist_key_dx< dim, bg_key > &v1) -> decltype(loc_grid.get(v1.getSub()).template insert< p >(v1.getKey()))
insert an element in the grid
St spacing(size_t i) const
Get the spacing of the grid in direction i.
const CellDecomposer_sm< dim, St, shift< dim, St > > & getCellDecomposer() const
Return the cell decomposer.
size_t getLocalDomainWithGhostSize() const
Get the total number of grid points with ghost for the calling processor.
comb< dim > cmb
Sector where it live the linked external ghost box.
bool send(size_t proc, size_t tag, const void *mem, size_t sz)
Send data to a processor.
void conv_cross(grid_key_dx< 3 > start, grid_key_dx< 3 > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
openfpm::vector< i_lbox_grid< dim > > loc_ig_box
Local internal ghost boxes in grid units.
void Create(openfpm::vector< Box< dim, long int >> &bx_def, const Ghost< dim, long int > &g, bool use_bx_def)
Create the grids on memory.
This class allocate, and destroy CPU memory.
void InitializeStructures(const size_t(&g_sz)[dim], openfpm::vector< Box< dim, long int >> &bx, const Ghost< dim, long int > &g, bool use_bx_def)
Initialize the grid.
Internal ghost box sent to construct external ghost box into the other processors.
Structure for stencil iterator.
void one()
Set to one the key.
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g, const periodicity< dim > &p, size_t opt=0, const grid_sm< dim, void > &g_dec=grid_sm< dim, void >())
Implementation of VCluster class.
auto getProp(const grid_dist_key_dx< dim, bgkey > &v1) const -> decltype(this->template get< p >(v1))
Get the reference of the selected element.
void conv(int(&stencil)[N][dim], grid_key_dx< 3 > start, grid_key_dx< 3 > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Point< dim, long int > up
offset to move up on an upper grid (coarse)
This structure store the Box that define the domain inside the Ghost + domain box.
void InitializeStructures(const size_t(&g_sz)[dim])
Initialize the grid.
void execute()
Execute all the requests.
This class define the domain decomposition interface.
bool write_debug(std::string output)
Write all grids indigually.
void setBackgroundValue(T &bv)
set the background value
bool init_i_g_box
Flag that indicate if the internal ghost box has been initialized.
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
device_grid d_grid
Which kind of grid the structure store.
bool init_local_e_g_box
Indicate if the local external ghost box has been initialized.
void InitializeCellDecomposer(const size_t(&g_sz)[dim], const size_t(&bc)[dim])
Initialize the Cell decomposer of the grid.
~grid_dist_id()
Destructor.
void save(const std::string &filename) const
Save the grid state on HDF5.
size_t size(size_t i) const
Return the total number of points in the grid.
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_iterator()), FIXED > getDomainGhostIterator() const
It return an iterator that span the grid domain + ghost part.
grid_dist_iterator_sub< dim, device_grid > getSubDomainIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop) const
It return an iterator that span the grid domain only in the specified part.
const openfpm::vector< std::string > & getPropNames()
Set the properties names.
Given the decomposition it create an iterator.
grid_dist_id(const Decomposition2 &dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
void conv_cross_b(grid_key_dx< 3 > start, grid_key_dx< 3 > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
grid_dist_iterator< dim, device_grid, decltype(device_grid::template type_of_subiterator< stencil_offset_compute< dim, Np >>()), FREE, stencil_offset_compute< dim, Np > > getDomainIteratorStencil(const grid_key_dx< dim >(&stencil_pnt)[Np]) const
It return an iterator that span the full grid domain (each processor span its local domain)
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
grid_dist_iterator_sub< dim, device_grid > getSubDomainIterator(const long int(&start)[dim], const long int(&stop)[dim]) const
It return an iterator that span the grid domain only in the specified part.
This class decompose a space into sub-sub-domains and distribute them across processors.
This is a distributed grid.
static Ghost< dim, St > convert_ghost(const Ghost< dim, long int > &gd, const CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm)
Convert a ghost from grid point units into continus space.
bool existPoint(const grid_dist_key_dx< dim, bg_key > &v1) const
Check if the point exist.
size_t getN_loc_grid()
Return the number of local grid.
CellDecomposer_sm< dim, St, shift< dim, St > > cd_sm
Structure that divide the space into cells.
grid_dist_id_iterator_dec< Decomposition > getGridIterator()
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
It contain the offset necessary to move to coarser and finer level grids.
Box< dim, size_t > getDomain(size_t i)
Given a local sub-domain i with a local grid Domain + ghost return the part of the local grid that is...
grid_sm< dim, void > ginfo_v
Grid informations object without type.
void flush_remove()
remove an element in the grid
it store a box, its unique id and the sub-domain from where it come from
void conv(grid_key_dx< dim > start, grid_key_dx< dim > stop, lambda_f func, ArgsT ... args)
apply a convolution on GPU
grid_dist_id_iterator_dec< Decomposition > getGridIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop)
void zero()
Set p1 and p2 to 0.
size_t rank()
Get the process unit id.
const openfpm::vector< GBoxes< device_grid::dims > > & getLocalGridsInfo()
It return the informations about the local grids.
static grid_dist_iterator_sub< dim, device_grid > type_of_subiterator()
This is a meta-function return which type of sub iterator a grid produce.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
void clear()
It delete all the points.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
const size_t(& getSize() const)[N]
Return the size of the grid as an array.
grid_dist_id(Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
openfpm::vector< e_box_multi< dim > > eb_gid_list
static void * msg_alloc_external_box(size_t msg_i, size_t total_msg, size_t total_p, size_t i, size_t ri, void *ptr)
Call-back to allocate buffer to receive incoming objects (external ghost boxes)
openfpm::vector< ip_box_grid< dim > > ig_box
Internal ghost boxes in grid units.
void conv2(grid_key_dx< dim > start, grid_key_dx< dim > stop, lambda_f func, ArgsT ... args)
apply a convolution on 2 property on GPU
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
bool recv(size_t proc, size_t tag, void *v, size_t sz)
Recv data from a processor.
void ghost_put()
It synchronize the ghost parts.
Distributed grid iterator.
size_t getProcessingUnits()
Get the total number of processors.
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_subiterator()), FREE > getDomainIterator() const
It return an iterator that span the full grid domain (each processor span its local domain)
auto get(const grid_dist_lin_dx &v1) -> decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))
Get the reference of the selected element.
It store the information about the external ghost box.
Ghost< dim, long int > ghost_int
Ghost expansion.
device_grid & get_loc_grid(size_t i)
Get the i sub-domain grid.
grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > & copy_sparse(grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g, bool use_memcpy=true)
Copy the give grid into this grid.
Box< dim, St > domain
Domain.
void conv_cross_ids(grid_key_dx< 3 > start, grid_key_dx< 3 > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &g, size_t opt=0)
bool init_fix_ie_g_box
Flag that indicate if the internal and external ghost box has been fixed.
mgpu::ofp_context_t & getmgpuContext(bool iw=true)
If nvidia cuda is activated return a mgpu context.
const Box< dim, St > getDomain() const
Get the domain where the grid is defined.
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g, size_t opt=0)
void setPropNames(const openfpm::vector< std::string > &names)
Set the properties names.
bool isValid() const
Check if the Box is a valid box P2 >= P1.
Memory memory_type
Type of Memory.
void InitializeCellDecomposer(const CellDecomposer_sm< dim, St, shift< dim, St >> &cd_old, const Box< dim, size_t > &ext)
Initialize the Cell decomposer of the grid enforcing perfect overlap of the cells.
void construct_link_up(self &grid_up, openfpm::vector< offset_mv< dim >> &mvof)
construct link between current and the level up
grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > & copy(grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g, bool use_memcpy=true)
Copy the give grid into this grid.
auto get(const grid_dist_g_dx< device_grid > &v1) const -> decltype(v1.getSub() ->template get< p >(v1.getKey()))
Get the reference of the selected element.
::Box< dim, long int > l_e_box
Box defining the external ghost box in local coordinates for gdb_ext.
void setBackgroundValue(const typename boost::mpl::at< typename T::type, boost::mpl::int_< p >>::type &bv)
set the background value
size_t getLocalDomainSize() const
Get the total number of grid points for the calling processor.
::Box< dim, long int > g_e_box
Box defining the external ghost box in global coordinates.
void remove_no_flush(const grid_dist_key_dx< dim, bg_key > &v1)
remove an element in the grid
void map_(Decomposition &dec, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm, openfpm::vector< device_grid > &loc_grid, 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)
Moves all the grids that does not belong to the local processor to the respective processor.
openfpm::vector< std::string > prp_names
properties names
size_t getSub() const
Get the local grid.
const Decomposition & getDecomposition() const
Get the object that store the information about the decomposition.
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
Declaration grid_key_dx_iterator_sub.
size_t r_sub
r_sub id of the sub-domain in the sent list
const grid_sm< dim, T > & getGridInfo() const
Get an object containing the grid informations.
auto get(const grid_dist_key_dx< dim, bg_key > &v1) -> decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))
Get the reference of the selected element.
openfpm::vector< HeapMemory > recv_mem_gg
Receiving buffer for particles ghost get.
this class is a functor for "for_each" algorithm
grid_key_dx_iterator_sub< dim, no_stencil > get_loc_grid_iterator(size_t i)
Get the i sub-domain grid.
size_t size_local_inserted() const
Return the local total number of points inserted in the grid.
size_t v_sub_unit_factor
Number of sub-sub-domain for each processor.
size_t size()
Get the total number of processors.
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
void conv2(int(&stencil)[N][dim], grid_key_dx< dim > start, grid_key_dx< dim > stop, lambda_f func, ArgsT ... args)
apply a convolution using the stencil N
void debugPrint()
It print the internal ghost boxes and external ghost boxes in global unit.
void ghost_get(size_t opt=0)
It synchronize the ghost parts.
auto getProp(const grid_dist_key_dx< dim, bgkey > &v1) -> decltype(this->template get< p >(v1))
Get the reference of the selected element.
openfpm::vector< size_t > gdb_ext_markers
void create_ig_box()
Create per-processor internal ghost boxes list in grid units and g_id_to_external_ghost_box.
Structure to copy aggregates.
grid_dist_id(Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
void ghost_get_(const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, const openfpm::vector< e_box_multi< dim >> &eb_gid_list, bool use_bx_def, openfpm::vector< device_grid > &loc_grid, const grid_sm< dim, void > &ginfo, std::unordered_map< size_t, size_t > &g_id_to_external_ghost_box, size_t opt)
It fill the ghost part of the grids.
void check_domain(const Box< dim, St > &dom)
Check the domain is valid.
Distributed grid iterator.
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &g, const periodicity< dim > &p, size_t opt=0)
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_subiterator()), FREE > getOldDomainIterator() const
It return an iterator that span the full grid domain (each processor span its local domain)
void setDecompositionGranularity(size_t n_sub)
Set the minimum number of sub-domain per processor.
openfpm::vector< ep_box_grid< dim > > eg_box
External ghost boxes in grid units.
void create_local_ig_box()
Create local internal ghost box in grid units.
openfpm::vector< device_grid > loc_grid
Local grids.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
size_t r_sub
from which sub-domain this internal ghost box is generated (or with which sub-domain is overlapping)
openfpm::vector< std::unordered_map< size_t, size_t > > g_id_to_internal_ghost_box
grid_dist_id(const Decomposition2 &dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
void load(const std::string &filename)
Reload the grid from HDF5 file.
bool isInvalidGhost()
check if the Ghost is valid
Point< dim, T > getP1() const
Get the point p1.
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
Decomposition & getDecomposition()
Get the object that store the information about the decomposition.
bool SSendRecv(openfpm::vector< T > &send, S &recv, openfpm::vector< size_t > &prc_send, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &sz_recv, size_t opt=NONE)
Semantic Send and receive, send the data to processors and receive from the other processors.
Box< dim, long int > GDbox
Ghost + Domain ghost.
void tagBoundaries()
construct link between current and the level up
long int who()
It return the id of structure in the allocation list.
char c[dim]
Array that store the combination.
void InitializeDecomposition(const size_t(&g_sz)[dim], const size_t(&bc)[dim], const grid_sm< dim, void > &g_dist=grid_sm< dim, void >())
Initialize the grid.
Point< dim, St > getOffset(size_t i)
Get the point where it start the origin of the grid of the sub-domain i.
Vcluster & getVC()
Get the Virtual Cluster machine.
bool isInside(const grid_key_dx< dim > &gk) const
Check that the global grid key is inside the grid domain.
Distributed linearized key.
void map(size_t opt=0)
It move all the grid parts that do not belong to the local processor to the respective processor.
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext_old
Extension of each old grid (old): Domain and ghost + domain.