OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_dist_operators_apply_kernel.hpp
1/*
2 * vector_dist_operators_apply_kernel.hpp
3 *
4 * Created on: Jun 19, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_HPP_
9#define OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_HPP_
10
12
13#define DEFINE_INTERACTION_3D(name) struct name \
14{\
15\
16 Point<3,double> value(const Point<3,double> & xp, const Point<3,double> xq)\
17 {
18
19#define END_INTERACTION }\
20 };
21
28template<typename ObjType, typename Sfinae = void>
29struct is_expression: std::false_type {};
30
31template<typename ObjType>
32struct is_expression<ObjType, typename Void<typename ObjType::is_expression>::type> : std::true_type
33{};
34
36template<typename exp, bool is_exp = is_expression<exp>::value>
38{
40 typedef typename exp::return_type rtype;
41};
42
44template<typename exp>
45struct apply_kernel_rtype<exp,false>
46{
48 typedef exp rtype;
49};
50
51
56template<typename rtype>
58{
60 __device__ __host__ static rtype create()
61 {
62 return 0.0;
63 }
64};
65
67template<unsigned int dim, typename T>
68struct set_zero<Point<dim,T>>
69{
71 __device__ __host__ static Point<dim,T> create()
72 {
73 Point<dim,T> ret;
74
75 ret.zero();
76 return ret;
77 }
78};
79
80constexpr int NN_index_sort = 1;
81constexpr int NN_index_unsort = 0;
82
83template<unsigned int impl>
85{
86 template<typename NN_type>
87 __device__ __host__ static auto get(NN_type & NN) -> decltype(NN.get())
88 {
89 return NN.get();
90 }
91};
92
93template<>
94struct NN_index<NN_index_sort>
95{
96 template<typename NN_type>
97 __device__ __host__ static auto get(NN_type & NN) -> decltype(NN.get_sort())
98 {
99 return NN.get_sort();
100 }
101};
102
107template<unsigned int impl, typename T, typename vector, typename exp,typename NN_type, typename Kernel, typename rtype, bool is_exp=is_expression<T>::value>
109{
121 inline __host__ __device__ static typename std::remove_reference<rtype>::type apply(const vector & vd, NN_type & cl, const exp & v_exp, const vect_dist_key_dx & key, Kernel & lker)
122 {
123 // accumulator
124 typename std::remove_reference<rtype>::type pse = set_zero<typename std::remove_reference<rtype>::type>::create();
125
126 // position of particle p
128
129 // property of the particle x
130 rtype prp_p = v_exp.value(key);
131
132 // Get the neighborhood of the particle
133 auto NN = cl.template getNNIterator<NO_CHECK>(cl.getCell(p));
134 while(NN.isNext())
135 {
136 auto nnp = NN_index<impl>::get(NN);
137
138 // Calculate contribution given by the kernel value at position p,
139 // given by the Near particle, exclude itself
140 if (nnp != key.getKey())
141 {
142 vect_dist_key_dx nnp_k;
143 nnp_k.setKey(nnp);
144
145 // property of the particle x
146 rtype prp_q = v_exp.value(nnp_k);
147
148 // position of the particle q
150
151 pse += lker.value(p,q,prp_p,prp_q);
152 }
153
154 // Next particle
155 ++NN;
156 }
157
158 return pse;
159 }
160};
161
162
167template<unsigned int impl, typename vector, typename exp,typename NN_type, typename Kernel, typename rtype>
169{
180 __device__ __host__ inline static typename std::remove_reference<rtype>::type apply(const vector & vd, NN_type & cl, const vect_dist_key_dx & key, Kernel & lker)
181 {
182 // accumulator
183 typename std::remove_reference<rtype>::type pse = set_zero<typename std::remove_reference<rtype>::type>::create();
184
185 // position of particle p
187
188 // Get the neighborhood of the particle
189 auto NN = cl.template getNNIterator<NO_CHECK>(cl.getCell(p));
190 while(NN.isNext())
191 {
192 auto nnp = NN_index<impl>::get(NN);
193
194 // Calculate contribution given by the kernel value at position p,
195 // given by the Near particle, exclude itself
196 if (nnp != key.getKey())
197 {
198 // position of the particle q
200
201 pse += lker.value(p,q);
202 }
203
204 // Next particle
205 ++NN;
206 }
207
208 return pse;
209 }
210};
211
212
213
218template<unsigned int impl, typename T, typename vector, typename exp,typename NN_type, typename Kernel, typename rtype, bool is_exp=is_expression<T>::value>
220{
232 __device__ __host__ inline static typename std::remove_reference<rtype>::type apply(const vector & vd, NN_type & cl, const exp & v_exp, const vect_dist_key_dx & key, Kernel & lker)
233 {
234 // accumulator
235 typename std::remove_reference<rtype>::type pse = set_zero<typename std::remove_reference<rtype>::type>::create();
236
237 // property of the particle x
238 rtype prp_p = v_exp.value(key);
239
240 // position of particle p
242
243 // Get the neighborhood of the particle
244 auto NN = cl.template getNNIterator<NO_CHECK>(cl.getCell(p));
245 while(NN.isNext())
246 {
247 auto nnp = NN_index<impl>::get(NN);
248
249 // Calculate contribution given by the kernel value at position p,
250 // given by the Near particle, exclude itself
251 if (nnp != key.getKey())
252 {
253 vect_dist_key_dx nnp_k;
254 nnp_k.setKey(nnp);
255
256 // property of the particle x
257 rtype prp_q = v_exp.value(nnp_k);
258
259 pse += lker.value(key.getKey(),nnp,prp_p,prp_q,vd);
260 }
261
262 // Next particle
263 ++NN;
264 }
265
266 return pse;
267 }
268};
269
270template<typename T, bool mm>
272{
273 T obj;
274
275 mutable_or_not(const T & obj)
276 :obj(obj)
277 {}
278};
279
280template<typename T>
281struct mutable_or_not<T,true>
282{
283 mutable T obj;
284
285 mutable_or_not(const T & obj)
286 :obj(obj)
287 {}
288};
289
290template<typename T, bool is_reference = std::is_reference<T>::value>
292{
293 typedef const T type;
294};
295
296template<typename T>
298{
299 typedef typename std::remove_reference<T>::type const & type;
300};
301
308template <typename exp1,typename vector_type>
309class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN>
310{
312 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
314 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
316 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
317
319 typedef typename std::remove_reference<NN>::type NN_nr;
321 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
323 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
324
326 const exp1 o1;
327
330
333
335 typename add_const_reference<vector_orig>::type vd;
336
338 typedef typename apply_kernel_rtype<decltype(o1.value(vect_dist_key_dx()))>::rtype rtype;
339
340public:
341
344
347
349 typedef boost::mpl::bool_<false> is_sort;
350
352 typedef NN_nr NN_type;
353
359 inline NN_nr * getNN() const
360 {
361 return &cl.obj;
362 }
363
369 inline const vtype & getVector() const
370 {
371 return vd;
372 }
373
379 inline void init() const
380 {
381 o1.init();
382 }
383
393 vector_dist_expression_op(const exp1 & o1, const NN& cl, Kernel & ker, const vector_orig_nr & vd)
394 :o1(o1),cl(cl),ker(ker),vd(vd)
395 {}
396
404 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
405 {
406 return apply_kernel_is_number_or_expression<NN_index_unsort,
407 decltype(o1.value(key)),
409 exp1,
410 NN_nr,
411 Kernel_nr,
412 rtype>::apply(vd,cl.obj,o1,key,ker.obj);
413 }
414};
415
422template <typename exp1,typename vector_type>
423class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN_SORT>
424{
426 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
428 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
430 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
431
433 typedef typename std::remove_reference<NN>::type NN_nr;
435 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
437 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
438
440 const exp1 o1;
441
444
447
449 typename add_const_reference<vector_orig>::type vd;
450
452 typedef typename apply_kernel_rtype<decltype(o1.value(vect_dist_key_dx()))>::rtype rtype;
453
454public:
455
458
461
463 typedef boost::mpl::bool_<true> is_sort;
464
466 typedef NN_nr NN_type;
467
473 inline NN_nr * getNN() const
474 {
475 return &cl.obj;
476 }
477
483 inline const vtype & getVector() const
484 {
485 return vd;
486 }
487
493 inline void init() const
494 {
495 o1.init();
496 }
497
506 vector_dist_expression_op(const exp1 & o1, NN & cl, Kernel & ker, const vector_orig_nr & vd)
507 :o1(o1),cl(cl),ker(ker),vd(vd)
508 {}
509
517 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
518 {
519 return apply_kernel_is_number_or_expression<NN_index_sort,
520 decltype(o1.value(key)),
522 exp1,
523 NN_nr,
524 Kernel_nr,
525 rtype>::apply(vd,cl.obj,o1,key,ker.obj);
526 }
527};
528
535template <typename exp1,typename vector_type>
536class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN_SIM>
537{
539 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
541 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
543 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
544
546 typedef typename std::remove_reference<NN>::type NN_nr;
548 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
550 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
551
554
557
560
563
564
565public:
566
569
572
574 typedef boost::mpl::bool_<false> is_sort;
575
577 typedef NN_nr NN_type;
578
584 inline NN_nr * getNN() const
585 {
586 return &cl.obj;
587 }
588
594 inline const vtype & getVector() const
595 {
596 return vd;
597 }
598
604 inline void init() const
605 {
606 }
607
615 vector_dist_expression_op(const NN & cl, Kernel & ker, const vector_orig & vd)
616 :cl(cl),ker(ker),vd(vd)
617 {}
618
626 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
627 {
628 return apply_kernel_is_number_or_expression_sim<NN_index_unsort,
630 exp1,
631 NN_nr,
632 Kernel_nr,
633 rtype>::apply(vd,cl.obj,key,ker.obj);
634 }
635};
636
643template <typename exp1,typename vector_type>
644class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN_SIM_SORT>
645{
647 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
649 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
651 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
652
654 typedef typename std::remove_reference<NN>::type NN_nr;
656 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
658 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
659
662
665
668
671
672
673public:
674
677
680
682 typedef boost::mpl::bool_<true> is_sort;
683
685 typedef NN_nr NN_type;
686
692 inline NN_nr * getNN() const
693 {
694 return &cl.obj;
695 }
696
702 inline const vtype & getVector() const
703 {
704 return vd;
705 }
706
712 inline void init() const
713 {
714 }
715
723 vector_dist_expression_op(const NN & cl, Kernel & ker, const vector_orig & vd)
724 :cl(cl),ker(ker),vd(vd)
725 {}
726
734 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
735 {
736 return apply_kernel_is_number_or_expression_sim<NN_index_sort,
738 exp1,
739 NN_nr,
740 Kernel_nr,
741 rtype>::apply(vd,cl.obj,key,ker.obj);
742 }
743};
744
751template <typename exp1,typename vector_type>
752class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN_GEN>
753{
755 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
757 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
758
760 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
761
763 typedef typename std::remove_reference<NN>::type NN_nr;
765 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
767 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
768
770 const exp1 o1;
771
774
777
780
782 typedef typename apply_kernel_rtype<decltype(o1.value(vect_dist_key_dx()))>::rtype rtype;
783
784public:
785
788
791
793 typedef boost::mpl::bool_<false> is_sort;
794
796 typedef NN_nr NN_type;
797
803 inline NN_nr * getNN() const
804 {
805 return &cl.obj;
806 }
807
813 inline const vtype & getVector() const
814 {
815 return vd;
816 }
817
823 inline void init() const
824 {
825 o1.init();
826 }
827
836 vector_dist_expression_op(const exp1 & o1, const NN & cl, Kernel & ker, const vector_orig & vd)
837 :o1(o1),cl(cl),ker(ker),vd(vd)
838 {}
839
847 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
848 {
849 return apply_kernel_is_number_or_expression_gen<NN_index_unsort,
850 decltype(o1.value(key)),
852 exp1,
853 NN_nr,
854 Kernel_nr,
855 rtype>::apply(vd,cl.obj,o1,key,ker.obj);
856 }
857};
858
865template <typename exp1,typename vector_type>
866class vector_dist_expression_op<exp1,vector_type,VECT_APPLYKER_IN_GEN_SORT>
867{
869 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type NN;
871 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type Kernel;
872
874 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type vector_orig;
875
877 typedef typename std::remove_reference<NN>::type NN_nr;
879 typedef typename std::remove_reference<Kernel>::type Kernel_nr;
881 typedef typename std::remove_reference<vector_orig>::type vector_orig_nr;
882
884 const exp1 o1;
885
888
891
894
896 typedef typename apply_kernel_rtype<decltype(o1.value(vect_dist_key_dx()))>::rtype rtype;
897
898public:
899
902
905
907 typedef boost::mpl::bool_<true> is_sort;
908
910 typedef NN_nr NN_type;
911
917 inline NN_nr * getNN() const
918 {
919 return &cl.obj;
920 }
921
927 inline const vtype & getVector() const
928 {
929 return vd;
930 }
931
937 inline void init() const
938 {
939 o1.init();
940 }
941
950 vector_dist_expression_op(const exp1 & o1, const NN & cl, Kernel & ker, const vector_orig & vd)
951 :o1(o1),cl(cl),ker(ker),vd(vd)
952 {}
953
961 __device__ __host__ inline typename std::remove_reference<rtype>::type value(const vect_dist_key_dx & key) const
962 {
963 return apply_kernel_is_number_or_expression_gen<NN_index_sort,
964 decltype(o1.value(key)),
966 exp1,
967 NN_nr,
968 Kernel_nr,
969 rtype>::apply(vd,cl.obj,o1,key,ker.obj);
970 }
971};
972
973template<typename cl_type, int impl=2*is_gpu_celllist<cl_type>::type::value + is_gpu_ker_celllist<cl_type>::type::value >
975{
976 typedef cl_type& ctype;
977
978 static ctype & get(cl_type & cl)
979 {
980 return cl;
981 }
982};
983
984template<typename cl_type>
985struct cl_selector_impl<cl_type,2>
986{
987 typedef decltype(std::declval<cl_type>().toKernel()) ctype;
988
989 static ctype get(cl_type & cl)
990 {
991 return cl.toKernel();
992 }
993};
994
995template<typename cl_type>
996struct cl_selector_impl<cl_type,1>
997{
998 typedef cl_type ctype;
999
1000 static ctype & get(cl_type & cl)
1001 {
1002 return cl;
1003 }
1004};
1005
1006template<typename kl_type, typename cl_type, int impl=2*is_gpu_celllist<cl_type>::type::value + is_gpu_ker_celllist<cl_type>::type::value >
1008{
1009 typedef kl_type& ktype;
1010};
1011
1012template<typename kl_type, typename cl_type>
1013struct kl_selector_impl<kl_type,cl_type,2>
1014{
1015 typedef kl_type ktype;
1016};
1017
1018template<typename kl_type, typename cl_type>
1019struct kl_selector_impl<kl_type,cl_type,1>
1020{
1021 typedef kl_type ktype;
1022};
1023
1024template<bool is_sorted, bool uwk, typename T>
1026{
1027 typedef T type;
1028
1029 static T & get(T & v)
1030 {
1031 return v;
1032 }
1033};
1034
1035template<typename T>
1036struct unroll_with_to_kernel<false,true,T>
1037{
1038 typedef decltype(std::declval<T>().toKernel()) type;
1039
1040 static type get(T & v)
1041 {
1042 return v.toKernel();
1043 }
1044};
1045
1046template<typename T>
1047struct unroll_with_to_kernel<true,true,T>
1048{
1049 typedef decltype(std::declval<T>().toKernel_sorted()) type;
1050
1051 static type get(T & v)
1052 {
1053 return v.toKernel_sorted();
1054 }
1055};
1056
1057template<bool is_sorted, typename vl_type, typename cl_type, int impl=2*is_gpu_celllist<cl_type>::type::value + is_gpu_ker_celllist<cl_type>::type::value>
1059{
1060 typedef vl_type& vtype;
1061
1062 static vtype & get(vl_type & v)
1063 {
1064 return v;
1065 }
1066};
1067
1068template<typename vl_type, typename cl_type>
1069struct vl_selector_impl<false,vl_type,cl_type,2>
1070{
1071 typedef decltype(std::declval<vl_type>().toKernel()) vtype;
1072
1073 static vtype get(vl_type & v)
1074 {
1075 return v.toKernel();
1076 }
1077};
1078
1079template<typename vl_type, typename cl_type>
1080struct vl_selector_impl<true,vl_type,cl_type,2>
1081{
1082 typedef decltype(std::declval<vl_type>().toKernel()) vtype;
1083
1084 static vtype get(vl_type & v)
1085 {
1086 return v.toKernel_sorted();
1087 }
1088};
1089
1090template<bool is_sorted, typename vl_type, typename cl_type>
1091struct vl_selector_impl<is_sorted, vl_type,cl_type,1>
1092{
1093 typedef typename unroll_with_to_kernel<is_sorted,has_toKernel<vl_type>::type::value,vl_type>::type vtype;
1094
1095 static vtype get(vl_type & v)
1096 {
1098 }
1099};
1100
1101
1104
1105/* \brief Apply kernel expression
1106 *
1107 * \param va vector expression one
1108 * \param vb vector expression two
1109 *
1110 * \return an object that encapsulate the expression
1111 *
1112 */
1113template<typename exp1, typename exp2, unsigned int op1, typename NN, typename Kernel, typename vector_type>
1115 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1116 typename kl_selector_impl<Kernel,NN>::ktype,
1118 VECT_APPLYKER_IN>
1119applyKernel_in(const vector_dist_expression_op<exp1,exp2,op1> & va, vector_type & vd, NN & cl, Kernel & ker)
1120{
1122 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1123 typename kl_selector_impl<Kernel,NN>::ktype,
1125 VECT_APPLYKER_IN> exp_sum(va,
1127 ker,
1129
1130 return exp_sum;
1131}
1132
1133
1136
1137/* \brief Apply kernel expression
1138 *
1139 * \param va vector expression one
1140 * \param vb vector expression two
1141 *
1142 * \return an object that encapsulate the expression
1143 *
1144 */
1145template<typename exp1, typename exp2, unsigned int op1, typename NN, typename Kernel, typename vector_type>
1147 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1148 typename kl_selector_impl<Kernel,NN>::ktype,
1150 VECT_APPLYKER_IN_SORT>
1151applyKernel_in_sort(const vector_dist_expression_op<exp1,exp2,op1> & va, vector_type & vd, NN & cl, Kernel & ker)
1152{
1154 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1155 typename kl_selector_impl<Kernel,NN>::ktype,
1157 VECT_APPLYKER_IN_SORT> exp_sum(va,
1159 ker,
1161
1162 return exp_sum;
1163}
1164
1165/* \brief Apply kernel expression
1166 *
1167 * \param va vector expression one
1168 * \param vb vector expression two
1169 *
1170 * \return an object that encapsulate the expression
1171 *
1172 */
1173template<typename exp1, typename exp2, unsigned int op1, typename NN, typename Kernel, typename vector_type>
1175 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1176 typename kl_selector_impl<Kernel,NN>::ktype,
1178 VECT_APPLYKER_IN_GEN>
1179applyKernel_in_gen(const vector_dist_expression_op<exp1,exp2,op1> & va, vector_type & vd, NN & cl, Kernel & ker)
1180{
1182 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1183 typename kl_selector_impl<Kernel,NN>::ktype,
1185 VECT_APPLYKER_IN_GEN> exp_sum(va,
1187 ker,
1189
1190 return exp_sum;
1191}
1192
1193/* \brief Apply kernel expression
1194 *
1195 * \param va vector expression one
1196 * \param vb vector expression two
1197 *
1198 * \return an object that encapsulate the expression
1199 *
1200 */
1201template<typename exp1, typename exp2, unsigned int op1, typename NN, typename Kernel, typename vector_type>
1203 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1204 typename kl_selector_impl<Kernel,NN>::ktype,
1206 VECT_APPLYKER_IN_GEN_SORT>
1207applyKernel_in_gen_sort(const vector_dist_expression_op<exp1,exp2,op1> & va, vector_type & vd, NN & cl, Kernel & ker)
1208{
1210 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1211 typename kl_selector_impl<Kernel,NN>::ktype,
1213 VECT_APPLYKER_IN_GEN_SORT> exp_sum(va,
1215 ker,
1217
1218 return exp_sum;
1219}
1220
1222
1223/* \brief Apply kernel expression
1224 *
1225 * \param va vector expression one
1226 * \param vb vector expression two
1227 *
1228 * \return an object that encapsulate the expression
1229 *
1230 */
1231template<unsigned int prp, typename NN, typename Kernel, typename vector_type, typename vector_type_ker>
1233 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1234 typename kl_selector_impl<Kernel,NN>::ktype,
1236 VECT_APPLYKER_IN>
1237applyKernel_in(const vector_dist_expression<prp,vector_type_ker> & va, vector_type & vd, NN & cl, Kernel & ker)
1238{
1240 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1241 typename kl_selector_impl<Kernel,NN>::ktype,
1243 VECT_APPLYKER_IN> exp_sum(va,
1245 ker,
1247
1248 return exp_sum;
1249}
1250
1251/* \brief Apply kernel expression
1252 *
1253 * \param va vector expression one
1254 * \param vb vector expression two
1255 *
1256 * \return an object that encapsulate the expression
1257 *
1258 */
1259template<unsigned int prp, typename NN, typename Kernel, typename vector_type, typename vector_type_ker>
1261 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1262 typename kl_selector_impl<Kernel,NN>::ktype,
1264 VECT_APPLYKER_IN_SORT>
1265applyKernel_in_sort(const vector_dist_expression<prp,vector_type_ker> & va, vector_type & vd, NN & cl, Kernel & ker)
1266{
1268 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1269 typename kl_selector_impl<Kernel,NN>::ktype,
1271 VECT_APPLYKER_IN_SORT> exp_sum(va,
1273 ker,
1275
1276 return exp_sum;
1277}
1278
1279/* \brief Apply kernel expression
1280 *
1281 * \param va vector expression one
1282 * \param vb vector expression two
1283 *
1284 * \return an object that encapsulate the expression
1285 *
1286 */
1287template<unsigned int prp, typename NN, typename Kernel, typename vector_type, typename vector_type_ker>
1289 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1290 typename kl_selector_impl<Kernel,NN>::ktype,
1292 VECT_APPLYKER_IN_GEN>
1293applyKernel_in_gen(const vector_dist_expression<prp,vector_type_ker> & va, vector_type & vd, NN & cl, Kernel & ker)
1294{
1296 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1297 typename kl_selector_impl<Kernel,NN>::ktype,
1299 VECT_APPLYKER_IN_GEN> exp_sum(va,
1301 ker,
1303
1304 return exp_sum;
1305}
1306
1307/* \brief Apply kernel expression
1308 *
1309 * \param va vector expression one
1310 * \param vb vector expression two
1311 *
1312 * \return an object that encapsulate the expression
1313 *
1314 */
1315template<unsigned int prp, typename NN, typename Kernel, typename vector_type, typename vector_type_ker>
1317 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1318 typename kl_selector_impl<Kernel,NN>::ktype,
1320 VECT_APPLYKER_IN_GEN_SORT>
1321applyKernel_in_gen_sort(const vector_dist_expression<prp,vector_type_ker> & va, vector_type & vd, NN & cl, Kernel & ker)
1322{
1324 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1325 typename kl_selector_impl<Kernel,NN>::ktype,
1327 VECT_APPLYKER_IN_GEN_SORT> exp_sum(va,
1329 ker,
1331
1332 return exp_sum;
1333}
1334
1335/* \brief Apply kernel expression
1336 *
1337 * \param va vector expression one
1338 * \param vb vector expression two
1339 *
1340 * \return an object that encapsulate the expression
1341 *
1342 */
1343template<typename NN, typename Kernel, typename vector_type>
1344inline vector_dist_expression_op<void,
1345 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1346 typename kl_selector_impl<Kernel,NN>::ktype,
1348 VECT_APPLYKER_IN_SIM>
1349applyKernel_in_sim(vector_type & vd, NN & cl, Kernel & ker)
1350{
1352 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1353 typename kl_selector_impl<Kernel,NN>::ktype,
1355 VECT_APPLYKER_IN_SIM> exp_sum(cl_selector_impl<NN>::get(cl),
1356 ker,
1358
1359 return exp_sum;
1360}
1361
1362/* \brief Apply kernel expression
1363 *
1364 * \param va vector expression one
1365 * \param vb vector expression two
1366 *
1367 * \return an object that encapsulate the expression
1368 *
1369 */
1370template<typename NN, typename Kernel, typename vector_type>
1371inline vector_dist_expression_op<void,
1372 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1373 typename kl_selector_impl<Kernel,NN>::ktype,
1375 VECT_APPLYKER_IN_SIM_SORT>
1376applyKernel_in_sim_sort(vector_type & vd, NN & cl, Kernel & ker)
1377{
1379 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
1380 typename kl_selector_impl<Kernel,NN>::ktype,
1382 VECT_APPLYKER_IN_SIM_SORT> exp_sum(cl_selector_impl<NN>::get(cl),
1383 ker,
1385
1386 return exp_sum;
1387}
1388
1389#endif /* OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_HPP_ */
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
__device__ __host__ void zero()
Set to zero the point coordinate.
Definition Point.hpp:284
__device__ __host__ T & value(size_t i)
Return the reference to the value at coordinate i.
Definition Point.hpp:419
Grid key for a distributed grid.
__device__ __host__ size_t getKey() const
Get the key.
__device__ __host__ void setKey(size_t key)
set the key
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
vector_dist_expression_op(const exp1 &o1, const NN &cl, Kernel &ker, const vector_orig_nr &vd)
Constructor.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
add_const_reference< vector_orig >::type vd
The vector that contain the particles.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Get the return type of applying the kernel to a particle.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type that contain the particle positions.
boost::mpl::bool_< false > is_sort
indicate that is apply_kernel is not a sorted version
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type of the vector containing the set of particles.
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
boost::mpl::bool_< false > is_sort
indicate that is apply_kernel is not a sorted version
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
vector_dist_expression_op(const exp1 &o1, const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Return type of the expression.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
vector_dist_expression_op(const exp1 &o1, const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Return type of the expression.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
boost::mpl::bool_< true > is_sort
indicate that is apply_kernel is not a sorted version
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type of the vector containing the set of particles.
vector_dist_expression_op(const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
apply_kernel_rtype< decltype(std::declval< Kernel_nr >().value(Point< vector_orig_nr::dims, typenamevector_orig_nr::stype >(0.0), Point< vector_orig_nr::dims, typenamevector_orig_nr::stype >(0.0)))>::rtype rtype
Get the return type of the expression.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Return the vector containing the position of the particles.
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
boost::mpl::bool_< false > is_sort
indicate that is apply_kernel is not a sorted version
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Return the type of the kernel.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Return the type of the Cell-list.
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
vector_dist_expression_op(const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
apply_kernel_rtype< decltype(std::declval< Kernel_nr >().value(Point< vector_orig_nr::dims, typenamevector_orig_nr::stype >(0.0), Point< vector_orig_nr::dims, typenamevector_orig_nr::stype >(0.0)))>::rtype rtype
Get the return type of the expression.
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
boost::mpl::bool_< true > is_sort
indicate that is apply_kernel is not a sorted version
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Return the vector containing the position of the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Return the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Return the type of the kernel.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Get the return type of applying the kernel to a particle.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
add_const_reference< vector_orig >::type vd
The vector that contain the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type that contain the particle positions.
boost::mpl::bool_< true > is_sort
indicate that is apply_kernel is not a sorted version
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
vector_dist_expression_op(const exp1 &o1, NN &cl, Kernel &ker, const vector_orig_nr &vd)
Constructor.
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
Unknown operation specialization.
Main class that encapsulate a vector properties operand to be used for expressions construction.
Distributed vector.
Void structure.
Definition common.hpp:74
Apply the kernel to particle differently that is a number or is an expression.
__device__ static __host__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const exp &v_exp, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
Apply the kernel to particle differently that is a number or is an expression.
__device__ static __host__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
Apply the kernel to particle differently that is a number or is an expression.
__host__ static __device__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const exp &v_exp, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
exp rtype
indicate the return type of the expression exp
It give the return type of the expression if applicable.
exp::return_type rtype
indicate the return type of the expression exp
is_expression check if a type is simple a type or is just an encapsulation of an expression
Check this is a gpu or cpu type cell-list.
Definition util.hpp:87
__device__ static __host__ Point< dim, T > create()
return a point with all the coordinates set to zero
Meta-function to return a compatible zero-element.
__device__ static __host__ rtype create()
return 0