OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
21template<unsigned int dim> struct periodicity
22{
23 size_t bc[dim];
24};
25
30template<unsigned int dim> struct periodicity_int
31{
32 int bc[dim];
33};
34
44template<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
88template<unsigned int dim, typename T>
89struct 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
117template<unsigned int dim, typename T>
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
139template<unsigned int dim,typename T> using Box_map = aggregate<Box<dim,T>,long int>;
140
142template<unsigned int dim, typename T>
144{
148
152};
153
155template<unsigned int dim, typename T>
157{
161
165
166
168 size_t proc;
169};
170
172template<unsigned int dim, typename T>
174{
178
182};
183
184// It store the sub-domain sent by the near processors
185template<unsigned int dim, typename T>
186struct N_box
187{
189 size_t id;
190
193
196
199
204
207 :id((size_t)-1),n_real_sub(0)
208 {};
209
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
298template<unsigned int dim, typename T>
299struct 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_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
Implementation of 1-D std::vector like structure.
Case for external ghost box.
Definition common.hpp:174
openfpm::vector_std< Box_sub< dim, T > > ebx
Definition common.hpp:177
openfpm::vector_std< Box_sub< dim, T > > ibx
Definition common.hpp:181
for each sub-domain box sub contain the real the sub-domain id
Definition common.hpp:46
size_t sub
The id of the real domain.
Definition common.hpp:51
comb< dim > cmb
in witch sector this sub-domain live
Definition common.hpp:54
Box< dim, T > bx
Box defining the sub-domain (copied)
Definition common.hpp:48
Box_loc_sub operator=(const Box< dim, T > &box)
Set the sub-domain box coordinates.
Definition common.hpp:69
Box_loc_sub()
Constructor.
Definition common.hpp:57
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
Case for local external ghost box.
Definition common.hpp:157
openfpm::vector<::Box< dim, T > > bx
Definition common.hpp:160
openfpm::vector<::Box< dim, T > > nbx
Definition common.hpp:164
size_t proc
processor
Definition common.hpp:168
Particular case for local internal ghost boxes.
Definition common.hpp:119
Box< dim, T > bx
extension of this local internal ghost box
Definition common.hpp:121
comb< dim > cmb
Where this sub_domain live.
Definition common.hpp:127
long int k
k
Definition common.hpp:130
size_t sub
Domain id.
Definition common.hpp:124
size_t id
see ebx_ibx_form in ie_ghost for the meaning
Definition common.hpp:98
size_t r_sub
see getNearSubdomainsRealId in nn_prcs
Definition common.hpp:101
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
size_t sub
Domain id.
Definition common.hpp:95
Box_sub()
Constructor reset cmb.
Definition common.hpp:107
openfpm::vector< size_t > r_sub
Definition common.hpp:203
N_box< dim, T > & operator=(N_box< dim, T > &&ele)
Copy the element.
Definition common.hpp:249
N_box< dim, T > & operator=(const N_box< dim, T > &ele)
Copy the element.
Definition common.hpp:231
openfpm::vector<::Box< dim, T > > bx
near processor sub-domains
Definition common.hpp:192
N_box(N_box< dim, T > &&b)
Copy constructor.
Definition common.hpp:218
bool operator==(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition common.hpp:267
size_t n_real_sub
Number of real sub-domains or sub-domain in the central sector.
Definition common.hpp:198
N_box()
Default constructor.
Definition common.hpp:206
N_box(const N_box< dim, T > &b)
Copy constructor.
Definition common.hpp:211
bool operator!=(const N_box< dim, T > &ele) const
Compare two N_box object.
Definition common.hpp:291
size_t id
id of the processor in the nn_processor list (local processor id)
Definition common.hpp:189
openfpm::vector< comb< dim > > pos
near processor sector position (or where they live outside the domain)
Definition common.hpp:195
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
Case for local ghost box.
Definition common.hpp:144
openfpm::vector_std< Box_sub_k< dim, T > > ebx
Definition common.hpp:147
openfpm::vector_std< Box_sub_k< dim, T > > ibx
Definition common.hpp:151
It store all the boxes of the near processors in a linear array.
Definition common.hpp:300
size_t shift_id
shift vector id
Definition common.hpp:310
::Box< dim, T > box
Definition common.hpp:303
bool operator==(const p_box &pb)
Check if two p_box are the same.
Definition common.hpp:319
size_t proc
processor rank
Definition common.hpp:307
size_t lc_proc
local processor id
Definition common.hpp:305
Boundary conditions.
Definition common.hpp:31
Boundary conditions.
Definition common.hpp:22