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;
46template<
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;
405 vb_int.template get<lc_proc_>(last) = lc_proc;
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>();
This class represent an N-dimensional box.
Point< dim, T > getP2() const
Get the point p2.
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Point< dim, T > getP1() const
Get the point p1.
__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.
CellIterator< CellList< dim, T, Mem_type, transform > > getCellIterator(size_t cell)
Get the Cell iterator.
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
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(size_t cell_id, typename Mem_type::local_index_type ele)
Add to the cell.
This class implement the point shape in an N-dimensional space.
This class represent an N-dimensional box.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
Declaration grid_key_dx_iterator_sub.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
bool isNext()
Check if there is the next element.
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
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, Memory2, layout_base2 > duplicate()
duplicate this structure changing layout and Memory
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.
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.
bool host_dev_transfer
host to device transfer
const openfpm::vector< Box_dom< dim, T > > & private_get_proc_int_box() const
Return the internal data structure proc_int_box.
void reset_host_dev_transfer()
Notify that the next toKernel() data-structures must be re-offloaded.
openfpm::vector< openfpm::vector< Box_proc< dim, T > > > box_nn_processor_int
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy operator.
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(& private_get_bc())[dim]
Return the internal data structure domain.
size_t getProcessorNEGhost(size_t id) const
Get the number of External ghost boxes for one processor id.
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 comb< dim > & getProcessorEGhostPos(size_t id, size_t j) const
Get the j External ghost box sector.
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
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.
shift_vect_converter< dim, T, Memory, layout_base > sc_convert
shift converter
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.
ie_ghost_gpu< dim, T, Memory, layout_base > toKernel()
toKernel() Convert this data-structure into a kernel usable data-structure
ie_ghost< dim, T, Memory, layout_base > & operator=(const ie_ghost< dim, T, Memory2, layout_base2 > &ie)
Copy operator.
const Box< dim, T > & private_get_domain() const
Return the internal data structure domain.
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...
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...
size_t getProcessorIGhostSSub(size_t id, size_t j) const
Get the sub-domain send-id at witch belong the internal ghost box.
const openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p() const
Return the internal data structure ids_p.
openfpm::vector< Point< dim, T >, Memory, layout_base > shifts
shift vectors
ie_ghost(const ie_ghost< dim, T, Memory, layout_base > &ie)
Copy constructor.
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...
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.
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.
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.
openfpm::vector< openfpm::vector< Box_proc< dim, T > > > & private_get_box_nn_processor_int()
Return the internal data structure box_nn_processor_int.
ie_ghost< dim, T, Memory, layout_base > & operator=(ie_ghost< dim, T, Memory, layout_base > &&ie)
Copy operator.
inline ::Box< dim, T > getIGhostBox(size_t b_id) const
Given the internal ghost box id, it return the internal ghost box.
bool write(std::string output, size_t p_id) const
write the information about the ghost in vtk format
const CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell() const
Return the internal data structure proc_int_box.
const ::Box< dim, T > & getProcessorEGhostBox(size_t id, size_t j) const
Get the j External ghost box.
openfpm::vector< Box_dom< dim, T > > & private_get_proc_int_box()
Return the internal data structure proc_int_box.
openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box()
Return the internal data structure vb_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.
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim])
Here we generare the shift vectors.
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...
const ::Box< dim, T > & getProcessorIGhostBox(size_t id, size_t j) const
Get the j Internal ghost box for one processor.
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.
const openfpm::vector< Box< dim, T >, Memory, layout_base > & private_get_vb_int_box() const
Return the internal data structure vb_int_box.
openfpm::vector< aggregate< unsigned int, unsigned int, unsigned int >, Memory, layout_base > & private_get_vb_int()
Return the internal data structure vb_int.
openfpm::vector< std::pair< size_t, size_t > > ids_p
Temporal buffers to return temporal information for ghost_processorID.
inline ::Box< dim, T > getEGhostBox(size_t b_id) const
Given the external ghost box id, it return the external ghost box.
size_t getProcessorEGhostSub(size_t id, size_t j) const
Get the local sub-domain at witch belong the external ghost box.
openfpm::vector< std::pair< size_t, size_t > > & private_get_ids_p()
Return the internal data structure ids_p.
openfpm::vector< size_t > & private_get_ids()
Return the internal data structure ids_p.
auto getInternalIDBoxes(Point< dim, T > &p) -> decltype(geo_cell.getCellIterator(geo_cell.getCell(p)))
const openfpm::vector< size_t > & private_get_ids() const
Return the internal data structure ids_p.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_geo_cell()
Return the internal data structure proc_int_box.
void Initialize_geo_cell(const Box< dim, T > &domain, const size_t(&div)[dim])
Initialize the geo cell list structure.
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.
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...
bool is_equal(ie_ghost< dim, T, Memory, layout_base > &ig)
Check if the ie_ghosts contain the same information.
openfpm::vector< Point< dim, T >, Memory, layout_base > & private_get_shifts()
Return the internal data structure shifts.
const openfpm::vector< p_box< dim, T > > & private_get_vb_ext() const
Return the internal data structure vb_ext.
ie_ghost()
Default constructor.
size_t getNEGhostBox() const
Get the number of the calculated external ghost boxes.
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 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
const openfpm::vector< Point< dim, T >, Memory, layout_base > & getShiftVectors()
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.
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.
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
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.
const openfpm::vector< comb< dim > > & getNearSubdomainsPos(size_t p_id) const
Get the sub-domains sector position of a near processor.
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< size_t > & getNearSubdomainsRealId(size_t p_id) const
Get the real-id of the sub-domains of a near processor.
size_t getNNProcessors() const
Get the number of Near processors.
const openfpm::vector< ::Box< dim, T > > & getNearSubdomains(size_t p_id) const
Get 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