OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
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 
16 
21 template<unsigned int dim> struct periodicity
22 {
23  size_t bc[dim];
24 };
25 
30 template<unsigned int dim> struct periodicity_int
31 {
32  int bc[dim];
33 };
34 
44 template<unsigned int dim, typename T>
46 {
49 
51  size_t sub;
52 
55 
58  :sub(0)
59  {
60  cmb.zero();
61  };
62 
64  Box_loc_sub(const Box<dim,T> & bx, size_t sub, const comb<dim> & cmb)
65  :bx(bx),sub(sub),cmb(cmb)
66  {};
67 
70  {
72 
73  return *this;
74  }
75 
76 
77 };
78 
88 template<unsigned int dim, typename T>
89 struct Box_sub
90 {
93 
95  size_t sub;
96 
98  size_t id;
99 
101  size_t r_sub;
102 
105 
108  {
109  r_sub = (size_t)-1;
110  cmb.zero();
111 
112  sub = (size_t)-1;
113  }
114 };
115 
117 template<unsigned int dim, typename T>
118 struct Box_sub_k
119 {
122 
124  size_t sub;
125 
128 
130  long int k;
131 
132  Box_sub_k()
133  :sub(0),k(-1)
134  {
135  cmb.zero();
136  }
137 };
138 
139 template<unsigned int dim,typename T> using Box_map = aggregate<Box<dim,T>,long int>;
140 
142 template<unsigned int dim, typename T>
143 struct lBox_dom
144 {
148 
152 };
153 
155 template<unsigned int dim, typename T>
156 struct Box_proc
157 {
161 
165 
166 
168  size_t proc;
169 };
170 
172 template<unsigned int dim, typename T>
173 struct Box_dom
174 {
178 
182 };
183 
184 // It store the sub-domain sent by the near processors
185 template<unsigned int dim, typename T>
186 struct N_box
187 {
189  size_t id;
190 
193 
196 
198  size_t n_real_sub;
199 
204 
207  :id((size_t)-1),n_real_sub(0)
208  {};
209 
211  N_box(const N_box<dim,T> & b)
212  :id((size_t)-1),n_real_sub(0)
213  {
214  this->operator=(b);
215  }
216 
219  :id((size_t)-1),n_real_sub(0)
220  {
221  this->operator=(b);
222  }
223 
232  {
233  id = ele.id;
234  bx = ele.bx;
235  pos = ele.pos;
236  n_real_sub = ele.n_real_sub;
237  r_sub = ele.r_sub;
238 
239  return * this;
240  }
241 
250  {
251  id = ele.id;
252  bx.swap(ele.bx);
253  pos.swap(ele.pos);
254  n_real_sub = ele.n_real_sub;
255  r_sub.swap(ele.r_sub);
256 
257  return * this;
258  }
259 
267  bool operator==(const N_box<dim,T> & ele) const
268  {
269  if (id != ele.id)
270  return false;
271 
272  if (pos != ele.pos)
273  return false;
274 
275  if (r_sub != ele.r_sub)
276  return false;
277 
278  if (n_real_sub != ele.n_real_sub)
279  return false;
280 
281  return bx == ele.bx;
282  }
283 
291  bool operator!=(const N_box<dim,T> & ele) const
292  {
293  return ! this->operator==(ele);
294  }
295 };
296 
298 template<unsigned int dim, typename T>
299 struct p_box
300 {
305  size_t lc_proc;
307  size_t proc;
308 
310  size_t shift_id;
311 
319  bool operator==(const p_box & pb)
320  {
321  return pb.lc_proc == lc_proc;
322  }
323 };
324 
325 #endif /* SRC_DECOMPOSITION_COMMON_HPP_ */
N_box(N_box< dim, T > &&b)
Copy constructor.
Definition: common.hpp:218
size_t sub
Domain id.
Definition: common.hpp:124
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:54
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:64
size_t proc
processor
Definition: common.hpp:168
size_t sub
The id of the real domain.
Definition: common.hpp:51
N_box< dim, T > & operator=(const N_box< dim, T > &ele)
Copy the element.
Definition: common.hpp:231
Case for local external ghost box.
Definition: common.hpp:156
Case for local ghost box.
Definition: common.hpp:143
Box< dim, T > bx
extension of this local internal ghost box
Definition: common.hpp:121
size_t sub
Domain id.
Definition: common.hpp:95
for each sub-domain box sub contain the real the sub-domain id
Definition: common.hpp:45
openfpm::vector<::Box< dim, T > > bx
Definition: common.hpp:160
openfpm::vector_std< Box_sub_k< dim, T > > ibx
Definition: common.hpp:151
openfpm::vector< size_t > r_sub
Definition: common.hpp:203
Box_loc_sub operator=(const Box< dim, T > &box)
Set the sub-domain box coordinates.
Definition: common.hpp:69
Case for external ghost box.
Definition: common.hpp:173
Box_loc_sub()
Constructor.
Definition: common.hpp:57
Particular case for local internal ghost boxes.
Definition: common.hpp:118
bool operator==(const p_box &pb)
Check if two p_box are the same.
Definition: common.hpp:319
size_t lc_proc
local processor id
Definition: common.hpp:305
Box< dim, T > bx
Box defining the sub-domain (copied)
Definition: common.hpp:48
bool operator==(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition: common.hpp:267
Box< dim, T > bx
Internal ghost box definition.
Definition: common.hpp:92
comb< dim > cmb
see ie_ghost follow sector explanation
Definition: common.hpp:104
::Box< dim, T > box
Definition: common.hpp:303
Boundary conditions.
Definition: common.hpp:30
size_t shift_id
shift vector id
Definition: common.hpp:310
size_t id
see ebx_ibx_form in ie_ghost for the meaning
Definition: common.hpp:98
size_t proc
processor rank
Definition: common.hpp:307
This class represent an N-dimensional box.
Definition: Box.hpp:60
size_t r_sub
see getNearSubdomainsRealId in nn_prcs
Definition: common.hpp:101
N_box()
Default constructor.
Definition: common.hpp:206
Box_sub()
Constructor reset cmb.
Definition: common.hpp:107
comb< dim > cmb
Where this sub_domain live.
Definition: common.hpp:127
openfpm::vector_std< Box_sub< dim, T > > ibx
Definition: common.hpp:181
long int k
k
Definition: common.hpp:130
openfpm::vector<::Box< dim, T > > nbx
Definition: common.hpp:164
openfpm::vector< comb< dim > > pos
near processor sector position (or where they live outside the domain)
Definition: common.hpp:195
size_t id
id of the processor in the nn_processor list (local processor id)
Definition: common.hpp:189
N_box< dim, T > & operator=(N_box< dim, T > &&ele)
Copy the element.
Definition: common.hpp:249
bool operator!=(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition: common.hpp:291
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:214
It store all the boxes of the near processors in a linear array.
Definition: common.hpp:299
openfpm::vector_std< Box_sub< dim, T > > ebx
Definition: common.hpp:177
openfpm::vector_std< Box_sub_k< dim, T > > ebx
Definition: common.hpp:147
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:202
openfpm::vector<::Box< dim, T > > bx
near processor sub-domains
Definition: common.hpp:192
size_t n_real_sub
Number of real sub-domains or sub-domain in the central sector.
Definition: common.hpp:198
Boundary conditions.
Definition: common.hpp:21
N_box(const N_box< dim, T > &b)
Copy constructor.
Definition: common.hpp:211