OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
FDScheme_unit_tests.cpp
1/*
2 * FDScheme_unit_tests.hpp
3 *
4 * Created on: Oct 5, 2015
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_FDSCHEME_UNIT_TESTS_HPP_
9#define OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_FDSCHEME_UNIT_TESTS_HPP_
10
11#define BOOST_TEST_DYN_LINK
12#include <boost/test/unit_test.hpp>
13
14#include "FiniteDifference/Derivative.hpp"
15#include "FiniteDifference/Laplacian.hpp"
16#include "Decomposition/CartDecomposition.hpp"
17#include "util/grid_dist_testing.hpp"
18#include "FiniteDifference/Average.hpp"
19#include "FiniteDifference/sum.hpp"
20#include "eq.hpp"
21
22constexpr unsigned int x = 0;
23constexpr unsigned int y = 1;
24constexpr unsigned int z = 2;
25constexpr unsigned int V = 0;
26
27struct sys_nn
28{
30 static const unsigned int dims = 2;
32 static const unsigned int nvar = 1;
33
34 static const unsigned int ord = EQS_FIELD;
35
37 static const bool boundary[];
38
40 typedef float stype;
41
44
46 typedef void testing;
47};
48
49const bool sys_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
50
51struct sys_pp
52{
54 static const unsigned int dims = 2;
56 static const unsigned int nvar = 1;
57 static const unsigned int ord = EQS_FIELD;
58
60 static const bool boundary[];
61
63 typedef float stype;
64
67
69 typedef void testing;
70};
71
72const bool sys_pp::boundary[] = {PERIODIC,PERIODIC};
73
75
76struct syss_nn
77{
79 static const unsigned int dims = 2;
81 static const unsigned int nvar = 1;
82
83 static const unsigned int ord = EQS_FIELD;
84
86 static const unsigned int grid_type = STAGGERED_GRID;
87
89 static const bool boundary[];
90
92 typedef float stype;
93
96
98 typedef void testing;
99};
100
101const bool syss_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
102
104{
106 static const unsigned int dims = 2;
108 static const unsigned int nvar = 1;
109 static const unsigned int ord = EQS_FIELD;
110
112 static const unsigned int grid_type = STAGGERED_GRID;
113
115 static const bool boundary[];
116
118 typedef float stype;
119
122
124 typedef void testing;
125};
126
127const bool syss_pp::boundary[] = {PERIODIC,PERIODIC};
128
129BOOST_AUTO_TEST_SUITE( fd_test )
130
131// Derivative central, composed central derivative,
132// and central bulk + one-sided non periodic
133
134BOOST_AUTO_TEST_CASE( der_central_non_periodic)
135{
137
138 // grid size
139 size_t sz[2]={16,16};
140
141 // grid_dist_testing
142 grid_dist_testing<2> g_map(sz);
143
144 // grid_sm
145 grid_sm<2,void> ginfo(sz);
146
147 // spacing
148 float spacing[2] = {0.5,0.3};
149
150 // Create several keys
154 grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
155
156 // filled colums
157 std::unordered_map<long int,float> cols_x;
158 std::unordered_map<long int,float> cols_y;
159
160 D<x,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,spacing,cols_x,1);
161 D<y,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,spacing,cols_y,1);
162
163 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
164 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
165
166 BOOST_REQUIRE_EQUAL(cols_x[17+1],1/spacing[0]/2.0);
167 BOOST_REQUIRE_EQUAL(cols_x[17-1],-1/spacing[0]/2.0);
168
169 BOOST_REQUIRE_EQUAL(cols_y[17+16],1/spacing[1]/2.0);
170 BOOST_REQUIRE_EQUAL(cols_y[17-16],-1/spacing[1]/2.0);
171
173
174 // filled colums
175
176 std::unordered_map<long int,float> cols_xx;
177 std::unordered_map<long int,float> cols_xy;
178 std::unordered_map<long int,float> cols_yx;
179 std::unordered_map<long int,float> cols_yy;
180
181 // Composed derivative
182
183 D<x,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_xx,1);
184 D<x,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_xy,1);
185 D<y,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_yx,1);
186 D<y,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_yy,1);
187
188 BOOST_REQUIRE_EQUAL(cols_xx.size(),3ul);
189 BOOST_REQUIRE_EQUAL(cols_xy.size(),4ul);
190 BOOST_REQUIRE_EQUAL(cols_yx.size(),4ul);
191 BOOST_REQUIRE_EQUAL(cols_yy.size(),3ul);
192
193 BOOST_REQUIRE_EQUAL(cols_xx[32],1/spacing[0]/spacing[0]/2.0/2.0);
194 BOOST_REQUIRE_EQUAL(cols_xx[34],-2/spacing[0]/spacing[0]/2.0/2.0);
195 BOOST_REQUIRE_EQUAL(cols_xx[36],1/spacing[0]/spacing[0]/2.0/2.0);
196
197 BOOST_REQUIRE_EQUAL(cols_xy[17],1/spacing[0]/spacing[1]/2.0/2.0);
198 BOOST_REQUIRE_EQUAL(cols_xy[19],-1/spacing[0]/spacing[1]/2.0/2.0);
199 BOOST_REQUIRE_EQUAL(cols_xy[49],-1/spacing[0]/spacing[1]/2.0/2.0);
200 BOOST_REQUIRE_EQUAL(cols_xy[51],1/spacing[0]/spacing[1]/2.0/2.0);
201
202 BOOST_REQUIRE_EQUAL(cols_yx[17],1/spacing[0]/spacing[1]/2.0/2.0);
203 BOOST_REQUIRE_EQUAL(cols_yx[19],-1/spacing[0]/spacing[1]/2.0/2.0);
204 BOOST_REQUIRE_EQUAL(cols_yx[49],-1/spacing[0]/spacing[1]/2.0/2.0);
205 BOOST_REQUIRE_EQUAL(cols_xy[51],1/spacing[0]/spacing[1]/2.0/2.0);
206
207 BOOST_REQUIRE_EQUAL(cols_yy[2],1/spacing[1]/spacing[1]/2.0/2.0);
208 BOOST_REQUIRE_EQUAL(cols_yy[34],-2/spacing[1]/spacing[1]/2.0/2.0);
209 BOOST_REQUIRE_EQUAL(cols_yy[66],1/spacing[1]/spacing[1]/2.0/2.0);
210
211 // Non periodic with one sided
212
213 cols_x.clear();
214 cols_y.clear();
215
216 D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key11,ginfo,spacing,cols_x,1);
217 D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key11,ginfo,spacing,cols_y,1);
218
219 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
220 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
221
222 BOOST_REQUIRE_EQUAL(cols_x[17+1],1/spacing[0]);
223 BOOST_REQUIRE_EQUAL(cols_x[17-1],-1/spacing[0]);
224
225 BOOST_REQUIRE_EQUAL(cols_y[17+16],1/spacing[1]);
226 BOOST_REQUIRE_EQUAL(cols_y[17-16],-1/spacing[1]);
227
228 // Border left
229
230 cols_x.clear();
231 cols_y.clear();
232
233 D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key00,ginfo,spacing,cols_x,1);
234 D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key00,ginfo,spacing,cols_y,1);
235
236 BOOST_REQUIRE_EQUAL(cols_x.size(),3ul);
237 BOOST_REQUIRE_EQUAL(cols_y.size(),3ul);
238
239 BOOST_REQUIRE_EQUAL(cols_x[0],-1.5/spacing[0]);
240 BOOST_REQUIRE_EQUAL(cols_x[1],2/spacing[0]);
241 BOOST_REQUIRE_EQUAL(cols_x[2],-0.5/spacing[0]);
242
243 BOOST_REQUIRE_CLOSE(cols_y[0],-1.5/spacing[1],0.001);
244 BOOST_REQUIRE_CLOSE(cols_y[16],2/spacing[1],0.001);
245 BOOST_REQUIRE_CLOSE(cols_y[32],-0.5/spacing[1],0.001);
246
247 // Border Top right
248
249 cols_x.clear();
250 cols_y.clear();
251
252 D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key1515,ginfo,spacing,cols_x,1);
253 D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(g_map,key1515,ginfo,spacing,cols_y,1);
254
255 BOOST_REQUIRE_EQUAL(cols_x.size(),3ul);
256 BOOST_REQUIRE_EQUAL(cols_y.size(),3ul);
257
258 BOOST_REQUIRE_EQUAL(cols_x[15*16+15],1.5/spacing[0]);
259 BOOST_REQUIRE_EQUAL(cols_x[15*16+14],-2/spacing[0]);
260 BOOST_REQUIRE_EQUAL(cols_x[15*16+13],0.5/spacing[0]);
261
262 BOOST_REQUIRE_CLOSE(cols_y[15*16+15],1.5/spacing[1],0.001);
263 BOOST_REQUIRE_CLOSE(cols_y[14*16+15],-2/spacing[1],0.001);
264 BOOST_REQUIRE_CLOSE(cols_y[13*16+15],0.5/spacing[1],0.001);
265}
266
267// Derivative forward and backward non periodic
268
269BOOST_AUTO_TEST_CASE( der_forward_backward_non_periodic )
270{
271 // grid size
272 size_t sz[2]={16,16};
273
274 // spacing
275 float spacing[2] = {0.5,0.3};
276
277 // grid_dist_testing
278 grid_dist_testing<2> g_map(sz);
279
280 // grid_sm
281 grid_sm<2,void> ginfo(sz);
282
283 // Create several keys
287 grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
288
289 // filled colums
290 std::unordered_map<long int,float> cols_x;
291 std::unordered_map<long int,float> cols_y;
292
293 D<x,Field<V,sys_nn>,sys_nn,FORWARD>::value(g_map,key11,ginfo,spacing,cols_x,1);
294 D<y,Field<V,sys_nn>,sys_nn,FORWARD>::value(g_map,key11,ginfo,spacing,cols_y,1);
295
296 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
297 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
298
299 BOOST_REQUIRE_EQUAL(cols_x[17+1],1/spacing[0]);
300 BOOST_REQUIRE_EQUAL(cols_x[17],-1/spacing[0]);
301
302 BOOST_REQUIRE_EQUAL(cols_y[17+16],1/spacing[1]);
303 BOOST_REQUIRE_EQUAL(cols_y[17],-1/spacing[1]);
304
305 cols_x.clear();
306 cols_y.clear();
307
308 D<x,Field<V,sys_nn>,sys_nn,BACKWARD>::value(g_map,key11,ginfo,spacing,cols_x,1);
309 D<y,Field<V,sys_nn>,sys_nn,BACKWARD>::value(g_map,key11,ginfo,spacing,cols_y,1);
310
311 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
312 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
313
314 BOOST_REQUIRE_EQUAL(cols_x[17],1/spacing[0]);
315 BOOST_REQUIRE_EQUAL(cols_x[17-1],-1/spacing[0]);
316
317 BOOST_REQUIRE_EQUAL(cols_y[17],1/spacing[1]);
318 BOOST_REQUIRE_EQUAL(cols_y[17-16],-1/spacing[1]);
319}
320
321// Average central non periodic
322
323BOOST_AUTO_TEST_CASE( avg_central_non_periodic)
324{
325 // grid size
326 size_t sz[2]={16,16};
327
328 // spacing
329 float spacing[2] = {0.5,0.3};
330
331 // grid_dist_testing
332 grid_dist_testing<2> g_map(sz);
333
334 // grid_sm
335 grid_sm<2,void> ginfo(sz);
336
337 // Create several keys
341 grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
342
343 // filled colums
344 std::unordered_map<long int,float> cols_x;
345 std::unordered_map<long int,float> cols_y;
346
347 Avg<x,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,spacing,cols_x,1);
348 Avg<y,Field<V,sys_nn>,sys_nn>::value(g_map,key11,ginfo,spacing,cols_y,1);
349
350 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
351 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
352
353 BOOST_REQUIRE_EQUAL(cols_x[17+1],0.5);
354 BOOST_REQUIRE_EQUAL(cols_x[17-1],0.5);
355
356 BOOST_REQUIRE_EQUAL(cols_y[17+16],0.5);
357 BOOST_REQUIRE_EQUAL(cols_y[17-16],0.5);
358
359 // filled colums
360
361 std::unordered_map<long int,float> cols_xx;
362 std::unordered_map<long int,float> cols_xy;
363 std::unordered_map<long int,float> cols_yx;
364 std::unordered_map<long int,float> cols_yy;
365
366 // Composed derivative
367
368 Avg<x,Avg<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_xx,1);
369 Avg<x,Avg<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_xy,1);
370 Avg<y,Avg<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_yx,1);
371 Avg<y,Avg<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(g_map,key22,ginfo,spacing,cols_yy,1);
372
373 BOOST_REQUIRE_EQUAL(cols_xx.size(),3ul);
374 BOOST_REQUIRE_EQUAL(cols_xy.size(),4ul);
375 BOOST_REQUIRE_EQUAL(cols_yx.size(),4ul);
376 BOOST_REQUIRE_EQUAL(cols_yy.size(),3ul);
377
378 BOOST_REQUIRE_EQUAL(cols_xx[32],1/2.0/2.0);
379 BOOST_REQUIRE_EQUAL(cols_xx[34],2/2.0/2.0);
380 BOOST_REQUIRE_EQUAL(cols_xx[36],1/2.0/2.0);
381
382 BOOST_REQUIRE_EQUAL(cols_xy[17],1/2.0/2.0);
383 BOOST_REQUIRE_EQUAL(cols_xy[19],1/2.0/2.0);
384 BOOST_REQUIRE_EQUAL(cols_xy[49],1/2.0/2.0);
385 BOOST_REQUIRE_EQUAL(cols_xy[51],1/2.0/2.0);
386
387 BOOST_REQUIRE_EQUAL(cols_yx[17],1/2.0/2.0);
388 BOOST_REQUIRE_EQUAL(cols_yx[19],1/2.0/2.0);
389 BOOST_REQUIRE_EQUAL(cols_yx[49],1/2.0/2.0);
390 BOOST_REQUIRE_EQUAL(cols_xy[51],1/2.0/2.0);
391
392 BOOST_REQUIRE_EQUAL(cols_yy[2],1/2.0/2.0);
393 BOOST_REQUIRE_EQUAL(cols_yy[34],2/2.0/2.0);
394 BOOST_REQUIRE_EQUAL(cols_yy[66],1/2.0/2.0);
395}
396
397
398
399BOOST_AUTO_TEST_CASE( der_central_staggered_non_periodic)
400{
401 // grid size
402 size_t sz[2]={16,16};
403
404 // spacing
405 float spacing[2] = {0.5,0.3};
406
407 // grid_sm
408 grid_sm<2,void> ginfo(sz);
409
410 // grid_dist_testing
411 grid_dist_testing<2> g_map(sz);
412
413 // Create several keys
416 grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
417
418 // filled colums
419 std::unordered_map<long int,float> cols_x;
420 std::unordered_map<long int,float> cols_y;
421
422 D<x,Field<V,syss_nn>,syss_pp>::value(g_map,key11,ginfo,spacing,cols_x,1);
423 D<y,Field<V,syss_nn>,syss_pp>::value(g_map,key11,ginfo,spacing,cols_y,1);
424
425 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
426 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
427
428 BOOST_REQUIRE_EQUAL(cols_x[17],1/spacing[0]);
429 BOOST_REQUIRE_EQUAL(cols_x[17-1],-1/spacing[0]);
430
431 BOOST_REQUIRE_EQUAL(cols_y[17],1/spacing[1]);
432 BOOST_REQUIRE_EQUAL(cols_y[17-16],-1/spacing[1]);
433
434 cols_x.clear();
435 cols_y.clear();
436}
437
438BOOST_AUTO_TEST_CASE( avg_central_staggered_non_periodic)
439{
440 // grid size
441 size_t sz[2]={16,16};
442
443 // spacing
444 float spacing[2] = {0.5,0.3};
445
446 // grid_sm
447 grid_sm<2,void> ginfo(sz);
448
449 // grid_dist_testing
450 grid_dist_testing<2> g_map(sz);
451
452 // Create several keys
455 grid_dist_key_dx<2> key1515(0,grid_key_dx<2>(15,15));
456
457 // filled colums
458 std::unordered_map<long int,float> cols_x;
459 std::unordered_map<long int,float> cols_y;
460
461 Avg<x,Field<V,syss_pp>,syss_pp>::value(g_map,key11,ginfo,spacing,cols_x,1);
462 Avg<y,Field<V,syss_pp>,syss_pp>::value(g_map,key11,ginfo,spacing,cols_y,1);
463
464 BOOST_REQUIRE_EQUAL(cols_x.size(),2ul);
465 BOOST_REQUIRE_EQUAL(cols_y.size(),2ul);
466
467 BOOST_REQUIRE_EQUAL(cols_x[17],1/2.0);
468 BOOST_REQUIRE_EQUAL(cols_x[17-1],1/2.0);
469
470 BOOST_REQUIRE_EQUAL(cols_y[17],1/2.0);
471 BOOST_REQUIRE_EQUAL(cols_y[17-16],1/2.0);
472
473 cols_x.clear();
474 cols_y.clear();
475}
476
478
479BOOST_AUTO_TEST_CASE( lap_periodic)
480{
482
483 // grid size
484 size_t sz[2]={16,16};
485
486 // grid_sm
487 grid_sm<2,void> ginfo(sz);
488
489 // spacing
490 float spacing[2] = {0.5,0.3};
491
492 // grid_dist_testing
493 grid_dist_testing<2> g_map(sz);
494
495 // Create several keys
498 grid_dist_key_dx<2> key1414(0,grid_key_dx<2>(14,14));
499
500 // filled colums
501 std::unordered_map<long int,float> cols;
502
503 Lap<Field<V,sys_pp>,sys_pp>::value(g_map,key11,ginfo,spacing,cols,1);
504
505 BOOST_REQUIRE_EQUAL(cols.size(),5ul);
506
507 BOOST_REQUIRE_EQUAL(cols[1],1/spacing[1]/spacing[1]);
508 BOOST_REQUIRE_EQUAL(cols[17-1],1/spacing[0]/spacing[0]);
509 BOOST_REQUIRE_EQUAL(cols[17+1],1/spacing[0]/spacing[0]);
510 BOOST_REQUIRE_EQUAL(cols[17+16],1/spacing[1]/spacing[1]);
511
512 BOOST_REQUIRE_EQUAL(cols[17],-2/spacing[0]/spacing[0] - 2/spacing[1]/spacing[1]);
513
515
516 cols.clear();
517
518 Lap<Field<V,sys_pp>,sys_pp>::value(g_map,key1414,ginfo,spacing,cols,1);
519
520 BOOST_REQUIRE_EQUAL(cols.size(),5ul);
521
522 BOOST_REQUIRE_EQUAL(cols[14*16+13],1.0/spacing[0]/spacing[0]);
523 BOOST_REQUIRE_EQUAL(cols[14*16+15],1.0/spacing[0]/spacing[0]);
524 BOOST_REQUIRE_CLOSE(cols[13*16+14],1.0/spacing[1]/spacing[1],0.001);
525 BOOST_REQUIRE_CLOSE(cols[15*16+14],1.0/spacing[1]/spacing[1],0.001);
526
527 BOOST_REQUIRE_EQUAL(cols[14*16+14],-2/spacing[0]/spacing[0] - 2/spacing[1]/spacing[1]);
528}
529
530// sum test
531
532
533BOOST_AUTO_TEST_CASE( sum_periodic)
534{
536
537 // grid size
538 size_t sz[2]={16,16};
539
540 // spacing
541 float spacing[2] = {0.5,0.3};
542
543 // grid_sm
544 grid_sm<2,void> ginfo(sz);
545
546 // grid_dist_testing
547 grid_dist_testing<2> g_map(sz);
548
549 // Create several keys
552 grid_dist_key_dx<2> key1414(0,grid_key_dx<2>(14,14));
553
554 // filled colums
555 std::unordered_map<long int,float> cols;
556
557 sum<Field<V,sys_pp>,Field<V,sys_pp>,sys_pp>::value(g_map,key11,ginfo,spacing,cols,1);
558
559 BOOST_REQUIRE_EQUAL(cols.size(),1ul);
560
561 BOOST_REQUIRE_EQUAL(cols[17],2);
562
564
565 cols.clear();
566
567 sum<Field<V,sys_pp>, Field<V,sys_pp> , Field<V,sys_pp> ,sys_pp>::value(g_map,key11,ginfo,spacing,cols,1);
568
569 BOOST_REQUIRE_EQUAL(cols.size(),1ul);
570
571 BOOST_REQUIRE_EQUAL(cols[17],3);
572
573 cols.clear();
574
576
577 sum<Field<V,sys_pp>, Field<V,sys_pp> , minus<Field<V,sys_pp>,sys_pp> ,sys_pp>::value(g_map,key11,ginfo,spacing,cols,1);
578
579 BOOST_REQUIRE_EQUAL(cols.size(),1ul);
580
581 BOOST_REQUIRE_EQUAL(cols[17],1ul);
582
584}
585
587
588BOOST_AUTO_TEST_CASE( fd_test_use_staggered_position)
589{
590 // grid size
591 size_t sz[2]={16,16};
592
593 // grid_sm
594 grid_sm<2,void> ginfo(sz);
595
596 // Create a derivative row Matrix
597 grid_key_dx<2> key00(0,0);
598 grid_key_dx<2> key11(1,1);
599 grid_key_dx<2> key22(2,2);
600 grid_key_dx<2> key1515(15,15);
601
602 comb<2> vx_c[] = {{(char)0,(char)-1}};
603 comb<2> vy_c[] = {{(char)-1,(char)0}};
604
605 grid_key_dx<2> key_ret_vx_x = D<x,Field<V,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
606 grid_key_dx<2> key_ret_vx_y = D<y,Field<V,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
607 grid_key_dx<2> key_ret_vy_x = D<x,Field<V,syss_nn>,syss_nn>::position(key00,ginfo,vy_c);
608 grid_key_dx<2> key_ret_vy_y = D<y,Field<V,syss_nn>,syss_nn>::position(key00,ginfo,vy_c);
609
610 BOOST_REQUIRE_EQUAL(key_ret_vx_x.get(0),0);
611 BOOST_REQUIRE_EQUAL(key_ret_vx_x.get(1),0);
612 BOOST_REQUIRE_EQUAL(key_ret_vx_y.get(0),-1);
613 BOOST_REQUIRE_EQUAL(key_ret_vx_y.get(1),-1);
614 BOOST_REQUIRE_EQUAL(key_ret_vy_y.get(0),0);
615 BOOST_REQUIRE_EQUAL(key_ret_vy_y.get(1),0);
616 BOOST_REQUIRE_EQUAL(key_ret_vy_x.get(0),-1);
617 BOOST_REQUIRE_EQUAL(key_ret_vy_x.get(1),-1);
618
619 // Composed derivative
620
621 grid_key_dx<2> key_ret_xx = D<x,D<x,Field<V,syss_nn>,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
622 grid_key_dx<2> key_ret_xy = D<x,D<y,Field<V,syss_nn>,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
623 grid_key_dx<2> key_ret_yx = D<y,D<x,Field<V,syss_nn>,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
624 grid_key_dx<2> key_ret_yy = D<y,D<y,Field<V,syss_nn>,syss_nn>,syss_nn>::position(key00,ginfo,vx_c);
625
626 BOOST_REQUIRE_EQUAL(key_ret_xx.get(0),-1);
627 BOOST_REQUIRE_EQUAL(key_ret_xx.get(1),0);
628
629 BOOST_REQUIRE_EQUAL(key_ret_xy.get(0),0);
630 BOOST_REQUIRE_EQUAL(key_ret_xy.get(1),-1);
631
632 BOOST_REQUIRE_EQUAL(key_ret_yx.get(0),0);
633 BOOST_REQUIRE_EQUAL(key_ret_yx.get(1),-1);
634
635 BOOST_REQUIRE_EQUAL(key_ret_yy.get(0),-1);
636 BOOST_REQUIRE_EQUAL(key_ret_yy.get(1),0);
637
639
640 key_ret_vx_x = D<x,Field<V,syss_nn>,syss_nn,CENTRAL_B_ONE_SIDE>::position(key00,ginfo,vx_c);
641 key_ret_vx_y = D<y,Field<V,syss_nn>,syss_nn,CENTRAL_B_ONE_SIDE>::position(key00,ginfo,vx_c);
642 key_ret_vy_x = D<x,Field<V,syss_nn>,syss_nn,CENTRAL_B_ONE_SIDE>::position(key00,ginfo,vy_c);
643 key_ret_vy_y = D<y,Field<V,syss_nn>,syss_nn,CENTRAL_B_ONE_SIDE>::position(key00,ginfo,vy_c);
644
645 BOOST_REQUIRE_EQUAL(key_ret_vx_x.get(0),-1);
646 BOOST_REQUIRE_EQUAL(key_ret_vx_x.get(1),0);
647 BOOST_REQUIRE_EQUAL(key_ret_vx_y.get(0),-1);
648 BOOST_REQUIRE_EQUAL(key_ret_vx_y.get(1),0);
649 BOOST_REQUIRE_EQUAL(key_ret_vy_y.get(0),0);
650 BOOST_REQUIRE_EQUAL(key_ret_vy_y.get(1),-1);
651 BOOST_REQUIRE_EQUAL(key_ret_vy_x.get(0),0);
652 BOOST_REQUIRE_EQUAL(key_ret_vy_x.get(1),-1);
653
654 // Border left*/
655}
656
657BOOST_AUTO_TEST_SUITE_END()
658
659
660#endif /* OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_FDSCHEME_UNIT_TESTS_HPP_ */
Average.
Definition Average.hpp:27
This class decompose a space into sub-sub-domains and distribute them across processors.
Derivative second order on h (spacing)
Definition eq.hpp:83
Laplacian second order on h (spacing)
Definition Laplacian.hpp:23
This is a distributed grid.
Grid key for a distributed grid.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
It ancapsulate the minus operation.
Definition sum.hpp:142
It model an expression expr1 + ... exprn.
Definition sum.hpp:93
static const unsigned int nvar
number of degree of freedoms
void testing
specify that we are on testing
static const unsigned int dims
dimensionaly of the equation (2D problem 3D problem ...)
grid_dist_id< dims, stype, aggregate< float >, CartDecomposition< 2, stype > > b_grid
Base grid.
static const bool boundary[]
boundary at X and Y
float stype
type of space float, double, ...
static const unsigned int nvar
number of degree of freedom in the system
grid_dist_id< dims, stype, aggregate< float >, CartDecomposition< 2, stype > > b_grid
Base grid.
static const bool boundary[]
boundary at X and Y
void testing
Indicate we are on testing.
float stype
type of space float, double, ...
static const unsigned int dims
dimensionaly of the equation (2D problem 3D problem ...)
grid_dist_id< dims, stype, aggregate< float >, CartDecomposition< 2, stype > > b_grid
Base grid.
float stype
type of space float, double, ...
void testing
Indicate we are on testing.
static const unsigned int nvar
Degree of freedom in the system.
static const bool boundary[]
boundary at X and Y
static const unsigned int dims
dimensionaly of the equation (2D problem 3D problem ...)
grid_dist_id< dims, stype, aggregate< float >, CartDecomposition< 2, stype > > b_grid
Base grid.
static const unsigned int dims
dimensionaly of the equation (2D problem 3D problem ...)
static const unsigned int nvar
number of fields in the system
static const bool boundary[]
boundary at X and Y
float stype
type of space float, double, ...
void testing
Indicate we are on testing.