8 #ifndef SRC_DECOMPOSITION_IE_GHOST_HPP_ 9 #define SRC_DECOMPOSITION_IE_GHOST_HPP_ 12 #include "nn_processor.hpp" 13 #include "Decomposition/shift_vect_converter.hpp" 14 #include "Decomposition/cuda/ie_ghost_gpu.cuh" 26 if (proc_id < pbi.proc_id)
28 else if (proc_id == pbi.proc_id)
30 return shift_id < pbi.shift_id;
46 template<
unsigned int dim,
typename T,
typename Memory,
template<
typename>
class layout_base >
120 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" sub-domain not found\n";
202 for (
int i = 0 ; i < dim ; i++)
256 for (
size_t i = 0 ; i < sub_domains.size() ; i++)
267 for (
size_t j = 0 ; j < box_nn_processor.get(i).size() ; j++)
270 size_t p_id = box_nn_processor.get(i).get(j);
287 for (
size_t b = 0 ; b < nn_processor_subdomains_g.
size() ; b++)
292 bool intersect = sub_with_ghost.
Intersect(sub_bb,bi);
294 if (intersect ==
true)
296 struct p_box<dim,T> pb;
315 box_nn_processor_int_gg.add(bi);
316 proc_int_box_g.
ebx.add();
317 proc_int_box_g.
ebx.last().bx = bi;
318 proc_int_box_g.
ebx.last().sub = i;
319 proc_int_box_g.
ebx.last().cmb = nnpsg_pos.get(b);
324 proc_int_box_g.
ebx.last().id =
ebx_ibx_form(k,r_sub.get(b),p_id,nnpsg_pos.get(b),n_r_sub,v_cl,
true);
358 for (
size_t i = 0 ; i < sub_domains.size() ; i++)
361 for (
size_t j = 0 ; j < box_nn_processor.get(i).size() ; j++)
364 size_t p_id = box_nn_processor.get(i).get(j);
379 for (
size_t k = 0 ; k < nn_p_box.
size() ; k++)
392 bool intersect = n_sub.
Intersect(l_sub,b_int);
395 if (intersect ==
true)
402 vb_int.template get<proc_>(last) = p_id;
423 p_box_int.add(b_int);
430 sb.
r_sub = r_sub.get(k);
431 sb.
cmb = nn_p_box_pos.get(k);
442 pr_box_int.ibx.add(sb);
457 auto key = g_sub.
get();
458 size_t cell = gi.LinId(key);
492 for (
size_t i = 0 ; i < dim ; i++) {div[i] =
geo_cell.getDiv()[i];}
505 for (
size_t i = 0 ; i < sz ; i++)
508 tmp_sort.get(i).proc_id =
vb_int.template get<proc_>(tmp_sort.get(i).box_id);
509 tmp_sort.get(i).shift_id =
vb_int.template get<shift_id_>(tmp_sort.get(i).box_id);
516 for (
size_t i = 0 ; i < sz ; i++)
550 ids_p.swap(ie.ids_p);
556 for (
int i = 0 ; i < dim ; i++)
578 for (
int i = 0 ; i < dim ; i++)
585 template<
typename Memory2,
template<
typename>
class layout_base2>
599 for (
int i = 0 ; i < dim ; i++)
600 {
bc[i] = ie.private_get_bc(i);}
612 template<
typename Memory2,
template <
typename>
class layout_base2>
629 for (
int i = 0 ; i < dim ; i++)
630 {tmp.private_get_bc()[i] =
bc[i];}
687 shifts.template hostToDevice<0>();
881 return vb_int.template get<proc_>(b_id);
903 return vb_ext.get(b_id).box;
916 return vb_ext.get(b_id).proc;
992 while (cell_it.isNext())
994 size_t bid = cell_it.get();
998 ids_p.add(std::pair<size_t,size_t>(id1::id(
vb_int.get(bid),bid),id2::id(
vb_int.get(bid),bid)));
1041 while (cell_it.isNext())
1043 size_t bid = cell_it.get();
1085 while (cell_it.isNext())
1087 size_t bid = cell_it.get();
1091 ids_p.add(std::pair<size_t,size_t>(id1::id(
vb_int.get(bid),bid),id2::id(
vb_int.get(bid),bid)));
1128 while (cell_it.isNext())
1130 size_t bid = cell_it.get();
1132 if (
vb_int.get(bid).box.isInsideNP_with_border(p,
bc,
domain) ==
true)
1162 bool write(std::string output,
size_t p_id)
const 1173 vtk_box3.write(output + std::string(
"internal_ghost_") + std::to_string(p_id) + std::string(
".vtk"));
1184 vtk_box4.write(output + std::string(
"external_ghost_") + std::to_string(p_id) + std::string(
".vtk"));
1253 for (
int i = 0 ; i < dim ; i++)
1255 if (
bc[i] != ig.
bc[i])
1531 vb_int.template hostToDevice<0,1,2>();
1532 shifts.template hostToDevice<0>();
const openfpm::vector< Box_dom< dim, T > > & private_get_proc_int_box() const
Return the internal data structure proc_int_box.
const openfpm::vector< p_box< dim, T > > & private_get_vb_ext() const
Return the internal data structure vb_ext.
void ghost_processor_ID(const Point< dim, T > &p, output_type &output, unsigned int base, unsigned int pi)
Get the number of processor a particle must sent.
This class represent an N-dimensional box.
void addCell(size_t cell_id, typename Mem_type::local_index_type ele)
Add to the cell.
const openfpm::vector< comb< dim > > & getNearSubdomainsPos(size_t p_id) const
Get the sub-domains sector position of a near processor.
size_t getProcessUnitID()
Get the process unit id.
bool isNext()
Check if there is the next element.
size_t getProcessorEGhostId(size_t id, size_t j) const
Get the j External ghost box id.
size_t ProctoID(size_t p) const
Convert the processor rank to the id in the list.
size_t(& private_get_bc())[dim]
Return the internal data structure domain.
void create_box_nn_processor_int(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > &sub_domains, const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const nn_prcs< dim, T, layout_base, Memory > &nn_p)
Create the box_nn_processor_int (nbx part) structure, the geo_cell list and proc_int_box.
Position of the element of dimension d in the hyper-cube of dimension dim.
void reorder_geo_cell()
in this function we reorder the list in each cells by processor id
const openfpm::vector< size_t > & getSentSubdomains(size_t p_id) const
For each near processor it give a vector with the id of the local sub-domain sent to that processor.
openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > & private_get_vb_int()
Return the internal data structure vb_int.
const openfpm::vector< Point< dim, T >, Memory, layout_base > & private_get_shifts() const
Return the internal data structure shifts.
const openfpm::vector< Point< dim, T >, Memory, layout_base > & getShiftVectors()
const openfpm::vector< size_t > ghost_processorID(const Point< dim, T > &p, const int opt=MULTIPLE)
Given a position it return if the position belong to any neighborhood processor ghost (Internal ghost...
const openfpm::vector< openfpm::vector< Box_proc< dim, T > > > & private_get_box_nn_processor_int() const
Return the internal data structure box_nn_processor_int.
void clear()
Clear the cell list.
openfpm::vector< Box_dom< dim, T > > & private_get_proc_int_box()
Return the internal data structure proc_int_box.
const openfpm::vector< size_t > & private_get_ids() const
Return the internal data structure ids_p.
size_t link_ebx_ibx(const nn_prcs< dim, T, layout_base, Memory > &nn_p, size_t p_id, size_t i)
Given a local sub-domain i, it give the id of such sub-domain in the sent list for the processor p_id...
Point< dim, T > getP2() const
Get the point p2.
size_t getNearProcessor(size_t p_id) const
Get the near processor id.
size_t getNNProcessors() const
Get the number of Near processors.
void destroy()
Litterary destroy the memory of the cell list, including the retained one.
size_t getNIGhostBox() const
Return the total number of the calculated internal ghost boxes.
void sign_flip()
Flip the sign of the combination.
const CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell() const
Return the internal data structure proc_int_box.
ie_ghost()
Default constructor.
bool operator<(const proc_box_id &pbi) const
operator to reorder
This class implement the point shape in an N-dimensional space.
const openfpm::vector< std::pair< size_t, size_t > > & ghost_processorID_pair(const encapc< 1, Point< dim, T >, Mem > &p, const int opt=MULTIPLE)
Given a position it return if the position belong to any neighborhood processor ghost (Internal ghost...
Case for external ghost box.
const Box< dim, T > & private_get_domain() const
Return the internal data structure domain.
openfpm::vector< std::pair< size_t, size_t > > ids_p
Temporal buffers to return temporal information for ghost_processorID.
openfpm::vector< p_box< dim, T > > vb_ext
External ghost boxes for this processor.
size_t getProcessorEGhostSub(size_t id, size_t j) const
Get the local sub-domain at witch belong the external ghost box.
size_t getNelements(const size_t cell_id) const
Return the number of elements in the cell.
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
CellIterator< CellList< dim, T, Mem_type, transform > > getCellIterator(size_t cell)
Get the Cell iterator.
size_t ebx_ibx_form(size_t k, size_t b, size_t p_id, const comb< dim > &c, size_t N_b, Vcluster<> &v_cl, const bool ei)
This is the external and internal ghost box link formula.
size_t convertShift(const comb< dim > &cmb)
bool host_dev_transfer
host to device transfer
size_t getEGhostBoxProcessor(size_t b_id) const
Given the external ghost box id, it return the near processor at witch belong or the near processor t...
const comb< dim > & getProcessorEGhostPos(size_t id, size_t j) const
Get the j External ghost box sector.
Implementation of VCluster class.
openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > vb_int
Internal ghost boxes for this processor domain.
const openfpm::vector< size_t > & ghost_processorID(const encapc< 1, Point< dim, T >, Mem > &p, const int opt=MULTIPLE)
Given a position it return if the position belong to any neighborhood processor ghost (Internal ghost...
size_t getProcessorNIGhost(size_t id) const
Get the number of Internal ghost boxes for one processor.
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
void Initialize_geo_cell(const Box< dim, T > &domain, const size_t(&div)[dim])
Initialize the geo cell list structure.
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
const openfpm::vector< size_t > & getNearSubdomainsRealId(size_t p_id) const
Get the real-id of the sub-domains of a near processor.
size_t lc_proc
local processor id
size_t getNEGhostBox() const
Get the number of the calculated external ghost boxes.
const openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p() const
Return the internal data structure ids_p.
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim])
Here we generare the shift vectors.
size_t lin() const
Linearization.
Box< dim, T > domain
domain
bool write(std::string output, size_t p_id) const
write the information about the ghost in vtk format
inline ::Box< dim, T > getIGhostBox(size_t b_id) const
Given the internal ghost box id, it return the internal ghost box.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell()
Return the internal data structure proc_int_box.
Box< dim, T > bx
Internal ghost box definition.
bool is_equal_ng(ie_ghost< dim, T, Memory, layout_base > &ig)
Check if the ie_loc_ghosts contain the same information with the exception of the ghost part It is an...
comb< dim > cmb
see ie_ghost follow sector explanation
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy operator.
const openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box() const
Return the internal data structure vb_int_box.
size_t bc[dim]
boundary conditions
const openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > & private_get_vb_int() const
Return the internal data structure vb_int.
const grid_key_dx< dim > & get() const
Get the actual key.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
structure that store and compute the internal and external local ghost box
openfpm::vector< Box< dim, T >, Memory, layout_base > vb_int_box
Internal ghost boxes for this processor domain.
const ::Box< dim, T > & getProcessorEGhostBox(size_t id, size_t j) const
Get the j External ghost box.
ie_ghost< dim, T, Memory2, layout_base2 > duplicate()
duplicate this structure changing layout and Memory
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
size_t shift_id
shift vector id
size_t id
see ebx_ibx_form in ie_ghost for the meaning
void reset_host_dev_transfer()
Notify that the next toKernel() data-structures must be re-offloaded.
size_t getProcessingUnits()
Get the total number of processors.
void Initialize(CellDecomposer_sm< dim, T, transform > &cd_sm, const Box< dim, T > &dom_box, const size_t pad=1, size_t slot=STARTING_NSLOT)
size_t proc
processor rank
size_t getProcessorIGhostSSub(size_t id, size_t j) const
Get the sub-domain send-id at witch belong the internal ghost box.
This class represent an N-dimensional box.
size_t r_sub
see getNearSubdomainsRealId in nn_prcs
size_t getIGhostBoxProcessor(size_t b_id) const
Given the internal ghost box id, it return the near processor at witch belong or the near processor t...
ie_ghost< dim, T, Memory, layout_base > & operator=(ie_ghost< dim, T, Memory, layout_base > &&ie)
Copy operator.
size_t getProcessorIGhostId(size_t id, size_t j) const
Get the j Internal ghost box id.
structure that store and compute the internal and external local ghost box. Version usable in kernel
openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p()
Return the internal data structure ids_p.
openfpm::vector< openfpm::vector< Box_proc< dim, T > > > & private_get_box_nn_processor_int()
Return the internal data structure box_nn_processor_int.
unsigned int ghost_processorID_N(const Point< dim, T > &p)
Get the number of processor a particle must sent.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > geo_cell
Cell-list that store the geometrical information of the internal ghost boxes.
openfpm::vector< Point< dim, T >, Memory, layout_base > shifts
shift vectors
in case of high dimensions shift vector converter
openfpm::vector< size_t > & private_get_ids()
Return the internal data structure ids_p.
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
openfpm::vector< openfpm::vector< Box_proc< dim, T > > > box_nn_processor_int
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
Box< dim, T > & private_get_domain()
Return the internal data structure domain.
openfpm::vector< Box_dom< dim, T > > proc_int_box
It store the same information of box_nn_processor_int organized by processor id.
size_t getNRealSubdomains(size_t p_id) const
Get the number of real sub-domains of a near processor.
openfpm::vector< p_box< dim, T > > & private_get_vb_ext()
Return the internal data structure vb_ext.
void create_box_nn_processor_ext(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > &sub_domains, const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const nn_prcs< dim, T, layout_base, Memory > &nn_p)
Create the box_nn_processor_int (bx part) structure.
const openfpm::vector< std::pair< size_t, size_t > > ghost_processorID_pair(Point< dim, T > &p, const int opt=MULTIPLE)
Given a position it return if the position belong to any neighborhood processor ghost (Internal ghost...
bool is_equal(ie_ghost< dim, T, Memory, layout_base > &ig)
Check if the ie_ghosts contain the same information.
const ::Box< dim, T > & getProcessorIGhostBox(size_t id, size_t j) const
Get the j Internal ghost box for one processor.
const openfpm::vector< ::Box< dim, T > > & getNearSubdomains(size_t p_id) const
Get the sub-domains of a near processor.
It store all the boxes of the near processors in a linear array.
openfpm::vector_std< Box_sub< dim, T > > ebx
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory2, layout_base2 > &ie)
Copy operator.
size_t getProcessorNEGhost(size_t id) const
Get the number of External ghost boxes for one processor id.
const comb< dim > & getProcessorIGhostPos(size_t id, size_t j) const
Get the ghost box sector of the external ghost box linked with the j internal ghost box.
size_t getProcessorIGhostSub(size_t id, size_t j) const
Get the local sub-domain at witch belong the internal ghost box.
Implementation of 1-D std::vector like structure.
Class for FAST cell list implementation.
ie_ghost(ie_ghost< dim, T, Memory, layout_base > &&ie)
Copy constructor.
bool isNext()
Check if there is the next element.
auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
auto labelPoint(Point< dim, T > &p) -> decltype(geo_cell.getCellIterator(geo_cell.getCell(p)))
if the point fall into the ghost of some near processor it return the processors id's in which it fal...
shift_vect_converter< dim, T, Memory, layout_base > sc_convert
shift converter
Point< dim, T > getP1() const
Get the point p1.
inline ::Box< dim, T > getEGhostBox(size_t b_id) const
Given the external ghost box id, it return the external ghost box.
openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box()
Return the internal data structure vb_int_box.
ie_ghost_gpu< dim, T, Memory, layout_base > toKernel()
toKernel() Convert this data-structure into a kernel usable data-structure
openfpm::vector< size_t > ids
Temporal buffers to return temporal information.
ie_ghost(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy constructor.
openfpm::vector< Point< dim, T >, Memory, layout_base > & private_get_shifts()
Return the internal data structure shifts.
void reset()
Reset the nn_prcs structure.
auto getInternalIDBoxes(Point< dim, T > &p) -> decltype(geo_cell.getCellIterator(geo_cell.getCell(p)))
This class store the adjacent processors and the adjacent sub_domains.