OpenFPM_pdata  4.1.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 namespace FD
12 {
13 
14  constexpr int NORM_EXPRESSION = 0;
15  constexpr int STAG_EXPRESSION = 1;
16  constexpr int GRID_COMP = 2;
17 
18  template <typename exp1,typename exp2, typename impl>
20  {
21  };
22 
23  struct g_comp {};
24 
25  template<unsigned int i>
27  {
28  template<unsigned int prp, typename base_type, typename gtype>
29  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, int comp)
30  {
31  if (c_where[i] != c_o1[i])
32  {
33  int sign = (c_where[i] > c_o1[i])?1:-1;
34 
35  grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
36  long int x0 = k.getKeyRef().get(i);
37 
38  k.getKeyRef().set_d(i, x0 + sign);
39  grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
40  k.getKeyRef().set_d(i, x0);
41  }
42  else
43  {
44  grid_dist_expression_value_impl_func_scal<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
45  }
46  }
47  };
48 
49  template<>
51  {
52  template<unsigned int prp, typename base_type, typename gtype>
53  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 , int comp)
54  {
55  if (c_where[0] != c_o1[0])
56  {
57  int sign = (c_where[0] > c_o1[0])?1:-1;
58 
59  inte_out += g.template getProp<prp>(k);
60 
61  long int x0 = k.getKeyRef().get(0);
62 
63  k.getKeyRef().set_d(0, x0 + sign);
64  inte_out += g.template getProp<prp>(k);
65  k.getKeyRef().set_d(0, x0);
66  c += 2;
67  }
68  else
69  {
70  inte_out += g.template getProp<prp>(k);
71  c += 1;
72  }
73  }
74  };
75 
76  template<typename base_type>
78  {
79  typedef base_type type;
80 
81  template<unsigned int prp, typename gtype>
82  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)
83  {
84  int c = 0;
85  base_type inte = 0;
86 
87  grid_dist_expression_value_impl_func_scal<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
88 
89  inte /= c;
90 
91  return inte;
92  }
93 
94  template<unsigned int prp, typename gtype>
95  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp)
96  {
97  return g.template getProp<prp>(k);
98  }
99 
100  template<unsigned int prp, typename gtype>
101  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp) -> decltype(g.template getProp<prp>(k))
102  {
103  return g.template getProp<prp>(k);
104  }
105  };
106 
107 
108  template<unsigned int i>
110  {
111  template<unsigned int prp, typename base_type, typename gtype>
112  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, int comp)
113  {
114  if (c_where[i] != c_o1[i])
115  {
116  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
117  long int x0 = k.getKeyRef().get(i);
118 
119  int sign = (c_where[i] > c_o1[i])?1:-1;
120 
121  k.getKeyRef().set_d(i, x0 + sign);
122  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
123  k.getKeyRef().set_d(i, x0);
124  }
125  else
126  {
127  grid_dist_expression_value_impl_func_vec<i-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte_out,c,comp);
128  }
129  }
130  };
131 
132  template<>
134  {
135  template<unsigned int prp, typename base_type, typename gtype>
136  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 , int comp)
137  {
138  if (c_where[0] != c_o1[0])
139  {
140  int sign = (c_where[0] > c_o1[0])?1:-1;
141 
142  inte_out += g.template getProp<prp>(k)[comp];
143 
144  long int x0 = k.getKeyRef().get(0);
145 
146  k.getKeyRef().set_d(0, x0 + sign);
147  inte_out += g.template getProp<prp>(k)[comp];
148  k.getKeyRef().set_d(0, x0);
149  c += 2;
150  }
151  else
152  {
153  inte_out += g.template getProp<prp>(k)[comp];
154  c += 1;
155  }
156  }
157  };
158 
159  template<typename base_type, unsigned int N1>
160  struct grid_dist_expression_value_impl<base_type[N1]>
161  {
162  typedef base_type type;
163 
164  template<unsigned int prp, typename gtype>
165  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)
166  {
167  int c = 0;
168  base_type inte = 0;
169 
170  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
171 
172  if (c != 0)
173  {inte /= c;}
174  else
175  {inte = g.template getProp<prp>(k)[comp];}
176 
177  return inte;
178  }
179 
180  template<unsigned int prp, typename gtype>
181  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp)
182  {
183  return g.template getProp<prp>(k)[comp];
184  }
185 
186  template<unsigned int prp, typename gtype>
187  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp) -> decltype(g.template getProp<prp>(k)[comp])
188  {
189  return g.template getProp<prp>(k)[comp];
190  }
191  };
192 
193  template<typename base_type, unsigned int N1>
195  {
196  typedef base_type type;
197 
198  template<unsigned int prp, typename gtype>
199  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)
200  {
201  int c = 0;
202  base_type inte = 0;
203 
204  grid_dist_expression_value_impl_func_vec<gtype::dims-1>::template inte<prp,base_type>(g,k,c_where,c_o1,inte,c,comp);
205 
206  if (c != 0)
207  {inte /= c;}
208  else
209  {inte = g.template getProp<prp>(k)[comp];}
210 
211  return inte;
212  }
213 
214  template<unsigned int prp, typename gtype>
215  static base_type value_n(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp)
216  {
217  return g.template getProp<prp>(k)[comp];
218  }
219 
220  template<unsigned int prp, typename gtype>
221  static auto value_ref(gtype & g, const grid_dist_key_dx<gtype::dims> & k, int comp) -> decltype(g.template getProp<prp>(k)[comp])
222  {
223  return g.template getProp<prp>(k)[comp];
224  }
225  };
226 
227  template<unsigned int i>
229  {
230  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
231  static void value_nz(const gmap_type & g_map,
232  unordered_map_type & cols,
233  gtype & g,
235  comb<gtype::dims> & c_where,
236  comb<gtype::dims> & c_o1,
237  typename Sys_eqs::stype coeff,
238  int & c,
239  int comp,
240  int var_id)
241  {
242  if (c_where[i] != c_o1[i])
243  {
244  int sign = (c_where[i] > c_o1[i])?1:-1;
245 
246  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);
247  //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
248 
249  long int x0 = key.getKeyRef().get(i);
250 
251  key.getKeyRef().set_d(i, x0 + sign);
252  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);
253  //cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
254  key.getKeyRef().set_d(i, x0);
255  }
256  else
257  {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);}
258  }
259  };
260 
261  template<>
263  {
264  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type ,typename gtype>
265  static void value_nz(const gmap_type & g_map,
266  unordered_map_type & cols,
267  gtype & g,
269  comb<gtype::dims> & c_where,
270  comb<gtype::dims> & c_o1,
271  typename Sys_eqs::stype coeff,
272  int & c ,
273  int comp,
274  int var_id)
275  {
276  if (c_where[0] != c_o1[0])
277  {
278  int sign = (c_where[0] > c_o1[0])?1:-1;
279 
280  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
281 
282  long int x0 = key.getKeyRef().get(0);
283 
284  key.getKeyRef().set_d(0, x0 + sign);
285  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff / c;
286  key.getKeyRef().set_d(0, x0);
287  }
288  else
289  {
290  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
291  }
292  }
293  };
294 
295  template<unsigned int prp, typename grid, unsigned int impl>
297  {};
298 
305  template<unsigned int prp, typename grid>
306  class grid_dist_expression<prp,grid,NORM_EXPRESSION>
307  {
309  grid & g;
310 
311  typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
312 
313  public:
314 
316  typedef grid gtype;
317 
319  static const unsigned int prop = prp;
320 
321  int var_id = 0;
322 
323  void setVarId(int var_id)
324  {
325  this->var_id = var_id;
326  }
327 
330  :g(g)
331  {}
332 
341  {
342  return g;
343  }
344 
352  const grid & getGrid() const
353  {
354  return g;
355  }
356 
362  inline void init() const
363  {}
364 
372  inline auto value(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, int comp = 0) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp))
373  {
374  return grid_dist_expression_value_impl<type_proc>::template value_n<prp>(g,k,comp);
375 // return g.template getProp<prp>(k);
376  }
377 
385  inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, int comp = 0) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp))
386  {
387  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
388 // return g.template getProp<prp>(k);
389  }
390 
398  template<unsigned int prp2> grid & operator=(const grid_dist_expression<prp2,grid,NORM_EXPRESSION> & g_exp)
399  {
400  g_exp.init();
401 
402  comb<grid::dims> s_pos;
403  s_pos.zero;
404 
405  auto it = g.getDomainIterator();
406 
407  while (it.isNext())
408  {
409  auto key = it.get();
410 
411  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
412 
413  ++it;
414  }
415 
416  return g;
417  }
418 
426  template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
427  {
428  g_exp.init();
429 
430  comb<grid::dims> s_pos;
431  s_pos.mone();
432 
433  auto it = g.getDomainIterator();
434 
435  while (it.isNext())
436  {
437  auto key = it.get();
438 
439  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
440 
441  ++it;
442  }
443 
444  return g;
445  }
446 
454  grid & operator=(double d)
455  {
456  auto it = g.getDomainIterator();
457 
458  //comb<grid::dims> s_pos;
459  //s_pos.mone();
460 
461  while (it.isNext())
462  {
463  auto key = it.get();
464 
465  g.template getProp<prp>(key) = d;
466 
467  ++it;
468  }
469 
470  return g;
471  }
472 
473 
474  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
475  inline void value_nz(const gmap_type & g_map,
477  const grid_sm<Sys_eqs::dims,void> & gs,
478  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
479  unordered_map_type & cols,
480  typename Sys_eqs::stype coeff,
481  unsigned int comp,
482  comb<Sys_eqs::dims> & c_where) const
483  {
484  cols[g_map.template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
485  }
486 
487  inline grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
488  {
489  int comp_n[1];
490 
491  comp_n[0] = comp;
492 
493  grid_dist_expression_op<grid_dist_expression<prp,grid,NORM_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
494 
495  return v_exp;
496  }
497 
498  //Need more treatment for staggered (c_where based on exp)
499  inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
500  {
501  comb<gtype::dims> c_where;
502  c_where.zero();
503  return this->value(key,c_where);
504  }
505 
506  int isConstant(){
507  return false;
508  }
509  };
510 
511  template<unsigned int prp, typename grid>
512  class grid_dist_expression<prp,grid,STAG_EXPRESSION>
513  {
515  grid & g;
516 
517  typedef typename boost::mpl::at<typename grid::value_type::type,boost::mpl::int_<prp>>::type type_proc;
518 
519  public:
520 
522  typedef grid gtype;
523 
525  static const unsigned int prop = prp;
526 
527  int var_id = 0;
528 
529  void setVarId(int var_id)
530  {
531  this->var_id = var_id;
532  }
533 
536  :g(g)
537  {}
538 
547  {
548  return g;
549  }
550 
558  const grid & getGrid() const
559  {
560  return g;
561  }
562 
568  inline void init() const
569  {}
570 
578  inline auto value_ref(const grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where,int comp = 0) const -> decltype(grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp))
579  {
580  return grid_dist_expression_value_impl<type_proc>::template value_ref<prp>(g,k,comp);
581  //return g.template getProp<prp>(k);
582  }
583 
591  inline auto value(grid_dist_key_dx<grid::dims> & k, comb<grid::dims> & c_where, int comp = 0) const -> decltype(grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_where,comp))
592  {
593  comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(comp);
594 
595  return grid_dist_expression_value_impl<type_proc>::template inte<prp>(g,k,c_where,c_o1,comp);
596  }
597 
605  template<unsigned int prp2> grid & operator=(const grid_dist_expression<prp2,grid,STAG_EXPRESSION> & g_exp)
606  {
607  g_exp.init();
608 
609  auto it = g.getDomainIterator();
610 
611  comb<grid::dims> s_pos = g.getStagPosition()[prp].get(0);
612 
613  while (it.isNext())
614  {
615  auto key = it.get();
616 
617  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
618 
619  ++it;
620  }
621 
622  return g;
623  }
624 
632  template<typename exp1, typename exp2, typename op> grid & operator=(const grid_dist_expression_op<exp1,exp2,op> & g_exp)
633  {
634  g_exp.init();
635 
636  auto it = g.getDomainIterator();
637 
638  comb<grid::dims> s_pos = g.getStagPositions()[prp].get(0);
639 
640  while (it.isNext())
641  {
642  auto key = it.get();
643 
644  g.template getProp<prp>(key) = g_exp.value(key,s_pos);
645 
646  ++it;
647  }
648 
649  return g;
650  }
651 
659  grid & operator=(double d)
660  {
661  auto it = g.getDomainIterator();
662 
663  while (it.isNext())
664  {
665  auto key = it.get();
666 
667  g.template getProp<prp>(key) = d;
668 
669  ++it;
670  }
671 
672  return g;
673  }
674 
675  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
676  inline void value_nz(const gmap_type & g_map,
678  const grid_sm<Sys_eqs::dims,void> & gs,
679  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
680  unordered_map_type & cols,
681  typename Sys_eqs::stype coeff,
682  unsigned int comp,
683  comb<Sys_eqs::dims> & c_where) const
684  {
685  int c = 1;
686  comb<grid::dims> c_o1 = g.getStagPositions()[prp].get(comp);
687 
688  // x0, dx are defined in proper dir є(x, y, z)
689 
690  for (int i = 0 ; i < grid::dims ; i++)
691  {
692  if (c_where[i] != c_o1[i])
693  {c *= 2;}
694  }
695 
696  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);
697 
698  }
699 
700  inline grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> operator[](int comp)
701  {
702  int comp_n[1];
703 
704  comp_n[0] = comp;
705 
706  grid_dist_expression_op<grid_dist_expression<prp,grid,STAG_EXPRESSION>,boost::mpl::int_<1>,g_comp> v_exp(*this,comp_n,var_id);
707 
708  return v_exp;
709  }
710 
711  };
712 
718  template<unsigned int dim>
719  class grid_dist_expression<dim,double,NORM_EXPRESSION>
720  {
722  double d;
723 
724  public:
725 
727  inline grid_dist_expression(const double & d)
728  :d(d)
729  {}
730 
736  inline void init() const
737  {}
738 
748  inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
749  {
750  return d;
751  }
752  };
753 
759  template<unsigned int dim>
760  class grid_dist_expression<dim,double,STAG_EXPRESSION>
761  {
763  double d;
764 
765  public:
766 
768  inline grid_dist_expression(const double & d)
769  :d(d)
770  {}
771 
777  inline void init() const
778  {}
779 
789  inline double value(const grid_dist_key_dx<dim> & k, comb<dim> & c_where) const
790  {
791  return d;
792  }
793  };
794 
800  template<unsigned int dim, unsigned int impl>
801  class grid_dist_expression<dim,float,impl>
802  {
804  float d;
805 
806  public:
807 
809  typedef float vtype;
810 
812  inline grid_dist_expression(const float & d)
813  :d(d)
814  {}
815 
821  inline void init() const
822  {}
823 
833  inline float value(const grid_dist_key_dx<dim> & k) const
834  {
835  return d;
836  }
837  };
838 
839  struct sum {};
840 
841  template <typename exp1, typename exp2>
842  class grid_dist_expression_op<exp1,exp2,sum>
843  {
845  const exp1 o1;
846 
848  const exp2 o2;
849 
850  public:
851 
852  typedef typename exp1::gtype gtype;
853 
855  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
856  :o1(o1),o2(o2)
857  {}
858 
864  inline void init() const
865  {
866  o1.init();
867  o2.init();
868  }
869 
877  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
878  {
879  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
880 
881  return o1.value(key,c_where) + o2.value(key,c_where);
882  }
883 
891  gtype & getGrid()
892  {
893  return o1.getGrid();
894  }
895 
903  const gtype & getGrid() const
904  {
905  return o1.getGrid();
906  }
907 
908  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
909  inline void value_nz(const gmap_type & g_map,
911  const grid_sm<Sys_eqs::dims,void> & gs,
912  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
913  unordered_map_type & cols,
914  typename Sys_eqs::stype coeff,
915  unsigned int comp,
916  comb<Sys_eqs::dims> & c_where) const
917  {
918  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
919  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
920  }
921  };
922 
923  struct sub {};
924 
925 
926  template <typename exp1, typename exp2>
927  class grid_dist_expression_op<exp1,exp2,sub>
928  {
930  const exp1 o1;
931 
933  const exp2 o2;
934 
935  public:
936 
937  typedef typename exp1::gtype gtype;
938 
940  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
941  :o1(o1),o2(o2)
942  {}
943 
949  inline void init() const
950  {
951  o1.init();
952  o2.init();
953  }
954 
962  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
963  {
964  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
965 
966  return o1.value(key,c_where) - o2.value(key,c_where);
967  }
968 
976  gtype & getGrid()
977  {
978  return o1.getGrid();
979  }
980 
988  const gtype & getGrid() const
989  {
990  return o1.getGrid();
991  }
992 
993  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
994  inline void value_nz(const gmap_type & g_map,
996  const grid_sm<Sys_eqs::dims,void> & gs,
997  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
998  unordered_map_type & cols,
999  typename Sys_eqs::stype coeff,
1000  unsigned int comp,
1001  comb<Sys_eqs::dims> & c_where) const
1002  {
1003  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp,c_where);
1004  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1005  }
1006  };
1007 
1008  struct subuni{};
1009 
1010  template <typename exp1>
1012  {
1014  const exp1 o1;
1015 
1016  public:
1017 
1018  typedef typename exp1::gtype gtype;
1019 
1021  inline grid_dist_expression_op(const exp1 & o1)
1022  :o1(o1)
1023  {}
1024 
1030  inline void init() const
1031  {
1032  o1.init();
1033  }
1034 
1042  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
1043  {
1044  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1045 
1046  return -o1.value(key,c_where);
1047  }
1048 
1056  gtype & getGrid()
1057  {
1058  return o1.getGrid();
1059  }
1060 
1068  const gtype & getGrid() const
1069  {
1070  return o1.getGrid();
1071  }
1072 
1073  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1074  inline void value_nz(const gmap_type & g_map,
1076  const grid_sm<Sys_eqs::dims,void> & gs,
1077  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1078  unordered_map_type & cols,
1079  typename Sys_eqs::stype coeff,
1080  unsigned int comp,
1081  comb<Sys_eqs::dims> & c_where) const
1082  {
1083  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,-coeff,comp,c_where);
1084  }
1085  };
1086 
1087  struct mul {};
1088 
1089  template <typename exp1, typename exp2>
1090  class grid_dist_expression_op<exp1,exp2,mul>
1091  {
1093  const exp1 o1;
1094 
1096  const exp2 o2;
1097 
1098  public:
1099 
1100  typedef typename exp2::gtype gtype;
1101 
1103  inline grid_dist_expression_op(const exp1 & o1,const exp2 & o2)
1104  :o1(o1),o2(o2)
1105  {}
1106 
1112  inline void init() const
1113  {
1114  o1.init();
1115  o2.init();
1116  }
1117 
1125  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
1126  {
1127  typename std::remove_reference<decltype(o1.value(key,c_where))>::type val;
1128 
1129  return o1.value(key,c_where) * o2.value(key,c_where);
1130  }
1131 
1139  gtype & getGrid()
1140  {
1141  return o1.getGrid();
1142  }
1143 
1151  const gtype & getGrid() const
1152  {
1153  return o1.getGrid();
1154  }
1155 
1156  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1157  inline void value_nz(const gmap_type & g_map,
1159  const grid_sm<Sys_eqs::dims,void> & gs,
1160  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1161  unordered_map_type & cols,
1162  typename Sys_eqs::stype coeff,
1163  unsigned int comp,
1164  comb<Sys_eqs::dims> & c_where) const
1165  {
1166  typename Sys_eqs::stype coeff_tmp = o1.value(key,c_where) * coeff;
1167 
1168  o2.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff_tmp,comp,c_where);
1169  }
1170  };
1171 
1179  template <typename grid_type, unsigned int prp>
1181  {
1183  __device__ __host__ static inline auto value(grid_type & v, const grid_dist_key_dx<grid_type::dims> & k) -> decltype(v.template getProp<prp>(k))
1184  {
1185  return v.template getProp<prp>(k);
1186  }
1187  };
1188 
1189  template<unsigned int, bool is_valid>
1191  {
1192  template<typename exp_type>
1193  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))
1194  {
1195  return o1.value(key,c_where);
1196  }
1197 
1198  template<typename exp_type>
1199  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))
1200  {
1201  return o1.value_ref(key,c_where);
1202  }
1203 
1204  template<unsigned int prop, typename exp_type, typename grid_type>
1205  inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1206  {
1207  pos_or_propL<grid_type,exp_type::prop>::value(g,key) = o1.value(key);
1208  }
1209 
1210  template<unsigned int prop, typename grid_type>
1211  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1212  {
1214  }
1215  };
1216 
1217  template<>
1219  {
1220  template<typename exp_type>
1221  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])
1222  {
1223  return 0;
1224  }
1225 
1226  template<unsigned int prop, typename exp_type, typename grid_type>
1227  inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<exp_type::gtype::dims> & key)
1228  {
1229  }
1230 
1231  template<unsigned int prop, typename grid_type>
1232  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key)
1233  {
1234  }
1235  };
1236 
1237  template<>
1239  {
1240  template<typename exp_type>
1241  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[0]))
1242  {
1243  return o1.value(key,c_where,comp[0]);
1244  }
1245 
1246  template<typename exp_type>
1247  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[0]))
1248  {
1249  return o1.value_ref(key,c_where,comp[0]);
1250  }
1251 
1252  template<unsigned int prop,typename exp_type, typename grid_type>
1253  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])
1254  {
1255  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = o1.value(key,c_where);
1256  }
1257 
1258  template<unsigned int prop, typename grid_type>
1259  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[1])
1260  {
1261  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]] = d;
1262  }
1263  };
1264 
1265  template<>
1267  {
1268  template<typename exp_type>
1269  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)[0][0])
1270  {
1271  return o1.value(key)[comp[0]][comp[1]];
1272  }
1273 
1274  template<unsigned int prop,typename exp_type, typename grid_type>
1275  inline static void assign(exp_type & o1, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1276  {
1277  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = o1.value(key);
1278  }
1279 
1280  template<unsigned int prop, typename grid_type>
1281  inline static void assign_double(double d, grid_type & g, const grid_dist_key_dx<grid_type::dims> & key, const int (& comp)[2])
1282  {
1283  pos_or_propL<grid_type,prop>::value(g,key)[comp[0]][comp[1]] = d;
1284  }
1285  };
1286 
1291  template <typename exp1,int n>
1292  class grid_dist_expression_op<exp1,boost::mpl::int_<n>,g_comp>
1293  {
1295  exp1 o1;
1296 
1298  int comp[n];
1299 
1300  int var_id = 0;
1301  void setVarId(int var_id)
1302  {
1303  this->var_id = var_id;
1304  }
1305 
1307 
1308  public:
1309 
1310  typedef std::false_type is_ker;
1311 
1312  typedef typename exp1::gtype gtype;
1313 
1315  static const unsigned int prop = exp1::prop;
1316 
1318 
1319  grid_dist_expression_op(const exp1 & o1, int (& comp)[n], int var_id)
1320  :o1(o1),var_id(var_id)
1321  {
1322  for (int i = 0 ; i < n ; i++)
1323  {this->comp[i] = comp[i];}
1324  }
1325 
1333  const gtype & getGrid() const
1334  {
1335  return o1.getGrid();
1336  }
1337 
1345  gtype & getGrid()
1346  {
1347  return o1.getGrid();
1348  }
1349 
1351  inline void init() const
1352  {
1353  o1.init();
1354  }
1355 
1357  typedef typename boost::mpl::at<typename gtype::value_type::type,boost::mpl::int_<exp1::prop>>::type property_act;
1358 
1369  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))
1370  {
1372  }
1373 
1384  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))
1385  {
1386  return get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::get_ref(o1,key,c_where,comp);
1387  }
1388 
1399  inline auto get(grid_dist_key_dx<gtype::dims> & key, comb<gtype::dims> & c_where) const -> decltype(value(key,c_where))
1400  {
1401  return this->value(key,c_where);
1402  }
1403 
1404  template<typename Sys_eqs, typename gmap_type, typename unordered_map_type>
1405  inline void value_nz(const gmap_type & g_map,
1407  const grid_sm<Sys_eqs::dims,void> & gs,
1408  typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
1409  unordered_map_type & cols,
1410  typename Sys_eqs::stype coeff,
1411  unsigned int comp_,
1412  comb<Sys_eqs::dims> & c_where) const
1413  {
1414  #ifdef SE_CLASS1
1415 
1416  if (n != 1)
1417  {
1418  std::cout << __FILE__ << ":" << __LINE__ << " Error it only work for tensore of rank 1 ... like vectors " << std::endl;
1419  }
1420 
1421  #endif
1422 
1423  o1.template value_nz<Sys_eqs>(g_map,key,gs,spacing,cols,coeff,comp_ + var_id + comp[0],c_where);
1424  }
1425 
1426  inline grid_dist_expression_op<exp1,boost::mpl::int_<2>,g_comp> operator[](int comp_)
1427  {
1428  int comp_n[n+1];
1429 
1430  for (int i = 0 ; i < n ; i++)
1431  {comp_n[i] = comp[i];}
1432  comp_n[n] = comp_;
1433 
1434  grid_dist_expression_op<exp1,boost::mpl::int_<2>,g_comp> v_exp(o1,comp_n,var_id);
1435 
1436  return v_exp;
1437  }
1438 
1439  //Need more treatment for staggered (c_where based on exp)
1440  inline typename gtype::stype get(grid_dist_key_dx<gtype::dims> & key)
1441  {
1442  comb<gtype::dims> c_where;
1443  c_where.zero();
1444  return this->value(key,c_where);
1445  }
1446 
1447 
1455  template<unsigned int prp2, unsigned int impl> gtype & operator=(const grid_dist_expression<prp2,gtype,impl> & v_exp)
1456  {
1457  v_exp.init();
1458 
1459  auto & g = getGrid();
1460 
1461  auto it = g.getDomainIterator();
1462 
1463  while (it.isNext())
1464  {
1465  auto key = it.get();
1466 
1467  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,comp);
1468 
1469  ++it;
1470  }
1471 
1472  return g;
1473  }
1474 
1482  template<typename exp1_, typename exp2_, typename op> gtype & operator=(const grid_dist_expression_op<exp1_,exp2_,op> & v_exp)
1483  {
1484  v_exp.init();
1485 
1486  auto & g = getGrid();
1487 
1488  auto it = g.getDomainIterator();
1489 
1490  comb<gtype::dims> c_where;
1491  c_where.zero();
1492 
1493  while (it.isNext())
1494  {
1495  auto key = it.get();
1496 
1497  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,g,key,c_where,comp);
1498 
1499  ++it;
1500  }
1501 
1502  return g;
1503  }
1504 
1512  gtype & operator=(double d)
1513  {
1514  auto & v = getGrid();
1515 
1516  auto it = v.getDomainIterator();
1517 
1518  while (it.isNext())
1519  {
1520  auto key = it.get();
1521 
1522  //pos_or_propL<vtype,exp1::prp>::value(v,key) = d;
1523  get_grid_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign_double<exp1::prop>(d,v,key,comp);
1524 
1525 
1526  ++it;
1527  }
1528 
1529  return v;
1530  }
1531 
1532  int isConstant(){
1533  return false;
1534  }
1535  };
1536 
1537 
1544  template <unsigned int prp,typename grid> inline grid_dist_expression<prp,grid,NORM_EXPRESSION> getV(grid & g)
1545  {
1546  grid_dist_expression<prp,grid,NORM_EXPRESSION> exp_g(g);
1547 
1548  return exp_g;
1549  }
1550 
1557  template <unsigned int prp, typename grid> inline grid_dist_expression<prp,grid,STAG_EXPRESSION> getV_stag(grid & g)
1558  {
1559  grid_dist_expression<prp,grid,STAG_EXPRESSION> exp_g(g);
1560 
1561  return exp_g;
1562  }
1563 
1564 };
1565 
1566 /* \brief sum two distributed grid expression
1567  *
1568  * \param ga grid expression one
1569  * \param gb grid expression two
1570  *
1571  * \return an object that encapsulate the expression
1572  *
1573  */
1574 template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
1577 {
1579 
1580  return exp_sum;
1581 }
1582 
1583 /* \brief sum two distributed grid expression
1584  *
1585  * \param ga grid expression one
1586  * \param gb grid expression two
1587  *
1588  * \return an object that encapsulate the expression
1589  *
1590  */
1591 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
1594 {
1596 
1597  return exp_sum;
1598 }
1599 
1600 /* \brief sum two distributed grid expression
1601  *
1602  * \param ga grid expression one
1603  * \param gb grid expression two
1604  *
1605  * \return an object that encapsulate the expression
1606  *
1607  */
1608 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
1611 {
1613 
1614  return exp_sum;
1615 }
1616 
1617 /* \brief sum two distributed grid expression
1618  *
1619  * \param ga grid expression one
1620  * \param gb grid expression two
1621  *
1622  * \return an object that encapsulate the expression
1623  *
1624  */
1625 template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
1628 {
1630 
1631  return exp_sum;
1632 }
1633 
1634 /* \brief sum two distributed grid expression
1635  *
1636  * \param ga grid expression one
1637  * \param gb grid expression two
1638  *
1639  * \return an object that encapsulate the expression
1640  *
1641  */
1642 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
1644 operator+(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
1645 {
1647 
1648  return exp_sum;
1649 }
1650 
1651 /* \brief sum two distributed grid expression
1652  *
1653  * \param ga grid expression one
1654  * \param gb grid expression two
1655  *
1656  * \return an object that encapsulate the expression
1657  *
1658  */
1659 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
1661 operator+(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
1662 {
1664 
1665  return exp_sum;
1666 }
1667 
1668 /* \brief sum two distributed grid expression
1669  *
1670  * \param ga grid expression one
1671  * \param gb grid expression two
1672  *
1673  * \return an object that encapsulate the expression
1674  *
1675  */
1676 template<typename exp1 , typename exp2, typename op1>
1678 operator+(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
1679 {
1681 
1682  return exp_sum;
1683 }
1684 
1685 /* \brief sum two distributed grid expression
1686  *
1687  * \param ga grid expression one
1688  * \param gb grid expression two
1689  *
1690  * \return an object that encapsulate the expression
1691  *
1692  */
1693 template<unsigned int p1, unsigned int p2, typename g1, typename g2, unsigned int impl_p1, unsigned int impl_p2>
1696 {
1698 
1699  return exp_sum;
1700 }
1701 
1702 /* \brief sum two distributed grid expression
1703  *
1704  * \param ga grid expression one
1705  * \param gb grid expression two
1706  *
1707  * \return an object that encapsulate the expression
1708  *
1709  */
1710 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
1713 {
1715 
1716  return exp_sum;
1717 }
1718 
1719 /* \brief sum two distributed grid expression
1720  *
1721  * \param ga grid expression one
1722  * \param gb grid expression two
1723  *
1724  * \return an object that encapsulate the expression
1725  *
1726  */
1727 template<typename exp1 , typename exp2, typename op1, unsigned int prp1, typename g1, unsigned int impl_p1>
1730 {
1732 
1733  return exp_sum;
1734 }
1735 
1736 /* \brief minus of a distributed grid expression
1737  *
1738  * \param ga grid expression one
1739  *
1740  * \return an object that encapsulate the expression
1741  *
1742  */
1743 template<typename exp1 , typename exp2_, typename op1>
1745 operator-(const FD::grid_dist_expression_op<exp1,exp2_,op1> & ga)
1746 {
1748 
1749  return exp_sum;
1750 }
1751 
1752 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
1754 operator-(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga)
1755 {
1757 
1758  return exp_sum;
1759 }
1760 
1761 
1762 /* \brief sum two distributed grid expression
1763  *
1764  * \param ga grid expression one
1765  * \param gb grid expression two
1766  *
1767  * \return an object that encapsulate the expression
1768  *
1769  */
1770 template<typename exp1 , typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
1773 {
1775 
1776  return exp_sum;
1777 }
1778 
1779 /* \brief sum two distributed grid expression
1780  *
1781  * \param ga grid expression one
1782  * \param gb grid expression two
1783  *
1784  * \return an object that encapsulate the expression
1785  *
1786  */
1787 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
1789 operator-(const FD::grid_dist_expression<prp1,g1,impl_p1> & ga, double d)
1790 {
1792 
1793  return exp_sum;
1794 }
1795 
1796 /* \brief sum two distributed grid expression
1797  *
1798  * \param ga grid expression one
1799  * \param gb grid expression two
1800  *
1801  * \return an object that encapsulate the expression
1802  *
1803  */
1804 template<unsigned int prp1 , typename g1, unsigned int impl_p1>
1806 operator-(double d, const FD::grid_dist_expression<prp1,g1,impl_p1> & gb)
1807 {
1809 
1810  return exp_sum;
1811 }
1812 
1813 /* \brief sum two distributed grid expression
1814  *
1815  * \param ga grid expression one
1816  * \param gb grid expression two
1817  *
1818  * \return an object that encapsulate the expression
1819  *
1820  */
1821 template<typename exp1 , typename exp2, typename op1>
1823 operator-(const FD::grid_dist_expression_op<exp1,exp2,op1> & ga, double d)
1824 {
1826 
1827  return exp_sum;
1828 }
1829 
1830 /* \brief Multiply two distributed grid expression
1831  *
1832  * \param va grid expression one
1833  * \param vb grid expression two
1834  *
1835  * \return an object that encapsulate the expression
1836  *
1837  */
1838 template<unsigned int p2, typename g2, unsigned int impl_p2>
1840 operator*(double d, const FD::grid_dist_expression<p2,g2,impl_p2> & vb)
1841 {
1843 
1844  return exp_sum;
1845 }
1846 
1847 /* \brief Multiply two distributed grid expression
1848  *
1849  * \param va grid expression one
1850  * \param vb grid expression two
1851  *
1852  * \return an object that encapsulate the expression
1853  *
1854  */
1855 template<unsigned int p2, typename g2, unsigned int impl_p2>
1857 operator*(const FD::grid_dist_expression<p2,g2,impl_p2> & va, double d)
1858 {
1860 
1861  return exp_sum;
1862 }
1863 
1864 /* \brief Multiply two distributed grid expression
1865  *
1866  * \param va grid expression one
1867  * \param vb grid expression two
1868  *
1869  * \return an object that encapsulate the expression
1870  *
1871  */
1872 template<unsigned int p1, typename v1,unsigned int p2, typename v2, unsigned int impl_p1, unsigned int impl_p2>
1875 {
1877 
1878  return exp_sum;
1879 }
1880 
1881 /* \brief Multiply two distributed grid expression
1882  *
1883  * \param va grid expression one
1884  * \param vb grid expression two
1885  *
1886  * \return an object that encapsulate the expression
1887  *
1888  */
1889 template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
1892 {
1894 
1895  return exp_sum;
1896 }
1897 
1898 /* \brief Multiply two distributed grid expression
1899  *
1900  * \param va grid expression one
1901  * \param vb grid expression two
1902  *
1903  * \return an object that encapsulate the expression
1904  *
1905  */
1906 template<unsigned int p1, typename v1, typename exp1, typename exp2, typename op1, unsigned int impl_p1>
1909 {
1911 
1912  return exp_sum;
1913 }
1914 
1915 /* \brief Multiply two distributed grid expression
1916  *
1917  * \param va grid expression one
1918  * \param vb grid expression two
1919  *
1920  * \return an object that encapsulate the expression
1921  *
1922  */
1923 template<typename exp1, typename exp2, typename op1, typename exp3 , typename exp4, typename op2>
1926 {
1928 
1929  return exp_sum;
1930 }
1931 
1932 /* \brief Multiply a distributed grid expression by a number
1933  *
1934  * \param va grid expression
1935  * \param d number
1936  *
1937  * \return an object that encapsulate the expression
1938  *
1939  */
1940 template<typename exp1 , typename exp2, typename op1>
1942 operator*(const FD::grid_dist_expression_op<exp1,exp2,op1> & va, double d)
1943 {
1945 
1946  return exp_sum;
1947 }
1948 
1949 /* \brief Multiply a distributed grid expression by a number
1950  *
1951  * \param d number
1952  * \param vb grid expression
1953  *
1954  * \return an object that encapsulate the expression
1955  *
1956  */
1957 template<typename exp1 , typename exp2, typename op1>
1959 operator*(double d, const FD::grid_dist_expression_op<exp1,exp2,op1> & vb)
1960 {
1962 
1963  return exp_sum;
1964 }
1965 
1966 #endif /* FD_EXPRESSIONS_HPP_ */
grid_dist_expression(const double &d)
constructor from a constant expression
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate 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.
const gtype & getGrid() const
Return the grid on which is acting.
base_key & getKeyRef()
Get the reference key.
grid_dist_expression(grid &g)
constructor for an external grid
float vtype
type of object the structure return then evaluated
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
grid_dist_expression(const float &d)
constrictor from constant value
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 -> 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.
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.
gtype & operator=(const grid_dist_expression< prp2, gtype, impl > &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.
gtype & getGrid()
Return the grid on which is acting.
void init() const
This function must be called before value.
Grid key for a distributed grid.
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:27
float value(const grid_dist_key_dx< dim > &k) const
Evaluate the expression.
grid & operator=(double d)
Fill the grid property with the double.
grid & operator=(const grid_dist_expression_op< exp1, exp2, op > &g_exp)
Fill the grid property with the evaluated expression.
grid_dist_expression(const double &d)
constructor from a constant expression
gtype & getGrid()
Return the grid on which is acting.
gtype & getGrid()
Return the vector on which is acting.
gtype & operator=(double d)
Fill the vector property with the double.
double value(const grid_dist_key_dx< dim > &k, comb< dim > &c_where) const
Evaluate the expression.
gtype & getGrid()
Return the grid on which is acting.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, int comp=0) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k, comp))
Evaluate the expression.
gtype & getGrid()
Return the grid on which is acting.
const gtype & getGrid() const
Return the vector on which is acting.
grid & getGrid()
Return the grid on which is acting.
auto value_ref(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, int comp=0) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_ref< prp >(g, k, comp))
Evaluate the expression.
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
const grid & getGrid() const
Return the grid on which is acting.
const grid & getGrid() const
Return the grid on which is acting.
This is a distributed grid.
const gtype & getGrid() const
Return the grid on which is acting.
__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
auto value(grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, int comp=0) const -> decltype(grid_dist_expression_value_impl< type_proc >::template inte< prp >(g, k, c_where, c_where, comp))
Evaluate the expression.
void init() const
This function must be called before value.
grid & operator=(const grid_dist_expression< prp2, grid, STAG_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
void mone()
Set all the elements to -1.
Definition: comb.hpp:95
grid_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a FD expression out of two expressions.
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.
void zero()
Set all the elements to zero.
Definition: comb.hpp:83
void init() const
This function must be called before value.
grid & getGrid()
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.
grid_dist_expression_op(const exp1 &o1, int(&comp)[n], int var_id)
constructor from an expresssion
const gtype & getGrid() const
Return the grid on which is acting.
grid & operator=(double d)
Fill the grid property with the double.
boost::mpl::at< typename gtype::value_type::type, boost::mpl::int_< exp1::prop > >::type property_act
property on which this view is acting
auto value(const grid_dist_key_dx< grid::dims > &k, comb< grid::dims > &c_where, int comp=0) const -> decltype(grid_dist_expression_value_impl< type_proc >::template value_n< prp >(g, k, comp))
Evaluate the expression.
void init() const
This function must be called before value.
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
const gtype & getGrid() const
Return the grid on which is acting.
selector for position or properties left side 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.
like std::rank but it also work for openfpm structures like Point where it return 1
Definition: Point.hpp:705
grid_dist_expression_op(const exp1 &o1)
Costruct a FD expression out of two expressions.
gtype & operator=(const grid_dist_expression_op< exp1_, exp2_, op > &v_exp)
Fill the vector property with the evaluated expression.
void init() const
This function must be called before value.
grid & operator=(const grid_dist_expression< prp2, grid, NORM_EXPRESSION > &g_exp)
Fill the grid property with the evaluated expression.
void init() const
This function must be called before value.
void init() const
This function must be called before value.
void init() const
This function must be called before value.