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" 
   38template<
unsigned int dim>
 
   49template<
unsigned int dim>
 
   62#define NO_GDB_EXT_SWITCH 0x1000 
   64template<
bool is_sparse>
 
   67    template<
typename key_type1, 
typename key_type2, 
typename spg_type, 
typename lg_type>
 
   68    static void assign(key_type1 & key, key_type2 & key_dst, spg_type & dg, lg_type & lg)
 
   70        dg.insert_o(key_dst) = lg.get_o(key);
 
   73    template<
typename gdb_ext_type, 
typename loc_gr
id_type>
 
   74    static void pre_load(gdb_ext_type & gdb_ext_old, loc_grid_type & loc_grid_old, gdb_ext_type & gdb_ext, loc_grid_type & loc_grid) 
 
   79template<
typename e_src, 
typename e_dst, 
typename indexT>
 
   84    e_dst & block_data_dst;
 
  100    __device__ __host__ 
inline void operator()(T& t)
 const 
  102        block_data_dst.template get<T::value>()[local_id] = 
block_data_src.template get<T::value>();
 
  113    template<
typename this_type, 
typename dec_type, 
typename cd_sm_type, 
typename loc_gr
id_type, 
typename gdb_ext_type>
 
  114    static void call(this_type * this_,
 
  117                     loc_grid_type & loc_grid, 
 
  118                     loc_grid_type & loc_grid_old, 
 
  119                     gdb_ext_type & gdb_ext, 
 
  120                     gdb_ext_type & gdb_ext_old, 
 
  121                     gdb_ext_type & gdb_ext_global, 
 
  124        this_->template map_<prp ...>(dec,cd_sm,loc_grid,loc_grid_old,gdb_ext,gdb_ext_old,gdb_ext_global,opt);
 
  132        bool operator<(
const ids_pl & i)
 const 
  137    bool operator==(
const ids_pl & i)
 const 
  146    template<
typename key_type1, 
typename key_type2, 
typename spg_type, 
typename lg_type>
 
  147    static void assign(key_type1 & key, key_type2 & key_dst, spg_type & dg, lg_type & lg)
 
  149        typename spg_type::indexT_ local_id;
 
  150        auto block_data_dst = dg.insertBlockFlush(key_dst, local_id);
 
  151        auto block_data_src = lg.get_o(key);
 
  153        copy_all_prop_sparse<
decltype(block_data_src),
decltype(block_data_dst),
decltype(local_id)> cp(block_data_src, block_data_dst, local_id);
 
  155        boost::mpl::for_each_ref< boost::mpl::range_c<int,0,
decltype(block_data_dst)::max_prop> >(cp);
 
  160    template<
typename gdb_ext_type, 
typename loc_gr
id_type>
 
  161    static void pre_load(gdb_ext_type & gdb_ext_old, loc_grid_type & loc_grid_old, gdb_ext_type & gdb_ext, loc_grid_type & loc_grid)
 
  163        auto & dg = loc_grid.get(0);
 
  164        auto dlin = dg.getGrid();
 
  165        typedef typename std::remove_reference<
decltype(dg)>::type sparse_grid_type;
 
  170        size_t sz[sparse_grid_type::dims];
 
  172        for (
int i = 0 ; i < sparse_grid_type::dims ; i++)
 
  183            for (
int i = 0 ; i < sparse_grid_type::dims ; i++)
 
  185                k.set_d(i,key.get(i)*dlin.getBlockEgdeSize());
 
  193        for (
int i = 0 ; i < gdb_ext_old.size() ; i++)
 
  196            auto & lg = loc_grid_old.
get(i);
 
  197            auto & indexBuffer = lg.private_get_index_array();
 
  198            auto & dg = loc_grid.
get(0);
 
  200            auto slin = loc_grid_old.get(i).getGrid();
 
  205            for (
int j = 0 ; j < sparse_grid_type::dims ; j++)
 
  207                orig.
set_d(j,gdb_ext_old.get(i).origin.get(j));
 
  210                        for (
int i = 0; i < indexBuffer.size() ; i++)
 
  212                for (
int ex = 0; ex < gg.
size() ; ex++) {
 
  213                    auto key = slin.InvLinId(indexBuffer.template get<0>(i),0);
 
  216                    for (
int j = 0 ; j < sparse_grid_type::dims ; j++)
 
  217                    {key_dst.
set_d(j,key.get(j) + orig.
get(j) + kp1.
get(j) + gg.get(ex).get(j));}
 
  219                    typename sparse_grid_type::indexT_ bid;
 
  222                    dlin.LinId(key_dst,bid,
lid);
 
  233        auto & indexBuffer = dg.private_get_index_array();
 
  234        auto & dataBuffer = dg.private_get_data_array();
 
  235        indexBuffer.reserve(ids.size()+8);
 
  236        dataBuffer.reserve(ids.size()+8);
 
  237        for (
int i = 0 ; i < ids.size() ; i++) 
 
  239            auto & dg = loc_grid.get(0);
 
  240            dg.insertBlockFlush(ids.get(i).id);
 
  271template<
unsigned int dim,
 
  323    CellDecomposer_sm<dim,St,shift<dim,St>> 
cd_sm;
 
  473        grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> * g = 
static_cast<grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> *
>(ptr);
 
  479        size_t lc_id = g->
dec.ProctoID(i);
 
  513            sub_domain = 
gdb_ext.get(sub_id).Dbox;
 
  514            sub_domain += 
gdb_ext.get(sub_id).origin;
 
  521        for (
size_t i = 0 ; i < dim ; i++)
 
  528            else if (cmb.
c[i] == -1)
 
  535        sub_domain_other_exp.
enlarge(g);
 
  536        if (sub_domain_other_exp.
Intersect(sub_domain,ib) == 
false)
 
  538            for (
size_t i = 0 ; i < dim ; i++)
 
  556        auto g = 
cd_sm.getGrid();
 
  561        for (
size_t i = 0 ; i < 
dec.getNNProcessors() ; i++)
 
  564            auto&& pib = 
ig_box.last();
 
  566            pib.prc = 
dec.IDtoProc(i);
 
  567            for (
size_t j = 0 ; j < 
dec.getProcessorNIGhost(i) ; j++)
 
  573                size_t sub_id = 
dec.getProcessorIGhostSub(i,j);
 
  574                size_t r_sub = 
dec.getProcessorIGhostSSub(i,j);
 
  576                auto & n_box = 
dec.getNearSubdomains(
dec.IDtoProc(i));
 
  579                                   n_box.get(r_sub),
dec.getProcessorIGhostPos(i,j),
 
  588                for (
size_t k = 0 ; k < ibv.
size() ; k++)
 
  591                    if (ibv.get(k).bx.isValid() == 
false)
 
  599                    bid_t.
g_id = 
dec.getProcessorIGhostId(i,j) | (k) << 52;
 
  601                    bid_t.
sub = convert_to_gdb_ext(
dec.getProcessorIGhostSub(i,j),
 
  606                    bid_t.
cmb = 
dec.getProcessorIGhostPos(i,j);
 
  607                    bid_t.
r_sub = 
dec.getProcessorIGhostSSub(i,j);
 
  625        auto g = 
cd_sm.getGrid();
 
  637        for(
size_t i = 0 ; i < 
dec.getNNProcessors() ; i++)
 
  639            for (
size_t j = 0 ; j < 
ig_box.get(i).bid.
size() ; j++)
 
  641                box_int_send.get(i).add();
 
  642                box_int_send.get(i).last().bx = 
ig_box.get(i).bid.get(j).box;
 
  643                box_int_send.get(i).last().g_id = 
ig_box.get(i).bid.get(j).g_id;
 
  644                box_int_send.get(i).last().r_sub = 
ig_box.get(i).bid.get(j).r_sub;
 
  645                box_int_send.get(i).last().cmb = 
ig_box.get(i).bid.get(j).cmb;
 
  647            prc.add(
dec.IDtoProc(i));
 
  650        v_cl.
SSendRecv(box_int_send,box_int_recv,prc,prc_recv,sz_recv);
 
  657        for (
size_t i = 0 ; i < box_int_recv.
size() ; i++)
 
  660            size_t p_id = 
dec.ProctoID(prc_recv.get(i));
 
  661            auto&& pib = 
eg_box.get(p_id);
 
  662            pib.prc = prc_recv.get(i);
 
  664            eg_box.get(p_id).recv_pnt = 0;
 
  665            eg_box.get(p_id).n_r_box = box_int_recv.get(i).
size();
 
  668            for (
size_t j = 0 ; j < box_int_recv.get(i).
size() ; j++)
 
  670                size_t vol_recv = box_int_recv.get(i).get(j).bx.getVolumeKey();
 
  672                eg_box.get(p_id).recv_pnt += vol_recv;
 
  673                size_t send_list_id = box_int_recv.get(i).get(j).r_sub;
 
  699                            size_t g_id = box_int_recv.get(i).get(j).g_id;
 
  700                            add_eg_box<dim>(k,box_int_recv.get(i).get(j).cmb,output,
 
  703                                    box_int_recv.get(i).get(j).bx.getP1(),
 
  706                            eb_gid_list.last().eb_list.add(pib.bid.size() - 1);
 
  715                    bool no_match = 
true;
 
  720                        if (pib.bid.get(eb_id).g_e_box == box_int_recv.get(i).get(j).bx)
 
  734                    if (no_match == 
true)
 
  739                        for (
size_t s = 0 ; s < dim ; s++)
 
  740                        {sz[s] = box_int_recv.get(i).get(j).bx.getHigh(s) - box_int_recv.get(i).get(j).bx.getLow(s) + 1;}
 
  748                        tmp.
GDbox = box_int_recv.get(i).get(j).bx;
 
  751                        for (
size_t s = 0 ; s < dim ; s++)
 
  767                        size_t g_id = box_int_recv.get(i).get(j).g_id;
 
  768                        add_eg_box<dim>(
gdb_ext.
size()-1,box_int_recv.get(i).get(j).cmb,output,
 
  771                                box_int_recv.get(i).get(j).bx.getP1(),
 
  777                        eb_gid_list.last().eb_list.add(pib.bid.size() - 1);
 
  784                    size_t sub_id = pib.bid.get(fm).sub;
 
  786                    for ( ; pib_cnt < pib.bid.size() ; pib_cnt++)
 
  788                        pib.bid.get(pib_cnt).lr_e_box -= 
gdb_ext.get(sub_id).origin;
 
  799                    size_t sub_id = s_sub.get(send_list_id);
 
  803                    bid_t.
cmb = box_int_recv.get(i).get(j).cmb;
 
  804                    bid_t.
cmb.sign_flip();
 
  807                    bid_t.
g_id = box_int_recv.get(i).get(j).g_id;
 
  810                    tb -= 
gdb_ext.get(sub_id).origin;
 
  835        auto g = 
cd_sm.getGrid();
 
  840        for (
size_t i = 0 ; i < 
dec.getNSubDomain() ; i++)
 
  845            for (
size_t j = 0 ; j < 
dec.getLocalNIGhost(i) ; j++)
 
  859                    for (
size_t k = 0 ; k < ibv.
size() ; k++)
 
  862                        if (ibv.get(k).bx.isValid() == 
false)
 
  866                        pib.bid.last().box = ibv.get(k).bx;
 
  868                        pib.bid.last().sub_gdb_ext = convert_to_gdb_ext(i,
 
  873                        pib.bid.last().sub = 
dec.getLocalIGhostSub(i,j);
 
  876                        pib.bid.last().cmb = 
dec.getLocalIGhostPos(i,j);
 
  890                    size_t r_sub = 
dec.getLocalIGhostSub(i,j);
 
  900                    pib.bid.last().box = ib;
 
  901                    pib.bid.last().sub = 
dec.getLocalIGhostSub(i,j);
 
  902                    pib.bid.last().k.add(
dec.getLocalIGhostE(i,j));
 
  903                    pib.bid.last().cmb = 
dec.getLocalIGhostPos(i,j);
 
  904                    pib.bid.last().sub_gdb_ext = i;
 
  919                        if (j == k) {
continue;}
 
  932                            pib.bid.last().box = output;
 
  934                            pib.bid.last().sub_gdb_ext = j;
 
  935                            pib.bid.last().sub = i;
 
  938                            pib.bid.last().cmb.
zero();
 
  957        auto g = 
cd_sm.getGrid();
 
  964        for (
size_t i = 0 ; i < 
dec.getNSubDomain() ; i++)
 
  968                long int volume_linked = 0;
 
  970                size_t le_sub = 
loc_ig_box.get(i).bid.get(j).sub;
 
  989                        bool intersect_domain = bx.
Intersect(flp_i,output);
 
  990                        bool intersect_gdomain = gbx.
Intersect(flp_i,output);
 
  993                        if (intersect_domain == 
false && intersect_gdomain == 
true)
 
  996                            loc_ig_box.get(i).bid.get(j).k.add(pib.bid.size());
 
  997                            size_t s = 
loc_ig_box.get(i).bid.get(j).k.last();
 
 1002                            add_loc_eg_box(le_sub,
 
 1011                            volume_linked += pib.bid.last().ebox.getVolumeKey();
 
 1020                    size_t s = 
loc_ig_box.get(i).bid.get(j).k.get(0);
 
 1021                    pib.bid.resize(
dec.getLocalNEGhost(k));
 
 1024                    pib.bid.get(s).sub = 
dec.getLocalEGhostSub(k,s);
 
 1025                    pib.bid.get(s).cmb = 
loc_ig_box.get(i).bid.get(j).cmb;
 
 1026                    pib.bid.get(s).cmb.sign_flip();
 
 1027                    pib.bid.get(s).k = j;
 
 1028                    pib.bid.get(s).initialized = 
true;
 
 1029                    pib.bid.get(s).sub_gdb_ext = k;
 
 1045        for (
size_t i = 0 ; i < dim ; i++)
 
 1048            {std::cerr << 
"Error: " << __FILE__ << 
":" << __LINE__ << 
" distributed grids with size smaller than 2 are not supported\n";}
 
 1059        for (
size_t i = 0 ; i < dim ; i++)
 
 1062            {std::cerr << 
"Error: " << __FILE__ << 
":" << __LINE__ << 
" error the simulation domain is invalid\n";}
 
 1088        for (
size_t i = 0 ; i < n_grid ; i++)
 
 1097            for (
size_t j = 0 ; j < dim ; j++)
 
 1115        cd_sm.setDimensions(cd_old,ext);
 
 1131        getCellDecomposerPar<dim>(c_g,
g_sz,bc);
 
 1146        for (
size_t i = 0 ; i < dim ; i++)  {this->g_sz[i] = 
g_sz[i];}
 
 1156        for (
size_t i = 0 ; i < dim ; i++)
 
 1157        {div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));}
 
 1159        if (g_dist.size(0) != 0)
 
 1161            for (
size_t i = 0 ; i < dim ; i++)
 
 1162            {div[i] = g_dist.size(i);}
 
 1167        dec.decompose(dec_options::DEC_SKIP_ICELL);
 
 1199        for (
size_t i = 0 ; i < dim ; i++)  {this->g_sz[i] = 
g_sz[i];}
 
 1241        for (
size_t i = 0 ; i < dim ; i++)
 
 1257        this->v_sub_unit_factor = n_sub;
 
 1260    void reset_ghost_structures()
 
 1298    static const unsigned int dims = dim;
 
 1331        return cd_sm.getCellBox().getHigh(i);
 
 1353        boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop>>(func);
 
 1362    template<
unsigned int p>
 
 1366        {
loc_grid.get(i).template setBackgroundValue<p>(bv);}
 
 1382        {lins += 
loc_grid.get(i).size_inserted();}
 
 1427        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1430        for (
size_t i = 0 ; i < dim ; i++)
 
 1444    template<
typename H>
 
 1451        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1454        size_t ext_dim[dim];
 
 1455        for (
size_t i = 0 ; i < dim ; i++) {ext_dim[i] = g.getGridInfoVoid().size(i) + ext.
getKP1().
get(i) + ext.
getKP2().
get(i);}
 
 1467        for (
size_t i = 0 ; i < dim ; i++)
 
 1471            if (g.getDecomposition().periodicity(i) == NON_PERIODIC)
 
 1473                this->domain.
setLow(i,g.getDomain().getLow(i) - ext.
getLow(i) * g.spacing(i) - g.spacing(i) / 2.0);
 
 1474                this->domain.
setHigh(i,g.getDomain().getHigh(i) + ext.
getHigh(i) * g.spacing(i) + g.spacing(i) / 2.0);
 
 1478                this->domain.
setLow(i,g.getDomain().getLow(i) - ext.
getLow(i) * g.spacing(i));
 
 1479                this->domain.
setHigh(i,g.getDomain().getHigh(i) + ext.
getHigh(i) * g.spacing(i));
 
 1483        dec.setParameters(g.getDecomposition(),
ghost,this->domain);
 
 1498    template<
typename Decomposition2>
 
 1500                 const size_t (& 
g_sz)[dim],
 
 1506        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1529        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1574    template<
typename Decomposition2>
 
 1607        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1663        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1690        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1733        check_new(
this,8,GRID_DIST_EVENT,4);
 
 1744        this->use_bx_def = 
true;
 
 1755        check_valid(
this,8);
 
 1768        check_valid(
this,8);
 
 1781        check_valid(
this,8);
 
 1794        check_valid(
this,8);
 
 1807        check_valid(
this,8);
 
 1822        check_valid(
this,8);
 
 1824        for (
size_t i = 0 ; i < dim ; i++)
 
 1826            if (gk.
get(i) < 0 || gk.
get(i) >= (
long int)
g_sz[i])
 
 1841        check_valid(
this,8);
 
 1847            total += 
gdb_ext.get(i).Dbox.getVolumeKey();
 
 1861        check_valid(
this,8);
 
 1867            total += 
gdb_ext.get(i).GDbox.getVolumeKey();
 
 1882        check_valid(
this,8);
 
 1895        check_valid(
this,8);
 
 1913            v_cl.
recv(0,0,&size_r,
sizeof(
size_t));
 
 1938                       decltype(device_grid::type_of_subiterator()),
 
 1943        check_valid(
this,8);
 
 1952                            decltype(device_grid::type_of_subiterator()),
 
 1980    template<
typename lambda_t2>
 
 1981    void setPoints(lambda_t2 f2)
 
 1983        auto it = getGridIteratorGPU();
 
 1994    template<
typename lambda_t2>
 
 1997        auto it = getGridIteratorGPU(k1,k2);
 
 2007    template<
typename lambda_t1, 
typename lambda_t2>
 
 2008    void addPoints(lambda_t1 f1, lambda_t2 f2)
 
 2010        auto it = getGridIteratorGPU();
 
 2011        it.setGPUInsertBuffer(1);
 
 2023    template<
typename lambda_t1, 
typename lambda_t2>
 
 2026        auto it = getGridIteratorGPU(k1,k2);
 
 2027        it.setGPUInsertBuffer(1);
 
 2063    getGridIteratorGPU()
 
 2101        for (
size_t i = 0; i < dim; i++)
 
 2117                       decltype(device_grid::type_of_subiterator()),FREE>
 
 2121        check_valid(
this,8);
 
 2130                            decltype(device_grid::type_of_subiterator()),
 
 2143    template<
unsigned int Np>
 
 2145                        decltype(device_grid::template type_of_subiterator<stencil_offset_compute<dim,Np>>()),
 
 2151        check_valid(
this,8);
 
 2160                           decltype(device_grid::template type_of_subiterator<stencil_offset_compute<dim,Np>>()),
 
 2173    decltype(device_grid::type_of_iterator()),
 
 2178        check_valid(
this,8);
 
 2181        for (
size_t i = 0 ; i < dim ; i++)
 
 2185                            decltype(device_grid::type_of_iterator()),
 
 2208        check_valid(
this,8);
 
 2251        check_valid(
this,8);
 
 2264            loc_grid.get(i).removeUnusedBuffers();
 
 2291        check_valid(
this,8);
 
 2309        check_valid(
this,8);
 
 2315    template<
typename ... v_reduce>
 
 2316    void flush(flush_type 
opt = flush_type::FLUSH_ON_HOST)
 
 2337        check_valid(
this,8);
 
 2357    -> 
decltype(
loc_grid.get(v1.getSub()).template insert<p>(v1.getKey()))
 
 2360        check_valid(
this,8);
 
 2363        return loc_grid.get(v1.getSub()).template insert<p>(v1.getKey());
 
 2384    -> 
decltype(
loc_grid.get(v1.getSub()).template insertFlush<p>(v1.getKey()))
 
 2387        check_valid(
this,8);
 
 2390        return loc_grid.get(v1.getSub()).template insertFlush<p>(v1.getKey());
 
 2413        check_valid(
this,8);
 
 2427    template <
unsigned int p, 
typename bg_key>
 
 2429    -> 
typename std::add_lvalue_reference<
decltype(
loc_grid.get(v1.getSub()).template get<p>(v1.getKey()))>::type
 
 2432        check_valid(
this,8);
 
 2434        return loc_grid.get(v1.getSub()).template get<p>(v1.getKey());
 
 2446    template <
unsigned int p, 
typename bg_key>
 
 2448    -> 
decltype(
loc_grid.get(v1.getSub()).template get<p>(v1.getKey()))
 
 2451        check_valid(
this,8);
 
 2453        return loc_grid.get(v1.getSub()).template get<p>(v1.getKey());
 
 2464    template <
unsigned int p = 0>
 
 2466    -> 
decltype(v1.getSub()->template get<p>(v1.getKey()))
 
 2469        check_valid(
this,8);
 
 2471        return v1.getSub()->template get<p>(v1.getKey());
 
 2482    template <
unsigned int p = 0>
 
 2486        check_valid(
this,8);
 
 2488        return v1.getSub()->template get<p>(v1.getKey());
 
 2499    template <
unsigned int p = 0>
 
 2503        check_valid(
this,8);
 
 2505        return loc_grid.get(v1.getSub()).template get<p>(v1.getKey());
 
 2516    template <
unsigned int p = 0>
 
 2520        check_valid(
this,8);
 
 2522        return loc_grid.get(v1.getSub()).template get<p>(v1.getKey());
 
 2533    template <
typename bg_key>
 
 2537        check_valid(
this,8);
 
 2541        for (
int i = 0 ; i < dim ; i++)
 
 2556    template<
typename bg_key>
 
 2570    template <
unsigned int p = 0, 
typename bgkey>
 
 2573        return this->
template get<p>(v1);
 
 2584    template <
unsigned int p = 0, 
typename bgkey>
 
 2587        return this->
template get<p>(v1);
 
 2598        check_valid(
this,8);
 
 2631    template<
template<
typename,
typename> 
class op,
int... prp> 
void ghost_put()
 
 2634        check_valid(
this,8);
 
 2672    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)
 
 2674        if (T::noPointers() == 
true && use_memcpy)
 
 2680                long int start = gs_src.LinId(
gdb_ext.get(i).Dbox.getKP1());
 
 2681                long int stop = gs_src.LinId(
gdb_ext.get(i).Dbox.getKP2());
 
 2683                if (stop < start) {
continue;}
 
 2685                void * dst = 
static_cast<void *
>(
static_cast<char *
>(this->
get_loc_grid(i).getPointer()) + start*
sizeof(T));
 
 2686                void * src = 
static_cast<void *
>(
static_cast<char *
>(g.
get_loc_grid(i).getPointer()) + start*
sizeof(T));
 
 2688                memcpy(dst,src,
sizeof(T) * (stop + 1 - start));
 
 2706                    auto Cp = it.template getStencil<0>();
 
 2708                    dst.insert_o(Cp) = src.get_o(Cp);
 
 2730    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)
 
 2752        return cd_sm.getCellBox().getP2();
 
 2768        check_valid(
this,8);
 
 2771        size_t sub_id = k.getSub();
 
 2776        k_glob = k_glob + 
gdb_ext.get(sub_id).origin;
 
 2791        CellDecomposer_sm<dim, St, shift<dim,St>> cdsm;
 
 2796        cdsm.setDimensions(
dec.getDomain(), 
dec.getDistGrid().getSize(), 0);
 
 2801        for (
size_t i = 0; i < dist.getNOwnerSubSubDomains() ; i++)
 
 2803            dist.getSubSubDomainPos(i,p);
 
 2804            dec.setSubSubDomainComputationCost(dist.getOwnerSubSubDomain(i) , 1 + md.resolution(p));
 
 2807        dec.computeCommunicationAndMigrationCosts(ts);
 
 2809        dist.setDistTol(md.distributionTol());
 
 2816    template<
unsigned int prop_src, 
unsigned int prop_dst, 
unsigned int stencil_size, 
unsigned int N, 
typename lambda_f, 
typename ... ArgsT >
 
 2824            for (
int j = 0 ; j < dim ; j++)
 
 2826                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2832            bool overlap = dom.
Intersect(base,inte);
 
 2834            if (overlap == 
true)
 
 2836                loc_grid.get(i).template conv<prop_src,prop_dst,stencil_size>(stencil,inte.
getKP1(),inte.
getKP2(),func,args...);
 
 2845    template<
unsigned int prop_src, 
unsigned int prop_dst, 
unsigned int stencil_size, 
typename lambda_f, 
typename ... ArgsT >
 
 2853            for (
int j = 0 ; j < dim ; j++)
 
 2855                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2861            bool overlap = dom.
Intersect(base,inte);
 
 2863            if (overlap == 
true)
 
 2865                loc_grid.get(i).template conv_cross<prop_src,prop_dst,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 2874    template<
unsigned int prop_src, 
unsigned int prop_dst, 
unsigned int stencil_size, 
typename lambda_f, 
typename ... ArgsT >
 
 2882            for (
int j = 0 ; j < dim ; j++)
 
 2884                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2890            bool overlap = dom.
Intersect(base,inte);
 
 2892            if (overlap == 
true)
 
 2894                loc_grid.get(i).template conv_cross_b<prop_src,prop_dst,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 2903    template<
unsigned int stencil_size, 
typename v_type, 
typename lambda_f, 
typename ... ArgsT >
 
 2911            for (
int j = 0 ; j < dim ; j++)
 
 2913                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2919            bool overlap = dom.
Intersect(base,inte);
 
 2921            if (overlap == 
true)
 
 2923                loc_grid.get(i).template conv_cross_ids<stencil_size,v_type>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 2932    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 >
 
 2940            for (
int j = 0 ; j < dim ; j++)
 
 2942                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2948            bool overlap = dom.
Intersect(base,inte);
 
 2950            if (overlap == 
true)
 
 2952                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...);
 
 2961    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 >
 
 2969            for (
int j = 0 ; j < dim ; j++)
 
 2971                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 2977            bool overlap = dom.
Intersect(base,inte);
 
 2979            if (overlap == 
true)
 
 2981                loc_grid.get(i).template conv2<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 2990    template<
unsigned int prop_src1, 
unsigned int prop_dst1, 
unsigned int stencil_size, 
typename lambda_f, 
typename ... ArgsT >
 
 2998            for (
int j = 0 ; j < dim ; j++)
 
 3000                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 3006            bool overlap = dom.
Intersect(base,inte);
 
 3008            if (overlap == 
true)
 
 3010                loc_grid.get(i).template conv<prop_src1,prop_dst1,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 3019    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 >
 
 3027            for (
int j = 0 ; j < dim ; j++)
 
 3029                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 3035            bool overlap = dom.
Intersect(base,inte);
 
 3037            if (overlap == 
true)
 
 3039                loc_grid.get(i).template conv2_b<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 3048    template<
unsigned int prop_src1, 
unsigned int prop_src2, 
unsigned int prop_src3, 
 
 3049             unsigned int prop_dst1, 
unsigned int prop_dst2, 
unsigned int prop_dst3, 
 
 3050             unsigned int stencil_size, 
typename lambda_f, 
typename ... ArgsT >
 
 3058            for (
int j = 0 ; j < dim ; j++)
 
 3060                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 3066            bool overlap = dom.
Intersect(base,inte);
 
 3068            if (overlap == 
true)
 
 3070                loc_grid.get(i).template conv3_b<prop_src1,prop_src2,prop_src3,prop_dst1,prop_dst2,prop_dst3,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 3075    template<
typename NNtype>
 
 3076    void findNeighbours()
 
 3088    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 >
 
 3096            for (
int j = 0 ; j < dim ; j++)
 
 3098                base.
setLow(j,(
long int)start.
get(j) - (
long int)
gdb_ext.get(i).origin.get(j));
 
 3104            bool overlap = dom.
Intersect(base,inte);
 
 3106            if (overlap == 
true)
 
 3108                loc_grid.get(i).template conv_cross2<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.
getKP1(),inte.
getKP2(),func,args...);
 
 3124    bool write(std::string output, 
size_t opt = VTK_WRITER | FORMAT_BINARY )
 
 3127        check_valid(
this,8);
 
 3130        file_type ft = file_type::ASCII;
 
 3132        if (
opt & FORMAT_BINARY)
 
 3133        {ft = file_type::BINARY;}
 
 3141            if (
opt & PRINT_GHOST)
 
 3163            for (
int j = 0 ; j < dim ; j++)
 
 3166            offset = 
gdb_ext.get(i).origin;
 
 3186    bool write_frame(std::string output, 
size_t i, 
size_t opt = VTK_WRITER | FORMAT_ASCII)
 
 3189        check_valid(
this,8);
 
 3191        file_type ft = file_type::ASCII;
 
 3193        if (
opt & FORMAT_BINARY)
 
 3194            ft = file_type::BINARY;
 
 3245                 gdb_ext.get(i).Dbox.getKP2());
 
 3255    template<
unsigned int Np>
 
 3286        return check_whoami(
this,8);
 
 3298        size_t tot_volume = 0;
 
 3300        std::cout << 
"-------- External Ghost boxes ---------- " << std::endl;
 
 3304            std::cout << 
"Processor: " << 
eg_box.get(i).prc << 
" Boxes:" << std::endl;
 
 3306            for (
size_t j = 0; j < 
eg_box.get(i).bid.
size() ; j++)
 
 3308                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;
 
 3309                tot_volume += 
eg_box.get(i).bid.get(j).g_e_box.getVolumeKey();
 
 3313        std::cout << 
"TOT volume external ghost " << tot_volume << std::endl;
 
 3315        std::cout << 
"-------- Internal Ghost boxes ---------- " << std::endl;
 
 3320            std::cout << 
"Processor: " << 
ig_box.get(i).prc << 
" Boxes:" << std::endl;
 
 3322            for (
size_t j = 0 ; j < 
ig_box.get(i).bid.
size() ; j++)
 
 3324                std::cout << 
" Box: " << 
ig_box.get(i).bid.get(j).box.toString() << 
"   Id: " << 
ig_box.get(i).bid.get(j).g_id << std::endl;
 
 3325                tot_volume += 
ig_box.get(i).bid.get(j).box.getVolumeKey();
 
 3329        std::cout << 
