Commit f9e6bc7a authored by incardon's avatar incardon

Fixing local ghost using_bx_def

parent 05875462
......@@ -286,40 +286,6 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
return g->recv_mem_gg.get(lc_id).getPointer();
}
/*! \brief flip box just convert and internal ghost box into an external ghost box
*
* \param box to convert
* \param cmb sector position of the box
*
* \return the converted box
*
*/
Box<dim,long int> flip_box(const Box<dim,long int> & box, const comb<dim> & cmb)
{
Box<dim,long int> flp;
for (size_t i = 0 ; i < dim; i++)
{
if (cmb[i] == 0)
{
flp.setLow(i,box.getLow(i));
flp.setHigh(i,box.getHigh(i));
}
else if (cmb[i] == 1)
{
flp.setLow(i,box.getLow(i) + ginfo.size(i));
flp.setHigh(i,box.getHigh(i) + ginfo.size(i));
}
else if (cmb[i] == -1)
{
flp.setLow(i,box.getLow(i) - ginfo.size(i));
flp.setHigh(i,box.getHigh(i) - ginfo.size(i));
}
}
return flp;
}
/*! \brief this function is for optimization of the ghost size
*
* Because the decomposition work in continuum and discrete ghost is
......@@ -519,7 +485,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
bx += gdb_ext.get(k).origin;
Box<dim,long int> output;
Box<dim,long int> flp_i = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb);
Box<dim,long int> flp_i = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb,ginfo);
// it intersect one sub-grid
if (bx.Intersect(flp_i,output))
......@@ -572,7 +538,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
// Add an unlinked gdb_ext
// An unlinked gdb_ext is an empty domain with only a external ghost
// part
Box<dim,long int> output = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb);
Box<dim,long int> output = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb,ginfo);
GBoxes<dim> tmp;
tmp.GDbox = box_int_recv.get(i).get(j).bx;
......@@ -632,7 +598,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
bid_t.sub = sub_id;
bid_t.cmb = box_int_recv.get(i).get(j).cmb;
bid_t.cmb.sign_flip();
::Box<dim,long int> ib = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb);
::Box<dim,long int> ib = flip_box(box_int_recv.get(i).get(j).bx,box_int_recv.get(i).get(j).cmb,ginfo);
bid_t.g_e_box = ib;
bid_t.g_id = box_int_recv.get(i).get(j).g_id;
// Translate in local coordinate
......@@ -690,7 +656,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
{
// Check if ib is valid if not it mean that the internal ghost does not contain information so skip it
if (ibv.get(k).bx.isValid() == false)
continue;
{continue;}
pib.bid.add();
pib.bid.last().box = ibv.get(k).bx;
......@@ -703,7 +669,6 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
pib.bid.last().sub = dec.getLocalIGhostSub(i,j);
// It will be filled later
/*pib.bid.last().k.add(-1)/*dec.getLocalIGhostE(i,j)*/;
pib.bid.last().cmb = dec.getLocalIGhostPos(i,j);
}
}
......@@ -822,7 +787,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
gbx += gdb_ext.get(k).origin;
Box<dim,long int> output;
Box<dim,long int> flp_i = flip_box(loc_ig_box.get(i).bid.get(j).box,loc_ig_box.get(i).bid.get(j).cmb);
Box<dim,long int> flp_i = flip_box(loc_ig_box.get(i).bid.get(j).box,loc_ig_box.get(i).bid.get(j).cmb,ginfo);
bool intersect_domain = bx.Intersect(flp_i,output);
bool intersect_gdomain = gbx.Intersect(flp_i,output);
......@@ -834,7 +799,6 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
loc_ig_box.get(i).bid.get(j).k.add(pib.bid.size());
size_t s = loc_ig_box.get(i).bid.get(j).k.last();
Box<dim,long int> flp_i = flip_box(loc_ig_box.get(i).bid.get(j).box,loc_ig_box.get(i).bid.get(j).cmb);
comb<dim> cmb = loc_ig_box.get(i).bid.get(j).cmb;
cmb.sign_flip();
......@@ -843,11 +807,11 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
j,
k,
pib.bid,
flp_i,
output,
cmb);
volume_linked += pib.bid.last().box.getVolumeKey();
volume_linked += pib.bid.last().ebox.getVolumeKey();
}
}
}
......@@ -859,7 +823,7 @@ class grid_dist_id : public grid_dist_id_comm<dim,St,T,Decomposition,Memory,devi
size_t s = loc_ig_box.get(i).bid.get(j).k.get(0);
pib.bid.resize(dec.getLocalNEGhost(k));
pib.bid.get(s).box = flip_box(loc_ig_box.get(i).bid.get(j).box,loc_ig_box.get(i).bid.get(j).cmb);
pib.bid.get(s).ebox = flip_box(loc_ig_box.get(i).bid.get(j).box,loc_ig_box.get(i).bid.get(j).cmb,ginfo);
pib.bid.get(s).sub = dec.getLocalEGhostSub(k,s);
pib.bid.get(s).cmb = loc_ig_box.get(i).bid.get(j).cmb;
pib.bid.get(s).cmb.sign_flip();
......@@ -2206,6 +2170,7 @@ public:
eb_gid_list,
use_bx_def,
loc_grid,
ginfo_v,
g_id_to_external_ghost_box);
}
......
......@@ -10,6 +10,7 @@
#include "Vector/vector_dist_ofb.hpp"
#include "Grid/copy_grid_fast.hpp"
#include "grid_dist_util.hpp"
/*! \brief Unpack selector
*
......@@ -190,6 +191,7 @@ class grid_dist_id_comm
const openfpm::vector<GBoxes<device_grid::dims>> & gdb_ext,
openfpm::vector<device_grid> & loc_grid,
std::unordered_map<size_t,size_t> & g_id_to_external_ghost_box,
const grid_sm<dim,void> & ginfo,
bool use_bx_def)
{
grid_key_dx<dim> cnt[1];
......@@ -201,13 +203,8 @@ class grid_dist_id_comm
//! For all the internal ghost boxes of each sub-domain
for (size_t j = 0 ; j < loc_ig_box.get(i).bid.size() ; j++)
{
Box<dim,size_t> bx_src = loc_ig_box.get(i).bid.get(j).box;
size_t sub_id_src_gdb_ext = loc_ig_box.get(i).bid.get(j).sub_gdb_ext;
// convert into local
bx_src -= gdb_ext.get(sub_id_src_gdb_ext).origin;
// sub domain connected with external box
size_t sub_id_dst = loc_ig_box.get(i).bid.get(j).sub;
......@@ -216,7 +213,7 @@ class grid_dist_id_comm
{
size_t k = loc_ig_box.get(i).bid.get(j).k.get(v);
Box<dim,size_t> bx_dst = loc_eg_box.get(sub_id_dst).bid.get(k).box;
Box<dim,size_t> bx_dst = loc_eg_box.get(sub_id_dst).bid.get(k).ebox;
// convert into local
size_t sub_id_dst_gdb_ext = loc_eg_box.get(sub_id_dst).bid.get(k).sub_gdb_ext;
......@@ -240,6 +237,9 @@ class grid_dist_id_comm
#endif
Box<dim,size_t> bx_src = flip_box(loc_eg_box.get(sub_id_dst).bid.get(k).ebox,loc_eg_box.get(sub_id_dst).bid.get(k).cmb,ginfo);
bx_src -= gdb_ext.get(sub_id_src_gdb_ext).origin;
auto & gd = loc_grid.get(sub_id_dst_gdb_ext);
gd.remove(bx_dst);
gd.copy_to(loc_grid.get(sub_id_src_gdb_ext),bx_src,bx_dst);
......@@ -274,7 +274,7 @@ class grid_dist_id_comm
if (loc_eg_box.get(i).bid.get(j).initialized == false)
continue;
Box<dim,size_t> bx_src = loc_eg_box.get(i).bid.get(j).box;
Box<dim,size_t> bx_src = loc_eg_box.get(i).bid.get(j).ebox;
// convert into local
bx_src -= gdb_ext.get(i).origin;
......@@ -951,6 +951,7 @@ public:
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)
{
#ifdef PROFILE_SCOREP
......@@ -1054,7 +1055,7 @@ public:
queue_recv_data_get<prp_object>(eg_box,prp_recv,prRecv_prp);
ghost_get_local<prp...>(loc_ig_box,loc_eg_box,gdb_ext,loc_grid,g_id_to_external_ghost_box,use_bx_def);
ghost_get_local<prp...>(loc_ig_box,loc_eg_box,gdb_ext,loc_grid,g_id_to_external_ghost_box,ginfo,use_bx_def);
merge_received_data_get<prp ...>(loc_grid,eg_box,prp_recv,prRecv_prp,g_id_to_external_ghost_box,eb_gid_list);
}
......
......@@ -245,6 +245,41 @@ template <unsigned int dim> struct e_box_id
size_t sub;
};
/*! \brief flip box just convert and internal ghost box into an external ghost box and the other way around
*
* \param box to convert
* \param cmb sector position of the box
*
* \return the converted box
*
*/
template<unsigned int dim, typename T, typename idT>
Box<dim,long int> flip_box(const Box<dim,idT> & box, const comb<dim> & cmb, const grid_sm<dim,T> & ginfo)
{
Box<dim,long int> flp;
for (size_t i = 0 ; i < dim; i++)
{
if (cmb[i] == 0)
{
flp.setLow(i,box.getLow(i));
flp.setHigh(i,box.getHigh(i));
}
else if (cmb[i] == 1)
{
flp.setLow(i,box.getLow(i) + ginfo.size(i));
flp.setHigh(i,box.getHigh(i) + ginfo.size(i));
}
else if (cmb[i] == -1)
{
flp.setLow(i,box.getLow(i) - ginfo.size(i));
flp.setHigh(i,box.getHigh(i) - ginfo.size(i));
}
}
return flp;
}
/*! \brief convert to sub-domain id
*
* In case the grid is not defined everywhere the ids returned by getProcessorIGhostSub
......@@ -274,7 +309,7 @@ inline size_t convert_to_gdb_ext(size_t sub_id,
template <unsigned int dim> struct e_lbox_id
{
//! Box defining the external ghost box in local coordinates
::Box<dim,long int> box;
::Box<dim,long int> ebox;
//! Has this external ghost box initialized
bool initialized = false;
......@@ -310,12 +345,12 @@ template<unsigned int dim> inline void add_loc_eg_box(size_t le_sub,
size_t j,
size_t k,
openfpm::vector<e_lbox_id<dim>> & bid,
const Box<dim,long int> & box,
const Box<dim,long int> & ebox,
comb<dim> & cmb)
{
bid.add();
bid.last().box = box;
bid.last().ebox = ebox;
bid.last().sub = se;
bid.last().sub_gdb_ext = k;
......
......@@ -100,15 +100,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_test )
phases.get(i).ghost_get<>();
}
////////////// DEBUG //////////////////////
for (size_t i = 0 ; i < 4 ; i++)
{
phases.get(i).write("PORCA" + std::to_string(i));
}
///////////////////////////////////////////
// Get the cell list of the phase 0 and 1
auto CL_phase0 = phases.get(0).getCellList(r_cut);
auto CL_phase1 = phases.get(1).getCellList(r_cut);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment