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++)
258 Box<dim,T> sub_with_ghost = sub_domains.get(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;
996 while (cell_it.isNext())
998 size_t bid = cell_it.get();
1002 ids_p.add(std::pair<size_t,size_t>(id1::id(
vb_int.get(bid),bid),id2::id(
vb_int.get(bid),bid)));
1050 while (cell_it.isNext())
1052 size_t bid = cell_it.get();
1099 while (cell_it.isNext())
1101 size_t bid = cell_it.get();
1105 ids_p.add(std::pair<size_t,size_t>(id1::id(
vb_int.get(bid),bid),id2::id(
vb_int.get(bid),bid)));
1147 while (cell_it.isNext())
1149 size_t bid = cell_it.get();
1151 if (
vb_int.get(bid).box.isInsideNP_with_border(p,
bc,
domain) ==
true)
1181 bool write(std::string output,
size_t p_id)
const
1192 vtk_box3.write(output + std::string(
"internal_ghost_") + std::to_string(p_id) + std::string(
".vtk"));
1203 vtk_box4.write(output + std::string(
"external_ghost_") + std::to_string(p_id) + std::string(
".vtk"));
1272 for (
int i = 0 ; i < dim ; i++)
1274 if (
bc[i] != ig.
bc[i])
1550 vb_int.template hostToDevice<0,1,2>();
1551 shifts.template hostToDevice<0>();
This class represent an N-dimensional box.
Point< dim, T > getP1() const
Get the point p1.
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
Point< dim, T > getP2() const
Get the point p2.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
__device__ __host__ bool isInsideNP_with_border(const Point< dim, T > &p, const Box< dim, T > &border, const bc_type(&bc)[dim]) const
Check if the point is inside the region excluding the positive part.
Class for FAST cell list implementation.
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.
auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
void clear()
Clear the cell list.
void destroy()
Litterary destroy the memory of the cell list, including the retained one.
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
CellIterator< CellList< dim, T, Mem_type, transform > > getParticleInCellIterator(size_t cell)
Get the Cell iterator.
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)
void addCell(local_index cell_id, local_index ele)
Add an element to the cell.
This class implement the point shape in an N-dimensional space.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
bool isNext()
Check if there is the next element.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
structure that store and compute the internal and external local ghost box. Version usable in kernel
structure that store and compute the internal and external local ghost box
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory2, layout_base2 > &ie)
Copy operator.
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...
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > geo_cell
Cell-list that store the geometrical information of the internal ghost boxes.
const openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p() const
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.
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< 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...
bool host_dev_transfer
host to device transfer
void reset_host_dev_transfer()
Notify that the next toKernel() data-structures must be re-offloaded.
const CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell() const
Return the internal data structure proc_int_box.
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.
openfpm::vector< openfpm::vector< Box_proc< dim, T > > > box_nn_processor_int
openfpm::vector< Box_dom< dim, T > > & private_get_proc_int_box()
Return the internal data structure proc_int_box.
size_t(& private_get_bc())[dim]
Return the internal data structure domain.
const ::Box< dim, T > & getProcessorIGhostBox(size_t id, size_t j) const
Get the j Internal ghost box for one processor.
size_t getProcessorNEGhost(size_t id) const
Get the number of External ghost boxes for one processor id.
openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > & private_get_vb_int()
Return the internal data structure vb_int.
ie_ghost< dim, T, Memory2, layout_base2 > duplicate()
duplicate this structure changing layout and Memory
openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p()
Return the internal data structure ids_p.
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
shift_vect_converter< dim, T, Memory, layout_base > sc_convert
shift converter
inline ::Box< dim, T > getEGhostBox(size_t b_id) const
Given the external ghost box id, it return the external ghost box.
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...
size_t getProcessorIGhostSSub(size_t id, size_t j) const
Get the sub-domain send-id at witch belong the internal ghost box.
openfpm::vector< Point< dim, T >, Memory, layout_base > shifts
shift vectors
ie_ghost(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy constructor.
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 openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box() const
Return the internal data structure vb_int_box.
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...
ie_ghost< dim, T, Memory, layout_base > & operator=(ie_ghost< dim, T, Memory, layout_base > &&ie)
Copy operator.
openfpm::vector< p_box< dim, T > > vb_ext
External ghost boxes for this processor.
openfpm::vector< Box< dim, T >, Memory, layout_base > vb_int_box
Internal ghost boxes for this processor domain.
void reset()
Reset the nn_prcs structure.
unsigned int ghost_processorID_N(const Point< dim, T > &p)
Get the number of processor a particle must sent.
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...
openfpm::vector< p_box< dim, T > > & private_get_vb_ext()
Return the internal data structure vb_ext.
ie_ghost(ie_ghost< dim, T, Memory, layout_base > &&ie)
Copy constructor.
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.
bool write(std::string output, size_t p_id) const
write the information about the ghost in vtk format
void create_box_nn_processor_int(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< Box< 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.
size_t bc[dim]
boundary conditions
size_t getProcessorEGhostId(size_t id, size_t j) const
Get the j External ghost box id.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell()
Return the internal data structure proc_int_box.
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim])
Here we generare the shift vectors.
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.
openfpm::vector< size_t > ids
Temporal buffers to return temporal information.
openfpm::vector< Box_dom< dim, T > > proc_int_box
It store the same information of box_nn_processor_int organized by processor id.
openfpm::vector< std::pair< size_t, size_t > > ids_p
Temporal buffers to return temporal information for ghost_processorID.
openfpm::vector< Point< dim, T >, Memory, layout_base > & private_get_shifts()
Return the internal data structure shifts.
size_t getProcessorEGhostSub(size_t id, size_t j) const
Get the local sub-domain at witch belong the external ghost box.
const Box< dim, T > & private_get_domain() const
Return the internal data structure domain.
const openfpm::vector< p_box< dim, T > > & private_get_vb_ext() const
Return the internal data structure vb_ext.
void Initialize_geo_cell(const Box< dim, T > &domain, const size_t(&div)[dim])
Initialize the geo cell list structure.
const openfpm::vector< size_t > & private_get_ids() const
Return the internal data structure ids_p.
size_t getProcessorNIGhost(size_t id) const
Get the number of Internal ghost boxes for one processor.
openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > vb_int
Internal ghost boxes for this processor domain.
openfpm::vector< size_t > & private_get_ids()
Return the internal data structure ids_p.
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.
openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box()
Return the internal data structure vb_int_box.
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy operator.
ie_ghost()
Default constructor.
const openfpm::vector< Point< dim, T >, Memory, layout_base > & getShiftVectors()
auto labelPoint(Point< dim, T > &p) -> decltype(geo_cell.getParticleInCellIterator(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...
ie_ghost_gpu< dim, T, Memory, layout_base > toKernel()
toKernel() Convert this data-structure into a kernel usable data-structure
const ::Box< dim, T > & getProcessorEGhostBox(size_t id, size_t j) const
Get the j External ghost box.
size_t getNEGhostBox() const
Get the number of the calculated external ghost boxes.
const comb< dim > & getProcessorEGhostPos(size_t id, size_t j) const
Get the j External ghost box sector.
void create_box_nn_processor_ext(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< Box< 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< Box_dom< dim, T > > & private_get_proc_int_box() const
Return the internal data structure proc_int_box.
inline ::Box< dim, T > getIGhostBox(size_t b_id) const
Given the internal ghost box id, it return the internal ghost box.
auto getInternalIDBoxes(Point< dim, T > &p) -> decltype(geo_cell.getParticleInCellIterator(geo_cell.getCell(p)))
size_t convertShift(const comb< dim > &cmb)
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.
Box< dim, T > domain
domain
size_t getNIGhostBox() const
Return the total number of the calculated internal ghost boxes.
size_t getProcessorIGhostSub(size_t id, size_t j) const
Get the local sub-domain at witch belong the internal ghost box.
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...
void reorder_geo_cell()
in this function we reorder the list in each cells by processor id
const openfpm::vector< Point< dim, T >, Memory, layout_base > & private_get_shifts() const
Return the internal data structure shifts.
Box< dim, T > & private_get_domain()
Return the internal data structure domain.
size_t getProcessorIGhostId(size_t id, size_t j) const
Get the j Internal ghost box id.
This class store the adjacent processors and the adjacent sub_domains.
size_t ProctoID(size_t p) const
Convert the processor rank to the id in the list.
size_t getNearProcessor(size_t p_id) const
Get the near processor id.
size_t getNRealSubdomains(size_t p_id) const
Get the number of real sub-domains of a near processor.
const openfpm::vector< ::Box< dim, T > > & getNearSubdomains(size_t p_id) const
Get the sub-domains of a near processor.
size_t getNNProcessors() const
Get the number of Near processors.
const openfpm::vector< comb< dim > > & getNearSubdomainsPos(size_t p_id) const
Get the sub-domains sector position of a near processor.
const openfpm::vector< size_t > & getNearSubdomainsRealId(size_t p_id) const
Get the real-id of the sub-domains of a near processor.
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.
Implementation of 1-D std::vector like structure.
in case of high dimensions shift vector converter
Case for external ghost box.
openfpm::vector_std< Box_sub< dim, T > > ebx
openfpm::vector_std< Box_sub< dim, T > > ibx
size_t id
see ebx_ibx_form in ie_ghost for the meaning
size_t r_sub
see getNearSubdomainsRealId in nn_prcs
Box< dim, T > bx
Internal ghost box definition.
comb< dim > cmb
see ie_ghost follow sector explanation
Position of the element of dimension d in the hyper-cube of dimension dim.
void sign_flip()
Flip the sign of the combination.
size_t lin() const
Linearization.
It store all the boxes of the near processors in a linear array.
size_t shift_id
shift vector id
size_t proc
processor rank
size_t lc_proc
local processor id
bool operator<(const proc_box_id &pbi) const
operator to reorder