OpenFPM  5.2.0
Project that contain the implementation of distributed structures
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 
11 template<typename T, typename Sfinae = void>
12 struct has_getGrid: std::false_type {};
13 
14 template<typename T>
15 struct has_getGrid<T, typename Void<decltype(std::declval<T>().getGrid())>::type > : std::true_type
16 {};
17 
18 namespace 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  if (g.getLocalGrid().get(k.getSub()).getGrid().size(i) > k.getKey().get(i)) {
65  grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c);
66  } else {
67  c += 1;
68  }
69  k.getKeyRef().set_d(i, x0);
70  }
71  else
72  {
73  grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c);
74  }
75  }
76  };
77 
78  template<>
80  {
81  template<unsigned int prp, typename base_type, typename gtype>
82  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)
83  {
84  if (c_where[0] != c_o1[0])
85  {
86  int sign = (c_where[0] > c_o1[0])?1:-1;
87 
88  inte_out += g.template getProp<prp>(k);
89 
90  long int x0 = k.getKeyRef().get(0);
91 
92  k.getKeyRef().set_d(0, x0 + sign);
93  inte_out += g.template getProp<prp>(k);
94  k.getKeyRef().set_d(0, x0);
95  c += 2;
96  }
97  else
98  {
99  inte_out += g.template getProp<prp>(k);
100  c += 1;
101  }
102  }
103  };
104 
105  template<typename base_type>
107  {
108  typedef base_type type;
109 
110  template<unsigned int prp, typename gtype>
111  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)
112  {
113  int c = 0;
114  base_type inte = 0;
115 
116  grid_dist_expression_value_impl_func_scal<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
117 
118  inte /= c;
119 
120  return inte;
121  }
122 
123  template<unsigned int prp, typename gtype>
124  static base_type inte(gtype & g, grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1)
125  {
126  int c = 0;
127  base_type inte = 0;
128 
129  grid_dist_expression_value_impl_func_scal<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c);
130 
131  inte /= c;
132 
133  return inte;
134  }
135 
136  template<unsigned int prp, typename gtype>
137  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
138  {
139  return g.template getProp<prp>(k);
140  }
141 
142  template<unsigned int prp, typename gtype>
143  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp)
144  {
145  return g.template getProp<prp>(k);
146  }
147 
148  template<unsigned int prp, typename gtype>
149  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k))
150  {
151  return g.template getProp<prp>(k);
152  }
153 
154  template<unsigned int prp, typename gtype>
155  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp) -> decltype(g.template getProp<prp>(k))
156  {
157  return g.template getProp<prp>(k);
158  }
159  };
160 
161 
162  template<unsigned int i>
164  {
165  template<unsigned int prp, typename base_type, typename gtype>
166  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])
167  {
168  if (c_where[i] != c_o1[i])
169  {
170  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
171  long int x0 = k.getKeyRef().get(i);
172 
173  int sign = (c_where[i] > c_o1[i])?1:-1;
174 
175  k.getKeyRef().set_d(i, x0 + sign);
176  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
177  k.getKeyRef().set_d(i, x0);
178  }
179  else
180  {
181  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
182  }
183  }
184  };
185 
186  template<>
188  {
189  template<unsigned int prp, typename base_type, typename gtype>
190  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])
191  {
192  if (c_where[0] != c_o1[0])
193  {
194  int sign = (c_where[0] > c_o1[0])?1:-1;
195 
196  inte_out += g.template getProp<prp>(k)[comp[0]];
197 
198  long int x0 = k.getKeyRef().get(0);
199 
200  k.getKeyRef().set_d(0, x0 + sign);
201  inte_out += g.template getProp<prp>(k)[comp[0]];
202  k.getKeyRef().set_d(0, x0);
203  c += 2;
204  }
205  else
206  {
207  inte_out += g.template getProp<prp>(k)[comp[0]];
208  c += 1;
209  }
210  }
211  };
212 
213  template<typename base_type, unsigned int N1>
214  struct grid_dist_expression_value_impl<base_type[N1]>
215  {
216  typedef base_type type;
217 
218  template<unsigned int prp, typename gtype>
219  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])
220  {
221  int c = 0;
222  base_type inte = 0;
223 
224  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
225 
226  if (c != 0)
227  {inte /= c;}
228  else
229  {inte = g.template getProp<prp>(k)[comp];}
230 
231  return inte;
232  }
233 
234  template<unsigned int prp, typename gtype>
235  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
236  {
237  printf("Error wrong expression please check the components");
238  return g.template getProp<prp>(k)[0];
239  }
240 
241  template<unsigned int prp, typename gtype>
242  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1])
243  {
244  return g.template getProp<prp>(k)[comp[0]];
245  }
246 
247  template<unsigned int prp, typename gtype>
248  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0])
249  {
250  printf("Error wrong expression please check the components");
251  return g.template getProp<prp>(k)[0];
252  }
253 
254  template<unsigned int prp, typename gtype>
255  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]])
256  {
257  return g.template getProp<prp>(k)[comp[0]];
258  }
259  };
260 
261 
262 
263 
264  template<typename base_type, unsigned int N1,unsigned int N2>
265  struct grid_dist_expression_value_impl<base_type[N1][N2]>
266  {
267  typedef base_type type;
268 
269  template<unsigned int prp, typename gtype>
270  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])
271  {
272  int c = 0;
273  base_type inte = 0;
274 
275  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
276 
277  if (c != 0)
278  {inte /= c;}
279  else
280  {inte = g.template getProp<prp>(k)[comp[0]][comp[1]];}
281 
282  return inte;
283  }
284 
285  template<unsigned int prp, typename gtype>
286  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
287  {
288  printf("Error wrong expression please check the components");
289  return g.template getProp<prp>(k)[0][0];
290  }
291 
292  template<unsigned int prp, typename gtype>
293  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2])
294  {
295  return g.template getProp<prp>(k)[comp[0]][comp[1]];
296  }
297 
298  template<unsigned int prp, typename gtype>
299  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0][0])
300  {
301  printf("Error wrong expression please check the components");
302  return g.template getProp<prp>(k)[0][0];
303  }
304 
305  template<unsigned int prp, typename gtype>
306  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])
307  {
308  return g.template getProp<prp>(k)[comp[0]][comp[1]];
309  }
310  };
311 
312  template<typename base_type, unsigned int N1,unsigned int N2, unsigned int N3>
313  struct grid_dist_expression_value_impl<base_type[N1][N2][N3]>
314  {
315  typedef base_type type;
316 
317  template<unsigned int prp, typename gtype>
318  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])
319  {
320  int c = 0;
321  base_type inte = 0;
322 
323  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
324 
325  if (c != 0)
326  {inte /= c;}
327  else
328  {inte = g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];}
329 
330  return inte;
331  }
332 
333  template<unsigned int prp, typename gtype>
334  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
335  {
336  printf("Error wrong expression please check the components");
337  return g.template getProp<prp>(k)[0][0][0];
338  }
339 
340  template<unsigned int prp, typename gtype>
341  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[2])
342  {
343  printf("Error wrong expression please check the components");
344  return g.template getProp<prp>(k)[0][comp[0]][comp[1]];
345  }
346 
347  template<unsigned int prp, typename gtype>
348  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[3])
349  {
350  return g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];
351  }
352 
353  template<unsigned int prp, typename gtype>
354  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0][0][0])
355  {
356  printf("Error wrong expression please check the components");
357  return g.template getProp<prp>(k)[0][0][0];
358  }
359 
360  template<unsigned int prp, typename gtype>
361  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])
362  {
363  printf("Error wrong expression please check the components");
364  return g.template getProp<prp>(k)[0][comp[1]][comp[0]];
365  }
366 
367  template<unsigned int prp, typename gtype>
368  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])
369  {
370  return g.template getProp<prp>(k)[comp[0]][comp[1]][comp[2]];
371  }
372  };
373 
374  template<typename base_type, unsigned int N1>
376  {
377  typedef base_type type;
378 
379  template<unsigned int prp, typename gtype>
380  static base_type inte(gtype & g, const grid_dist_key_dx<gtype::dims> & k, comb<gtype::dims> & c_where, comb<gtype::dims> & c_o1)
381  {
382  int comp[1];
383  printf("Error wrong expression please check the components");
384  int c = 0;
385  base_type inte = 0;
386 
387  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
388 
389  if (c != 0)
390  {inte /= c;}
391  else
392  {inte = g.template getProp<prp>(k)[0];}
393 
394  return inte;
395  }
396 
397  template<unsigned int prp, typename gtype>
398  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])
399  {
400  int c = 0;
401  base_type inte = 0;
402 
404 
405  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k_,c_where,c_o1,inte,c,comp);
406 
407  if (c != 0)
408  {inte /= c;}
409  else
410  {inte = g.template getProp<prp>(k)[comp[0]];}
411 
412  return inte;
413  }
414 
415  template<unsigned int prp, typename gtype>
416  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k)
417  {
418  printf("Error wrong expression please check the components");
419  return g.template getProp<prp>(k)[0];
420  }
421 
422  template<unsigned int prp, typename gtype>
423  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, const int (& comp)[1])
424  {
425  return g.template getProp<prp>(k)[comp[0]];
426  }
427 
428  template<unsigned int prp, typename gtype>
429  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]])
430  {
431  return g.template getProp<prp>(k)[comp[0]];
432  }
433 
434  template<unsigned int prp, typename gtype>
435  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k) -> decltype(g.template getProp<prp>(k)[0])
436  {
437  printf("Error wrong expression please check the components");
438  return g.template getProp<prp>(k)[0];
439  }
440  };
441 
442  template<unsigned int i>
444  {
445  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
446  static void value_nz(const gmap_type & g_map,
447  unordered_map_type & cols,
448  gtype & g,
450  comb<gtype::dims> & c_where,
451  comb<gtype::dims> & c_o1,
452  typename Sys_eqs::stype coeff,
453  int & c,
454  int comp,
455  int var_id)
456  {
457  if (c_where[i] != c_o1[i])
458  {
459  int sign = (c_where[i] > c_o1[i])?1:-1;
460 
461  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);
462  //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
463 
464  long int x0 = key.getKeyRef().get(i);
465 
466  key.getKeyRef().set_d(i, x0 + sign);
467  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);
468  //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
469  key.getKeyRef().set_d(i, x0);
470  }
471  else
472  {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);}
473  }
474  };
475 
476  template<>
478  {
479  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
480  static void value_nz(const gmap_type & g_map,
481  unordered_map_type & cols,
482  gtype & g,
484  comb<gtype::dims> & c_where,
485  comb<gtype::dims> & c_o1,
486  typename Sys_eqs::stype coeff,
487  int & c ,
488  int comp,
489  int var_id)
490  {
491  if (c_where[0] != c_o1[0])
492  {
493  int sign = (c_where[0] > c_o1[0])?1:-1;
494 
495  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
496 
497  long int x0 = key.getKeyRef().get(0);
498 
499  key.getKeyRef().set_d(0, x0 + sign);
500  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
501  key.getKeyRef().set_d(0, x0);
502  }
503  else
504  {
505  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
506  }
507  }
508  };
509 
510  template<unsigned int prp, typename grid, unsigned int impl>
512  {};
513 
520  template<unsigned int prp, typename grid>
521  class grid_dist_expression<prp,grid,NORM_EXPRESSION>
522  {
524  grid & g;
525 
526  typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
527 
528  public:
529 
531  typedef grid gtype;
532 
534  static const unsigned int prop = prp;
535 
536  int var_id = 0;
537 
538  void setVarId(int var_id)
539  {
540  this->var_id = var_id;
541  }
542 
545  :g(g)
546  {}
547 
556  {
557  return g;
558  }
559 
567  const grid & getGrid() const
568  {
569  return g;
570  }
571 
577  inline void init() const
578  {}
579 
587  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))
588  {
590  }
591 
599  template<unsigned int nc>
600  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))
601  {
602  return grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp);
603  }
604 
612  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))
613  {
614  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k);
615  }
616 
624  template<unsigned int nc>
625  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))
626  {
627  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
628  }
629 
637  template<unsigned int prp2,typename grid_type> grid & operator=(const grid_dist_expression<prp2,grid_type,NORM_EXPRESSION> & g_exp)
638  {
639  g_exp.init();
640 
641  comb<grid::dims> s_pos;
642  s_pos.zero();
643 
644  auto it = g.getDomainIterator();
645 
646  while (it.isNext())
647  {
648  auto key = it.get();
649 
650  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
651 
652  ++it;
653  }
654 
655  return g;
656  }
657 
665  template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
666  {
667  g_exp.init();
668 
669  comb<grid::dims> s_pos;
670  s_pos.mone();
671 
672  auto it = g.getDomainIterator();
673 
674  while (it.isNext())
675  {
676  auto key = it.get();
677 
678  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
679 
680  ++it;
681  }
682 
683  return g;
684  }
685 
693  grid & operator=(double d)
694  {
695  auto it = g.getDomainIterator();
696 
697  //comb<grid::dims> s_pos;
698  //s_pos.mone();
699 
700  while (it.isNext())
701  {
702  auto key = it.get();
703 
704  g.template getProp<prp>(key) = d;
705 
706  ++it;
707  }
708 
709  return g;
710  }
711 
712 
713  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
714  inline void value_nz(const gmap_type & g_map,
716  const grid_sm<Sys_eqs::dims,void> & gs,
717  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
718  unordered_map_type & cols,
719  typename Sys_eqs::stype coeff,
720  unsigned int comp,
721  comb<Sys_eqs::dims> & c_where) const
722  {
723  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
724  }
725 
726  inline grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
727  {
728  int comp_n[1];
729 
730  comp_n[0] = comp;
731 
732  grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
733 
734  return v_exp;
735  }
736 
737  //Need more treatment for staggered (c_where based on exp)
738  inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
739  {
740  comb<gtype::dims> c_where;
741  c_where.zero();
742  return this->value(key,c_where);
743  }
744 
745  int isConstant(){
746  return false;
747  }
748  };
749 
750  template<unsigned int prp, typename grid>
751  class grid_dist_expression<prp,grid,STAG_EXPRESSION>
752  {
754  grid & g;
755 
756  typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
757 
758  public:
759 
761  typedef grid gtype;
762 
764  static const unsigned int prop = prp;
765 
766  int var_id = 0;
767 
768  void setVarId(int var_id)
769  {
770  this->var_id = var_id;
771  }
772 
775  :g(g)
776  {}
777 
786  {
787  return g;
788  }
789 
797  const grid & getGrid() const
798  {
799  return g;
800  }
801 
807  inline void init() const
808  {}
809 
817  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))
818  {
819  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k);
820  //return g.template getProp<prp>(k);
821  }
822 
830  template<unsigned int nc>
831  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))
832  {
833  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
834  //return g.template getProp<prp>(k);
835  }
836 
844  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))
845  {
846  comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(0);
847 
848 
849  return grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_o1);
850  }
851 
859  template<unsigned int nc>
860  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))
861  {
862  comb<grid::dims> c_o1;
863 
864  if (comp[0] < g.getStagPositions()[prp].size())
865  c_o1 = g.getStagPositions()[prp].get(comp[0]);
866  else
867  c_o1 = g.getStagPositions()[prp].get(0);
868 
869  return grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_o1,comp);
870 // return g.template getProp<prp>(k);
871  }
872 
880  template<unsigned int prp2> grid & operator=(const grid_dist_expression<prp2,grid,STAG_EXPRESSION> & g_exp)
881  {
882  g_exp.init();
883 
884  auto it = g.getDomainIterator();
885 
886  comb<grid::dims> s_pos = g.getStagPositions()[prp].get(0);
887 
888  while (it.isNext())
889  {
890  auto key = it.get();
891 
892  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
893 
894  ++it;
895  }
896 
897  return g;
898  }
899 
907  template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
908  {
909  g_exp.init();
910 
911  auto it = g.getDomainIterator();
912  const auto& gLocalGrid = g.getLocalGrid();
913 
914  comb<grid::dims> s_pos = g.getStagPositions()[prp].get(0);
915 
916  while (it.isNext())
917  {
918  auto key = it.get();
919 
920  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
921 
922  ++it;
923  }
924 
925  return g;
926  }
927 
935  grid & operator=(double d)
936  {
937  auto it = g.getDomainIterator();
938 
939  while (it.isNext())
940  {
941  auto key = it.get();
942 
943  g.template getProp<prp>(key) = d;
944 
945  ++it;
946  }
947 
948  return g;
949  }
950 
951  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
952  inline void value_nz(const gmap_type & g_map,
954  const grid_sm<Sys_eqs::dims,void> & gs,
955  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
956  unordered_map_type & cols,
957  typename Sys_eqs::stype coeff,
958  unsigned int comp,
959  comb<Sys_eqs::dims> & c_where) const
960  {
961  int c = 1;
962  comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(comp);
963 
964  // x0, dx are defined in proper dir Ñ”(x, y, z)
965 
966  for (int i = 0 ; i < grid::dims ; i++)
967  {
968  if (c_where[i] != c_o1[i])
969  {c *= 2;}
970  }
971 
972  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);
973 
974  }
975 
976  inline grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
977  {
978  int comp_n[1];
979 
980  comp_n[0] = comp;
981 
982  grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
983 
984  return v_exp;
985  }
986 
987  };
988 
994  template<unsigned int dim>
995  class grid_dist_expression<dim,double,NORM_EXPRESSION>
996  {
998  double d;
999 
1000  public:
1001 
1003  inline grid_dist_expression(const double & d)
1004  :d(d)
1005  {}
1006 
1012  inline void init() const
1013  {}
1014 
1024  inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
1025  {
1026  return d;
1027  }
1028  };
1029 
1035  template<unsigned int dim>
1036  class grid_dist_expression<dim,double,STAG_EXPRESSION>
1037  {
1039  double d;
1040 
1041  public:
1042 
1044  inline grid_dist_expression(const double & d)
1045  :d(d)
1046  {}
1047 
1053  inline void init() const
1054  {}
1055 
1065  inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
1066  {
1067  return d;
1068  }
1069  };
1070 
1076  template<unsigned int dim, unsigned int impl>
1077  class grid_dist_expression<dim,float,impl>
1078  {
1080  float d;
1081 
1082  public:
1083 
1085  typedef float vtype;
1086 
1088  inline grid_dist_expression(const float & d)
1089  :d(d)
1090  {}
1091 
1097  inline void init() const
1098  {}
1099 
1109  inline float value(const grid_dist_key_dx<dim> & k) const
1110  {
1111  return d;
1112  }
1113  };
1114 
1115  struct sum {};
1116 
1117  template <typename exp1, typename exp2>
1118  class grid_dist_expression_op<exp1,exp2,sum>
1119  {
1121  const exp1 o1;
1122 
1124  const exp2 o2;
1125 
1126  public:
1127 
1128  typedef typename exp1::gtype gtype;
1129 
1131  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1132  :o1(o1),o2(o2)
1133  {}
1134 
1140  inline void init() const
1141  {
1142  o1.init();
1143  o2.init();
1144  }
1145 
1153  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
1154  {
1155  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1156 
1157  return o1.value(key,c_where) + o2.value(key,c_where);
1158  }
1159 
1167  gtype & getGrid()
1168  {
1169  return o1.getGrid();
1170  }
1171 
1179  const gtype & getGrid() const
1180  {
1181  return o1.getGrid();
1182  }
1183 
1184  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1185  inline void value_nz(const gmap_type & g_map,
1187  const grid_sm<Sys_eqs::dims,void> & gs,
1188  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1189  unordered_map_type & cols,
1190  typename Sys_eqs::stype coeff,
1191  unsigned int comp,
1192  comb<Sys_eqs::dims> & c_where) const
1193  {
1194  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1195  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1196  }
1197  };
1198 
1199  struct sub {};
1200 
1201 
1202  template <typename exp1, typename exp2>
1203  class grid_dist_expression_op<exp1,exp2,sub>
1204  {
1206  const exp1 o1;
1207 
1209  const exp2 o2;
1210 
1211  public:
1212 
1213  typedef typename exp1::gtype gtype;
1214 
1216  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1217  :o1(o1),o2(o2)
1218  {}
1219 
1225  inline void init() const
1226  {
1227  o1.init();
1228  o2.init();
1229  }
1230 
1238  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
1239  {
1240  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1241 
1242  return o1.value(key,c_where) - o2.value(key,c_where);
1243  }
1244 
1252  gtype & getGrid()
1253  {
1254  return o1.getGrid();
1255  }
1256 
1264  const gtype & getGrid() const
1265  {
1266  return o1.getGrid();
1267  }
1268 
1269  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1270  inline void value_nz(const gmap_type & g_map,
1272  const grid_sm<Sys_eqs::dims,void> & gs,
1273  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1274  unordered_map_type & cols,
1275  typename Sys_eqs::stype coeff,
1276  unsigned int comp,
1277  comb<Sys_eqs::dims> & c_where) const
1278  {
1279  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1280  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1281  }
1282  };
1283 
1284  struct subuni{};
1285 
1286  template <typename exp1>
1288  {
1290  const exp1 o1;
1291 
1292  public:
1293 
1294  typedef typename exp1::gtype gtype;
1295 
1297  inline grid_dist_expression_op(const exp1 & o1)
1298  :o1(o1)
1299  {}
1300 
1306  inline void init() const
1307  {
1308  o1.init();
1309  }
1310 
1318  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
1319  {
1320  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1321 
1322  return -o1.value(key,c_where);
1323  }
1324 
1332  gtype & getGrid()
1333  {
1334  return o1.getGrid();
1335  }
1336 
1344  const gtype & getGrid() const
1345  {
1346  return o1.getGrid();
1347  }
1348 
1349  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1350  inline void value_nz(const gmap_type & g_map,
1352  const grid_sm<Sys_eqs::dims,void> & gs,
1353  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1354  unordered_map_type & cols,
1355  typename Sys_eqs::stype coeff,
1356  unsigned int comp,
1357  comb<Sys_eqs::dims> & c_where) const
1358  {
1359  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1360  }
1361  };
1362 
1363  struct mul {};
1364 
1365  template <typename exp1, typename exp2>
1366  class grid_dist_expression_op<exp1,exp2,mul>
1367  {
1369  const exp1 o1;
1370 
1372  const exp2 o2;
1373 
1374  public:
1375 
1376  typedef typename exp2::gtype gtype;
1377 
1379  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1380  :o1(o1),o2(o2)
1381  {}
1382 
1388  inline void init() const
1389  {
1390  o1.init();
1391  o2.init();
1392  }
1393 
1401  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
1402  {
1403  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1404 
1405  return o1.value(key,c_where) * o2.value(key,c_where);
1406  }
1407 
1415  auto getGrid() -> decltype(first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2))
1416  {
1417  return first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2);
1418  }
1419 
1427  auto getGrid() const -> decltype(first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2))
1428  {
1429  return first_or_second<has_getGrid<exp1>::value,exp1,exp2>::getGrid(o1,o2);
1430  }
1431 
1432  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1433  inline void value_nz(const gmap_type & g_map,
1435  const grid_sm<Sys_eqs::dims,void> & gs,
1436  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1437  unordered_map_type & cols,
1438  typename Sys_eqs::stype coeff,
1439  unsigned int comp,
1440  comb<Sys_eqs::dims> & c_where) const
1441  {
1442  typename Sys_eqs::stype coeff_tmp = o1.value(key,c_where) * coeff;
1443 
1444  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff_tmp,comp,c_where);
1445  }
1446  };
1447 
1455  template <typename grid_type, unsigned int prp>
1457  {
1459  __device__ __host__ static inline auto value(grid_type & v, const grid_dist_key_dx<grid_type::dims> & k) -> decltype(v.template getProp<prp>(k))
1460  {
1461  return v.template getProp<prp>(k);
1462  }
1463  };
1464 
1465  template<unsigned int, bool is_valid>
1467  {
1468  template<typename exp_type>
1469  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))
1470  {
1471  return o1.value(key,c_where);
1472  }
1473 
1474  template<typename exp_type>
1475  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))
1476  {
1477  return o1.value_ref(key,c_where);
1478  }
1479 
1480  template<unsigned int prop, typename exp_type, typename grid_type>
1481  inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1482  {
1483  pos_or_propL<grid_type,exp_type::prop>::value(g,key) = o1.value(key);
1484  }
1485 
1486  template<unsigned int prop, typename grid_type>
1487  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1488  {
1490  }
1491  };
1492 
1493  template<>
1495  {
1496  template<typename exp_type>
1497  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])
1498  {
1499  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1500  return 0;
1501  }
1502 
1503  template<typename exp_type>
1504  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))
1505  {
1506  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1507  return o1.value_ref(key,c_where);
1508  }
1509 
1510  template<unsigned int prop, typename exp_type, typename grid_type>
1511  inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1512  {
1513  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1514  }
1515 
1516  template<unsigned int prop, typename grid_type>
1517  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1518  {
1519  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1520  }
1521  };
1522 
1523  template<>
1525  {
1526  template<typename exp_type>
1527  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) )
1528  {
1529  return o1.value(key,c_where,comp);
1530  }
1531 
1532  template<typename exp_type>
1533  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) )
1534  {
1535  return o1.value_ref(key,c_where,comp);
1536  }
1537 
1538  template<unsigned int prop,typename exp_type, typename grid_type>
1539  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])
1540  {
1541  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = o1.value(key,c_where);
1542  }
1543 
1544  template<unsigned int prop, typename grid_type>
1545  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[1])
1546  {
1547  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = d;
1548  }
1549  };
1550 
1551  template<>
1553  {
1554  template<typename exp_type>
1555  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) )
1556  {
1557  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1558  return o1.value(key,c_where,comp);
1559  }
1560 
1561  template<typename exp_type>
1562  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) )
1563  {
1564  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1565  return o1.value_ref(key,c_where,comp);
1566  }
1567 
1568  template<unsigned int prop,typename exp_type, typename grid_type>
1569  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])
1570  {
1571  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1572  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = o1.value(key,c_where);
1573  }
1574 
1575  template<unsigned int prop, typename grid_type>
1576  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1577  {
1578  printf("ERROR: Slicer, the expression is incorrect, please check it\n");
1579  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = d;
1580  }
1581  };
1582 
1583  template<>
1585  {
1586  template<typename exp_type>
1587  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) )
1588  {
1589  return o1.value(key,c_where,comp);
1590  }
1591 
1592  template<typename exp_type>
1593  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) )
1594  {
1595  return o1.value_ref(key,c_where,comp);
1596  }
1597 
1598  template<unsigned int prop,typename exp_type, typename grid_type>
1599  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])
1600  {
1601  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = o1.value(key,c_where);
1602  }
1603 
1604  template<unsigned int prop, typename grid_type>
1605  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1606  {
1607  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = d;
1608  }
1609  };
1610 
1611  template<>
1613  {
1614  template<typename exp_type>
1615  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) )
1616  {
1617  return o1.value(key,c_where,comp);
1618  }
1619 
1620  template<typename exp_type>
1621  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) )
1622  {
1623  return o1.value_ref(key,c_where,comp);
1624  }
1625 
1626  template<unsigned int prop,typename exp_type, typename grid_type>
1627  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])
1628  {
1629  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]][comp[2]] = o1.value(key,c_where);
1630  }
1631 
1632  template<unsigned int prop, typename grid_type>
1633  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[3])
1634  {
1635  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]][comp[2]] = d;
1636  }
1637  };
1638 
1643  template <typename exp1,int n>
1644  class grid_dist_expression_op<exp1,boost::mpl::int_<n>,g_comp>
1645  {
1647  exp1 o1;
1648 
1650  int comp[n];
1651 
1652  int var_id = 0;
1653  void setVarId(int var_id)
1654  {
1655  this->var_id = var_id;
1656  }
1657 
1659 
1660  public:
1661 
1662  typedef std::false_type is_ker;
1663 
1664  typedef typename exp1::gtype gtype;
1665 
1667  static const unsigned int prop = exp1::prop;
1668 
1670 
1671  grid_dist_expression_op(const exp1 & o1, int (& comp)[n], int var_id)
1672  :o1(o1),var_id(var_id)
1673  {
1674  for (int i = 0 ; i < n ; i++)
1675  {this->comp[i] = comp[i];}
1676  }
1677 
1685  const gtype & getGrid() const
1686  {
1687  return o1.getGrid();
1688  }
1689 
1697  gtype & getGrid()
1698  {
1699  return o1.getGrid();
1700  }
1701 
1703  inline void init() const
1704  {
1705  o1.init();
1706  }
1707 
1709  typedef typename boost::mpl::at<typename gtype::value_type::type,boost::mpl::int_<exp1::prop>>::type property_act;
1710 
1721  inline 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))
1722  {
1724  }
1725 
1736  inline 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))
1737  {
1738  return get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::get_ref(o1,key,c_where,comp);
1739  }
1740 
1751  inline auto get(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> decltype(value(key,c_where))
1752  {
1753  return this->value(key,c_where);
1754  }
1755 
1756  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1757  inline void value_nz(const gmap_type & g_map,
1759  const grid_sm<Sys_eqs::dims,void> & gs,
1760  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1761  unordered_map_type & cols,
1762  typename Sys_eqs::stype coeff,
1763  unsigned int comp_,
1764  comb<Sys_eqs::dims> & c_where) const
1765  {
1766  #ifdef SE_CLASS1
1767 
1768  if (n != 1)
1769  {
1770  std::cout << __FILE__ << ":" << __LINE__ << " Error it only work for tensore of rank 1 ... like vectors " << std::endl;
1771  }
1772 
1773  #endif
1774 
1775  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp_ + var_id + comp[0],c_where);
1776  }
1777 
1778  inline grid_dist_expression_op<exp1,boost::mpl::int_<n+1>,g_comp> operator[](int comp_)
1779  {
1780  int comp_n[n+1];
1781 
1782  for (int i = 0 ; i < n ; i++)
1783  {comp_n[i] = comp[i];}
1784  comp_n[n] = comp_;
1785 
1786  grid_dist_expression_op<exp1,boost::mpl::int_<n+1>,g_comp> v_exp(o1,comp_n,var_id);
1787 
1788  return v_exp;
1789  }
1790 
1791  //Need more treatment for staggered (c_where based on exp)
1792  inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
1793  {
1794  comb<gtype::dims> c_where;
1795  c_where.zero();
1796  return this->value(key,c_where);
1797  }
1798 
1799 
1807  template<unsigned int prp2, typename gtype2, unsigned int impl> gtype & operator=(const grid_dist_expression<prp2,gtype2,impl> & v_exp)
1808  {
1809  v_exp.init();
1810 
1811  auto & g = getGrid();
1812 
1813  auto it = g.getDomainIterator();
1814 
1815  comb<gtype::dims> c_where;
1816  c_where.zero();
1817 
1818  while (it.isNext())
1819  {
1820  auto key = it.get();
1821 
1822  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,c_where,comp);
1823 
1824  ++it;
1825  }
1826 
1827  return g;
1828  }
1829 
1837  template<typename exp1_, typename exp2_, typename op> gtype & operator=(const grid_dist_expression_op<exp1_,exp2_,op> & v_exp)
1838  {
1839  v_exp.init();
1840 
1841  auto & g = getGrid();
1842 
1843  auto it = g.getDomainIterator();
1844 
1845  comb<gtype::dims> c_where;
1846  c_where.zero();
1847 
1848  while (it.isNext())
1849  {
1850  auto key = it.get();
1851 
1852  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,c_where,comp);
1853 
1854  ++it;
1855  }
1856 
1857  return g;
1858  }
1859 
1867  gtype & operator=(double d)
1868  {
1869  auto & v = getGrid();
1870 
1871  auto it = v.getDomainIterator();
1872 
1873  while (it.isNext())
1874  {
1875  auto key = it.get();
1876 
1877  //pos_or_propL<vtype,exp1::prp>::value(v,key) = d;
1878  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign_double<exp1::prop>(d,v,key,comp);
1879 
1880 
1881  ++it;
1882  }
1883 
1884  return v;
1885  }
1886 
1887  int isConstant(){
1888  return false;
1889  }
1890  };
1891 
1892 
1899  template <unsigned int prp,typename grid> inline grid_dist_expression<prp,grid,NORM_EXPRESSION> getV(grid & g)
1900  {
1901  grid_dist_expression<prp,grid,NORM_EXPRESSION> exp_g(g);
1902 
1903  return exp_g;
1904  }
1905 
1912  template <unsigned int prp, typename grid> inline grid_dist_expression<prp,grid,STAG_EXPRESSION> getV_stag(grid & g)
1913  {
1914  grid_dist_expression<prp,grid,STAG_EXPRESSION> exp_g(g);
1915 
1916  return exp_g;
1917  }
1918 
1919 
1921 
1922  template<unsigned int dim>
1924  {
1925  grid_sm<dim,void> & ginfo_v;
1926 
1927  openfpm::vector<GBoxes<dim>> & gdb_ext;
1928 
1929  bool operator==(const gdb_ext_plus_g_info & tmp)
1930  {
1931  bool is_equal = gdb_ext.size() == tmp.gdb_ext.size();
1932 
1933  for (int i = 0 ; i < gdb_ext.size() ; i++)
1934  {
1935  is_equal &= gdb_ext.get(i) == tmp.gdb_ext.get(i);
1936  }
1937 
1938  is_equal &= ginfo_v == tmp.ginfo_v;
1939 
1940  return is_equal;
1941  }
1942  };
1943 
1944  template<unsigned int dim>
1946  {
1949 
1952 
1953  openfpm::vector<GBoxes<dim>> & gdb_ext;
1954 
1956 
1957  public:
1958 
1959  static constexpr unsigned int dims = dim;
1960 
1962  openfpm::vector<GBoxes<dim>> & gdb_ext,
1964  :loc_grid(loc_grid),gdb_ext(gdb_ext),ginfo_v(ginfo_v)
1965  {}
1966 
1968  {
1969  return gdb_ext_plus_g_info<dim>{ginfo_v,gdb_ext};
1970  }
1971 
1972  //Need more treatment for staggered (c_where based on exp)
1973  template<unsigned int prp>
1974  inline auto get(grid_dist_key_dx<dim> & key) -> decltype(loc_grid.get(key.getSub()).template get<0>(key.getKey()))
1975  {
1976  return loc_grid.get(key.getSub()).template get<0>(key.getKey());
1977  }
1978 
1979 
1985  size_t getN_loc_grid() const
1986  {
1987  return loc_grid.size();
1988  }
1989 
1998  {
1999  return loc_grid.get(i);
2000  }
2001 
2009  const device_grid & get_loc_grid(size_t i) const
2010  {
2011  return loc_grid.get(i);
2012  }
2013 
2020  {
2021  return ginfo_v;
2022  }
2023 
2030  {
2031  return gdb_ext;
2032  }
2033 
2034  void resize(const gdb_ext_plus_g_info<dim> & input)
2035  {
2036  size_t Nloc_grid = input.gdb_ext.size();
2037 
2038  loc_grid.resize(Nloc_grid);
2039 
2040  for (int i = 0 ; i < Nloc_grid; i++)
2041  {
2042  size_t sz[dim];
2043 
2044  for (int j = 0 ; j < dim ; j++) {sz[j] = input.gdb_ext.get(i).GDbox.getKP2().get(j) + 1;}
2045 
2046  loc_grid.get(i).resize(sz);
2047  }
2048 
2049  gdb_ext = input.gdb_ext;
2050  ginfo_v = input.ginfo_v;
2051  }
2052 
2054  decltype(device_grid::type_of_subiterator()),FREE> getIterator()
2055  {
2057  grid_key_dx<dim> one;
2058  one.one();
2059  stop = stop - one;
2060 
2062  decltype(device_grid::type_of_subiterator()),
2063  FREE> it(loc_grid,gdb_ext,stop);
2064 
2065  return it;
2066  }
2067  };
2068 
2069  template<typename patches>
2071  {
2072  static constexpr unsigned int dims = patches::dims;
2073 
2074  openfpm::vector<patches> loc_grid;
2075  };
2076 
2083  template<unsigned int dim>
2084  class grid_dist_expression<0,grid_patches<grid_cpu<dim,aggregate<double>>>,NORM_EXPRESSION>
2085  {
2088 
2089  mutable openfpm::vector<GBoxes<dim>> gdb_ext;
2090 
2093 
2094  typedef double type_proc;
2095 
2096  template<typename super_general>
2097  void operator_equal(super_general & g_exp)
2098  {
2099  g_exp.init();
2100 
2101  resize(g_exp.getGrid());
2102 
2103  comb<dim> s_pos;
2104  s_pos.zero();
2105 
2106  auto it = this->getVector().getIterator();
2107 
2108  while (it.isNext())
2109  {
2110  auto key = it.get();
2111 
2112  data.loc_grid.get(key.getSub()).template get<0>(key.getKey()) = g_exp.value(key,s_pos);
2113 
2114  ++it;
2115  }
2116  }
2117 
2118  public:
2119 
2120  static constexpr unsigned int dims = dim;
2121 
2122  typedef grid_dist_key_dx<dim,grid_key_dx<dim>> index_type;
2123 
2126 
2128  static const unsigned int prop = 0;
2129 
2131  {}
2132 
2133  gdb_ext_plus_g_info<dim> size() const
2134  {
2135  return gdb_ext_plus_g_info<dim>{ginfo_v,gdb_ext};
2136  }
2137 
2139  template<typename grid>
2141  {
2142  resize(g);
2143  }
2144 
2145  template<typename grid>
2146  void resize(grid & g)
2147  {
2148  size_t Nloc_grid = g.getN_loc_grid();
2149 
2150  data.loc_grid.resize(Nloc_grid);
2151 
2152  for (int i = 0 ; i < Nloc_grid; i++)
2153  {
2154  data.loc_grid.get(i).resize(g.get_loc_grid(i).getGrid().getSize());
2155  }
2156 
2157  gdb_ext = g.getLocalGridsInfo();
2158  ginfo_v = g.getGridInfoVoid();
2159  }
2160 
2161  grid_dist_expression_iterator_to_make_algebra_work<dim> getVector() const
2162  {
2163  return grid_dist_expression_iterator_to_make_algebra_work<dim>(data.loc_grid,gdb_ext,ginfo_v);
2164  }
2165 
2174  {
2175  return getVector();
2176  }
2177 
2186  {
2187  return getVector();
2188  }
2189 
2195  inline void init() const
2196  {}
2197 
2205  inline double value(const grid_dist_key_dx<dim> & k, const comb<dim> & c_where = comb<dim>()) const
2206  {
2207  return data.loc_grid.get(k.getSub()).template get<0>(k.getKey());
2208  }
2209 
2217  // template<unsigned int nc>
2218  // 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))
2219  // {
2220  // return loc_grid.get(k.getSub()).template get<0>(k.getKey());
2221  // }
2222 
2230  inline double & value_ref(const grid_dist_key_dx<dim> & k, const comb<dim> & c_where = comb<dim>())
2231  {
2232  return data.loc_grid.get(k.getSub()).template get<0>(k.getKey());
2233  }
2234 
2242  template<unsigned int prp2, typename grid> const grid & operator=(const grid_dist_expression<prp2,grid,NORM_EXPRESSION> & g_exp)
2243  {
2244  operator_equal(g_exp);
2245 
2246  return g_exp.getGrid();
2247  }
2248 
2256  template<typename exp1, typename exp2, typename op> auto operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp) -> decltype(g_exp.getGrid())
2257  {
2258  operator_equal(g_exp);
2259 
2260  return g_exp.getGrid();
2261  }
2262 
2263  //Need more treatment for staggered (c_where based on exp)
2264  inline double get(grid_dist_key_dx<dim> & key)
2265  {
2266  comb<dim> c_where;
2267  c_where.zero();
2268  return this->value(key,c_where);
2269  }
2270 
2271  int isConstant(){
2272  return false;
2273  }
2274  };
2275 
2276 };
2277 
2278 
2279 template<unsigned int dim, typename T> using texp_g = FD::grid_dist_expression<0,FD::grid_patches<grid_cpu<dim,aggregate<T>>>,FD::NORM_EXPRESSION>;
2280 
2281 /* \brief sum two distributed grid expression
2282  *
2283  * \param ga grid expression one
2284  * \param gb grid expression two
2285  *
2286  * \return an object that encapsulate the expression
2287  *
2288  */
2289 template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
2292 {
2294 
2295  return exp_sum;
2296 }
2297 
2298 /* \brief sum two distributed grid expression
2299  *
2300  * \param ga grid expression one
2301  * \param gb grid expression two
2302  *
2303  * \return an object that encapsulate the expression
2304  *
2305  */
2306 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2309 {
2311 
2312  return exp_sum;
2313 }
2314 
2315 /* \brief sum two distributed grid expression
2316  *
2317  * \param ga grid expression one
2318  * \param gb grid expression two
2319  *
2320  * \return an object that encapsulate the expression
2321  *
2322  */
2323 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2326 {
2328 
2329  return exp_sum;
2330 }
2331 
2332 /* \brief sum two distributed grid expression
2333  *
2334  * \param ga grid expression one
2335  * \param gb grid expression two
2336  *
2337  * \return an object that encapsulate the expression
2338  *
2339  */
2340 template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2343 {
2345 
2346  return exp_sum;
2347 }
2348 
2349 /* \brief sum two distributed grid expression
2350  *
2351  * \param ga grid expression one
2352  * \param gb grid expression two
2353  *
2354  * \return an object that encapsulate the expression
2355  *
2356  */
2357 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2359 operator+(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
2360 {
2362 
2363  return exp_sum;
2364 }
2365 
2366 /* \brief sum two distributed grid expression
2367  *
2368  * \param ga grid expression one
2369  * \param gb grid expression two
2370  *
2371  * \return an object that encapsulate the expression
2372  *
2373  */
2374 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2376 operator+(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
2377 {
2379 
2380  return exp_sum;
2381 }
2382 
2383 /* \brief sum two distributed grid expression
2384  *
2385  * \param ga grid expression one
2386  * \param gb grid expression two
2387  *
2388  * \return an object that encapsulate the expression
2389  *
2390  */
2391 template<typename exp1 , typename exp2, typename op1>
2393 operator+(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
2394 {
2396 
2397  return exp_sum;
2398 }
2399 
2400 /* \brief sum two distributed grid expression
2401  *
2402  * \param ga grid expression one
2403  * \param gb grid expression two
2404  *
2405  * \return an object that encapsulate the expression
2406  *
2407  */
2408 template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
2411 {
2413 
2414  return exp_sum;
2415 }
2416 
2417 /* \brief sum two distributed grid expression
2418  *
2419  * \param ga grid expression one
2420  * \param gb grid expression two
2421  *
2422  * \return an object that encapsulate the expression
2423  *
2424  */
2425 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2428 {
2430 
2431  return exp_sum;
2432 }
2433 
2434 /* \brief sum two distributed grid expression
2435  *
2436  * \param ga grid expression one
2437  * \param gb grid expression two
2438  *
2439  * \return an object that encapsulate the expression
2440  *
2441  */
2442 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
2445 {
2447 
2448  return exp_sum;
2449 }
2450 
2451 /* \brief minus of a distributed grid expression
2452  *
2453  * \param ga grid expression one
2454  *
2455  * \return an object that encapsulate the expression
2456  *
2457  */
2458 template<typename exp1 , typename exp2_, typename op1>
2460 operator-(const FD::grid_dist_expression_op<exp1,exp2_,op1> & ga)
2461 {
2463 
2464  return exp_sum;
2465 }
2466 
2467 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2469 operator-(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga)
2470 {
2472 
2473  return exp_sum;
2474 }
2475 
2476 
2477 /* \brief sum two distributed grid expression
2478  *
2479  * \param ga grid expression one
2480  * \param gb grid expression two
2481  *
2482  * \return an object that encapsulate the expression
2483  *
2484  */
2485 template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2488 {
2490 
2491  return exp_sum;
2492 }
2493 
2494 /* \brief sum two distributed grid expression
2495  *
2496  * \param ga grid expression one
2497  * \param gb grid expression two
2498  *
2499  * \return an object that encapsulate the expression
2500  *
2501  */
2502 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2504 operator-(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
2505 {
2507 
2508  return exp_sum;
2509 }
2510 
2511 /* \brief sum two distributed grid expression
2512  *
2513  * \param ga grid expression one
2514  * \param gb grid expression two
2515  *
2516  * \return an object that encapsulate the expression
2517  *
2518  */
2519 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
2521 operator-(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
2522 {
2524 
2525  return exp_sum;
2526 }
2527 
2528 /* \brief sum two distributed grid expression
2529  *
2530  * \param ga grid expression one
2531  * \param gb grid expression two
2532  *
2533  * \return an object that encapsulate the expression
2534  *
2535  */
2536 template<typename exp1 , typename exp2, typename op1>
2538 operator-(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
2539 {
2541 
2542  return exp_sum;
2543 }
2544 
2545 /* \brief Multiply two distributed grid expression
2546  *
2547  * \param va grid expression one
2548  * \param vb grid expression two
2549  *
2550  * \return an object that encapsulate the expression
2551  *
2552  */
2553 template<unsigned int p2, typename g2, unsigned int impl_p2>
2555 operator*(double d, const FD::grid_dist_expression<p2,g2,impl_p2> & vb)
2556 {
2558 
2559  return exp_sum;
2560 }
2561 
2562 /* \brief Multiply two distributed grid expression
2563  *
2564  * \param va grid expression one
2565  * \param vb grid expression two
2566  *
2567  * \return an object that encapsulate the expression
2568  *
2569  */
2570 template<unsigned int p2, typename g2, unsigned int impl_p2>
2572 operator*(const FD::grid_dist_expression<p2,g2,impl_p2> & va, double d)
2573 {
2575 
2576  return exp_sum;
2577 }
2578 
2579 /* \brief Multiply two distributed grid expression
2580  *
2581  * \param va grid expression one
2582  * \param vb grid expression two
2583  *
2584  * \return an object that encapsulate the expression
2585  *
2586  */
2587 template<unsigned int p1, typename v1,unsigned int p2, typename v2, unsigned int impl_p1, unsigned int impl_p2>
2590 {
2592 
2593  return exp_sum;
2594 }
2595 
2596 /* \brief Multiply two distributed grid expression
2597  *
2598  * \param va grid expression one
2599  * \param vb grid expression two
2600  *
2601  * \return an object that encapsulate the expression
2602  *
2603  */
2604 template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
2607 {
2609 
2610  return exp_sum;
2611 }
2612 
2613 /* \brief Multiply two distributed grid expression
2614  *
2615  * \param va grid expression one
2616  * \param vb grid expression two
2617  *
2618  * \return an object that encapsulate the expression
2619  *
2620  */
2621 template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
2624 {
2626 
2627  return exp_sum;
2628 }
2629 
2630 /* \brief Multiply two distributed grid expression
2631  *
2632  * \param va grid expression one
2633  * \param vb grid expression two
2634  *
2635  * \return an object that encapsulate the expression
2636  *
2637  */
2638 template<typename exp1, typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
2641 {
2643 
2644  return exp_sum;
2645 }
2646 
2647 /* \brief Multiply a distributed grid expression by a number
2648  *
2649  * \param va grid expression
2650  * \param d number
2651  *
2652  * \return an object that encapsulate the expression
2653  *
2654  */
2655 template<typename exp1 , typename exp2, typename op1>
2657 operator*(const FD::grid_dist_expression_op<exp1,exp2,op1> & va, double d)
2658 {
2660 
2661  return exp_sum;
2662 }
2663 
2664 /* \brief Multiply a distributed grid expression by a number
2665  *
2666  * \param d number
2667  * \param vb grid expression
2668  *
2669  * \return an object that encapsulate the expression
2670  *
2671  */
2672 template<typename exp1 , typename exp2, typename op1>
2674 operator*(double d, const FD::grid_dist_expression_op<exp1,exp2,op1> & vb)
2675 {
2677 
2678  return exp_sum;
2679 }
2680 
2681 #endif /* FD_EXPRESSIONS_HPP_ */
FD::grid_dist_expression_op< exp1, void, subuni >::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.
Definition: FD_expressions.hpp:1318
FD::grid_dist_expression_iterator_to_make_algebra_work::ginfo_v
grid_sm< dim, void > & ginfo_v
Grid informations object without type.
Definition: FD_expressions.hpp:1948
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::operator=
grid & operator=(const grid_dist_expression< prp2, grid, STAG_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:880
FD::grid_dist_expression_op< exp1, exp2, mul >::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.
Definition: FD_expressions.hpp:1401
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::getGrid
gtype & getGrid()
Return the vector on which is acting.
Definition: FD_expressions.hpp:1697
grid
Definition: grid_test.hpp:218
FD::grid_dist_expression_op< exp1, exp2, sub >::getGrid
gtype & getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:1252
FD::grid_dist_expression< dim, double, STAG_EXPRESSION >::value
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate the expression.
Definition: FD_expressions.hpp:1065
FD::grid_dist_expression_op< exp1, void, subuni >::getGrid
const gtype & getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:1344
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::value_ref
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.
Definition: FD_expressions.hpp:831
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::init
void init() const
initialize the expression tree
Definition: FD_expressions.hpp:1703
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:807
FD::grid_dist_expression_iterator_to_make_algebra_work::get_loc_grid
device_grid & get_loc_grid(size_t i)
Get the i sub-domain grid.
Definition: FD_expressions.hpp:1997
FD::grid_dist_expression_op< exp1, exp2, sub >::grid_dist_expression_op
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
Definition: FD_expressions.hpp:1216
FD::grid_dist_expression_op< exp1, exp2, mul >::getGrid
auto getGrid() const -> decltype(first_or_second< has_getGrid< exp1 >::value, exp1, exp2 >::getGrid(o1, o2))
Return the grid on which is acting.
Definition: FD_expressions.hpp:1427
FD::grid_dist_expression< dim, float, impl >::grid_dist_expression
grid_dist_expression(const float &d)
constrictor from constant value
Definition: FD_expressions.hpp:1088
FD::mul
Definition: FD_expressions.hpp:1363
grid_sm::getSize
__device__ const __host__ size_t(& getSize() const)[N]
Return the size of the grid as an array.
Definition: grid_sm.hpp:760
FD::grid_dist_expression_op< exp1, void, subuni >::o1
const exp1 o1
expression 1
Definition: FD_expressions.hpp:1290
FD::get_grid_dist_expression_op
Definition: FD_expressions.hpp:1466
grid_base
Definition: map_grid.hpp:76
FD::grid_dist_expression_value_impl_vnz
Definition: FD_expressions.hpp:443
FD::grid_dist_expression_iterator_to_make_algebra_work
Definition: FD_expressions.hpp:1945
FD::sub
Definition: FD_expressions.hpp:1199
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::getGrid
const grid_dist_expression_iterator_to_make_algebra_work< dim > getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:2185
FD::grid_dist_expression< dim, float, impl >::value
float value(const grid_dist_key_dx< dim > &k) const
Evaluate the expression.
Definition: FD_expressions.hpp:1109
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::gtype
grid gtype
The type of the internal grid.
Definition: FD_expressions.hpp:531
FD::grid_dist_expression_iterator_to_make_algebra_work::loc_grid
openfpm::vector< grid_cpu< dim, aggregate< double > > > & loc_grid
The grid.
Definition: FD_expressions.hpp:1951
FD::grid_dist_expression_value_impl_func_vec
Definition: FD_expressions.hpp:163
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::getGrid
grid & getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:555
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::operator=
gtype & operator=(double d)
Fill the vector property with the double.
Definition: FD_expressions.hpp:1867
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::ginfo_v
grid_sm< dim, void > ginfo_v
Grid informations object without type.
Definition: FD_expressions.hpp:2092
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:577
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::value_ref
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.
Definition: FD_expressions.hpp:612
grid_dist_key_dx::getSub
size_t getSub() const
Get the local grid.
Definition: grid_dist_key.hpp:70
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::operator=
auto operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp) -> decltype(g_exp.getGrid())
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:2256
grid_sm< Sys_eqs::dims, void >
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::value
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.
Definition: FD_expressions.hpp:1721
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::grid_dist_expression
grid_dist_expression(grid &g)
constructor for an external grid
Definition: FD_expressions.hpp:544
FD::grid_dist_expression_op< exp1, exp2, sum >::getGrid
const gtype & getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:1179
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::getGrid
const grid & getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:797
grid_dist_iterator
Distributed grid iterator.
Definition: grid_dist_id_iterator.hpp:277
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::getGrid
const grid & getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:567
FD::grid_dist_expression_value_impl
Definition: FD_expressions.hpp:106
FD::grid_dist_expression< dim, float, impl >::vtype
float vtype
type of object the structure return then evaluated
Definition: FD_expressions.hpp:1085
openfpm::vector::size
size_t size()
Stub size.
Definition: map_vector.hpp:212
aggregate
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:220
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::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.
Definition: FD_expressions.hpp:600
grid_dist_key_dx
Grid key for a distributed grid.
Definition: grid_dist_key.hpp:6
FD::subuni
Definition: FD_expressions.hpp:1284
openfpm::vector
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:203
FD::sum
Definition: FD_expressions.hpp:1115
FD::grid_dist_expression_op< exp1, exp2, sum >::getGrid
gtype & getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:1167
comb
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
grid_dist_key_dx::getKeyRef
base_key & getKeyRef()
Get the reference key.
Definition: grid_dist_key.hpp:91
FD::g_comp
Definition: FD_expressions.hpp:48
FD::pos_or_propL::value
__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
Definition: FD_expressions.hpp:1459
FD::grid_dist_expression
Definition: FD_expressions.hpp:511
FD::grid_dist_expression_op< exp1, exp2, sum >::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.
Definition: FD_expressions.hpp:1153
FD::grid_dist_expression< dim, float, impl >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1097
FD::gdb_ext_plus_g_info
Definition: FD_expressions.hpp:1923
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::operator=
grid & operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp)
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:665
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::value
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.
Definition: FD_expressions.hpp:844
FD::grid_dist_expression< dim, double, NORM_EXPRESSION >::value
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate the expression.
Definition: FD_expressions.hpp:1024
FD::grid_dist_expression< dim, float, impl >::d
float d
constant value
Definition: FD_expressions.hpp:1080
FD::grid_dist_expression_op< exp1, exp2, sub >::getGrid
const gtype & getGrid() const
Return the grid on which is acting.
Definition: FD_expressions.hpp:1264
FD::grid_dist_expression_iterator_to_make_algebra_work::getGridInfoVoid
const grid_sm< dim, void > & getGridInfoVoid() const
Get an object containing the grid informations without type.
Definition: FD_expressions.hpp:2019
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::gtype
grid_dist_expression_iterator_to_make_algebra_work< dim > gtype
The type of the internal grid.
Definition: FD_expressions.hpp:2125
FD::grid_dist_expression< dim, double, NORM_EXPRESSION >::d
double d
constant parameter
Definition: FD_expressions.hpp:998
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::data
grid_patches< grid_cpu< dim, aggregate< double > > > data
The grid.
Definition: FD_expressions.hpp:2087
FD::grid_dist_expression_op
Definition: FD_expressions.hpp:44
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::value_ref
double & value_ref(const grid_dist_key_dx< dim > &k, const comb< dim > &c_where=comb< dim >())
Evaluate the expression.
Definition: FD_expressions.hpp:2230
FD::grid_dist_expression_iterator_to_make_algebra_work::get_loc_grid
const device_grid & get_loc_grid(size_t i) const
Get the i sub-domain grid.
Definition: FD_expressions.hpp:2009
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::property_act
boost::mpl::at< typename gtype::value_type::type, boost::mpl::int_< exp1::prop > >::type property_act
property on which this view is acting
Definition: FD_expressions.hpp:1709
FD::grid_dist_expression_op< exp1, exp2, mul >::grid_dist_expression_op
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
Definition: FD_expressions.hpp:1379
FD::grid_dist_expression< dim, double, STAG_EXPRESSION >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1053
FD::grid_dist_expression_op< exp1, exp2, sum >::o2
const exp2 o2
expression 1
Definition: FD_expressions.hpp:1124
FD::grid_dist_expression_op< exp1, void, subuni >::grid_dist_expression_op
grid_dist_expression_op(const exp1 &o1)
Costruct a FD expression out of two expressions.
Definition: FD_expressions.hpp:1297
FD::grid_dist_expression< dim, double, STAG_EXPRESSION >::d
double d
constant parameter
Definition: FD_expressions.hpp:1039
FD::grid_dist_expression_op< exp1, exp2, mul >::getGrid
auto getGrid() -> decltype(first_or_second< has_getGrid< exp1 >::value, exp1, exp2 >::getGrid(o1, o2))
Return the grid on which is acting.
Definition: FD_expressions.hpp:1415
FD::grid_dist_expression_op< exp1, exp2, sub >::o2
const exp2 o2
expression 1
Definition: FD_expressions.hpp:1209
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::g
grid & g
The grid.
Definition: FD_expressions.hpp:524
rank_gen
like std::rank but it also work for openfpm structures like Point where it return 1
Definition: Point.hpp:720
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:2195
FD::grid_dist_expression_value_impl_func_scal
Definition: FD_expressions.hpp:51
FD::grid_dist_expression_op< exp1, exp2, mul >::o1
const exp1 o1
expression 1
Definition: FD_expressions.hpp:1369
FD::grid_dist_expression_op< exp1, exp2, sum >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1140
FD::grid_dist_expression_op< exp1, void, subuni >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1306
FD::grid_dist_expression< dim, double, NORM_EXPRESSION >::grid_dist_expression
grid_dist_expression(const double &d)
constructor from a constant expression
Definition: FD_expressions.hpp:1003
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::g
grid & g
The grid.
Definition: FD_expressions.hpp:754
FD::grid_dist_expression_op< exp1, exp2, sub >::o1
const exp1 o1
expression 1
Definition: FD_expressions.hpp:1206
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::operator=
gtype & operator=(const grid_dist_expression_op< exp1_, exp2_, op > &v_exp)
Fill the vector property with the evaluated expression.
Definition: FD_expressions.hpp:1837
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::getGrid
grid & getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:785
comb::zero
void zero()
Set all the elements to zero.
Definition: comb.hpp:83
grid_key_dx< dim >
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::value
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.
Definition: FD_expressions.hpp:587
FD::grid_dist_expression_op< exp1, exp2, mul >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1388
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::operator=
grid & operator=(double d)
Fill the grid property with the double.
Definition: FD_expressions.hpp:693
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::getGrid
grid_dist_expression_iterator_to_make_algebra_work< dim > getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:2173
FD::grid_dist_expression_op< exp1, exp2, sub >::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.
Definition: FD_expressions.hpp:1238
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::getGrid
const gtype & getGrid() const
Return the vector on which is acting.
Definition: FD_expressions.hpp:1685
FD::grid_dist_expression_op< exp1, void, subuni >::getGrid
gtype & getGrid()
Return the grid on which is acting.
Definition: FD_expressions.hpp:1332
device_grid
Definition: map_grid.hpp:475
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::operator=
grid & operator=(const grid_dist_expression< prp2, grid_type, NORM_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:637
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::get
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.
Definition: FD_expressions.hpp:1751
Void
Void structure.
Definition: common.hpp:73
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::operator=
grid & operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp)
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:907
FD::grid_dist_expression_iterator_to_make_algebra_work::getLocalGridsInfo
const openfpm::vector< GBoxes< device_grid::dims > > & getLocalGridsInfo() const
It return the informations about the local grids.
Definition: FD_expressions.hpp:2029
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::grid_dist_expression
grid_dist_expression(grid &g)
constructor for an external grid
Definition: FD_expressions.hpp:774
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::gtype
grid gtype
The type of the internal grid.
Definition: FD_expressions.hpp:761
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::operator=
const grid & operator=(const grid_dist_expression< prp2, grid, NORM_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
Definition: FD_expressions.hpp:2242
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::value_ref
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.
Definition: FD_expressions.hpp:817
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::operator=
grid & operator=(double d)
Fill the grid property with the double.
Definition: FD_expressions.hpp:935
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::value_ref
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.
Definition: FD_expressions.hpp:1736
FD::grid_dist_expression< dim, double, STAG_EXPRESSION >::grid_dist_expression
grid_dist_expression(const double &d)
constructor from a constant expression
Definition: FD_expressions.hpp:1044
FD::grid_dist_expression_op< exp1, exp2, sum >::o1
const exp1 o1
expression 1
Definition: FD_expressions.hpp:1121
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::grid_dist_expression_op
grid_dist_expression_op(const exp1 &o1, int(&comp)[n], int var_id)
constructor from an expresssion
Definition: FD_expressions.hpp:1671
has_getGrid
Definition: FD_expressions.hpp:12
comb::mone
void mone()
Set all the elements to -1.
Definition: comb.hpp:95
FD::grid_dist_expression< prp, grid, NORM_EXPRESSION >::value_ref
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.
Definition: FD_expressions.hpp:625
Point
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:27
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::o1
exp1 o1
expression 1
Definition: FD_expressions.hpp:1647
FD::grid_dist_expression_op< exp1, exp2, sum >::grid_dist_expression_op
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
Definition: FD_expressions.hpp:1131
grid_key_dx::one
void one()
Set to one the key.
Definition: grid_key.hpp:179
FD::grid_dist_expression_op< exp1, exp2, mul >::o2
const exp2 o2
expression 1
Definition: FD_expressions.hpp:1372
grid_dist_key_dx::getKey
base_key getKey() const
Get the key.
Definition: grid_dist_key.hpp:80
GBoxes
This structure store the Box that define the domain inside the Ghost + domain box.
Definition: GBoxes.hpp:39
FD::pos_or_propL
selector for position or properties left side expression
Definition: FD_expressions.hpp:1456
FD::grid_patches
Definition: FD_expressions.hpp:2070
FD::first_or_second
Definition: FD_expressions.hpp:22
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::value
double value(const grid_dist_key_dx< dim > &k, const comb< dim > &c_where=comb< dim >()) const
Evaluate the expression.
Definition: FD_expressions.hpp:2205
FD::grid_dist_expression< 0, grid_patches< grid_cpu< dim, aggregate< double > > >, NORM_EXPRESSION >::grid_dist_expression
grid_dist_expression(grid &g)
constructor for an external grid
Definition: FD_expressions.hpp:2140
FD::grid_dist_expression_iterator_to_make_algebra_work::getN_loc_grid
size_t getN_loc_grid() const
Return the number of local grid.
Definition: FD_expressions.hpp:1985
FD::grid_dist_expression_op< exp1, boost::mpl::int_< n >, g_comp >::operator=
gtype & operator=(const grid_dist_expression< prp2, gtype2, impl > &v_exp)
Fill the vector property with the evaluated expression.
Definition: FD_expressions.hpp:1807
grid_dist_id
This is a distributed grid.
Definition: grid_dist_id.hpp:278
FD::grid_dist_expression< dim, double, NORM_EXPRESSION >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1012
FD::grid_dist_expression_op< exp1, exp2, sub >::init
void init() const
This function must be called before value.
Definition: FD_expressions.hpp:1225
FD::grid_dist_expression< prp, grid, STAG_EXPRESSION >::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 inte< prp >(g, k, c_where, c_where, comp))
Evaluate the expression.
Definition: FD_expressions.hpp:860