"TOT volume internal ghost " << tot_volume << std::endl;
 
 3393            for(
int j = 0 ; j < dim ; j++)
 
 3394            {p_dw.
get(j) = mvof.get(i).dw.get(j);}
 
 3411            for(
int j = 0 ; j < dim ; j++)
 
 3412            {p_up.
get(j) = mvof.get(i).up.get(j);}
 
 3424    template<
typename stencil_type>
 
 3447                            T> ca(
loc_grid.get(0).getBackgroundValue(),bv);
 
 3449        boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(ca);
 
 3451        if (!(
opt & NO_GDB_EXT_SWITCH))
 
 3471        reset_ghost_structures();
 
 3482    inline void save(
const std::string & filename)
 const 
 3494    inline void load(
const std::string & filename)
 
 3506            size_t opt_ = NO_GDB_EXT_SWITCH;
 
 3507            if (std::is_same<Memory,CudaMemory>::value == 
true)
 
 3508            {opt_ |= RUN_ON_DEVICE;}
 
 3522                    for (
int j = 0 ; j < dim ; j++)
 
 3527                    while (it_src.isNext())
 
 3529                        auto key = it_src.get();
 
 3532                        for (
int j = 0 ; j < dim ; j++)
 
 3533                        {key_dst.
set_d(j,key.get(j) + orig.
get(j) + kp1.
get(j));}
 
 3540                    dg.template hostToDevice<0>();
 
 3550    template <
