OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
FD_expressions.hpp
1/*
2 * FD_expressions.hpp
3 *
4 * Created on: May 7, 2020
5 * Author: i-bird
6 */
7
8#ifndef FD_EXPRESSIONS_HPP_
9#define FD_EXPRESSIONS_HPP_
10
11template<typename T, typename Sfinae = void>
12struct has_getGrid: std::false_type {};
13
14template<typename T>
15struct has_getGrid<T, typename Void<decltype(std::declval<T>().getGrid())>::type > : std::true_type
16{};
17
18namespace FD
19{
20
21 template<bool cond, typename exp1, typename exp2>
23 {
24 static auto getGrid(const exp1 & o1, const exp2 & o2) -> decltype(o2.getGrid())
25 {
26 return o2.getGrid();
27 }
28 };
29
30 template<typename exp1, typename exp2>
31 struct first_or_second<true,exp1,exp2>
32 {
33 static auto getGrid(const exp1 & o1, const exp2 & o2) -> decltype(o1.getGrid())
34 {
35 return o1.getGrid();
36 }
37 };
38
39 constexpr int NORM_EXPRESSION = 0;
40 constexpr int STAG_EXPRESSION = 1;
41 constexpr int GRID_COMP = 2;
42
43 template <typename exp1,typename exp2, typename impl>
45 {
46 };
47
48 struct g_comp {};
49
50 template<unsigned int i>
52 {
53 template<unsigned int prp, typename base_type, typename gtype>
54 static void inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, base_type & inte_out, int & c)
55 {
56 if (c_where[i] != c_o1[i])
57 {
58 int sign = (c_where[i] > c_o1[i])?1:-1;
59
60 grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c);
61 long int x0 = k.getKeyRef().get(i);
62
63 k.getKeyRef().set_d(i, x0 + sign);
64 grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c);
65 k.getKeyRef().set_d(i, x0);
66 }
67 else
68 {
69 grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c);
70 }
71 }
72 };
73
74 template<>
76 {
77 template<unsigned int prp, typename base_type, typename gtype>
78 static void inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, base_type & inte_out , int & c)
79 {
80 if (c_where[0] != c_o1[0])
81 {
82 int sign = (c_where[0] > c_o1[0])?1:-1;
83
84 inte_out += g.template getProp<prp>(k);
85
86 long int x0 = k.getKeyRef().get(0);
87
88 k.getKeyRef().set_d(0, x0 + sign);
89 inte_out += g.template getProp<prp>(k);
90 k.getKeyRef().set_d(0, x0);
91 c += 2;
92 }
93 else
94 {
95 inte_out += g.template getProp<prp>(k);
96 c += 1;
97 }
98 }
99 };
100
101 template<typename base_type>
103 {
104 typedef base_type type;
105
106 template<unsigned int prp, typename gtype>
107 static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, int comp)
108 {
109 int c = 0;
110 base_type inte = 0;
111
112 grid_dist_expression_value_impl_func_scal<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
113
114 inte /= c;
115
116 return inte;
117 }
118
119 template<unsigned int prp, typename gtype>
120 static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1)
121 {
122 int c = 0;
123 base_type inte = 0;
124
125 grid_dist_expression_value_impl_func_scal<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c);
126
127 inte /= c;
128
129 return inte;
130 }
131
132 template<unsigned int prp, typename gtype>
133 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
134 {
135 return g.template getProp<prp>(k);
136 }
137
138 template<unsigned int prp, typename gtype>
139 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp)
140 {
141 return g.template getProp<prp>(k);
142 }
143
144 template<unsigned int prp, typename gtype>
145 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k))
146 {
147 return g.template getProp<prp>(k);
148 }
149
150 template<unsigned int prp, typename gtype>
151 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp) -> decltype(g.template getProp<prp>(k))
152 {
153 return g.template getProp<prp>(k);
154 }
155 };
156
157
158 template<unsigned int i>
160 {
161 template<unsigned int prp, typename base_type, typename gtype>
162 static void inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, base_type & inte_out, int & c, const int (& comp)[1])
163 {
164 if (c_where[i] != c_o1[i])
165 {
166 grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
167 long int x0 = k.getKeyRef().get(i);
168
169 int sign = (c_where[i] > c_o1[i])?1:-1;
170
171 k.getKeyRef().set_d(i, x0 + sign);
172 grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
173 k.getKeyRef().set_d(i, x0);
174 }
175 else
176 {
177 grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
178 }
179 }
180 };
181
182 template<>
184 {
185 template<unsigned int prp, typename base_type, typename gtype>
186 static void inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, base_type & inte_out , int & c , const int (& comp)[1])
187 {
188 if (c_where[0] != c_o1[0])
189 {
190 int sign = (c_where[0] > c_o1[0])?1:-1;
191
192 inte_out += g.template getProp<prp>(k)[comp[0]];
193
194 long int x0 = k.getKeyRef().get(0);
195
196 k.getKeyRef().set_d(0, x0 + sign);
197 inte_out += g.template getProp<prp>(k)[comp[0]];
198 k.getKeyRef().set_d(0, x0);
199 c += 2;
200 }
201 else
202 {
203 inte_out += g.template getProp<prp>(k)[comp[0]];
204 c += 1;
205 }
206 }
207 };
208
209 template<typename base_type, unsigned int N1>
211 {
212 typedef base_type type;
213
214 template<unsigned int prp, typename gtype>
215 static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, const int (& comp)[1])
216 {
217 int c = 0;
218 base_type inte = 0;
219
220 grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
221
222 if (c != 0)
223 {inte /= c;}
224 else
225 {inte = g.template getProp<prp>(k)[comp];}
226
227 return inte;
228 }
229
230 template<unsigned int prp, typename gtype>
231 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
232 {
233 printf("Error wrong expression please check the components");
234 return g.template getProp<prp>(k)[0];
235 }
236
237 template<unsigned int prp, typename gtype>
238 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1])
239 {
240 return g.template getProp<prp>(k)[comp[0]];
241 }
242
243 template<unsigned int prp, typename gtype>
244 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0])
245 {
246 printf("Error wrong expression please check the components");
247 return g.template getProp<prp>(k)[0];
248 }
249
250 template<unsigned int prp, typename gtype>
251 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1]) -> decltype(g.template getProp<prp>(k)[comp[0]])
252 {
253 return g.template getProp<prp>(k)[comp[0]];
254 }
255 };
256
257
258
259
260 template<typename base_type, unsigned int N1,unsigned int N2>
261 struct grid_dist_expression_value_impl<base_type[N1][N2]>
262 {
263 typedef base_type type;
264
265 template<unsigned int prp, typename gtype>
266 static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, const int (& comp)[2])
267 {
268 int c = 0;
269 base_type inte = 0;
270
271 grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
272
273 if (c != 0)
274 {inte /= c;}
275 else
276 {inte = g.template getProp<prp>(k)[comp[0]][comp[1]];}
277
278 return inte;
279 }
280
281 template<unsigned int prp, typename gtype>
282 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
283 {
284 printf("Error wrong expression please check the components");
285 return g.template getProp<prp>(k)[0][0];
286 }
287
288 template<unsigned int prp, typename gtype>
289 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2])
290 {
291 return g.template getProp<prp>(k)[comp[0]][comp[1]];
292 }
293
294 template<unsigned int prp, typename gtype>
295 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0][0])
296 {
297 printf("Error wrong expression please check the components");
298 return g.template getProp<prp>(k)[0][0];
299 }
300
301 template<unsigned int prp, typename gtype>
302 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2]) -> decltype(g.template getProp<prp>(k)[0][0])
303 {
304 return g.template getProp<prp>(k)[comp[0]][comp[1]];
305 }
306 };
307
308 template<typename base_type, unsigned int N1,unsigned int N2, unsigned int N3>
309 struct grid_dist_expression_value_impl<base_type[N1][N2][N3]>
310 {
311 typedef base_type type;
312
313 template<unsigned int prp, typename gtype>
314 static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, const int (& comp)[3])
315 {
316 int c = 0;
317 base_type inte = 0;
318
319 grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
320
321 if (c != 0)
322 {inte /= c;}
323 else
324 {inte = g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];}
325
326 return inte;
327 }
328
329 template<unsigned int prp, typename gtype>
330 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
331 {
332 printf("Error wrong expression please check the components");
333 return g.template getProp<prp>(k)[0][0][0];
334 }
335
336 template<unsigned int prp, typename gtype>
337 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2])
338 {
339 printf("Error wrong expression please check the components");
340 return g.template getProp<prp>(k)[0][comp[0]][comp[1]];
341 }
342
343 template<unsigned int prp, typename gtype>
344 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[3])
345 {
346 return g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];
347 }
348
349 template<unsigned int prp, typename gtype>
350 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0][0][0])
351 {
352 printf("Error wrong expression please check the components");
353 return g.template getProp<prp>(k)[0][0][0];
354 }
355
356 template<unsigned int prp, typename gtype>
357 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2]) -> decltype(g.template getProp<prp>(k)[0][0][0])
358 {
359 printf("Error wrong expression please check the components");
360 return g.template getProp<prp>(k)[0][comp[1]][comp[0]];
361 }
362
363 template<unsigned int prp, typename gtype>
364 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[3]) -> decltype(g.template getProp<prp>(k)[0][0][0])
365 {
366 return g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];
367 }
368 };
369
370 template<typename base_type, unsigned int N1>
372 {
373 typedef base_type type;
374
375 template<unsigned int prp, typename gtype>
376 static base_type inte(gtype & g, const grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1)
377 {
378 int comp[1];
379 printf("Error wrong expression please check the components");
380 int c = 0;
381 base_type inte = 0;
382
383 grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
384
385 if (c != 0)
386 {inte /= c;}
387 else
388 {inte = g.template getProp<prp>(k)[0];}
389
390 return inte;
391 }
392
393 template<unsigned int prp, typename gtype>
394 static base_type inte(gtype & g, const grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1, const int (& comp)[1])
395 {
396 int c = 0;
397 base_type inte = 0;
398
400
401 grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k_,c_where,c_o1,inte,c,comp);
402
403 if (c != 0)
404 {inte /= c;}
405 else
406 {inte = g.template getProp<prp>(k)[comp[0]];}
407
408 return inte;
409 }
410
411 template<unsigned int prp, typename gtype>
412 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
413 {
414 printf("Error wrong expression please check the components");
415 return g.template getProp<prp>(k)[0];
416 }
417
418 template<unsigned int prp, typename gtype>
419 static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1])
420 {
421 return g.template getProp<prp>(k)[comp[0]];
422 }
423
424 template<unsigned int prp, typename gtype>
425 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1]) -> decltype(g.template getProp<prp>(k)[comp[0]])
426 {
427 return g.template getProp<prp>(k)[comp[0]];
428 }
429
430 template<unsigned int prp, typename gtype>
431 static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0])
432 {
433 printf("Error wrong expression please check the components");
434 return g.template getProp<prp>(k)[0];
435 }
436 };
437
438 template<unsigned int i>
440 {
441 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
442 static void value_nz(const gmap_type & g_map,
443 unordered_map_type & cols,
444 gtype & g,
446 comb<gtype::dims> & c_where,
447 comb<gtype::dims> & c_o1,
448 typename Sys_eqs::stype coeff,
449 int & c,
450 int comp,
451 int var_id)
452 {
453 if (c_where[i] != c_o1[i])
454 {
455 int sign = (c_where[i] > c_o1[i])?1:-1;
456
457 grid_dist_expression_value_impl_vnz<i-1>::template value_nz<Sys_eqs>(g_map,cols,g,key,c_where,c_o1,coeff,c,comp,var_id);
458 //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
459
460 long int x0 = key.getKeyRef().get(i);
461
462 key.getKeyRef().set_d(i, x0 + sign);
463 grid_dist_expression_value_impl_vnz<i-1>::template value_nz<Sys_eqs>(g_map,cols,g,key,c_where,c_o1,coeff,c,comp,var_id);
464 //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
465 key.getKeyRef().set_d(i, x0);
466 }
467 else
468 {grid_dist_expression_value_impl_vnz<i-1>::template value_nz<Sys_eqs>(g_map,cols,g,key,c_where,c_o1,coeff,c,comp,var_id);}
469 }
470 };
471
472 template<>
474 {
475 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
476 static void value_nz(const gmap_type & g_map,
477 unordered_map_type & cols,
478 gtype & g,
480 comb<gtype::dims> & c_where,
481 comb<gtype::dims> & c_o1,
482 typename Sys_eqs::stype coeff,
483 int & c ,
484 int comp,
485 int var_id)
486 {
487 if (c_where[0] != c_o1[0])
488 {
489 int sign = (c_where[0] > c_o1[0])?1:-1;
490
491 cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
492
493 long int x0 = key.getKeyRef().get(0);
494
495 key.getKeyRef().set_d(0, x0 + sign);
496 cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
497 key.getKeyRef().set_d(0, x0);
498 }
499 else
500 {
501 cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
502 }
503 }
504 };
505
506 template<unsigned int prp, typename grid, unsigned int impl>
508 {};
509
516 template<unsigned int prp, typename grid>
517 class grid_dist_expression<prp,grid,NORM_EXPRESSION>
518 {
521
522 typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
523
524 public:
525
527 typedef grid gtype;
528
530 static const unsigned int prop = prp;
531
532 int var_id = 0;
533
534 void setVarId(int var_id)
535 {
536 this->var_id = var_id;
537 }
538
541 :g(g)
542 {}
543
552 {
553 return g;
554 }
555
563 const grid & getGrid() const
564 {
565 return g;
566 }
567
573 inline void init() const
574 {}
575
583 inline auto value(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k))
584 {
586 }
587
595 template<unsigned int nc>
596 inline auto value(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, const int (& comp)[nc]) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp))
597 {
598 return grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp);
599 }
600
608 inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k))
609 {
611 }
612
620 template<unsigned int nc>
621 inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, const int (& comp)[nc]) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp))
622 {
623 return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
624 }
625
633 template<unsigned int prp2,typename grid_type> grid & operator=(const grid_dist_expression<prp2,grid_type,NORM_EXPRESSION> & g_exp)
634 {
635 g_exp.init();
636
637 comb<grid::dims> s_pos;
638 s_pos.zero();
639
640 auto it = g.getDomainIterator();
641
642 while (it.isNext())
643 {
644 auto key = it.get();
645
646 g.template getProp<prp>(key) = g_exp.value(key,s_pos);
647
648 ++it;
649 }
650
651 return g;
652 }
653
661 template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
662 {
663 g_exp.init();
664
665 comb<grid::dims> s_pos;
666 s_pos.mone();
667
668 auto it = g.getDomainIterator();
669
670 while (it.isNext())
671 {
672 auto key = it.get();
673
674 g.template getProp<prp>(key) = g_exp.value(key,s_pos);
675
676 ++it;
677 }
678
679 return g;
680 }
681
689 grid & operator=(double d)
690 {
691 auto it = g.getDomainIterator();
692
693 //comb<grid::dims> s_pos;
694 //s_pos.mone();
695
696 while (it.isNext())
697 {
698 auto key = it.get();
699
700 g.template getProp<prp>(key) = d;
701
702 ++it;
703 }
704
705 return g;
706 }
707
708
709 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
710 inline void value_nz(const gmap_type & g_map,
713 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
714 unordered_map_type & cols,
715 typename Sys_eqs::stype coeff,
716 unsigned int comp,
717 comb<Sys_eqs::dims> & c_where) const
718 {
719 cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
720 }
721
722 inline grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
723 {
724 int comp_n[1];
725
726 comp_n[0] = comp;
727
728 grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
729
730 return v_exp;
731 }
732
733 //Need more treatment for staggered (c_where based on exp)
734 inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
735 {
736 comb<gtype::dims> c_where;
737 c_where.zero();
738 return this->value(key,c_where);
739 }
740
741 int isConstant(){
742 return false;
743 }
744 };
745
746 template<unsigned int prp, typename grid>
747 class grid_dist_expression<prp,grid,STAG_EXPRESSION>
748 {
751
752 typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
753
754 public:
755
757 typedef grid gtype;
758
760 static const unsigned int prop = prp;
761
762 int var_id = 0;
763
764 void setVarId(int var_id)
765 {
766 this->var_id = var_id;
767 }
768
771 :g(g)
772 {}
773
782 {
783 return g;
784 }
785
793 const grid & getGrid() const
794 {
795 return g;
796 }
797
803 inline void init() const
804 {}
805
813 inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k))
814 {
816 //return g.template getProp<prp>(k);
817 }
818
826 template<unsigned int nc>
827 inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, const int (& comp)[nc]) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp))
828 {
829 return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
830 //return g.template getProp<prp>(k);
831 }
832
840 inline auto value(grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where) const -> decltype(grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_where))
841 {
842 comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(0);
843
844 return grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_o1);
845 }
846
854 template<unsigned int nc>
855 inline auto value(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, const int (& comp)[nc]) const -> decltype(grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_where,comp))
856 {
857 comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(comp[0]);
858
859 return grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_o1,comp);
860// return g.template getProp<prp>(k);
861 }
862
870 template<unsigned int prp2> grid & operator=(const grid_dist_expression<prp2,grid,STAG_EXPRESSION> & g_exp)
871 {
872 g_exp.init();
873
874 auto it = g.getDomainIterator();
875
876 comb<grid::dims> s_pos = g.getStagPosition()[prp].get(0);
877
878 while (it.isNext())
879 {
880 auto key = it.get();
881
882 g.template getProp<prp>(key) = g_exp.value(key,s_pos);
883
884 ++it;
885 }
886
887 return g;
888 }
889
897 template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
898 {
899 g_exp.init();
900
901 auto it = g.getDomainIterator();
902
903 comb<grid::dims> s_pos = g.getStagPositions()[prp].get(0);
904
905 while (it.isNext())
906 {
907 auto key = it.get();
908
909 g.template getProp<prp>(key) = g_exp.value(key,s_pos);
910
911 ++it;
912 }
913
914 return g;
915 }
916
924 grid & operator=(double d)
925 {
926 auto it = g.getDomainIterator();
927
928 while (it.isNext())
929 {
930 auto key = it.get();
931
932 g.template getProp<prp>(key) = d;
933
934 ++it;
935 }
936
937 return g;
938 }
939
940 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
941 inline void value_nz(const gmap_type & g_map,
944 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
945 unordered_map_type & cols,
946 typename Sys_eqs::stype coeff,
947 unsigned int comp,
948 comb<Sys_eqs::dims> & c_where) const
949 {
950 int c = 1;
951 comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(comp);
952
953 // x0, dx are defined in proper dir Ñ”(x, y, z)
954
955 for (int i = 0 ; i < grid::dims ; i++)
956 {
957 if (c_where[i] != c_o1[i])
958 {c *= 2;}
959 }
960
961 grid_dist_expression_value_impl_vnz<Sys_eqs::dims-1>::template value_nz<Sys_eqs>(g_map,cols,g,key,c_where,c_o1,coeff,c,comp,var_id);
962
963 }
964
965 inline grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
966 {
967 int comp_n[1];
968
969 comp_n[0] = comp;
970
971 grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
972
973 return v_exp;
974 }
975
976 };
977
983 template<unsigned int dim>
984 class grid_dist_expression<dim,double,NORM_EXPRESSION>
985 {
987 double d;
988
989 public:
990
992 inline grid_dist_expression(const double & d)
993 :d(d)
994 {}
995
1001 inline void init() const
1002 {}
1003
1013 inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
1014 {
1015 return d;
1016 }
1017 };
1018
1024 template<unsigned int dim>
1025 class grid_dist_expression<dim,double,STAG_EXPRESSION>
1026 {
1028 double d;
1029
1030 public:
1031
1033 inline grid_dist_expression(const double & d)
1034 :d(d)
1035 {}
1036
1042 inline void init() const
1043 {}
1044
1054 inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
1055 {
1056 return d;
1057 }
1058 };
1059
1065 template<unsigned int dim, unsigned int impl>
1066 class grid_dist_expression<dim,float,impl>
1067 {
1069 float d;
1070
1071 public:
1072
1074 typedef float vtype;
1075
1077 inline grid_dist_expression(const float & d)
1078 :d(d)
1079 {}
1080
1086 inline void init() const
1087 {}
1088
1098 inline float value(const grid_dist_key_dx<dim> & k) const
1099 {
1100 return d;
1101 }
1102 };
1103
1104 struct sum {};
1105
1106 template <typename exp1, typename exp2>
1108 {
1110 const exp1 o1;
1111
1113 const exp2 o2;
1114
1115 public:
1116
1117 typedef typename exp1::gtype gtype;
1118
1120 inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1121 :o1(o1),o2(o2)
1122 {}
1123
1129 inline void init() const
1130 {
1131 o1.init();
1132 o2.init();
1133 }
1134
1142 inline auto value(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> typename std::remove_reference<decltype(o1.value(key,c_where))>::type
1143 {
1144 typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1145
1146 return o1.value(key,c_where) + o2.value(key,c_where);
1147 }
1148
1156 gtype & getGrid()
1157 {
1158 return o1.getGrid();
1159 }
1160
1168 const gtype & getGrid() const
1169 {
1170 return o1.getGrid();
1171 }
1172
1173 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1174 inline void value_nz(const gmap_type & g_map,
1176 const grid_sm<Sys_eqs::dims,void> & gs,
1177 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1178 unordered_map_type & cols,
1179 typename Sys_eqs::stype coeff,
1180 unsigned int comp,
1181 comb<Sys_eqs::dims> & c_where) const
1182 {
1183 o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1184 o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1185 }
1186 };
1187
1188 struct sub {};
1189
1190
1191 template <typename exp1, typename exp2>
1193 {
1195 const exp1 o1;
1196
1198 const exp2 o2;
1199
1200 public:
1201
1202 typedef typename exp1::gtype gtype;
1203
1205 inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1206 :o1(o1),o2(o2)
1207 {}
1208
1214 inline void init() const
1215 {
1216 o1.init();
1217 o2.init();
1218 }
1219
1227 inline auto value(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> typename std::remove_reference<decltype(o1.value(key,c_where))>::type
1228 {
1229 typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1230
1231 return o1.value(key,c_where) - o2.value(key,c_where);
1232 }
1233
1241 gtype & getGrid()
1242 {
1243 return o1.getGrid();
1244 }
1245
1253 const gtype & getGrid() const
1254 {
1255 return o1.getGrid();
1256 }
1257
1258 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1259 inline void value_nz(const gmap_type & g_map,
1261 const grid_sm<Sys_eqs::dims,void> & gs,
1262 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1263 unordered_map_type & cols,
1264 typename Sys_eqs::stype coeff,
1265 unsigned int comp,
1266 comb<Sys_eqs::dims> & c_where) const
1267 {
1268 o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1269 o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1270 }
1271 };
1272
1273 struct subuni{};
1274
1275 template <typename exp1>
1277 {
1279 const exp1 o1;
1280
1281 public:
1282
1283 typedef typename exp1::gtype gtype;
1284
1286 inline grid_dist_expression_op(const exp1 & o1)
1287 :o1(o1)
1288 {}
1289
1295 inline void init() const
1296 {
1297 o1.init();
1298 }
1299
1307 inline auto value(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> typename std::remove_reference<decltype(o1.value(key,c_where))>::type
1308 {
1309 typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1310
1311 return -o1.value(key,c_where);
1312 }
1313
1321 gtype & getGrid()
1322 {
1323 return o1.getGrid();
1324 }
1325
1333 const gtype & getGrid() const
1334 {
1335 return o1.getGrid();
1336 }
1337
1338 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1339 inline void value_nz(const gmap_type & g_map,
1341 const grid_sm<Sys_eqs::dims,void> & gs,
1342 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1343 unordered_map_type & cols,
1344 typename Sys_eqs::stype coeff,
1345 unsigned int comp,
1346 comb<Sys_eqs::dims> & c_where) const
1347 {
1348 o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1349 }
1350 };
1351
1352 struct mul {};
1353
1354 template <typename exp1, typename exp2>
1356 {
1358 const exp1 o1;
1359
1361 const exp2 o2;
1362
1363 public:
1364
1365 typedef typename exp2::gtype gtype;
1366
1368 inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1369 :o1(o1),o2(o2)
1370 {}
1371
1377 inline void init() const
1378 {
1379 o1.init();
1380 o2.init();
1381 }
1382
1390 inline auto value(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> typename std::remove_reference<decltype(o1.value(key,c_where))>::type
1391 {
1392 typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1393
1394 return o1.value(key,c_where) * o2.value(key,c_where);
1395 }
1396
1404 auto getGrid() -> decltype(first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2))
1405 {
1406 return first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2);
1407 }
1408
1416 auto getGrid() const -> decltype(first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2))
1417 {
1418 return first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2);
1419 }
1420
1421 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1422 inline void value_nz(const gmap_type & g_map,
1424 const grid_sm<Sys_eqs::dims,void> & gs,
1425 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1426 unordered_map_type & cols,
1427 typename Sys_eqs::stype coeff,
1428 unsigned int comp,
1429 comb<Sys_eqs::dims> & c_where) const
1430 {
1431 typename Sys_eqs::stype coeff_tmp = o1.value(key,c_where) * coeff;
1432
1433 o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff_tmp,comp,c_where);
1434 }
1435 };
1436
1444 template <typename grid_type, unsigned int prp>
1446 {
1448 __device__ __host__ static inline auto value(grid_type & v, const grid_dist_key_dx<grid_type::dims> & k) -> decltype(v.template getProp<prp>(k))
1449 {
1450 return v.template getProp<prp>(k);
1451 }
1452 };
1453
1454 template<unsigned int, bool is_valid>
1456 {
1457 template<typename exp_type>
1458 inline static auto get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where) -> decltype(o1.value(key,c_where))
1459 {
1460 return o1.value(key,c_where);
1461 }
1462
1463 template<typename exp_type>
1464 inline static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where) -> decltype(o1.value_ref(key,c_where))
1465 {
1466 return o1.value_ref(key,c_where);
1467 }
1468
1469 template<unsigned int prop, typename exp_type, typename grid_type>
1470 inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1471 {
1472 pos_or_propL<grid_type,exp_type::prop>::value(g,key) = o1.value(key);
1473 }
1474
1475 template<unsigned int prop, typename grid_type>
1476 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1477 {
1479 }
1480 };
1481
1482 template<>
1484 {
1485 template<typename exp_type>
1486 static int get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[1])
1487 {
1488 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1489 return 0;
1490 }
1491
1492 template<typename exp_type>
1493 static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[1]) -> decltype(o1.value_ref(key,c_where))
1494 {
1495 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1496 return o1.value_ref(key,c_where);
1497 }
1498
1499 template<unsigned int prop, typename exp_type, typename grid_type>
1500 inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1501 {
1502 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1503 }
1504
1505 template<unsigned int prop, typename grid_type>
1506 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1507 {
1508 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1509 }
1510 };
1511
1512 template<>
1514 {
1515 template<typename exp_type>
1516 static auto get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[1]) -> decltype(o1.value(key,c_where,comp) )
1517 {
1518 return o1.value(key,c_where,comp);
1519 }
1520
1521 template<typename exp_type>
1522 static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[1]) -> decltype(o1.value_ref(key,c_where,comp) )
1523 {
1524 return o1.value_ref(key,c_where,comp);
1525 }
1526
1527 template<unsigned int prop,typename exp_type, typename grid_type>
1528 inline static void assign(exp_type & o1, grid_type & g, grid_dist_key_dx<exp_type::gtype::dims> & key,comb<exp_type::gtype::dims> & c_where, const int (& comp)[1])
1529 {
1530 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = o1.value(key,c_where);
1531 }
1532
1533 template<unsigned int prop, typename grid_type>
1534 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[1])
1535 {
1536 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = d;
1537 }
1538 };
1539
1540 template<>
1542 {
1543 template<typename exp_type>
1544 static auto get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2]) -> decltype(o1.value(key,c_where,comp) )
1545 {
1546 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1547 return o1.value(key,c_where,comp);
1548 }
1549
1550 template<typename exp_type>
1551 static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2]) -> decltype(o1.value_ref(key,c_where,comp) )
1552 {
1553 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1554 return o1.value_ref(key,c_where,comp);
1555 }
1556
1557 template<unsigned int prop,typename exp_type, typename grid_type>
1558 inline static void assign(exp_type & o1, grid_type & g, grid_dist_key_dx<grid_type::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2])
1559 {
1560 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1561 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = o1.value(key,c_where);
1562 }
1563
1564 template<unsigned int prop, typename grid_type>
1565 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1566 {
1567 printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1568 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = d;
1569 }
1570 };
1571
1572 template<>
1574 {
1575 template<typename exp_type>
1576 static auto get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2]) -> decltype(o1.value(key,c_where,comp) )
1577 {
1578 return o1.value(key,c_where,comp);
1579 }
1580
1581 template<typename exp_type>
1582 static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2]) -> decltype(o1.value_ref(key,c_where,comp) )
1583 {
1584 return o1.value_ref(key,c_where,comp);
1585 }
1586
1587 template<unsigned int prop,typename exp_type, typename grid_type>
1588 inline static void assign(exp_type & o1, grid_type & g, grid_dist_key_dx<grid_type::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[2])
1589 {
1590 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = o1.value(key,c_where);
1591 }
1592
1593 template<unsigned int prop, typename grid_type>
1594 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1595 {
1596 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = d;
1597 }
1598 };
1599
1600 template<>
1602 {
1603 template<typename exp_type>
1604 static auto get(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[3]) -> decltype(o1.value(key,c_where,comp) )
1605 {
1606 return o1.value(key,c_where,comp);
1607 }
1608
1609 template<typename exp_type>
1610 static auto get_ref(exp_type & o1, grid_dist_key_dx<exp_type::gtype::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[3]) -> decltype(o1.value_ref(key,c_where,comp) )
1611 {
1612 return o1.value_ref(key,c_where,comp);
1613 }
1614
1615 template<unsigned int prop,typename exp_type, typename grid_type>
1616 inline static void assign(exp_type & o1, grid_type & g, grid_dist_key_dx<grid_type::dims> & key, comb<exp_type::gtype::dims> & c_where, const int (& comp)[3])
1617 {
1618 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]][comp[2]] = o1.value(key,c_where);
1619 }
1620
1621 template<unsigned int prop, typename grid_type>
1622 inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[3])
1623 {
1624 pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]][comp[2]] = d;
1625 }
1626 };
1627
1632 template <typename exp1,int n>
1633 class grid_dist_expression_op<exp1,boost::mpl::int_<n>,g_comp>
1634 {
1636 exp1 o1;
1637
1639 int comp[n];
1640
1641 int var_id = 0;
1642 void setVarId(int var_id)
1643 {
1644 this->var_id = var_id;
1645 }
1646
1648
1649 public:
1650
1651 typedef std::false_type is_ker;
1652
1653 typedef typename exp1::gtype gtype;
1654
1656 static const unsigned int prop = exp1::prop;
1657
1659
1660 grid_dist_expression_op(const exp1 & o1, int (& comp)[n], int var_id)
1661 :o1(o1),var_id(var_id)
1662 {
1663 for (int i = 0 ; i < n ; i++)
1664 {this->comp[i] = comp[i];}
1665 }
1666
1674 const gtype & getGrid() const
1675 {
1676 return o1.getGrid();
1677 }
1678
1686 gtype & getGrid()
1687 {
1688 return o1.getGrid();
1689 }
1690
1692 inline void init() const
1693 {
1694 o1.init();
1695 }
1696
1698 typedef typename boost::mpl::at<typename gtype::value_type::type,boost::mpl::int_<exp1::prop>>::type property_act;
1699
1711 {
1713 }
1714
1726 {
1728 }
1729
1740 inline auto get(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> decltype(value(key,c_where))
1741 {
1742 return this->value(key,c_where);
1743 }
1744
1745 template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1746 inline void value_nz(const gmap_type & g_map,
1748 const grid_sm<Sys_eqs::dims,void> & gs,
1749 typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1750 unordered_map_type & cols,
1751 typename Sys_eqs::stype coeff,
1752 unsigned int comp_,
1753 comb<Sys_eqs::dims> & c_where) const
1754 {
1755 #ifdef SE_CLASS1
1756
1757 if (n != 1)
1758 {
1759 std::cout << __FILE__ << ":" << __LINE__ << " Error it only work for tensore of rank 1 ... like vectors " << std::endl;
1760 }
1761
1762 #endif
1763
1764 o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp_ + var_id + comp[0],c_where);
1765 }
1766
1767 inline grid_dist_expression_op<exp1,boost::mpl::int_<n+1>,g_comp> operator[](int comp_)
1768 {
1769 int comp_n[n+1];
1770
1771 for (int i = 0 ; i < n ; i++)
1772 {comp_n[i] = comp[i];}
1773 comp_n[n] = comp_;
1774
1775 grid_dist_expression_op<exp1,boost::mpl::int_<n+1>,g_comp> v_exp(o1,comp_n,var_id);
1776
1777 return v_exp;
1778 }
1779
1780 //Need more treatment for staggered (c_where based on exp)
1781 inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
1782 {
1783 comb<gtype::dims> c_where;
1784 c_where.zero();
1785 return this->value(key,c_where);
1786 }
1787
1788
1796 template<unsigned int prp2, typename gtype2, unsigned int impl> gtype & operator=(const grid_dist_expression<prp2,gtype2,impl> & v_exp)
1797 {
1798 v_exp.init();
1799
1800 auto & g = getGrid();
1801
1802 auto it = g.getDomainIterator();
1803
1804 comb<gtype::dims> c_where;
1805 c_where.zero();
1806
1807 while (it.isNext())
1808 {
1809 auto key = it.get();
1810
1811 get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,c_where,comp);
1812
1813 ++it;
1814 }
1815
1816 return g;
1817 }
1818
1826 template<typename exp1_, typename exp2_, typename op> gtype & operator=(const grid_dist_expression_op<exp1_,exp2_,op> & v_exp)
1827 {
1828 v_exp.init();
1829
1830 auto & g = getGrid();
1831
1832 auto it = g.getDomainIterator();
1833
1834 comb<gtype::dims> c_where;
1835 c_where.zero();
1836
1837 while (it.isNext())
1838 {
1839 auto key = it.get();
1840
1841 get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,c_where,comp);
1842
1843 ++it;
1844 }
1845
1846 return g;
1847 }
1848
1856 gtype & operator=(double d)
1857 {
1858 auto & v = getGrid();
1859
1860 auto it = v.getDomainIterator();
1861
1862 while (it.isNext())
1863 {
1864 auto key = it.get();
1865
1866 //pos_or_propL<vtype,exp1::prp>::value(v,key) = d;
1867 get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign_double<exp1::prop>(d,v,key,comp);
1868
1869
1870 ++it;
1871 }
1872
1873 return v;
1874 }
1875
1876 int isConstant(){
1877 return false;
1878 }
1879 };
1880
1881
1888 template <unsigned int prp,typename grid> inline grid_dist_expression<prp,grid,NORM_EXPRESSION> getV(grid & g)
1889 {
1890 grid_dist_expression<prp,grid,NORM_EXPRESSION> exp_g(g);
1891
1892 return exp_g;
1893 }
1894
1901 template <unsigned int prp, typename grid> inline grid_dist_expression<prp,grid,STAG_EXPRESSION> getV_stag(grid & g)
1902 {
1903 grid_dist_expression<prp,grid,STAG_EXPRESSION> exp_g(g);
1904
1905 return exp_g;
1906 }
1907
1908
1910
1911 template<unsigned int dim>
1913 {
1914 grid_sm<dim,void> & ginfo_v;
1915
1916 openfpm::vector<GBoxes<dim>> & gdb_ext;
1917
1918 bool operator==(const gdb_ext_plus_g_info & tmp)
1919 {
1920 bool is_equal = gdb_ext.size() == tmp.gdb_ext.size();
1921
1922 for (int i = 0 ; i < gdb_ext.size() ; i++)
1923 {
1924 is_equal &= gdb_ext.get(i) == tmp.gdb_ext.get(i);
1925 }
1926
1927 is_equal &= ginfo_v == tmp.ginfo_v;
1928
1929 return is_equal;
1930 }
1931 };
1932
1933 template<unsigned int dim>
1935 {
1938
1941
1942 openfpm::vector<GBoxes<dim>> & gdb_ext;
1943
1945
1946 public:
1947
1948 static constexpr unsigned int dims = dim;
1949
1951 openfpm::vector<GBoxes<dim>> & gdb_ext,
1953 :loc_grid(loc_grid),gdb_ext(gdb_ext),ginfo_v(ginfo_v)
1954 {}
1955
1957 {
1958 return gdb_ext_plus_g_info<dim>{ginfo_v,gdb_ext};
1959 }
1960
1961 //Need more treatment for staggered (c_where based on exp)
1962 template<unsigned int prp>
1963 inline auto get(grid_dist_key_dx<dim> & key) -> decltype(loc_grid.get(key.getSub()).template get<0>(key.getKey()))
1964 {
1965 return loc_grid.get(key.getSub()).template get<0>(key.getKey());
1966 }
1967
1968
1974 size_t getN_loc_grid() const
1975 {
1976 return loc_grid.size();
1977 }
1978
1987 {
1988 return loc_grid.get(i);
1989 }
1990
1998 const device_grid & get_loc_grid(size_t i) const
1999 {
2000 return loc_grid.get(i);
2001 }
2002
2009 {
2010 return ginfo_v;
2011 }
2012
2019 {
2020 return gdb_ext;
2021 }
2022
2023 void resize(const gdb_ext_plus_g_info<dim> & input)
2024 {
2025 size_t Nloc_grid = input.gdb_ext.size();
2026
2027 loc_grid.resize(Nloc_grid);
2028
2029 for (int i = 0 ; i < Nloc_grid; i++)
2030 {
2031 size_t sz[dim];
2032
2033 for (int j = 0 ; j < dim ; j++) {sz[j] = input.gdb_ext.get(i).GDbox.getKP2().get(j) + 1;}
2034
2035 loc_grid.get(i).resize(sz);
2036 }
2037
2038 gdb_ext = input.gdb_ext;
2039 ginfo_v = input.ginfo_v;
2040 }
2041
2043 decltype(device_grid::type_of_subiterator()),FREE> getIterator()
2044 {
2046 grid_key_dx<dim> one;
2047 one.one();
2048 stop = stop - one;
2049
2051 decltype(device_grid::type_of_subiterator()),
2052 FREE> it(loc_grid,gdb_ext,stop);
2053
2054 return it;
2055 }
2056 };
2057
2058 template<typename patches>
2060 {
2061 static constexpr unsigned int dims = patches::dims;
2062
2063 openfpm::vector<patches> loc_grid;
2064 };
2065
2072 template<unsigned int dim>
2073 class grid_dist_expression<0,grid_patches<grid_cpu<dim,aggregate<double>>>,NORM_EXPRESSION>
2074 {
2077
2078 mutable openfpm::vector<GBoxes<dim>> gdb_ext;
2079
2082
2083 typedef double type_proc;
2084
2085 template<typename super_general>
2086 void operator_equal(super_general & g_exp)
2087 {
2088 g_exp.init();
2089
2090 resize(g_exp.getGrid());
2091
2092 comb<dim> s_pos;
2093 s_pos.zero();
2094
2095 auto it = this->getVector().getIterator();
2096
2097 while (it.isNext())
2098 {
2099 auto key = it.get();
2100
2101 data.loc_grid.get(key.getSub()).template get<0>(key.getKey()) = g_exp.value(key,s_pos);
2102
2103 ++it;
2104 }
2105 }
2106
2107 public:
2108
2109 static constexpr unsigned int dims = dim;
2110
2111 typedef grid_dist_key_dx<dim,grid_key_dx<dim>> index_type;
2112
2115
2117 static const unsigned int prop = 0;
2118
2120 {}
2121
2122 gdb_ext_plus_g_info<dim> size() const
2123 {
2124 return gdb_ext_plus_g_info<dim>{ginfo_v,gdb_ext};
2125 }
2126
2128 template<typename grid>
2130 {
2131 resize(g);
2132 }
2133
2134 template<typename grid>
2135 void resize(grid & g)
2136 {
2137 size_t Nloc_grid = g.getN_loc_grid();
2138
2139 data.loc_grid.resize(Nloc_grid);
2140
2141 for (int i = 0 ; i < Nloc_grid; i++)
2142 {
2143 data.loc_grid.get(i).resize(g.get_loc_grid(i).getGrid().getSize());
2144 }
2145
2146 gdb_ext = g.getLocalGridsInfo();
2147 ginfo_v = g.getGridInfoVoid();
2148 }
2149
2150 grid_dist_expression_iterator_to_make_algebra_work<dim> getVector() const
2151 {
2152 return grid_dist_expression_iterator_to_make_algebra_work<dim>(data.loc_grid,gdb_ext,ginfo_v);
2153 }
2154
2163 {
2164 return getVector();
2165 }
2166
2175 {
2176 return getVector();
2177 }
2178
2184 inline void init() const
2185 {}
2186
2194 inline double value(const grid_dist_key_dx<dim> & k, const comb<dim> & c_where = comb<dim>()) const
2195 {
2196 return data.loc_grid.get(k.getSub()).template get<0>(k.getKey());
2197 }
2198
2206 // template<unsigned int nc>
2207 // inline auto value(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, const int (& comp)[nc]) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp))
2208 // {
2209 // return loc_grid.get(k.getSub()).template get<0>(k.getKey());
2210 // }
2211
2219 inline double & value_ref(const grid_dist_key_dx<dim> & k, const comb<dim> & c_where = comb<dim>())
2220 {
2221 return data.loc_grid.get(k.getSub()).template get<0>(k.getKey());
2222 }
2223
2231 template<unsigned int prp2, typename grid> const grid & operator=(const grid_dist_expression<prp2,grid,NORM_EXPRESSION> & g_exp)
2232 {
2233 operator_equal(g_exp);
2234
2235 return g_exp.getGrid();
2236 }
2237
2245 template<typename exp1, typename exp2, typename op> auto operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp) -> decltype(g_exp.getGrid())
2246 {
2247 operator_equal(g_exp);
2248
2249 return g_exp.getGrid();
2250 }
2251
2252 //Need more treatment for staggered (c_where based on exp)
2253 inline double get(grid_dist_key_dx<dim> & key)
2254 {
2255 comb<dim> c_where;
2256 c_where.zero();
2257 return this->value(key,c_where);
2258 }
2259
2260 int isConstant(){
2261 return false;
2262 }
2263 };
2264
2265};
2266
2267
2268template<unsigned int dim, typename T> using texp_g = FD::grid_dist_expression<0,FD::grid_patches<grid_cpu<dim,aggregate<T>>>,FD::NORM_EXPRESSION>;
2269
2270/* \brief sum two distributed grid expression
2271 *
2272 * \param ga grid expression one
2273 * \param gb grid expression two
2274 *
2275 * \return an object that encapsulate the expression
2276 *
2277 */
2278template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
2281{
2283
2284 return exp_sum;
2285}
2286
2287/* \brief sum two distributed grid expression
2288 *
2289 * \param ga grid expression one
2290 * \param gb grid expression two
2291 *
2292 * \return an object that encapsulate the expression
2293 *
2294 */
2295template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2298{
2300
2301 return exp_sum;
2302}
2303
2304/* \brief sum two distributed grid expression
2305 *
2306 * \param ga grid expression one
2307 * \param gb grid expression two
2308 *
2309 * \return an object that encapsulate the expression
2310 *
2311 */
2312template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2315{
2317
2318 return exp_sum;
2319}
2320
2321/* \brief sum two distributed grid expression
2322 *
2323 * \param ga grid expression one
2324 * \param gb grid expression two
2325 *
2326 * \return an object that encapsulate the expression
2327 *
2328 */
2329template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2332{
2334
2335 return exp_sum;
2336}
2337
2338/* \brief sum two distributed grid expression
2339 *
2340 * \param ga grid expression one
2341 * \param gb grid expression two
2342 *
2343 * \return an object that encapsulate the expression
2344 *
2345 */
2346template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2348operator+(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
2349{
2351
2352 return exp_sum;
2353}
2354
2355/* \brief sum two distributed grid expression
2356 *
2357 * \param ga grid expression one
2358 * \param gb grid expression two
2359 *
2360 * \return an object that encapsulate the expression
2361 *
2362 */
2363template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2365operator+(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
2366{
2368
2369 return exp_sum;
2370}
2371
2372/* \brief sum two distributed grid expression
2373 *
2374 * \param ga grid expression one
2375 * \param gb grid expression two
2376 *
2377 * \return an object that encapsulate the expression
2378 *
2379 */
2380template<typename exp1 , typename exp2, typename op1>
2382operator+(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
2383{
2385
2386 return exp_sum;
2387}
2388
2389/* \brief sum two distributed grid expression
2390 *
2391 * \param ga grid expression one
2392 * \param gb grid expression two
2393 *
2394 * \return an object that encapsulate the expression
2395 *
2396 */
2397template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
2400{
2402
2403 return exp_sum;
2404}
2405
2406/* \brief sum two distributed grid expression
2407 *
2408 * \param ga grid expression one
2409 * \param gb grid expression two
2410 *
2411 * \return an object that encapsulate the expression
2412 *
2413 */
2414template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2417{
2419
2420 return exp_sum;
2421}
2422
2423/* \brief sum two distributed grid expression
2424 *
2425 * \param ga grid expression one
2426 * \param gb grid expression two
2427 *
2428 * \return an object that encapsulate the expression
2429 *
2430 */
2431template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2434{
2436
2437 return exp_sum;
2438}
2439
2440/* \brief minus of a distributed grid expression
2441 *
2442 * \param ga grid expression one
2443 *
2444 * \return an object that encapsulate the expression
2445 *
2446 */
2447template<typename exp1 , typename exp2_, typename op1>
2450{
2452
2453 return exp_sum;
2454}
2455
2456template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2459{
2461
2462 return exp_sum;
2463}
2464
2465
2466/* \brief sum two distributed grid expression
2467 *
2468 * \param ga grid expression one
2469 * \param gb grid expression two
2470 *
2471 * \return an object that encapsulate the expression
2472 *
2473 */
2474template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2477{
2479
2480 return exp_sum;
2481}
2482
2483/* \brief sum two distributed grid expression
2484 *
2485 * \param ga grid expression one
2486 * \param gb grid expression two
2487 *
2488 * \return an object that encapsulate the expression
2489 *
2490 */
2491template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2493operator-(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
2494{
2496
2497 return exp_sum;
2498}
2499
2500/* \brief sum two distributed grid expression
2501 *
2502 * \param ga grid expression one
2503 * \param gb grid expression two
2504 *
2505 * \return an object that encapsulate the expression
2506 *
2507 */
2508template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2510operator-(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
2511{
2513
2514 return exp_sum;
2515}
2516
2517/* \brief sum two distributed grid expression
2518 *
2519 * \param ga grid expression one
2520 * \param gb grid expression two
2521 *
2522 * \return an object that encapsulate the expression
2523 *
2524 */
2525template<typename exp1 , typename exp2, typename op1>
2527operator-(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
2528{
2530
2531 return exp_sum;
2532}
2533
2534/* \brief Multiply two distributed grid expression
2535 *
2536 * \param va grid expression one
2537 * \param vb grid expression two
2538 *
2539 * \return an object that encapsulate the expression
2540 *
2541 */
2542template<unsigned int p2, typename g2, unsigned int impl_p2>
2544operator*(double d, const FD::grid_dist_expression<p2,g2,impl_p2> & vb)
2545{
2547
2548 return exp_sum;
2549}
2550
2551/* \brief Multiply two distributed grid expression
2552 *
2553 * \param va grid expression one
2554 * \param vb grid expression two
2555 *
2556 * \return an object that encapsulate the expression
2557 *
2558 */
2559template<unsigned int p2, typename g2, unsigned int impl_p2>
2561operator*(const FD::grid_dist_expression<p2,g2,impl_p2> & va, double d)
2562{
2564
2565 return exp_sum;
2566}
2567
2568/* \brief Multiply two distributed grid expression
2569 *
2570 * \param va grid expression one
2571 * \param vb grid expression two
2572 *
2573 * \return an object that encapsulate the expression
2574 *
2575 */
2576template<unsigned int p1, typename v1,unsigned int p2, typename v2, unsigned int impl_p1, unsigned int impl_p2>
2579{
2581
2582 return exp_sum;
2583}
2584
2585/* \brief Multiply two distributed grid expression
2586 *
2587 * \param va grid expression one
2588 * \param vb grid expression two
2589 *
2590 * \return an object that encapsulate the expression
2591 *
2592 */
2593template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
2596{
2598
2599 return exp_sum;
2600}
2601
2602/* \brief Multiply two distributed grid expression
2603 *
2604 * \param va grid expression one
2605 * \param vb grid expression two
2606 *
2607 * \return an object that encapsulate the expression
2608 *
2609 */
2610template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
2613{
2615
2616 return exp_sum;
2617}
2618
2619/* \brief Multiply two distributed grid expression
2620 *
2621 * \param va grid expression one
2622 * \param vb grid expression two
2623 *
2624 * \return an object that encapsulate the expression
2625 *
2626 */
2627template<typename exp1, typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2630{
2632
2633 return exp_sum;
2634}
2635
2636/* \brief Multiply a distributed grid expression by a number
2637 *
2638 * \param va grid expression
2639 * \param d number
2640 *
2641 * \return an object that encapsulate the expression
2642 *
2643 */
2644template<typename exp1 , typename exp2, typename op1>
2646operator*(const FD::grid_dist_expression_op<exp1,exp2,op1> & va, double d)
2647{
2649
2650 return exp_sum;
2651}
2652
2653/* \brief Multiply a distributed grid expression by a number
2654 *
2655 * \param d number
2656 * \param vb grid expression
2657 *
2658 * \return an object that encapsulate the expression
2659 *
2660 */
2661template<typename exp1 , typename exp2, typename op1>
2663operator*(double d, const FD::grid_dist_expression_op<exp1,exp2,op1> & vb)
2664{
2666
2667 return exp_sum;
2668}
2669
2670#endif /* FD_EXPRESSIONS_HPP_ */
auto operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp) -> decltype(g_exp.getGrid())
Fill the grid property with the evaluated expression.
const grid_dist_expression_iterator_to_make_algebra_work< dim > getGrid() const
Return the grid on which is acting.
const grid & operator=(const grid_dist_expression< prp2, grid, NORM_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
double & value_ref(const grid_dist_key_dx< dim > &k, const comb< dim > &c_where=comb< dim >())
Evaluate the expression.
grid_dist_expression_iterator_to_make_algebra_work< dim > gtype
The type of the internal grid.
double value(const grid_dist_key_dx< dim > &k, const comb< dim > &c_where=comb< dim >()) const
Evaluate the expression.
grid_dist_expression_iterator_to_make_algebra_work< dim > getGrid()
Return the grid on which is acting.
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate the expression.
grid_dist_expression(const double &d)
constructor from a constant expression
void init() const
This function must be called before value.
void init() const
This function must be called before value.
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate the expression.
grid_dist_expression(const double &d)
constructor from a constant expression
float value(const grid_dist_key_dx< dim > &k) const
Evaluate the expression.
grid_dist_expression(const float &d)
constrictor from constant value
float vtype
type of object the structure return then evaluated
void init() const
This function must be called before value.
grid & getGrid()
Return the grid on which is acting.
auto value(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_n< prp >(g, k))
Evaluate the expression.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, const int(&comp)[nc]) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k, comp))
Evaluate the expression.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k))
Evaluate the expression.
grid_dist_expression(grid &g)
constructor for an external grid
grid & operator=(const grid_dist_expression< prp2, grid_type, NORM_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
grid & operator=(double d)
Fill the grid property with the double.
void init() const
This function must be called before value.
auto value(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, const int(&comp)[nc]) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_n< prp >(g, k, comp))
Evaluate the expression.
const grid & getGrid() const
Return the grid on which is acting.
grid & operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp)
Fill the grid property with the evaluated expression.
void init() const
This function must be called before value.
grid & getGrid()
Return the grid on which is acting.
const grid & getGrid() const
Return the grid on which is acting.
grid & operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp)
Fill the grid property with the evaluated expression.
grid_dist_expression(grid &g)
constructor for an external grid
grid & operator=(double d)
Fill the grid property with the double.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k))
Evaluate the expression.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, const int(&comp)[nc]) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k, comp))
Evaluate the expression.
auto value(grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where) const -> decltype(grid_dist_expression_value_impl< type_proc >::template inte< prp >(g, k, c_where, c_where))
Evaluate the expression.
grid & operator=(const grid_dist_expression< prp2, grid, STAG_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
auto value(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, const int(&comp)[nc]) const -> decltype(grid_dist_expression_value_impl< type_proc >::template inte< prp >(g, k, c_where, c_where, comp))
Evaluate the expression.
const device_grid & get_loc_grid(size_t i) const
Get the i sub-domain grid.
const grid_sm< dim, void > & getGridInfoVoid() const
Get an object containing the grid informations without type.
openfpm::vector< grid_cpu< dim, aggregate< double > > > & loc_grid
The grid.
device_grid & get_loc_grid(size_t i)
Get the i sub-domain grid.
size_t getN_loc_grid() const
Return the number of local grid.
const openfpm::vector< GBoxes< device_grid::dims > > & getLocalGridsInfo() const
It return the informations about the local grids.
grid_sm< dim, void > & ginfo_v
Grid informations object without type.
auto get(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> decltype(value(key, c_where))
Return the result of the expression.
const gtype & getGrid() const
Return the vector on which is acting.
auto value(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> decltype(get_grid_dist_expression_op< n, n==rank_gen< property_act >::type::value >::get(o1, key, c_where, comp))
Return the result of the expression.
gtype & operator=(const grid_dist_expression< prp2, gtype2, impl > &v_exp)
Fill the vector property with the evaluated expression.
gtype & operator=(double d)
Fill the vector property with the double.
boost::mpl::at< typenamegtype::value_type::type, boost::mpl::int_< exp1::prop > >::type property_act
property on which this view is acting
grid_dist_expression_op(const exp1 &o1, int(&comp)[n], int var_id)
constructor from an expresssion
gtype & operator=(const grid_dist_expression_op< exp1_, exp2_, op > &v_exp)
Fill the vector property with the evaluated expression.
auto value_ref(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> decltype(get_grid_dist_expression_op< n, n==rank_gen< property_act >::type::value >::get_ref(o1, key, c_where, comp))
Return the result of the expression.
auto value(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> typename std::remove_reference< decltype(o1.value(key, c_where))>::type
Evaluate the expression.
void init() const
This function must be called before value.
auto getGrid() -> decltype(first_or_second< has_getGrid< exp1 >::value, exp1, exp2 >::getGrid(o1, o2))
Return the grid on which is acting.
auto getGrid() const -> decltype(first_or_second< has_getGrid< exp1 >::value, exp1, exp2 >::getGrid(o1, o2))
Return the grid on which is acting.
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
void init() const
This function must be called before value.
gtype & getGrid()
Return the grid on which is acting.
auto value(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> typename std::remove_reference< decltype(o1.value(key, c_where))>::type
Evaluate the expression.
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
const gtype & getGrid() const
Return the grid on which is acting.
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
gtype & getGrid()
Return the grid on which is acting.
auto value(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> typename std::remove_reference< decltype(o1.value(key, c_where))>::type
Evaluate the expression.
const gtype & getGrid() const
Return the grid on which is acting.
void init() const
This function must be called before value.
auto value(grid_dist_key_dx< gtype::dims > &key, comb< gtype::dims > &c_where) const -> typename std::remove_reference< decltype(o1.value(key, c_where))>::type
Evaluate the expression.
void init() const
This function must be called before value.
gtype & getGrid()
Return the grid on which is acting.
grid_dist_expression_op(const exp1 &o1)
Costruct a FD expression out of two expressions.
const gtype & getGrid() const
Return the grid on which is acting.
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
This is a distributed grid.
Distributed grid iterator.
Grid key for a distributed grid.
size_t getSub() const
Get the local grid.
base_key getKey() const
Get the key.
base_key & getKeyRef()
Get the reference key.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
void one()
Set to one the key.
Definition grid_key.hpp:179
Declaration grid_sm.
Definition grid_sm.hpp:167
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
Definition grid_sm.hpp:760
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
selector for position or properties left side expression
__device__ static __host__ auto value(grid_type &v, const grid_dist_key_dx< grid_type::dims > &k) -> decltype(v.template getProp< prp >(k))
return the value (position or property) of the particle k in the vector v
This structure store the Box that define the domain inside the Ghost + domain box.
Definition GBoxes.hpp:40
Void structure.
Definition common.hpp:74
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
void mone()
Set all the elements to -1.
Definition comb.hpp:95
void zero()
Set all the elements to zero.
Definition comb.hpp:83