11 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
12 #define BOOST_MPL_LIMIT_VECTOR_SIZE 30
16 #define BOOST_TEST_DYN_LINK
18 #include "util/util_debug.hpp"
19 #include <boost/test/unit_test.hpp>
21 #include "DCPSE/DCPSE_op/DCPSE_op.hpp"
22 #include "DCPSE/DCPSE_op/DCPSE_Solver.hpp"
23 #include "Operators/Vector/vector_dist_operators.hpp"
24 #include "Vector/vector_dist_subset.hpp"
25 #include "Vector/vector_dist_multiphase_functions.hpp"
26 #include "DCPSE/DCPSE_op/EqnsStruct.hpp"
27 #include "DCPSE/DcpseInterpolation.hpp"
29 BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests)
30 BOOST_AUTO_TEST_CASE(dcpse_op_tests) {
31 size_t edgeSemiSize = 40;
32 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
34 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
36 spacing[0] = 2 * M_PI / (sz[0] - 1);
37 spacing[1] = 2 * M_PI / (sz[1] - 1);
39 double rCut = 3.9 * spacing[0];
40 BOOST_TEST_MESSAGE(
"Init vector_dist...");
41 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
43 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
48 BOOST_TEST_MESSAGE(
"Init domain...");
50 auto it = domain.getGridIterator(sz);
53 double minNormOne = 999;
57 mem_id k0 = key.get(0);
58 double x = k0 * spacing[0];
59 domain.getLastPos()[0] = x;
60 mem_id k1 = key.get(1);
61 double y = k1 * spacing[1];
62 domain.getLastPos()[1] = y;
64 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
65 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
69 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
72 domain.ghost_get<0>();
74 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
76 Derivative_x<decltype(verletList)> Dx(domain, verletList, 2, rCut);
77 Derivative_y<decltype(verletList)> Dy(domain, verletList, 2, rCut);
78 Gradient<decltype(verletList)> Grad(domain, verletList, 2, rCut);
79 Laplacian<decltype(verletList)>
Lap(domain, verletList, 2, rCut);
80 auto v = getV<1>(domain);
81 auto P = getV<0>(domain);
84 auto it2 = domain.getDomainIterator();
88 while (it2.isNext()) {
91 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
92 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
99 BOOST_REQUIRE(worst < 0.03);
103 BOOST_AUTO_TEST_CASE(dcpse_op_save_load) {
104 size_t edgeSemiSize = 40;
105 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
107 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
109 spacing[0] = 2 * M_PI / (sz[0] - 1);
110 spacing[1] = 2 * M_PI / (sz[1] - 1);
112 double rCut = 3.9 * spacing[0];
113 BOOST_TEST_MESSAGE(
"Init vector_dist...");
114 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
116 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
121 BOOST_TEST_MESSAGE(
"Init domain...");
123 auto it = domain.getGridIterator(sz);
126 double minNormOne = 999;
127 while (it.isNext()) {
130 mem_id k0 = key.get(0);
131 double x = k0 * spacing[0];
132 domain.getLastPos()[0] = x;
133 mem_id k1 = key.get(1);
134 double y = k1 * spacing[1];
135 domain.getLastPos()[1] = y;
137 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
138 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
142 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
145 domain.ghost_get<0>();
147 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
148 Derivative_x<decltype(verletList)> Dx(domain, verletList, 2, rCut);
149 Derivative_y<decltype(verletList)> Dy(domain, verletList, 2, rCut);
150 auto v = getV<1>(domain);
151 auto v2 = getV<3>(domain);
152 auto P = getV<0>(domain);
153 v2 = 2*Dx(
P) + Dy(
P);
154 Dx.save(domain,
"DX_test");
155 Dy.save(domain,
"DY_test");
156 Derivative_x<decltype(verletList)> DxLoaded(domain, verletList, 2, rCut, support_options::LOAD);
157 Derivative_y<decltype(verletList)> DyLoaded(domain, verletList, 2, rCut, support_options::LOAD);
158 DxLoaded.load(domain,
"DX_test");
159 DyLoaded.load(domain,
"DY_test");
160 v= 2*DxLoaded(
P)+DyLoaded(
P);
161 auto it2 = domain.getDomainIterator();
163 while (it2.isNext()) {
166 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
167 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
172 domain.deleteGhost();
174 BOOST_REQUIRE(worst < 0.03);
177 BOOST_AUTO_TEST_CASE(dcpse_op_save_load2) {
178 size_t edgeSemiSize = 40;
179 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
181 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
183 spacing[0] = 2 * M_PI / (sz[0] - 1);
184 spacing[1] = 2 * M_PI / (sz[1] - 1);
186 double rCut = 3.9 * spacing[0];
187 BOOST_TEST_MESSAGE(
"Init vector_dist...");
188 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
190 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
195 BOOST_TEST_MESSAGE(
"Init domain...");
197 auto it = domain.getGridIterator(sz);
200 double minNormOne = 999;
201 while (it.isNext()) {
204 mem_id k0 = key.get(0);
205 double x = k0 * spacing[0];
206 domain.getLastPos()[0] = x;
207 mem_id k1 = key.get(1);
208 double y = k1 * spacing[1];
209 domain.getLastPos()[1] = y;
211 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
212 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
216 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
219 domain.ghost_get<0>();
220 auto v = getV<1>(domain);
221 auto v2 = getV<3>(domain);
222 auto P = getV<0>(domain);
223 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
224 Derivative_x<decltype(verletList)> DxLoaded(domain, verletList, 2, rCut, support_options::LOAD);
225 Derivative_y<decltype(verletList)> DyLoaded(domain, verletList, 2, rCut, support_options::LOAD);
226 DxLoaded.load(domain,
"DX_test");
227 DyLoaded.load(domain,
"DY_test");
228 v= 2*DxLoaded(
P)+DyLoaded(
P);
229 auto it2 = domain.getDomainIterator();
231 while (it2.isNext()) {
234 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
235 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
240 domain.deleteGhost();
242 BOOST_REQUIRE(worst < 0.03);
245 BOOST_AUTO_TEST_CASE(dcpse_op_tests_fa) {
246 size_t edgeSemiSize = 40;
247 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
249 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
251 spacing[0] = 2 * M_PI / (sz[0] - 1);
252 spacing[1] = 2 * M_PI / (sz[1] - 1);
254 double rCut = 4.1 * spacing[0];
255 BOOST_TEST_MESSAGE(
"Init vector_dist...");
256 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
263 BOOST_TEST_MESSAGE(
"Init domain...");
265 auto it = domain.getGridIterator(sz);
268 double minNormOne = 999;
269 while (it.isNext()) {
272 mem_id k0 = key.get(0);
273 double x = k0 * spacing[0];
274 domain.getLastPos()[0] = x;
275 mem_id k1 = key.get(1);
276 double y = k1 * spacing[1];
277 domain.getLastPos()[1] = y;
279 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
280 domain.template getLastProp<2>() = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
284 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
287 domain.ghost_get<0>();
289 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC>(rCut);
291 auto v = getV<1>(domain);
292 auto P = getV<0>(domain);
295 auto it2 = domain.getDomainIterator();
297 while (it2.isNext()) {
299 if (fabs(domain.getProp<1>(p) - domain.getProp<0>(p)) > worst) {
300 worst = fabs(domain.getProp<1>(p) - domain.getProp<0>(p));
305 domain.deleteGhost();
307 BOOST_REQUIRE(worst < 0.03);
310 BOOST_AUTO_TEST_CASE(dcpse_op_tests_mfa) {
311 size_t edgeSemiSize = 40;
312 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
314 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
316 spacing[0] = 2 * M_PI / (sz[0] - 1);
317 spacing[1] = 2 * M_PI / (sz[1] - 1);
319 double rCut = 3.9 * spacing[0];
320 BOOST_TEST_MESSAGE(
"Init vector_dist...");
321 double sigma2 = spacing[0] * spacing[1] / ( 4);
322 std::normal_distribution<> gaussian{0, sigma2};
323 std::mt19937 rng{6666666};
325 typedef vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>>> vector_dist2;
327 vector_dist1 domain(0, box,bc,ghost);
328 vector_dist2 domain2(domain.getDecomposition(),0);
331 BOOST_TEST_MESSAGE(
"Init domain...");
333 auto it = domain.getGridIterator(sz);
336 double minNormOne = 999;
337 while (it.isNext()) {
341 mem_id k0 = key.get(0);
342 mem_id k1 = key.get(1);
343 double x = k0 * spacing[0];
344 double y = k1 * spacing[1];
345 domain.getLastPos()[0] = x;
346 domain.getLastPos()[1] = y;
347 if(x!=0 && y!=0 && x!=box.getHigh(0) && y!=box.getHigh(1)){
348 domain2.getLastPos()[0] = x+ gaussian(rng);
349 domain2.getLastPos()[1] = y+ gaussian(rng);
352 domain2.getLastPos()[0] = x;
353 domain2.getLastPos()[1] = y;
356 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
357 domain.template getLastProp<1>() = 0.0;
358 domain2.template getLastProp<0>() = sin(domain2.getLastPos()[0]) + sin(domain2.getLastPos()[1]);
362 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
366 domain.ghost_get<0>();
367 domain2.ghost_get<0>();
369 auto cellListDomain2 = domain2.getCellList(rCut);
370 auto verletList = createVerletTwoPhase(domain,domain2,cellListDomain2,rCut);
372 PPInterpolation<vector_dist2,vector_dist1,decltype(verletList)> Fx(domain2, domain, verletList, 2, rCut);
376 auto it2 = domain.getDomainIterator();
378 while (it2.isNext()) {
381 if (fabs(domain.getProp<1>(p) - domain.getProp<0>(p)) > worst) {
382 worst = fabs(domain.getProp<1>(p) - domain.getProp<0>(p));
387 domain.deleteGhost();
390 BOOST_REQUIRE(worst < 0.03);
394 BOOST_AUTO_TEST_CASE(dcpse_op_test_lap) {
395 size_t edgeSemiSize = 81;
396 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
398 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
400 spacing[0] = 2 * M_PI / (sz[0] - 1);
401 spacing[1] = 2 * M_PI / (sz[1] - 1);
403 double rCut = 3.9 * spacing[0];
404 BOOST_TEST_MESSAGE(
"Init vector_dist...");
405 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
412 BOOST_TEST_MESSAGE(
"Init domain...");
413 std::normal_distribution<> gaussian{0, sigma2};
415 auto it = domain.getGridIterator(sz);
418 double minNormOne = 999;
419 while (it.isNext()) {
422 mem_id k0 = key.get(0);
423 double x = k0 * spacing[0];
424 domain.getLastPos()[0] = x;
425 mem_id k1 = key.get(1);
426 double y = k1 * spacing[1];
427 domain.getLastPos()[1] = y;
429 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
431 domain.template getLastProp<1>() = - sin(domain.getLastPos()[0]) - sin(domain.getLastPos()[1]);
432 domain.template getLastProp<4>()[0] = -sin(domain.getLastPos()[0]);
433 domain.template getLastProp<4>()[1] = -sin(domain.getLastPos()[1]);
438 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
441 domain.ghost_get<0>();
443 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
444 Laplacian<decltype(verletList)>
Lap(domain, verletList, 2, rCut);
445 auto v = getV<1>(domain);
446 auto P = getV<0>(domain);
447 auto vv = getV<2>(domain);
448 auto errv = getV<3>(domain);
451 auto it2 = domain.getDomainIterator();
455 while (it2.isNext()) {
458 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
459 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
465 domain.deleteGhost();
466 BOOST_REQUIRE(worst < 0.3);
469 BOOST_AUTO_TEST_CASE(dcpse_op_div) {
472 size_t edgeSemiSize = 31;
473 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
475 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
477 spacing[0] = box.getHigh(0) / (sz[0] - 1);
478 spacing[1] = box.getHigh(1) / (sz[1] - 1);
479 double rCut = 3.1* spacing[0];
481 BOOST_TEST_MESSAGE(
"Init vector_dist...");
482 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
484 vector_dist<2, double, aggregate<double, VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,double,
double>> domain(
488 BOOST_TEST_MESSAGE(
"Init domain...");
491 std::mt19937 rng{6666666};
493 std::normal_distribution<> gaussian{0, sigma2};
495 auto it = domain.getGridIterator(sz);
498 double minNormOne = 999;
499 while (it.isNext()) {
502 mem_id k0 = key.get(0);
503 double x = k0 * spacing[0];
504 domain.getLastPos()[0] = x;
505 mem_id k1 = key.get(1);
506 double y = k1 * spacing[1];
507 domain.getLastPos()[1] = y;
509 domain.template getLastProp<1>()[0] = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
510 domain.template getLastProp<1>()[1] = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
514 domain.template getLastProp<0>()= cos(domain.getLastPos()[0]) - sin(domain.getLastPos()[1]);
526 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
529 domain.ghost_get<0>();
531 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
532 Divergence<decltype(verletList)> Div(domain, verletList, 2, rCut);
533 Derivative_x<decltype(verletList)> Dx(domain, verletList, 2, rCut);
534 Derivative_y<decltype(verletList)> Dy(domain, verletList, 2, rCut);
536 auto v = getV<1>(domain);
537 auto anasol = getV<0>(domain);
538 auto div = getV<5>(domain);
539 auto div2 = getV<6>(domain);
541 domain.ghost_get<1>();
543 div2=Dx(v[0])+Dy(v[1]);
544 auto it2 = domain.getDomainIterator();
549 while (it2.isNext()) {
551 if (fabs(domain.getProp<0>(p) - domain.getProp<5>(p)) > worst1) {
552 worst1 = fabs(domain.getProp<0>(p) - domain.getProp<5>(p));
554 if (fabs(domain.getProp<0>(p) - domain.getProp<6>(p)) > worst2) {
555 worst2 = fabs(domain.getProp<0>(p) - domain.getProp<6>(p));
560 domain.deleteGhost();
567 BOOST_REQUIRE(worst1 < 0.05);
568 BOOST_REQUIRE(worst2 < 0.05);
572 BOOST_AUTO_TEST_CASE(dcpse_op_vec) {
575 size_t edgeSemiSize = 160;
576 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
578 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
580 spacing[0] = box.getHigh(0) / (sz[0] - 1);
581 spacing[1] = box.getHigh(1) / (sz[1] - 1);
583 double rCut = 3.1 * spacing[0];
584 BOOST_TEST_MESSAGE(
"Init vector_dist...");
585 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
587 vector_dist<2, double, aggregate<double, VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,double,
double>> domain(
591 BOOST_TEST_MESSAGE(
"Init domain...");
594 std::mt19937 rng{6666666};
596 std::normal_distribution<> gaussian{0, sigma2};
598 auto it = domain.getGridIterator(sz);
601 double minNormOne = 999;
602 while (it.isNext()) {
605 mem_id k0 = key.get(0);
606 double x = k0 * spacing[0];
607 domain.getLastPos()[0] = x;
608 mem_id k1 = key.get(1);
609 double y = k1 * spacing[1];
610 domain.getLastPos()[1] = y;
612 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
613 domain.template getLastProp<1>()[0] = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
614 domain.template getLastProp<1>()[1] = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
617 domain.template getLastProp<2>()[0] = 0;
618 domain.template getLastProp<2>()[1] = 0;
619 domain.template getLastProp<4>()[0] =
620 cos(domain.getLastPos()[0]) * (sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1])) +
621 cos(domain.getLastPos()[1]) * (cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]));
622 domain.template getLastProp<4>()[1] =
623 -sin(domain.getLastPos()[0]) * (sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1])) -
624 sin(domain.getLastPos()[1]) * (cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]));
626 domain.template getLastProp<5>() = cos(domain.getLastPos()[0])*(sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]))+cos(domain.getLastPos()[1]) * (cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]));
632 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
635 domain.ghost_get<0>();
637 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
638 Advection<decltype(verletList)> Adv(domain, verletList, 2, rCut);
639 auto v = getV<1>(domain);
640 auto P = getV<0>(domain);
641 auto dv = getV<3>(domain);
642 auto dP = getV<6>(domain);
645 domain.ghost_get<1>();
647 auto it2 = domain.getDomainIterator();
651 while (it2.isNext()) {
654 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]) > worst1) {
655 worst1 = fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]);
664 BOOST_REQUIRE(worst1 < 0.03);
668 auto it3 = domain.getDomainIterator();
672 while (it3.isNext()) {
674 if (fabs(domain.getProp<6>(p) - domain.getProp<5>(p)) > worst2) {
675 worst2 = fabs(domain.getProp<6>(p) - domain.getProp<5>(p));
683 domain.deleteGhost();
685 BOOST_REQUIRE(worst2 < 0.03);
690 BOOST_AUTO_TEST_CASE(dcpse_slice) {
691 const size_t sz[2] = {31,31};
693 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
694 double spacing = box.getHigh(0) / (sz[0] - 1);
696 double rCut = 3.9 * spacing;
700 auto it = Particles.getGridIterator(sz);
701 while (it.isNext()) {
704 double x = key.get(0) * it.getSpacing(0);
705 Particles.getLastPos()[0] = x;
706 double y = key.get(1) * it.getSpacing(1);
707 Particles.getLastPos()[1] = y;
709 Particles.getLastProp<1>()[0] = sin(x+y);
710 Particles.getLastProp<1>()[1] = cos(x+y);
716 Particles.ghost_get<0,1>();
719 auto P = getV<0>(Particles);
720 auto V = getV<1>(Particles);
721 auto S = getV<2>(Particles);
722 auto Sig = getV<3>(Particles);
725 auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
726 Derivative_x<decltype(verletList)> Dx(Particles, verletList, 2, rCut);
729 S = V[0]*V[0] + V[1]*V[1];
731 Sig[0][1] = V[0]*V[0] + V[1]*V[1];
735 auto it2 = Particles.getDomainIterator();
743 if (fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]) >= err )
745 err = fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]);
748 if (fabs(Particles.getProp<2>(p) - 1.0) >= err )
750 err = fabs(Particles.getProp<2>(p) - 1.0);
753 if (fabs(Particles.getProp<3>(p)[0][1] - 1.0) >= err )
755 err = fabs(Particles.getProp<3>(p)[0][1] - 1.0);
758 if (fabs(Particles.getProp<3>(p)[1][0] - Particles.getProp<1>(p)[1]) >= err )
760 err = fabs(Particles.getProp<3>(p)[1][0] - Particles.getProp<1>(p)[1]);
763 if (fabs(Particles.getProp<3>(p)[2][2] - 5.0) >= err )
765 err = fabs(Particles.getProp<3>(p)[2][2] - 5.0);
773 BOOST_REQUIRE(err < 0.03);
777 BOOST_AUTO_TEST_CASE(dcpse_slice_3d) {
778 const size_t sz[3] = {17,17,17};
780 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC,NON_PERIODIC};
781 double spacing = box.getHigh(0) / (sz[0] - 1);
783 double rCut = 3.9 * spacing;
787 auto it = Particles.getGridIterator(sz);
788 while (it.isNext()) {
791 double x = key.get(0) * it.getSpacing(0);
792 Particles.getLastPos()[0] = x;
793 double y = key.get(1) * it.getSpacing(1);
794 Particles.getLastPos()[1] = y;
795 double z = key.get(2) * it.getSpacing(2);
796 Particles.getLastPos()[2] = z;
798 Particles.getLastProp<1>()[0] = sin(x+y);
799 Particles.getLastProp<1>()[1] = cos(x+y);
800 Particles.getLastProp<1>()[2] = 1.0;
806 Particles.ghost_get<0,1>();
809 auto P = getV<0>(Particles);
810 auto V = getV<1>(Particles);
811 auto S = getV<2>(Particles);
812 auto Sig = getV<3>(Particles);
814 auto verletList = Particles.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
815 Derivative_x<decltype(verletList)> Dx(Particles, verletList, 2, rCut);
818 S = V[0]*V[0] + V[1]*V[1]+V[2]*V[2];
820 Sig[0][1] = V[0]*V[0] + V[1]*V[1]+V[2]*V[2];
824 auto it2 = Particles.getDomainIterator();
837 if (fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]) >= err1 )
839 err1 = fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]);
842 if (fabs(Particles.getProp<2>(p) - 2.0) >= err2 )
844 err2 = fabs(Particles.getProp<2>(p) - 2.0);
847 if (fabs(Particles.getProp<3>(p)[0][1] - 2.0) >= err3 )
849 err3 = fabs(Particles.getProp<3>(p)[0][1] - 2.0);
853 if (fabs(Particles.getProp<3>(p)[0][1] - Particles.getProp<2>(p)) >= err4 )
855 err4 = fabs(Particles.getProp<3>(p)[0][1] - Particles.getProp<2>(p));
858 if (fabs(Particles.getProp<3>(p)[2][2] - 5.0) >= err5 )
860 err5 = fabs(Particles.getProp<3>(p)[2][2] - 5.0);
867 BOOST_REQUIRE(err1 < 0.08);
868 BOOST_REQUIRE(err2 < 0.03);
869 BOOST_REQUIRE(err3 < 0.03);
870 BOOST_REQUIRE(err4 < 0.03);
871 BOOST_REQUIRE(err5 < 0.03);
876 BOOST_AUTO_TEST_CASE(slicer_3index_tensor) {
880 constexpr
int VEC{0};
881 constexpr
int MAT{1};
882 constexpr
int ERR{2};
890 double grid_spacing{2.0/32.0};
893 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
896 part.setPropNames(propNames);
898 std::array<double,3> center{0,0,0};
899 std::array<double,3> coord;
901 if (v_cl.
rank() == 0) {
902 std::cout <<
"1. Creating particles\n";
905 const double pi{3.14159265358979323846};
906 const double golden_ang = pi*(3.0 - std::sqrt(5.0));
907 const double prefactor{std::sqrt(0.75/pi)};
908 double rad, theta, arg, thetaB, phi, phi_norm;
910 for (
int i = 0; i < n_part; ++i) {
912 coord[1] = 1.0 - 2.0*(i/double(n_part-1));
913 rad = std::sqrt(1.0 - (coord[1]-center[1])*(coord[1]-center[1]));
914 theta = golden_ang * i;
915 coord[0] = std::cos(theta) * rad;
916 coord[2] = std::sin(theta) * rad;
918 arg = (coord[0]-center[0]) * (coord[0]-center[0]) + (coord[1]-center[1]) * (coord[1]-center[1]);
919 thetaB = std::atan2(std::sqrt(arg),(coord[2]-center[2]));
920 phi = std::atan2((coord[1]-center[1]),(coord[0]-center[0]));
923 part.getLastPos()[0] = coord[0];
924 part.getLastPos()[1] = coord[1];
925 part.getLastPos()[2] = coord[2];
927 for (
int l = 0; l < 3; ++l)
928 for (
int k = 0; k < 3; ++k)
929 for (
int m = 0; m < 3; ++m) {
931 int linIdx = (l*3 + k)*3 + m;
933 part.getLastProp<VEC>()[linIdx] =
double(linIdx);
934 part.getLastProp<MAT>()[l][k][m] =
double(linIdx);
940 part.ghost_get<VEC>();
943 auto vec{getV<VEC>(part)};
944 auto mat{getV<MAT>(part)};
945 auto err{getV<ERR>(part)};
947 err[0] = mat[0][0][0] - vec[0];
948 err[1] = mat[0][0][1] - vec[1];
949 err[2] = mat[0][0][2] - vec[2];
950 err[3] = mat[0][1][0] - vec[3];
951 err[4] = mat[0][1][1] - vec[4];
952 err[5] = mat[0][1][2] - vec[5];
953 err[6] = mat[0][2][0] - vec[6];
954 err[7] = mat[0][2][1] - vec[7];
955 err[8] = mat[0][2][2] - vec[8];
956 err[9] = mat[1][0][0] - vec[9];
957 err[10] = mat[1][0][1] - vec[10];
958 err[11] = mat[1][0][2] - vec[11];
959 err[12] = mat[1][1][0] - vec[12];
960 err[13] = mat[1][1][1] - vec[13];
961 err[14] = mat[1][1][2] - vec[14];
962 err[15] = mat[1][2][0] - vec[15];
963 err[16] = mat[1][2][1] - vec[16];
964 err[17] = mat[1][2][2] - vec[17];
965 err[18] = mat[2][0][0] - vec[18];
966 err[19] = mat[2][0][1] - vec[19];
967 err[20] = mat[2][0][2] - vec[20];
968 err[21] = mat[2][1][0] - vec[21];
969 err[22] = mat[2][1][1] - vec[22];
970 err[23] = mat[2][1][2] - vec[23];
971 err[24] = mat[2][2][0] - vec[24];
972 err[25] = mat[2][2][1] - vec[25];
973 err[26] = mat[2][2][2] - vec[26];
975 auto pit{part.getDomainIterator()};
976 while (pit.isNext()) {
990 for (
int i = 0; i < 3*3*3; ++i) {
991 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[0],0, eps);
992 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[1],0, eps);
993 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[2],0, eps);
994 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[3],0, eps);
995 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[4],0, eps);
996 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[5],0, eps);
997 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[6],0, eps);
998 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[7],0, eps);
999 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[8],0, eps);
1000 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[9],0, eps);
1001 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[10],0, eps);
1002 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[11],0, eps);
1003 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[12],0, eps);
1004 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[13],0, eps);
1005 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[14],0, eps);
1006 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[15],0, eps);
1007 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[16],0, eps);
1008 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[17],0, eps);
1009 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[18],0, eps);
1010 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[19],0, eps);
1011 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[20],0, eps);
1012 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[21],0, eps);
1013 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[22],0, eps);
1014 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[23],0, eps);
1015 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[24],0, eps);
1016 BOOST_REQUIRE_CLOSE(part.getProp<ERR>(key)[25],0, eps);
1025 BOOST_AUTO_TEST_CASE(dcpse_op_convection) {
1026 size_t edgeSemiSize = 20;
1027 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
1029 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
1031 spacing[0] = 2.0/ (sz[0] - 1);
1032 spacing[1] = 2.0 / (sz[1] - 1);
1033 double rCut = 3.1 * spacing[0];
1036 BOOST_TEST_MESSAGE(
"Init vector_dist...");
1040 domain.setPropNames({
"Concentration",
"Concentration_temp",
"Temp",
"Velocity"});
1043 BOOST_TEST_MESSAGE(
"Init domain...");
1045 auto it = domain.getGridIterator(sz);
1046 while (it.isNext()) {
1048 auto key = it.get();
1049 mem_id k0 = key.get(0);
1050 double x = -1.0+k0 * spacing[0];
1051 domain.getLastPos()[0] = x;
1052 mem_id k1 = key.get(1);
1053 double y = -1.0+k1 * spacing[1];
1054 domain.getLastPos()[1] = y;
1056 if (x>-1 && y>-1 && x<1 && y<1)
1058 domain.template getLastProp<3>()[0] = (-y)*exp(-10*((x)*(x)+(y)*(y)));;
1059 domain.template getLastProp<3>()[1] = (x)*exp(-10*((x)*(x)+(y)*(y)));;
1062 domain.template getLastProp<3>()[0] = 0.0;
1063 domain.template getLastProp<3>()[1] = 0.0;
1065 if (x==0.0 && y>-0.5 && y<0.5)
1067 domain.template getLastProp<0>() = 1.0;
1071 domain.template getLastProp<0>() = 0.0;
1075 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
1078 domain.ghost_get<0>();
1080 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
1083 Derivative_xx<decltype(verletList)> Dxx(domain, verletList, 2, rCut);
1085 Derivative_yy<decltype(verletList)> Dyy(domain, verletList, 2, rCut);
1086 auto C = getV<0>(domain);
1087 auto V = getV<3>(domain);
1088 auto Cnew = getV<1>(domain);
1089 auto Pos = getV<POS_PROP>(domain);
1093 double t=0,tf=1,dt=1e-2;
1096 domain.write_frame(
"Convection",ctr);
1097 domain.ghost_get<0>();
1098 Cnew=C+dt*0.01*(Dxx(C)+Dyy(C));
1102 domain.ghost_get<0>();
1103 auto it2 = domain.getDomainIterator();
1104 while (it2.isNext()) {
1107 double x=xp[0],y=xp[1];
1108 if (x>-1 && y>-1 && x<1 && y<1)
1110 domain.template getProp<3>(p)[0] = (-y)*exp(-10*((x)*(x)+(y)*(y)));
1111 domain.template getProp<3>(p)[1] = (x)*exp(-10*((x)*(x)+(y)*(y)));;
1114 domain.template getProp<3>(p)[0] = 0.0;
1115 domain.template getProp<3>(p)[1] = 0.0;
1120 domain.updateVerlet(verletList,rCut);
1129 Dxx.deallocate(domain);
1130 Dyy.deallocate(domain);
1158 BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Laplacian second order on h (spacing)
Class to perform particle to particle interpolation using DC-PSE kernels.
Test structure used for several test.
This class implement the point shape in an N-dimensional space.
size_t rank()
Get the process unit id.
Implementation of VCluster class.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...