typename stencil = no_stencil>
 
 3578        std::cout << 
"-- REPORT --" << std::endl;
 
 3579#ifdef ENABLE_GRID_DIST_ID_PERF_STATS 
 3580        std::cout << 
"Processor: " << 
v_cl.
rank() << 
" Time spent in packing data: " << tot_pack << std::endl;
 
 3581        std::cout << 
"Processor: " << 
v_cl.
rank() << 
" Time spent in sending and receving data: " << tot_sendrecv << std::endl;
 
 3582        std::cout << 
"Processor: " << 
v_cl.
rank() << 
" Time spent in merging: " << tot_merge << std::endl;
 
 3583        std::cout << 
"Processor: " << 
v_cl.
rank() << 
" Time spent in local merging: " << tot_loc_merge << std::endl;
 
 3586        std::cout << 
"Enable ENABLE_GRID_DIST_ID_PERF_STATS if you want to activate this feature" << std::endl;
 
 3593#ifdef ENABLE_GRID_DIST_ID_PERF_STATS 
 3599        std::cout << 
"Enable ENABLE_GRID_DIST_ID_PERF_STATS if you want to activate this feature" << std::endl;
 
 3611    void setNumberOfInsertPerThread(
size_t n_ins)
 
 3616    template<
typename func_t,
typename it_t, 
typename ... args_t>
 
 3617    void iterateGridGPU(it_t & it, args_t ... args)
 
 3622        {
loc_grid.get(i).setGPUInsertBuffer(0ul,1ul);}
 
 3624        while(it.isNextGrid())
 
 3628            size_t i = it.getGridId();
 
 3630            auto ite = 
