OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
common.hpp
1 /*
2  * basic.hpp
3  *
4  * Created on: Aug 8, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_DECOMPOSITION_COMMON_HPP_
9 #define SRC_DECOMPOSITION_COMMON_HPP_
10 
11 #define UNIQUE 1
12 #define MULTIPLE 2
13 
14 #include "Vector/map_vector.hpp"
15 
25 template<unsigned int dim, typename T>
27 {
30 
32  size_t sub;
33 
36 
39  :sub(0)
40  {
41  cmb.zero();
42  };
43 
45  Box_loc_sub(const Box<dim,T> & bx, size_t sub, const comb<dim> & cmb)
46  :bx(bx),sub(sub),cmb(cmb)
47  {};
48 
51  {
53 
54  return *this;
55  }
56 
57 
58 };
59 
69 template<unsigned int dim, typename T>
70 struct Box_sub
71 {
74 
76  size_t sub;
77 
79  size_t id;
80 
82  size_t r_sub;
83 
86 
89  {
90  cmb.zero();
91  }
92 };
93 
95 template<unsigned int dim, typename T>
96 struct Box_sub_k
97 {
100 
102  size_t sub;
103 
106 
108  long int k;
109 
110  Box_sub_k()
111  :sub(0),k(-1)
112  {
113  cmb.zero();
114  }
115 };
116 
118 template<unsigned int dim, typename T>
119 struct lBox_dom
120 {
124 
128 };
129 
131 template<unsigned int dim, typename T>
132 struct Box_proc
133 {
137 
141 
142 
144  size_t proc;
145 };
146 
148 template<unsigned int dim, typename T>
149 struct Box_dom
150 {
154 
158 };
159 
160 // It store the sub-domain sent by the near processors
161 template<unsigned int dim, typename T>
162 struct N_box
163 {
165  size_t id;
166 
169 
172 
174  size_t n_real_sub;
175 
180 
183  :id((size_t)-1),n_real_sub(0)
184  {};
185 
187  N_box(const N_box<dim,T> & b)
188  :id((size_t)-1),n_real_sub(0)
189  {
190  this->operator=(b);
191  }
192 
195  :id((size_t)-1),n_real_sub(0)
196  {
197  this->operator=(b);
198  }
199 
208  {
209  id = ele.id;
210  bx = ele.bx;
211  pos = ele.pos;
212  n_real_sub = ele.n_real_sub;
213  r_sub = ele.r_sub;
214 
215  return * this;
216  }
217 
226  {
227  id = ele.id;
228  bx.swap(ele.bx);
229  pos.swap(ele.pos);
230  n_real_sub = ele.n_real_sub;
231  r_sub.swap(ele.r_sub);
232 
233  return * this;
234  }
235 
243  bool operator==(const N_box<dim,T> & ele) const
244  {
245  if (id != ele.id)
246  return false;
247 
248  if (pos != ele.pos)
249  return false;
250 
251  if (r_sub != ele.r_sub)
252  return false;
253 
254  if (n_real_sub != ele.n_real_sub)
255  return false;
256 
257  return bx == ele.bx;
258  }
259 
267  bool operator!=(const N_box<dim,T> & ele) const
268  {
269  return ! this->operator==(ele);
270  }
271 };
272 
274 template<unsigned int dim, typename T>
275 struct p_box
276 {
281  size_t lc_proc;
283  size_t proc;
284 
286  size_t shift_id;
287 
295  bool operator==(const p_box & pb)
296  {
297  return pb.lc_proc == lc_proc;
298  }
299 };
300 
301 #endif /* SRC_DECOMPOSITION_COMMON_HPP_ */
N_box(N_box< dim, T > &&b)
Copy constructor.
Definition: common.hpp:194
size_t sub
Domain id.
Definition: common.hpp:102
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
comb< dim > cmb
in witch sector this sub-domain live
Definition: common.hpp:35
Box_loc_sub(const Box< dim, T > &bx, size_t sub, const comb< dim > &cmb)
Constructor from box, domain id and sector where it live.
Definition: common.hpp:45
size_t proc
processor
Definition: common.hpp:144
size_t sub
The id of the real domain.
Definition: common.hpp:32
N_box< dim, T > & operator=(const N_box< dim, T > &ele)
Copy the element.
Definition: common.hpp:207
Case for local external ghost box.
Definition: common.hpp:132
Case for local ghost box.
Definition: common.hpp:119
Box< dim, T > bx
extension of this local internal ghost box
Definition: common.hpp:99
size_t sub
Domain id.
Definition: common.hpp:76
for each sub-domain box sub contain the real the sub-domain id
Definition: common.hpp:26
openfpm::vector<::Box< dim, T > > bx
Definition: common.hpp:136
openfpm::vector_std< Box_sub_k< dim, T > > ibx
Definition: common.hpp:127
openfpm::vector< size_t > r_sub
Definition: common.hpp:179
Box_loc_sub operator=(const Box< dim, T > &box)
Set the sub-domain box coordinates.
Definition: common.hpp:50
Case for external ghost box.
Definition: common.hpp:149
Box_loc_sub()
Constructor.
Definition: common.hpp:38
Particular case for local internal ghost boxes.
Definition: common.hpp:96
bool operator==(const p_box &pb)
Check if two p_box are the same.
Definition: common.hpp:295
size_t lc_proc
local processor id
Definition: common.hpp:281
Box< dim, T > bx
Box defining the sub-domain (copied)
Definition: common.hpp:29
Box< dim, T > bx
Internal ghost box definition.
Definition: common.hpp:73
comb< dim > cmb
see ie_ghost follow sector explanation
Definition: common.hpp:85
::Box< dim, T > box
Definition: common.hpp:279
size_t shift_id
shift vector id
Definition: common.hpp:286
size_t id
see ebx_ibx_form in ie_ghost for the meaning
Definition: common.hpp:79
bool operator==(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition: common.hpp:243
size_t proc
processor rank
Definition: common.hpp:283
This class represent an N-dimensional box.
Definition: Box.hpp:56
size_t r_sub
see getNearSubdomainsRealId in nn_prcs
Definition: common.hpp:82
N_box()
Default constructor.
Definition: common.hpp:182
Box_sub()
Constructor reset cmb.
Definition: common.hpp:88
comb< dim > cmb
Where this sub_domain live.
Definition: common.hpp:105
bool operator!=(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition: common.hpp:267
openfpm::vector_std< Box_sub< dim, T > > ibx
Definition: common.hpp:157
long int k
k
Definition: common.hpp:108
openfpm::vector<::Box< dim, T > > nbx
Definition: common.hpp:140
openfpm::vector< comb< dim > > pos
near processor sector position (or where they live outside the domain)
Definition: common.hpp:171
size_t id
id of the processor in the nn_processor list (local processor id)
Definition: common.hpp:165
N_box< dim, T > & operator=(N_box< dim, T > &&ele)
Copy the element.
Definition: common.hpp:225
It store all the boxes of the near processors in a linear array.
Definition: common.hpp:275
openfpm::vector_std< Box_sub< dim, T > > ebx
Definition: common.hpp:153
openfpm::vector_std< Box_sub_k< dim, T > > ebx
Definition: common.hpp:123
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
openfpm::vector<::Box< dim, T > > bx
near processor sub-domains
Definition: common.hpp:168
size_t n_real_sub
Number of real sub-domains or sub-domain in the central sector.
Definition: common.hpp:174
N_box(const N_box< dim, T > &b)
Copy constructor.
Definition: common.hpp:187