OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
SparseGridUtil.hpp
1/*
2 * SparseGridUtil.hpp
3 *
4 * Created on: Oct 27, 2017
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_SPARSEGRID_SPARSEGRIDUTIL_HPP_
9#define OPENFPM_DATA_SRC_SPARSEGRID_SPARSEGRIDUTIL_HPP_
10
11const static int cnk_pos = 0;
12const static int cnk_nele = 1;
13const static int cnk_mask = 2;
14
15#include "util/sparsegrid_util_common.hpp"
16
18#define SGRID_CACHE 2
19
21#define FLUSH_REMOVE 1024
22
23template<typename T>
25{
26 typedef T type;
27};
28
30template <typename n_ele, typename T>
32{
34};
35
37template <typename n_ele, typename T, int N1>
38struct Ft_chunk<n_ele,const T(&)[N1]>
39{
40// typedef typename T::culo culo;
42};
43
44template<unsigned int dim>
46{
47 static const int nNN = 2*dim;
48
49 static const int is_cross = false;
50};
51
62template<unsigned int dim, unsigned int stencil_size, typename vector_blocks_ext,typename vector_ext>
64{
66 size_t sz_tot[dim];
67
69 size_t sz_ext[dim];
70
72 size_t sz_ext_b[dim];
73
75 size_t sz_block[dim];
76
78 template<typename T>
79 inline void operator()(T& val)
80 {
81 sz_tot[T::value] = boost::mpl::at<typename vector_blocks_ext::type,boost::mpl::int_<T::value>>::type::value * boost::mpl::at<vector_ext,boost::mpl::int_<T::value>>::type::value + 2*stencil_size;
82 sz_ext[T::value] = boost::mpl::at<vector_ext,boost::mpl::int_<T::value>>::type::value;
83 sz_ext_b[T::value] = boost::mpl::at<vector_ext,boost::mpl::int_<T::value>>::type::value + 2*stencil_size;
84 sz_block[T::value] = boost::mpl::at<typename vector_blocks_ext::type,boost::mpl::int_<T::value>>::type::value;
85 }
86};
87
88template<unsigned int dim>
90{
91 typedef void type;
92};
93
94
95
96template<>
98{
99 typedef boost::mpl::vector<boost::mpl::int_<128>> type;
100
101 typedef boost::mpl::vector<boost::mpl::int_<7>> shift;
102
103 typedef boost::mpl::vector<boost::mpl::int_<7>> shift_c;
104
105 typedef boost::mpl::int_<128> size;
106};
107
108template<>
110{
111 typedef boost::mpl::vector<boost::mpl::int_<32>,
112 boost::mpl::int_<32>> type;
113
114 typedef boost::mpl::vector<boost::mpl::int_<5>,
115 boost::mpl::int_<5>> shift;
116
117 typedef boost::mpl::vector<boost::mpl::int_<5>,
118 boost::mpl::int_<10>> shift_c;
119
120 typedef boost::mpl::int_<1024> size;
121};
122
123template<>
125{
126 typedef boost::mpl::vector<boost::mpl::int_<16>,
127 boost::mpl::int_<16>,
128 boost::mpl::int_<16>> type;
129
130 typedef boost::mpl::vector<boost::mpl::int_<4>,
131 boost::mpl::int_<4>,
132 boost::mpl::int_<4>> shift;
133
134 typedef boost::mpl::vector<boost::mpl::int_<4>,
135 boost::mpl::int_<8>,
136 boost::mpl::int_<12>> shift_c;
137
138 typedef boost::mpl::int_<4096> size;
139
140 typedef boost::mpl::int_<1736> bord_size;
141};
142
143template<>
145{
146 typedef boost::mpl::vector<boost::mpl::int_<8>,
147 boost::mpl::int_<8>,
148 boost::mpl::int_<8>,
149 boost::mpl::int_<8>> type;
150
151 typedef boost::mpl::vector<boost::mpl::int_<3>,
152 boost::mpl::int_<3>,
153 boost::mpl::int_<3>,
154 boost::mpl::int_<3>> shift;
155
156 typedef boost::mpl::vector<boost::mpl::int_<3>,
157 boost::mpl::int_<6>,
158 boost::mpl::int_<9>,
159 boost::mpl::int_<12>> shift_c;
160
161 typedef boost::mpl::int_<4096> size;
162};
163
164template<>
166{
167 typedef boost::mpl::vector<boost::mpl::int_<4>,
168 boost::mpl::int_<4>,
169 boost::mpl::int_<4>,
170 boost::mpl::int_<4>,
171 boost::mpl::int_<4>> type;
172
173 typedef boost::mpl::vector<boost::mpl::int_<2>,
174 boost::mpl::int_<2>,
175 boost::mpl::int_<2>,
176 boost::mpl::int_<2>,
177 boost::mpl::int_<2>> shift;
178
179 typedef boost::mpl::vector<boost::mpl::int_<2>,
180 boost::mpl::int_<4>,
181 boost::mpl::int_<6>,
182 boost::mpl::int_<8>,
183 boost::mpl::int_<10>> shift_c;
184
185 typedef boost::mpl::int_<1024> size;
186};
187
188
189template<>
191{
192 typedef boost::mpl::vector<boost::mpl::int_<4>,
193 boost::mpl::int_<4>,
194 boost::mpl::int_<4>,
195 boost::mpl::int_<4>,
196 boost::mpl::int_<4>,
197 boost::mpl::int_<4>> type;
198
199 typedef boost::mpl::vector<boost::mpl::int_<2>,
200 boost::mpl::int_<2>,
201 boost::mpl::int_<2>,
202 boost::mpl::int_<2>,
203 boost::mpl::int_<2>,
204 boost::mpl::int_<2>> shift_c;
205
206 typedef boost::mpl::vector<boost::mpl::int_<2>,
207 boost::mpl::int_<4>,
208 boost::mpl::int_<6>,
209 boost::mpl::int_<8>,
210 boost::mpl::int_<10>,
211 boost::mpl::int_<12>> shift;
212
213 typedef boost::mpl::int_<4096> size;
214};
215
216
217template<>
219{
220 typedef boost::mpl::vector<boost::mpl::int_<64>,
221 boost::mpl::int_<4>,
222 boost::mpl::int_<4>,
223 boost::mpl::int_<1>,
224 boost::mpl::int_<1>,
225 boost::mpl::int_<1>,
226 boost::mpl::int_<1>> type;
227
228 typedef boost::mpl::vector<boost::mpl::int_<6>,
229 boost::mpl::int_<2>,
230 boost::mpl::int_<2>,
231 boost::mpl::int_<0>,
232 boost::mpl::int_<0>,
233 boost::mpl::int_<0>,
234 boost::mpl::int_<0>> shift;
235
236 typedef boost::mpl::vector<boost::mpl::int_<6>,
237 boost::mpl::int_<8>,
238 boost::mpl::int_<10>,
239 boost::mpl::int_<10>,
240 boost::mpl::int_<10>,
241 boost::mpl::int_<10>,
242 boost::mpl::int_<10>> shift_c;
243
244 typedef boost::mpl::int_<1024> size;
245};
246
247
248template<>
250{
251 typedef boost::mpl::vector<boost::mpl::int_<64>,
252 boost::mpl::int_<4>,
253 boost::mpl::int_<4>,
254 boost::mpl::int_<1>,
255 boost::mpl::int_<1>,
256 boost::mpl::int_<1>,
257 boost::mpl::int_<1>,
258 boost::mpl::int_<1>> type;
259
260 typedef boost::mpl::vector<boost::mpl::int_<6>,
261 boost::mpl::int_<2>,
262 boost::mpl::int_<2>,
263 boost::mpl::int_<0>,
264 boost::mpl::int_<0>,
265 boost::mpl::int_<0>,
266 boost::mpl::int_<0>,
267 boost::mpl::int_<0>> shift;
268
269 typedef boost::mpl::vector<boost::mpl::int_<6>,
270 boost::mpl::int_<8>,
271 boost::mpl::int_<10>,
272 boost::mpl::int_<10>,
273 boost::mpl::int_<10>,
274 boost::mpl::int_<10>,
275 boost::mpl::int_<10>,
276 boost::mpl::int_<10>> shift_c;
277
278 typedef boost::mpl::int_<1024> size;
279};
280
281template<unsigned int dim,
282 typename T,
283 typename S,
284 typename grid_lin = grid_sm<dim,void>,
285 typename layout=typename memory_traits_lin<T>::type,
286 template<typename> class layout_base = memory_traits_lin,
287 typename chunking = default_chunking<dim>>
288class sgrid_cpu;
289
290
291template<unsigned int dim, typename chunk>
293{
294 inline static void shift(grid_key_dx<dim> & k)
295 {
296 std::cerr << __FILE__ << ":" << __LINE__ << " error dimensionality " << dim << " is not implemented" << std::endl;
297 }
298};
299
300template<unsigned int dim, typename chunk>
301struct sublin
302{
303 inline static size_t lin(grid_key_dx<dim> & k)
304 {
305 std::cerr << __FILE__ << ":" << __LINE__ << " error dimensionality " << dim << " is not implemented" << std::endl;
306
307 return 0;
308 }
309};
310
311template<typename chunk>
312struct key_shift<1,chunk>
313{
314 inline static void shift(grid_key_dx<1> & kh, grid_key_dx<1> &kl)
315 {
316 kl.set_d(0,kh.get(0) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<0>>::type::value -1));
317 kh.set_d(0,kh.get(0) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
318 }
319
320 inline static void cpos(grid_key_dx<1> & kh)
321 {
322 kh.set_d(0,kh.get(0) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
323 }
324};
325
326template<typename chunk>
327struct sublin<1,chunk>
328{
329 inline static size_t lin(grid_key_dx<1> & k)
330 {
331 return k.get(0);
332 }
333};
334
335template<typename chunk>
336struct key_shift<2,chunk>
337{
338 inline static void shift(grid_key_dx<2> & kh, grid_key_dx<2> &kl)
339 {
340 kl.set_d(0,kh.get(0) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<0>>::type::value-1));
341 kh.set_d(0,kh.get(0) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
342 kl.set_d(1,kh.get(1) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<1>>::type::value-1));
343 kh.set_d(1,kh.get(1) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<1>>::type::value);
344 }
345
346 inline static void cpos(grid_key_dx<2> & kh)
347 {
348 kh.set_d(0,kh.get(0) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
349 kh.set_d(1,kh.get(1) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<1>>::type::value);
350 }
351};
352
353template<typename chunk>
354struct sublin<2,chunk>
355{
356 inline static size_t lin(grid_key_dx<2> & k)
357 {
358 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
359 }
360};
361
362template<typename chunk>
363struct key_shift<3,chunk>
364{
365 inline static void shift(grid_key_dx<3> & kh, grid_key_dx<3> & kl)
366 {
367 kl.set_d(0,kh.get(0) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<0>>::type::value - 1));
368 kh.set_d(0,kh.get(0) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
369 kl.set_d(1,kh.get(1) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<1>>::type::value - 1));
370 kh.set_d(1,kh.get(1) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<1>>::type::value);
371 kl.set_d(2,kh.get(2) & (boost::mpl::at<typename chunk::type,boost::mpl::int_<2>>::type::value - 1));
372 kh.set_d(2,kh.get(2) >> boost::mpl::at<typename chunk::shift,boost::mpl::int_<2>>::type::value);
373 }
374
375 inline static void cpos(grid_key_dx<3> & kh)
376 {
377 kh.set_d(0,kh.get(0) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<0>>::type::value);
378 kh.set_d(1,kh.get(1) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<1>>::type::value);
379 kh.set_d(2,kh.get(2) << boost::mpl::at<typename chunk::shift,boost::mpl::int_<2>>::type::value);
380 }
381};
382
383template<typename chunk>
384struct sublin<3,chunk>
385{
386 inline static size_t lin(grid_key_dx<3> & k)
387 {
388 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
389 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
390 }
391};
392
393template<typename chunk>
394struct key_shift<4,chunk>
395{
396 inline static void shift(grid_key_dx<4> & kh, grid_key_dx<4> & kl)
397 {
398 kl.set_d(0,kh.get(0) & (boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value - 1));
399 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
400 kl.set_d(1,kh.get(1) & (boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value - 1));
401 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
402 kl.set_d(2,kh.get(2) & (boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value - 1));
403 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
404 kl.set_d(3,kh.get(3) & (boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value - 1));
405 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
406 }
407
408 inline static void cpos(grid_key_dx<4> & kh)
409 {
410 kh.set_d(0,kh.get(0) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
411 kh.set_d(1,kh.get(1) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
412 kh.set_d(2,kh.get(2) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
413 kh.set_d(3,kh.get(3) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
414 }
415};
416
417
418template<typename chunk>
419struct sublin<4,chunk>
420{
421 inline static size_t lin(grid_key_dx<4> & k)
422 {
423 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
424 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value) +
425 (k.get(3) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
426 }
427};
428
429template<typename chunk>
430struct key_shift<5,chunk>
431{
432 inline static void shift(grid_key_dx<5> & kh, grid_key_dx<5> & kl)
433 {
434 kl.set_d(0,kh.get(0) & (boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value - 1));
435 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
436 kl.set_d(1,kh.get(1) & (boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value - 1));
437 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
438 kl.set_d(2,kh.get(2) & (boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value - 1));
439 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
440 kl.set_d(3,kh.get(3) & (boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value - 1));
441 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
442 kl.set_d(4,kh.get(4) & (boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value - 1));
443 kh.set_d(4,kh.get(4) >> boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
444 }
445
446 inline static void cpos(grid_key_dx<5> & kh)
447 {
448 kh.set_d(0,kh.get(0) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
449 kh.set_d(1,kh.get(1) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
450 kh.set_d(2,kh.get(2) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
451 kh.set_d(3,kh.get(3) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
452 kh.set_d(4,kh.get(4) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
453 }
454
455};
456
457template<typename chunk>
458struct sublin<5,chunk>
459{
460 inline static size_t lin(grid_key_dx<5> & k)
461 {
462 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
463 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value) +
464 (k.get(3) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value) +
465 (k.get(4) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
466 }
467};
468
469template<typename chunk>
470struct key_shift<6,chunk>
471{
472 inline static void shift(grid_key_dx<6> & kh, grid_key_dx<6> & kl)
473 {
474 kl.set_d(0,kh.get(0) & (boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value - 1));
475 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
476 kl.set_d(1,kh.get(1) & (boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value - 1));
477 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
478 kl.set_d(2,kh.get(2) & (boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value - 1));
479 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
480 kl.set_d(3,kh.get(3) & (boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value - 1));
481 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
482 kl.set_d(4,kh.get(4) & (boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value - 1));
483 kh.set_d(4,kh.get(4) >> boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
484 kl.set_d(5,kh.get(5) & (boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value - 1));
485 kh.set_d(5,kh.get(5) >> boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
486 }
487
488 inline static void cpos(grid_key_dx<6> & kh)
489 {
490 kh.set_d(0,kh.get(0) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
491 kh.set_d(1,kh.get(1) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
492 kh.set_d(2,kh.get(2) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
493 kh.set_d(3,kh.get(3) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
494 kh.set_d(4,kh.get(4) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
495 kh.set_d(5,kh.get(5) << boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
496 }
497};
498
499template<typename chunk>
500struct sublin<6,chunk>
501{
502 inline static size_t lin(grid_key_dx<6> & k)
503 {
504 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
505 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value) +
506 (k.get(3) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value) +
507 (k.get(4) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value) +
508 (k.get(5) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
509
510 }
511};
512
513
514template<typename chunk>
515struct key_shift<7,chunk>
516{
517 inline static void shift(grid_key_dx<7> & kh, grid_key_dx<7> & kl)
518 {
519 kl.set_d(0,kh.get(0) & (boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value - 1));
520 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
521 kl.set_d(1,kh.get(1) & (boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value - 1));
522 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
523 kl.set_d(2,kh.get(2) & (boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value - 1));
524 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
525 kl.set_d(3,kh.get(3) & (boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value - 1));
526 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
527 kl.set_d(4,kh.get(4) & (boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value - 1));
528 kh.set_d(4,kh.get(4) >> boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
529 kl.set_d(5,kh.get(5) & (boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value - 1));
530 kh.set_d(5,kh.get(5) >> boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
531 kl.set_d(6,kh.get(6) & (boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value - 1));
532 kh.set_d(6,kh.get(6) >> boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value);
533 }
534
535 inline static void cpos(grid_key_dx<7> & kh)
536 {
537 kh.set_d(0,kh.get(0) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
538 kh.set_d(1,kh.get(1) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
539 kh.set_d(2,kh.get(2) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
540 kh.set_d(3,kh.get(3) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
541 kh.set_d(4,kh.get(4) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
542 kh.set_d(5,kh.get(5) << boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
543 kh.set_d(6,kh.get(6) << boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value);
544 }
545};
546
547template<typename chunk>
548struct sublin<7,chunk>
549{
550 inline static size_t lin(grid_key_dx<7> & k)
551 {
552 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
553 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value) +
554 (k.get(3) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value) +
555 (k.get(4) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value) +
556 (k.get(5) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value) +
557 (k.get(6) << boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
558 }
559};
560
561template<typename chunk>
562struct key_shift<8,chunk>
563{
564 inline static void shift(grid_key_dx<8> & kh, grid_key_dx<8> & kl)
565 {
566 kl.set_d(0,kh.get(0) & (boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value - 1));
567 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
568 kl.set_d(1,kh.get(1) & (boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value - 1));
569 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
570 kl.set_d(2,kh.get(2) & (boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value - 1));
571 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
572 kl.set_d(3,kh.get(3) & (boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value - 1));
573 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
574 kl.set_d(4,kh.get(4) & (boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value - 1));
575 kh.set_d(4,kh.get(4) >> boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
576 kl.set_d(5,kh.get(5) & (boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value - 1));
577 kh.set_d(5,kh.get(5) >> boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
578 kl.set_d(6,kh.get(6) & (boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value - 1));
579 kh.set_d(6,kh.get(6) >> boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value);
580 kl.set_d(7,kh.get(7) & (boost::mpl::at<chunk,boost::mpl::int_<7>>::type::value - 1));
581 kh.set_d(7,kh.get(7) >> boost::mpl::at<chunk,boost::mpl::int_<7>>::type::value);
582 }
583
584 inline static void cpos(grid_key_dx<8> & kh)
585 {
586 kh.set_d(0,kh.get(0) >> boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value);
587 kh.set_d(1,kh.get(1) >> boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value);
588 kh.set_d(2,kh.get(2) >> boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value);
589 kh.set_d(3,kh.get(3) >> boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value);
590 kh.set_d(4,kh.get(4) >> boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value);
591 kh.set_d(5,kh.get(5) >> boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value);
592 kh.set_d(6,kh.get(6) >> boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value);
593 kh.set_d(7,kh.get(7) >> boost::mpl::at<chunk,boost::mpl::int_<7>>::type::value);
594 }
595};
596
597template<typename chunk>
598struct sublin<8,chunk>
599{
600 inline static size_t lin(grid_key_dx<8> & k)
601 {
602 return k.get(0) + (k.get(1) << boost::mpl::at<chunk,boost::mpl::int_<0>>::type::value) +
603 (k.get(2) << boost::mpl::at<chunk,boost::mpl::int_<1>>::type::value) +
604 (k.get(3) << boost::mpl::at<chunk,boost::mpl::int_<2>>::type::value) +
605 (k.get(4) << boost::mpl::at<chunk,boost::mpl::int_<3>>::type::value) +
606 (k.get(5) << boost::mpl::at<chunk,boost::mpl::int_<4>>::type::value) +
607 (k.get(6) << boost::mpl::at<chunk,boost::mpl::int_<5>>::type::value) +
608 (k.get(7) << boost::mpl::at<chunk,boost::mpl::int_<6>>::type::value);
609 }
610};
611
612
613
614template<typename T>
616{
617 template<unsigned int p, typename chunks_vector_type>
618 static T & get(chunks_vector_type & chunks, size_t active_cnk, int ele_id)
619 {
620 return chunks.template get<p>(active_cnk)[ele_id];
621 }
622
623 template<unsigned int p, typename chunks_vector_type>
624 static const T & get_const(chunks_vector_type & chunks, size_t active_cnk, int ele_id)
625 {
626 return chunks.template get<p>(active_cnk)[ele_id];
627 }
628};
629
630template<typename T, unsigned int N1>
631struct get_selector<T[N1]>
632{
633 template<unsigned int p, typename chunks_vector_type>
634 static std_array_vector_view<decltype(std::declval<chunks_vector_type>().template get<p>(0))> get(chunks_vector_type & chunks, size_t active_cnk, int ele_id)
635 {
636 return std_array_vector_view<decltype(chunks.template get<p>(active_cnk))>(ele_id,chunks.template get<p>(active_cnk));
637 }
638
639 template<unsigned int p, typename chunks_vector_type>
640 static const std_array_vector_view<decltype(std::declval<chunks_vector_type>().template get<p>(0))> get_const(chunks_vector_type & chunks, size_t active_cnk, int ele_id)
641 {
642 return std_array_vector_view<decltype(chunks.template get<p>(active_cnk))>(ele_id,chunks.template get<p>(active_cnk));
643 }
644};
645
646#endif /* OPENFPM_DATA_SRC_SPARSEGRID_SPARSEGRIDUTIL_HPP_ */
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
Definition grid_key.hpp:516
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167
transform T=aggregate<float,double,int> into aggregate<std::array<float,n_ele>,std::array<double,...
this class is a functor for "for_each" algorithm
size_t sz_block[dim]
sizes
size_t sz_tot[dim]
sizes in point with border
void operator()(T &val)
It call the copy function for each property.
size_t sz_ext_b[dim]
sizes with border block
size_t sz_ext[dim]
sizes blocks
Transform the boost::fusion::vector into memory specification (memory_traits)