loc_grid.get(i).getGridGPUIterator(b.getKP1int(),b.getKP2int());
 
 3632            loc_grid.get(i).setGPUInsertBuffer(ite.nblocks(),ite.nthrs());
 
 3633            loc_grid.get(i).initializeGPUInsertBuffer();
 
 3635            ite_gpu_dist<dim> itd = ite;
 
 3637            for (
int j = 0 ; j < dim ; j++)
 
 3639                itd.origin.set_d(j,
gdb_ext.get(i).origin.get(j));
 
 3640                itd.start_base.set_d(j,0);
 
 3643            CUDA_LAUNCH((grid_apply_functor),ite,
loc_grid.get(i).toKernel(),itd,func_t(),args...);
 
 3664            bout -= 
gdb_ext.get(i).origin;
 
 3678    template<
unsigned int ... prp> 
void deviceToHost()
 
 3682            loc_grid.get(i).template deviceToHost<prp ...>();
 
 3689    template<
unsigned int ... prp> 
void hostToDevice()
 
 3693            loc_grid.get(i).template hostToDevice<prp ...>();
 
 3707template<
unsigned int dim, 
typename St, 
typename T, 
typename Memory = HeapMemory, 
typename Decomposition = CartDecomposition<dim,St> >
 
 3710template<
