8 #ifndef OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_UNIT_TESTS_HPP_
9 #define OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_UNIT_TESTS_HPP_
11 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel(vector & vd, Kernel & ker, NN_type & NN)
14 auto it = vd.getDomainIterator();
20 auto it2 = vd.getDomainIterator();
28 float base1 = vd.template getProp<A>(p);
30 float prp_x = vd.template getProp<VC>(p) * vd.template getProp<VB>(p) + norm(vd.template getProp<VB>(p));
33 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
40 if (q == p.getKey()) {++Np;
continue;};
45 float prp_y = vd.template getProp<VC>(q) * vd.template getProp<VB>(q) + norm(vd.template getProp<VB>(q));
47 base2 += ker.value(xp,xq,prp_x,prp_y);
52 base2 += vd.template getProp<C>(p);
54 ret &= base1 == base2;
59 BOOST_REQUIRE_EQUAL(ret,
true);
64 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel_reduce(vector & vd, Kernel & ker, NN_type & NN)
67 auto it = vd.getDomainIterator();
73 auto it2 = vd.getDomainIterator();
81 float prp_x = vd.template getProp<VC>(p) * vd.template getProp<VB>(p) + norm(vd.template getProp<VB>(p));
84 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
91 if (q == p.getKey()) {++Np;
continue;};
96 float prp_y = vd.template getProp<VC>(q) * vd.template getProp<VB>(q) + norm(vd.template getProp<VB>(q));
98 ker_accu += ker.value(xp,xq,prp_x,prp_y);
108 auto it3 = vd.getDomainIterator();
113 base1 = vd.template getProp<A>(p);
114 base3 = vd.template getProp<C>(p) + base2;
116 ret &= base1 == base3;
121 BOOST_REQUIRE_EQUAL(ret,
true);
126 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel2(vector & vd, Kernel & ker, NN_type & NN)
129 auto it = vd.getDomainIterator();
135 auto it2 = vd.getDomainIterator();
145 Point<3,float> prp_x = 2.0 * vd.template getProp<VC>(p) + vd.template getProp<VB>(p);
148 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
155 if (q == p.getKey()) {++Np;
continue;};
160 Point<3,float> prp_y = 2.0 * vd.template getProp<VC>(q) + vd.template getProp<VB>(q);
162 base2 += ker.
value(xp,xq,prp_x,prp_y);
167 base2 += vd.template getProp<VC>(p);
169 ret &= base1 == base2;
174 BOOST_REQUIRE_EQUAL(ret,
true);
179 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel3(vector & vd, Kernel & ker, NN_type & NN)
182 auto it = vd.getDomainIterator();
188 auto it2 = vd.getDomainIterator();
201 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
208 if (q == p.getKey()) {++Np;
continue;};
215 base2 += ker.
value(xp,xq,prp_x,prp_y);
220 base2 += vd.template getProp<VC>(p);
222 ret &= base1 == base2;
227 BOOST_REQUIRE_EQUAL(ret,
true);
232 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel2_reduce(vector & vd, Kernel & ker, NN_type & NN)
235 auto it = vd.getDomainIterator();
241 auto it2 = vd.getDomainIterator();
249 Point<3,float> prp_x = 2.0f*vd.template getProp<VC>(p) + vd.template getProp<VB>(p);
252 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
259 if (q == p.getKey()) {++Np;
continue;};
263 Point<3,float> prp_y = 2.0f*vd.template getProp<VC>(q) + vd.template getProp<VB>(q);
265 ker_accu += ker.
value(xp,xq,prp_x,prp_y);
275 auto it3 = vd.getDomainIterator();
280 base1 = vd.template getProp<VA>(p);
281 base3 = vd.template getProp<VC>(p) + base2;
283 ret &= base1 == base3;
288 BOOST_REQUIRE_EQUAL(ret,
true);
293 template <
typename vector,
typename Kernel,
typename NN_type>
bool check_values_apply_kernel3_reduce(vector & vd, Kernel & ker, NN_type & NN,
const Point<2,float> & p)
296 auto it = vd.getDomainIterator();
300 auto it2 = vd.getDomainIterator();
310 auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(xp));
317 if (q == p.getKey()) {++Np;
continue;};
322 ker_accu += ker.
value(xp,xq);
332 BOOST_REQUIRE_EQUAL(p.
get(0),base2.
get(0));
333 BOOST_REQUIRE_EQUAL(p.
get(1),base2.
get(1));
338 BOOST_AUTO_TEST_CASE( vector_dist_operators_apply_kernel_test )
340 if (create_vcluster().getProcessingUnits() > 3)
346 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
351 vector_dist<3,float,aggregate<float,float,float,VectorS<3,float>,
VectorS<3,float>,VectorS<3,float>,
float>> vd(512,box,bc,ghost);
353 auto vA = getV<A>(vd);
354 auto vC = getV<C>(vd);
356 auto vVA = getV<VA>(vd);
357 auto vVB = getV<VB>(vd);
358 auto vVC = getV<VC>(vd);
364 vd.ghost_get<0,1,2,3,4,5,6>();
368 auto cl = vd.getCellList(0.05);
371 vA = applyKernel_in(vVC * vVB + norm(vVB),vd,cl,ker) + vC;
372 check_values_apply_kernel(vd,ker,cl);
374 vVA = applyKernel_in(2.0*vVC + vVB ,vd,cl,ker) + vVC;
375 check_values_apply_kernel2(vd,ker,cl);
377 vA = rsum(applyKernel_in(vVC * vVB + norm(vVB),vd,cl,ker),vd) + vC;
378 check_values_apply_kernel_reduce(vd,ker,cl);
380 vVA = rsum(applyKernel_in(2.0*vVC + vVB ,vd,cl,ker),vd) + vVC;
381 check_values_apply_kernel2_reduce(vd,ker,cl);
383 vA = applyKernel_in_gen(vVC * vVB + norm(vVB),vd,cl,ker) + vC;
384 check_values_apply_kernel(vd,ker,cl);
386 vVA = applyKernel_in_gen(2.0*vVC + vVB ,vd,cl,ker) + vVC;
387 check_values_apply_kernel2(vd,ker,cl);
389 vA = rsum(applyKernel_in_gen(vVC * vVB + norm(vVB),vd,cl,ker),vd) + vC;
390 check_values_apply_kernel_reduce(vd,ker,cl);
392 vVA = rsum(applyKernel_in_gen(2.0*vVC + vVB ,vd,cl,ker),vd) + vVC;
393 check_values_apply_kernel2_reduce(vd,ker,cl);
396 vVA = applyKernel_in_gen(vVC,vd,cl,ker) + vVC;
397 check_values_apply_kernel3(vd,ker,cl);
399 vVA = applyKernel_in (vVC,vd,cl,ker) + vVC;
400 check_values_apply_kernel3(vd,ker,cl);
404 check_values_apply_kernel3_reduce(vd,ker,cl,p);
This class implement the point shape in an N-dimensional space.
T & value(size_t i)
Return the reference to the value at coordinate i.
const T & get(size_t i) const
Get coordinate.