unsigned int dim, 
typename St, 
typename T, 
typename Memory = HeapMemory, 
typename Decomposition = CartDecomposition<dim,St>>
 
 3713template<
unsigned int dim, 
typename St, 
typename T, 
typename devg, 
typename Memory = HeapMemory, 
typename Decomposition = CartDecomposition<dim,St>>
 
 3717template<
unsigned int dim, 
typename St, 
typename T, 
typename Memory = CudaMemory, 
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
 
 3720template<
unsigned int dim, 
typename St, 
typename T, 
typename Memory = CudaMemory, 
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
 
 3723template<
unsigned int dim, 
typename St, 
typename T, 
typename Memory = CudaMemory, 
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_
inte> >
 
This class represent an N-dimensional box.
 
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
 
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
 
void zero()
Set p1 and p2 to 0.
 
__device__ __host__ T getHigh(int i) const
get the high interval of the box
 
void magnify_fix_P1(T mg)
Magnify the box by a factor keeping fix the point P1.
 
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
 
bool isValid() const
Check if the Box is a valid box P2 >= P1.
 
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
 
Point< dim, T > getP1() const
Get the point p1.
 
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
 
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
 
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
 
This class decompose a space into sub-sub-domains and distribute them across processors.
 
This class define the domain decomposition interface.
 
bool isInvalidGhost()
check if the Ghost is valid
 
This class allocate, and destroy CPU memory.
 
This class implement the point shape in an N-dimensional space.
 
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
 
This class represent an N-dimensional box.
 
void execute()
Execute all the requests.
 
size_t rank()
Get the process unit id.
 
size_t size()
Get the total number of processors.
 
size_t getProcessUnitID()
Get the process unit id.
 
size_t getProcessingUnits()
Get the total number of processors.
 
gpu::ofp_context_t & getgpuContext(bool iw=true)
If nvidia cuda is activated return a gpu context.
 
bool recv(size_t proc, size_t tag, void *v, size_t sz)
Recv data from a processor.
 
bool send(size_t proc, size_t tag, const void *mem, size_t sz)
Send data to a processor.
 
Implementation of VCluster class.
 
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
 
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.
 
Distributed linearized key.
 
This class is an helper for the communication of grid_dist_id.
 
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 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.
 
size_t opt
Receiving option.
 
Given the decomposition it create an iterator.
 
Given the decomposition it create an iterator.
 
This is a distributed grid.
 
const grid_sm< dim, void > & getGridInfoVoid() const
Get an object containing the grid informations without type.
 
Decomposition & getDecomposition()
Get the object that store the information about the decomposition.
 
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
 
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.
 
openfpm::vector< std::string > prp_names
properties names
 
const openfpm::vector< GBoxes< device_grid::dims > > & getLocalGridsInfo() const
It return the informations about the local grids.
 
void setBackgroundValue(T &bv)
set the background value
 
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.
 
grid_sm< dim, void > ginfo_v
Grid informations object without type.
 
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
 
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.
 
bool init_e_g_box
Flag that indicate if the external ghost box has been initialized.
 
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)
 
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.
 
grid_sm< dim, T > ginfo
Grid informations object.
 
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
 
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
 
grid_key_dx_iterator_sub< dim, no_stencil > get_loc_grid_iterator(size_t i)
Get the i sub-domain grid.
 
void removeUnusedBuffers()
Eliminate many internal temporary buffer you can use this between flushes if you get some out of memo...
 
openfpm::vector< ip_box_grid< dim > > ig_box
Internal ghost boxes in grid units.
 
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &g, size_t opt=0)
 
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.
 
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)
 
void map(size_t opt=0)
It move all the grid parts that do not belong to the local processor to the respective processor.
 
grid_dist_id(Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
 
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.
 
const Decomposition & getDecomposition() const
Get the object that store the information about the decomposition.
 
grid_dist_id(const Decomposition &dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
 
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.
 
Memory memory_type
Type of Memory.
 
device_grid d_grid
Which kind of grid the structure store.
 
openfpm::vector< size_t > gdb_ext_markers
 
const grid_sm< dim, T > & getGridInfo() const
Get an object containing the grid informations.
 
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)
 
Box< dim, St > domain
Domain.
 
size_t getLocalDomainSize() const
Get the total number of grid points for the calling processor.
 
openfpm::vector< e_lbox_grid< dim > > loc_eg_box
Local external ghost boxes in grid units.
 
Point< dim, St > getOffset(size_t i)
Get the point where it start the origin of the grid of the sub-domain i.
 
void flush_remove()
remove an element in the 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 init_i_g_box
Flag that indicate if the internal ghost box has been initialized.
 
const Box< dim, St > getDomain() const
Get the domain where the grid is defined.
 
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
 
device_grid & get_loc_grid(size_t i)
Get the i sub-domain grid.
 
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
 
void ghost_get(size_t opt=0)
It synchronize the ghost parts.
 
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 >())
 
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, 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.
 
void getGlobalGridsInfo(openfpm::vector< GBoxes< device_grid::dims > > &gdb_ext_global) const
It gathers the information about local grids for all of the processors.
 
Decomposition dec
Space Decomposition.
 
openfpm::vector< e_box_multi< dim > > eb_gid_list
 
device_grid device_grid_type
Type of device grid.
 
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.
 
void construct_link_up(self &grid_up, openfpm::vector< offset_mv< dim > > &mvof)
construct link between current and the level up
 
void create_ig_box()
Create per-processor internal ghost boxes list in grid units and g_id_to_external_ghost_box.
 
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext
Extension of each grid: Domain and ghost + domain.
 
Ghost< dim, long int > ghost_int
Ghost expansion.
 
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.
 
size_t size(size_t i) const
Return the total number of points in the grid.
 
auto getProp(const grid_dist_key_dx< dim, bgkey > &v1) const -> decltype(this->template get< p >(v1))
Get the reference of the selected element.
 
size_t g_sz[dim]
Size of the grid on each dimension.
 
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_key_dx< dim > getGKey(const grid_dist_key_dx< dim > &k) const
Convert a g_dist_key_dx into a global key.
 
void setDecompositionGranularity(size_t n_sub)
Set the minimum number of sub-domain per processor.
 
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< i_lbox_grid< dim > > & get_loc_ig_box()
Get the internal local ghost box.
 
void clear()
It delete all the points.
 
void construct_link_dw(self &grid_dw, openfpm::vector< offset_mv< dim > > &mvof)
construct link between current and the level down
 
grid_dist_id_iterator_dec< Decomposition > getGridIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop)
 
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(const grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g)
Copy constructor.
 
void tagBoundaries()
construct link between current and the level up
 
bool existPoint(const grid_dist_key_dx< dim, bg_key > &v1) const
Check if the point exist.
 
const openfpm::vector< std::string > & getPropNames()
Set the properties names.
 
size_t size() const
Return the total number of points in the grid.
 
Point< dim, St > getPos(const grid_dist_key_dx< dim, bg_key > &v1)
Get the reference of the selected element.
 
~grid_dist_id()
Destructor.
 
void addComputationCosts(Model md=Model(), size_t ts=1)
Add the computation cost on the decomposition using a resolution function.
 
const openfpm::vector< i_lbox_grid< dim > > & get_ig_box()
Get the internal ghost box.
 
auto getProp(const grid_dist_key_dx< dim, bgkey > &v1) -> decltype(this->template get< p >(v1))
Get the reference of the selected element.
 
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.
 
St spacing(size_t i) const
Get the spacing of the grid in direction i.
 
bool write(std::string output, size_t opt=VTK_WRITER|FORMAT_BINARY)
Write the distributed grid information.
 
bool use_bx_def
Indicate if we have to use bx_def to define the grid.
 
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)
 
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.
 
Vcluster & v_cl
Communicator class.
 
openfpm::vector< i_lbox_grid< dim > > loc_ig_box
Local internal ghost boxes in grid units.
 
grid_dist_id_iterator_dec< Decomposition > getGridIterator()
 
void ghost_put()
It synchronize the ghost parts.
 
size_t getLocalDomainWithGhostSize() const
Get the total number of grid points with ghost for the calling processor.
 
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.
 
const CellDecomposer_sm< dim, St, shift< dim, St > > & getCellDecomposer() const
Return the cell decomposer.
 
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.
 
grid_dist_id(Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
 
void create_local_eg_box()
Create per-processor external ghost boxes list in grid units.
 
Ghost< dim, St > ghost
Ghost expansion.
 
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.
 
void setBackgroundValue(const typename boost::mpl::at< typename T::type, boost::mpl::int_< p > >::type &bv)
set the background value
 
bool init_local_i_g_box
Indicate if the local internal ghost box has been initialized.
 
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
 
openfpm::vector< device_grid > loc_grid_old
Old local grids.
 
void save(const std::string &filename) const
Save the grid state on HDF5.
 
auto insertFlush(const grid_dist_key_dx< dim, bg_key > &v1) -> decltype(loc_grid.get(v1.getSub()).template insertFlush(v1.getKey()))
insert an element in the grid
 
openfpm::vector< std::unordered_map< size_t, size_t > > g_id_to_internal_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
 
Point< dim, St > getSpacing()
Get the spacing on each dimension.
 
grid_dist_id(const Decomposition2 &dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
 
const device_grid & get_loc_grid(size_t i) const
Get the i sub-domain grid.
 
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.
 
openfpm::vector< device_grid > loc_grid
Local grids.
 
long int who()
It return the id of structure in the allocation list.
 
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext_global
Global gdb_ext.
 
grid_dist_id_iterator_dec< Decomposition, true > getGridGhostIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop)
 
Vcluster & getVC()
Get the Virtual Cluster machine.
 
openfpm::vector< size_t > recv_sz
Receiving size.
 
void check_domain(const Box< dim, St > &dom)
Check the domain is valid.
 
void remove_no_flush(const grid_dist_key_dx< dim, bg_key > &v1)
remove an element in the grid
 
bool isInside(const grid_key_dx< dim > &gk) const
Check that the global grid key is inside the grid domain.
 
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)
 
void remove(const grid_dist_key_dx< dim, bg_key > &v1)
remove an element in the grid
 
void load(const std::string &filename)
Reload the grid from HDF5 file.
 
size_t getN_loc_grid() const
Return the number of local grid.
 
void create_eg_box()
Create per-processor internal ghost box list in grid units.
 
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.
 
static const unsigned int dims
Number of dimensions.
 
bool init_fix_ie_g_box
Flag that indicate if the internal and external ghost box has been fixed.
 
void construct_link(self &grid_up, self &grid_dw)
construct link between levels
 
openfpm::vector< ep_box_grid< dim > > eg_box
External ghost boxes in grid units.
 
void debugPrint()
It print the internal ghost boxes and external ghost boxes in global unit.
 
void create_local_ig_box()
Create local internal ghost box in grid units.
 
grid_dist_id(const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g, size_t opt=0)
 
grid_dist_id(const Decomposition2 &dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
 
Decomposition decomposition
Decomposition used.
 
void InitializeStructures(const size_t(&g_sz)[dim])
Initialize the grid.
 
std::unordered_map< size_t, size_t > g_id_to_external_ghost_box
 
CellDecomposer_sm< dim, St, shift< dim, St > > cd_sm
Structure that divide the space into cells.
 
void check_size(const size_t(&g_sz)[dim])
Check the grid has a valid size.
 
void conv3_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 is_staggered() const
Indicate that this grid is not staggered.
 
openfpm::vector< Box< dim, long int > > bx_def
Set of boxes that define where the grid is defined.
 
bool write_debug(std::string output)
Write all grids indigually.
 
openfpm::vector< HeapMemory > recv_mem_gg
Receiving buffer for particles ghost get.
 
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.
 
openfpm::vector< GBoxes< device_grid::dims > > gdb_ext_old
Extension of each old grid (old): Domain and ghost + domain.
 
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...
 
void InitializeCellDecomposer(const size_t(&g_sz)[dim], const size_t(&bc)[dim])
Initialize the Cell decomposer of the grid.
 
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
 
size_t gpu_n_insert_thread
number of insert each GPU thread does
 
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
 
void setPropNames(const openfpm::vector< std::string > &names)
Set the properties names.
 
bool init_local_e_g_box
Indicate if the local external ghost box has been initialized.
 
bool write_frame(std::string output, size_t i, size_t opt=VTK_WRITER|FORMAT_ASCII)
Write the distributed grid information.
 
Distributed grid iterator.
 
Distributed grid iterator.
 
Grid key for a distributed grid.
 
size_t getSub() const
Get the local grid.
 
base_key getKey() const
Get the key.
 
base_key & getKeyRef()
Get the reference key.
 
Distributed linearized key.
 
Declaration grid_key_dx_iterator_sub.
 
const grid_key_dx< dim > & get() const
Get the actual key.
 
bool isNext()
Check if there is the next element.
 
grid_key_dx is the key to access any element in the grid
 
void one()
Set to one the key.
 
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
 
__device__ __host__ index_type get(index_type i) const
Get the i index.
 
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
 
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
 
__device__ __host__ size_t size() const
Return the size of the grid.
 
Implementation of 1-D std::vector like structure.
 
Internal ghost box sent to construct external ghost box into the other processors.
 
size_t g_id
Global id of the internal ghost box.
 
comb< dim > cmb
In which sector live the box.
 
size_t r_sub
from which sub-domain this internal ghost box is generated (or with which sub-domain is overlapping)
 
Box< dim, size_t > bx
Box in global unit.
 
This structure store the Box that define the domain inside the Ghost + domain box.
 
Box< dim, long int > GDbox
Ghost + Domain ghost.
 
Point< dim, long int > origin
origin of GDbox in global grid coordinates
 
Box< dim, long int > Dbox
Domain box.
 
Position of the element of dimension d in the hyper-cube of dimension dim.
 
void sign_flip()
Flip the sign of the combination.
 
signed char c[dim]
Array that store the combination.
 
Structure to copy aggregates.
 
const e_src & block_data_src
encapsulated source object
 
__device__ __host__ copy_all_prop_sparse(const e_src &block_data_src, e_dst &block_data_dst, indexT local_id)
constructor
 
It store the information about the external ghost box.
 
size_t sub
sub_id in which sub-domain this box live
 
::Box< dim, long int > g_e_box
Box defining the external ghost box in global coordinates.
 
::Box< dim, long int > l_e_box
Box defining the external ghost box in local coordinates for gdb_ext.
 
comb< dim > cmb
Sector position of the external ghost.
 
it store a box, its unique id and the sub-domain from where it come from
 
comb< dim > cmb
Sector where it live the linked external ghost box.
 
::Box< dim, long int > box
Box.
 
size_t r_sub
r_sub id of the sub-domain in the sent list
 
It contain the offset necessary to move to coarser and finer level grids.
 
Point< dim, long int > up
offset to move up on an upper grid (coarse)
 
Point< dim, long int > dw
offset to move on the lower grid (finer)
 
this class is a functor for "for_each" algorithm
 
Structure for stencil iterator.