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_op.hpp"
22#include "../DCPSE_Solver.hpp"
23#include "Operators/Vector/vector_dist_operators.hpp"
24#include "Vector/vector_dist_subset.hpp"
25#include "../EqnsStruct.hpp"
26#include "DCPSE/DcpseInterpolation.hpp"
28BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests)
29BOOST_AUTO_TEST_CASE(dcpse_op_tests) {
30 size_t edgeSemiSize = 40;
31 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
33 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
35 spacing[0] = 2 * M_PI / (sz[0] - 1);
36 spacing[1] = 2 * M_PI / (sz[1] - 1);
38 double rCut = 3.9 * spacing[0];
39 BOOST_TEST_MESSAGE(
"Init vector_dist...");
40 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
42 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
47 BOOST_TEST_MESSAGE(
"Init domain...");
49 auto it = domain.getGridIterator(sz);
52 double minNormOne = 999;
56 mem_id k0 = key.get(0);
57 double x = k0 * spacing[0];
58 domain.getLastPos()[0] = x;
59 mem_id k1 = key.get(1);
60 double y = k1 * spacing[1];
61 domain.getLastPos()[1] = y;
63 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
64 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
68 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
71 domain.ghost_get<0>();
72 Derivative_x Dx(domain, 2, rCut);
73 Derivative_y Dy(domain, 2, rCut);
74 Gradient Grad(domain, 2, rCut);
75 Laplacian
Lap(domain, 2, rCut);
76 auto v = getV<1>(domain);
77 auto P = getV<0>(domain);
80 auto it2 = domain.getDomainIterator();
84 while (it2.isNext()) {
87 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
88 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
95 BOOST_REQUIRE(worst < 0.03);
99 BOOST_AUTO_TEST_CASE(dcpse_op_save_load) {
100 size_t edgeSemiSize = 40;
101 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
103 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
105 spacing[0] = 2 * M_PI / (sz[0] - 1);
106 spacing[1] = 2 * M_PI / (sz[1] - 1);
108 double rCut = 3.9 * spacing[0];
109 BOOST_TEST_MESSAGE(
"Init vector_dist...");
110 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
112 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
117 BOOST_TEST_MESSAGE(
"Init domain...");
119 auto it = domain.getGridIterator(sz);
122 double minNormOne = 999;
123 while (it.isNext()) {
126 mem_id k0 = key.get(0);
127 double x = k0 * spacing[0];
128 domain.getLastPos()[0] = x;
129 mem_id k1 = key.get(1);
130 double y = k1 * spacing[1];
131 domain.getLastPos()[1] = y;
133 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
134 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
138 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
141 domain.ghost_get<0>();
142 Derivative_x Dx(domain, 2, rCut);
143 Derivative_y Dy(domain, 2, rCut);
144 auto v = getV<1>(domain);
145 auto v2 = getV<3>(domain);
146 auto P = getV<0>(domain);
147 v2 = 2*Dx(
P) + Dy(
P);
148 Dx.save(domain,
"DX_test");
149 Dy.save(domain,
"DY_test");
150 Derivative_x DxLoaded(domain, 2, rCut,1,support_options::LOAD);
151 Derivative_y DyLoaded(domain, 2, rCut,1,support_options::LOAD);
152 DxLoaded.load(domain,
"DX_test");
153 DyLoaded.load(domain,
"DY_test");
154 v= 2*DxLoaded(
P)+DyLoaded(
P);
155 auto it2 = domain.getDomainIterator();
157 while (it2.isNext()) {
160 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
161 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
166 domain.deleteGhost();
168 BOOST_REQUIRE(worst < 0.03);
171 BOOST_AUTO_TEST_CASE(dcpse_op_save_load2) {
172 size_t edgeSemiSize = 40;
173 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
175 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
177 spacing[0] = 2 * M_PI / (sz[0] - 1);
178 spacing[1] = 2 * M_PI / (sz[1] - 1);
180 double rCut = 3.9 * spacing[0];
181 BOOST_TEST_MESSAGE(
"Init vector_dist...");
182 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
184 vector_dist<2, double, aggregate<double, double, double, VectorS<2, double>,
VectorS<2, double>>> domain(0, box,
189 BOOST_TEST_MESSAGE(
"Init domain...");
191 auto it = domain.getGridIterator(sz);
194 double minNormOne = 999;
195 while (it.isNext()) {
198 mem_id k0 = key.get(0);
199 double x = k0 * spacing[0];
200 domain.getLastPos()[0] = x;
201 mem_id k1 = key.get(1);
202 double y = k1 * spacing[1];
203 domain.getLastPos()[1] = y;
205 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
206 domain.template getLastProp<2>() = 2*cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
210 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
213 domain.ghost_get<0>();
214 auto v = getV<1>(domain);
215 auto v2 = getV<3>(domain);
216 auto P = getV<0>(domain);
217 Derivative_x DxLoaded(domain, 2, rCut,1,support_options::LOAD);
218 Derivative_y DyLoaded(domain, 2, rCut,1,support_options::LOAD);
219 DxLoaded.load(domain,
"DX_test");
220 DyLoaded.load(domain,
"DY_test");
221 v= 2*DxLoaded(
P)+DyLoaded(
P);
222 auto it2 = domain.getDomainIterator();
224 while (it2.isNext()) {
227 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
228 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
233 domain.deleteGhost();
235 BOOST_REQUIRE(worst < 0.03);
238 BOOST_AUTO_TEST_CASE(dcpse_op_tests_fa) {
239 size_t edgeSemiSize = 40;
240 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
242 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
244 spacing[0] = 2 * M_PI / (sz[0] - 1);
245 spacing[1] = 2 * M_PI / (sz[1] - 1);
247 double rCut = 3.9 * spacing[0];
248 BOOST_TEST_MESSAGE(
"Init vector_dist...");
249 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
256 BOOST_TEST_MESSAGE(
"Init domain...");
258 auto it = domain.getGridIterator(sz);
261 double minNormOne = 999;
262 while (it.isNext()) {
265 mem_id k0 = key.get(0);
266 double x = k0 * spacing[0];
267 domain.getLastPos()[0] = x;
268 mem_id k1 = key.get(1);
269 double y = k1 * spacing[1];
270 domain.getLastPos()[1] = y;
272 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
273 domain.template getLastProp<2>() = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
277 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
280 domain.ghost_get<0>();
283 auto v = getV<1>(domain);
284 auto P = getV<0>(domain);
287 auto it2 = domain.getDomainIterator();
289 while (it2.isNext()) {
291 if (fabs(domain.getProp<1>(p) - domain.getProp<0>(p)) > worst) {
292 worst = fabs(domain.getProp<1>(p) - domain.getProp<0>(p));
297 domain.deleteGhost();
299 BOOST_REQUIRE(worst < 0.03);
302 BOOST_AUTO_TEST_CASE(dcpse_op_tests_mfa) {
303 size_t edgeSemiSize = 40;
304 const size_t sz[2] = {2 * edgeSemiSize, 2 * edgeSemiSize};
306 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
308 spacing[0] = 2 * M_PI / (sz[0] - 1);
309 spacing[1] = 2 * M_PI / (sz[1] - 1);
311 double rCut = 3.9 * spacing[0];
312 BOOST_TEST_MESSAGE(
"Init vector_dist...");
313 double sigma2 = spacing[0] * spacing[1] / ( 4);
314 std::normal_distribution<> gaussian{0, sigma2};
315 std::mt19937 rng{6666666};
322 BOOST_TEST_MESSAGE(
"Init domain...");
324 auto it = domain.getGridIterator(sz);
327 double minNormOne = 999;
328 while (it.isNext()) {
332 mem_id k0 = key.get(0);
333 mem_id k1 = key.get(1);
334 double x = k0 * spacing[0];
335 double y = k1 * spacing[1];
336 domain.getLastPos()[0] = x;
337 domain.getLastPos()[1] = y;
338 if(x!=0 && y!=0 && x!=box.getHigh(0) && y!=box.getHigh(1)){
339 domain2.getLastPos()[0] = x+ gaussian(rng);
340 domain2.getLastPos()[1] = y+ gaussian(rng);
343 domain2.getLastPos()[0] = x;
344 domain2.getLastPos()[1] = y;
347 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
348 domain.template getLastProp<1>() = 0.0;
349 domain2.template getLastProp<0>() = sin(domain2.getLastPos()[0]) + sin(domain2.getLastPos()[1]);
353 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
357 domain.ghost_get<0>();
358 domain2.ghost_get<0>();
364 auto it2 = domain.getDomainIterator();
366 while (it2.isNext()) {
369 if (fabs(domain.getProp<1>(p) - domain.getProp<0>(p)) > worst) {
370 worst = fabs(domain.getProp<1>(p) - domain.getProp<0>(p));
375 domain.deleteGhost();
378 BOOST_REQUIRE(worst < 0.03);
382 BOOST_AUTO_TEST_CASE(dcpse_op_test_lap) {
383 size_t edgeSemiSize = 81;
384 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
386 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
388 spacing[0] = 2 * M_PI / (sz[0] - 1);
389 spacing[1] = 2 * M_PI / (sz[1] - 1);
391 double rCut = 3.9 * spacing[0];
392 BOOST_TEST_MESSAGE(
"Init vector_dist...");
393 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
400 BOOST_TEST_MESSAGE(
"Init domain...");
401 std::normal_distribution<> gaussian{0, sigma2};
403 auto it = domain.getGridIterator(sz);
406 double minNormOne = 999;
407 while (it.isNext()) {
410 mem_id k0 = key.get(0);
411 double x = k0 * spacing[0];
412 domain.getLastPos()[0] = x;
413 mem_id k1 = key.get(1);
414 double y = k1 * spacing[1];
415 domain.getLastPos()[1] = y;
417 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
419 domain.template getLastProp<1>() = - sin(domain.getLastPos()[0]) - sin(domain.getLastPos()[1]);
420 domain.template getLastProp<4>()[0] = -sin(domain.getLastPos()[0]);
421 domain.template getLastProp<4>()[1] = -sin(domain.getLastPos()[1]);
426 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
429 domain.ghost_get<0>();
431 Laplacian
Lap(domain, 2, rCut);
432 auto v = getV<1>(domain);
433 auto P = getV<0>(domain);
434 auto vv = getV<2>(domain);
435 auto errv = getV<3>(domain);
438 auto it2 = domain.getDomainIterator();
442 while (it2.isNext()) {
445 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) > worst) {
446 worst = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
452 domain.deleteGhost();
453 BOOST_REQUIRE(worst < 0.3);
456 BOOST_AUTO_TEST_CASE(dcpse_op_div) {
459 size_t edgeSemiSize = 31;
460 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
462 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
464 spacing[0] = box.getHigh(0) / (sz[0] - 1);
465 spacing[1] = box.getHigh(1) / (sz[1] - 1);
466 double rCut = 3.1* spacing[0];
468 BOOST_TEST_MESSAGE(
"Init vector_dist...");
469 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
471 vector_dist<2, double, aggregate<double, VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,double,
double>> domain(
475 BOOST_TEST_MESSAGE(
"Init domain...");
478 std::mt19937 rng{6666666};
480 std::normal_distribution<> gaussian{0, sigma2};
482 auto it = domain.getGridIterator(sz);
485 double minNormOne = 999;
486 while (it.isNext()) {
489 mem_id k0 = key.get(0);
490 double x = k0 * spacing[0];
491 domain.getLastPos()[0] = x;
492 mem_id k1 = key.get(1);
493 double y = k1 * spacing[1];
494 domain.getLastPos()[1] = y;
496 domain.template getLastProp<1>()[0] = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
497 domain.template getLastProp<1>()[1] = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
501 domain.template getLastProp<0>()= cos(domain.getLastPos()[0]) - sin(domain.getLastPos()[1]);
513 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
516 domain.ghost_get<0>();
518 Divergence Div(domain, 2, rCut);
519 Derivative_x Dx(domain, 2, rCut);
520 Derivative_y Dy(domain, 2, rCut);
522 auto v = getV<1>(domain);
523 auto anasol = getV<0>(domain);
524 auto div = getV<5>(domain);
525 auto div2 = getV<6>(domain);
527 domain.ghost_get<1>();
529 div2=Dx(v[0])+Dy(v[1]);
530 auto it2 = domain.getDomainIterator();
535 while (it2.isNext()) {
537 if (fabs(domain.getProp<0>(p) - domain.getProp<5>(p)) > worst1) {
538 worst1 = fabs(domain.getProp<0>(p) - domain.getProp<5>(p));
540 if (fabs(domain.getProp<0>(p) - domain.getProp<6>(p)) > worst2) {
541 worst2 = fabs(domain.getProp<0>(p) - domain.getProp<6>(p));
546 domain.deleteGhost();
553 BOOST_REQUIRE(worst1 < 0.05);
554 BOOST_REQUIRE(worst2 < 0.05);
558 BOOST_AUTO_TEST_CASE(dcpse_op_vec) {
561 size_t edgeSemiSize = 160;
562 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
564 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
566 spacing[0] = box.getHigh(0) / (sz[0] - 1);
567 spacing[1] = box.getHigh(1) / (sz[1] - 1);
569 double rCut = 3.1 * spacing[0];
570 BOOST_TEST_MESSAGE(
"Init vector_dist...");
571 double sigma2 = spacing[0] * spacing[1] / (2 * 4);
573 vector_dist<2, double, aggregate<double, VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,double,
double>> domain(
577 BOOST_TEST_MESSAGE(
"Init domain...");
580 std::mt19937 rng{6666666};
582 std::normal_distribution<> gaussian{0, sigma2};
584 auto it = domain.getGridIterator(sz);
587 double minNormOne = 999;
588 while (it.isNext()) {
591 mem_id k0 = key.get(0);
592 double x = k0 * spacing[0];
593 domain.getLastPos()[0] = x;
594 mem_id k1 = key.get(1);
595 double y = k1 * spacing[1];
596 domain.getLastPos()[1] = y;
598 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
599 domain.template getLastProp<1>()[0] = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]);
600 domain.template getLastProp<1>()[1] = cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]);
603 domain.template getLastProp<2>()[0] = 0;
604 domain.template getLastProp<2>()[1] = 0;
605 domain.template getLastProp<4>()[0] =
606 cos(domain.getLastPos()[0]) * (sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1])) +
607 cos(domain.getLastPos()[1]) * (cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]));
608 domain.template getLastProp<4>()[1] =
609 -sin(domain.getLastPos()[0]) * (sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1])) -
610 sin(domain.getLastPos()[1]) * (cos(domain.getLastPos()[0]) + cos(domain.getLastPos()[1]));
612 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]));
618 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
621 domain.ghost_get<0>();
623 Advection Adv(domain, 2, rCut);
624 auto v = getV<1>(domain);
625 auto P = getV<0>(domain);
626 auto dv = getV<3>(domain);
627 auto dP = getV<6>(domain);
630 domain.ghost_get<1>();
632 auto it2 = domain.getDomainIterator();
636 while (it2.isNext()) {
639 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]) > worst1) {
640 worst1 = fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]);
649 BOOST_REQUIRE(worst1 < 0.03);
653 auto it3 = domain.getDomainIterator();
657 while (it3.isNext()) {
659 if (fabs(domain.getProp<6>(p) - domain.getProp<5>(p)) > worst2) {
660 worst2 = fabs(domain.getProp<6>(p) - domain.getProp<5>(p));
668 domain.deleteGhost();
670 BOOST_REQUIRE(worst2 < 0.03);
675 BOOST_AUTO_TEST_CASE(dcpse_slice) {
676 const size_t sz[2] = {31,31};
678 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
679 double spacing = box.getHigh(0) / (sz[0] - 1);
681 double rCut = 3.9 * spacing;
685 auto it = Particles.getGridIterator(sz);
686 while (it.isNext()) {
689 double x = key.get(0) * it.getSpacing(0);
690 Particles.getLastPos()[0] = x;
691 double y = key.get(1) * it.getSpacing(1);
692 Particles.getLastPos()[1] = y;
694 Particles.getLastProp<1>()[0] = sin(x+y);
695 Particles.getLastProp<1>()[1] = cos(x+y);
701 Particles.ghost_get<0,1>();
704 auto P = getV<0>(Particles);
705 auto V = getV<1>(Particles);
706 auto S = getV<2>(Particles);
707 auto Sig = getV<3>(Particles);
710 Derivative_x Dx(Particles, 2, rCut,2);
713 S = V[0]*V[0] + V[1]*V[1];
715 Sig[0][1] = V[0]*V[0] + V[1]*V[1];
719 auto it2 = Particles.getDomainIterator();
727 if (fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]) >= err )
729 err = fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]);
732 if (fabs(Particles.getProp<2>(p) - 1.0) >= err )
734 err = fabs(Particles.getProp<2>(p) - 1.0);
737 if (fabs(Particles.getProp<3>(p)[0][1] - 1.0) >= err )
739 err = fabs(Particles.getProp<3>(p)[0][1] - 1.0);
742 if (fabs(Particles.getProp<3>(p)[1][0] - Particles.getProp<1>(p)[1]) >= err )
744 err = fabs(Particles.getProp<3>(p)[1][0] - Particles.getProp<1>(p)[1]);
747 if (fabs(Particles.getProp<3>(p)[2][2] - 5.0) >= err )
749 err = fabs(Particles.getProp<3>(p)[2][2] - 5.0);
757 BOOST_REQUIRE(err < 0.03);
761 BOOST_AUTO_TEST_CASE(dcpse_slice_3d) {
762 const size_t sz[3] = {17,17,17};
764 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC,NON_PERIODIC};
765 double spacing = box.getHigh(0) / (sz[0] - 1);
767 double rCut = 3.9 * spacing;
771 auto it = Particles.getGridIterator(sz);
772 while (it.isNext()) {
775 double x = key.get(0) * it.getSpacing(0);
776 Particles.getLastPos()[0] = x;
777 double y = key.get(1) * it.getSpacing(1);
778 Particles.getLastPos()[1] = y;
779 double z = key.get(2) * it.getSpacing(2);
780 Particles.getLastPos()[2] = z;
782 Particles.getLastProp<1>()[0] = sin(x+y);
783 Particles.getLastProp<1>()[1] = cos(x+y);
784 Particles.getLastProp<1>()[2] = 1.0;
790 Particles.ghost_get<0,1>();
793 auto P = getV<0>(Particles);
794 auto V = getV<1>(Particles);
795 auto S = getV<2>(Particles);
796 auto Sig = getV<3>(Particles);
799 Derivative_x Dx(Particles, 2, rCut,2);
802 S = V[0]*V[0] + V[1]*V[1]+V[2]*V[2];
804 Sig[0][1] = V[0]*V[0] + V[1]*V[1]+V[2]*V[2];
808 auto it2 = Particles.getDomainIterator();
821 if (fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]) >= err1 )
823 err1 = fabs(Particles.getProp<0>(p) - Particles.getProp<1>(p)[1]);
826 if (fabs(Particles.getProp<2>(p) - 2.0) >= err2 )
828 err2 = fabs(Particles.getProp<2>(p) - 2.0);
831 if (fabs(Particles.getProp<3>(p)[0][1] - 2.0) >= err3 )
833 err3 = fabs(Particles.getProp<3>(p)[0][1] - 2.0);
837 if (fabs(Particles.getProp<3>(p)[0][1] - Particles.getProp<2>(p)) >= err4 )
839 err4 = fabs(Particles.getProp<3>(p)[0][1] - Particles.getProp<2>(p));
842 if (fabs(Particles.getProp<3>(p)[2][2] - 5.0) >= err5 )
844 err5 = fabs(Particles.getProp<3>(p)[2][2] - 5.0);
851 BOOST_REQUIRE(err1 < 0.08);
852 BOOST_REQUIRE(err2 < 0.03);
853 BOOST_REQUIRE(err3 < 0.03);
854 BOOST_REQUIRE(err4 < 0.03);
855 BOOST_REQUIRE(err5 < 0.03);
858 BOOST_AUTO_TEST_CASE(dcpse_op_convection) {
859 size_t edgeSemiSize = 20;
860 const size_t sz[2] = {2 * edgeSemiSize+1, 2 * edgeSemiSize+1};
862 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
864 spacing[0] = 2.0/ (sz[0] - 1);
865 spacing[1] = 2.0 / (sz[1] - 1);
866 double rCut = 3.1 * spacing[0];
869 BOOST_TEST_MESSAGE(
"Init vector_dist...");
873 domain.setPropNames({
"Concentration",
"Concentration_temp",
"Temp",
"Velocity"});
876 BOOST_TEST_MESSAGE(
"Init domain...");
878 auto it = domain.getGridIterator(sz);
879 while (it.isNext()) {
882 mem_id k0 = key.get(0);
883 double x = -1.0+k0 * spacing[0];
884 domain.getLastPos()[0] = x;
885 mem_id k1 = key.get(1);
886 double y = -1.0+k1 * spacing[1];
887 domain.getLastPos()[1] = y;
889 if (x>-1 && y>-1 && x<1 && y<1)
891 domain.template getLastProp<3>()[0] = (-y)*exp(-10*((x)*(x)+(y)*(y)));;
892 domain.template getLastProp<3>()[1] = (x)*exp(-10*((x)*(x)+(y)*(y)));;
895 domain.template getLastProp<3>()[0] = 0.0;
896 domain.template getLastProp<3>()[1] = 0.0;
898 if (x==0.0 && y>-0.5 && y<0.5)
900 domain.template getLastProp<0>() = 1.0;
904 domain.template getLastProp<0>() = 0.0;
908 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
911 domain.ghost_get<0>();
914 Derivative_xx Dxx(domain, 2, rCut);
916 Derivative_yy Dyy(domain, 2, rCut);
917 auto C = getV<0>(domain);
918 auto V = getV<3>(domain);
919 auto Cnew = getV<1>(domain);
920 auto Pos = getV<PROP_POS>(domain);
924 double t=0,tf=1,dt=1e-2;
927 domain.write_frame(
"Convection",ctr);
928 domain.ghost_get<0>();
929 Cnew=C+dt*0.01*(Dxx(C)+Dyy(C));
933 domain.ghost_get<0>();
934 auto it2 = domain.getDomainIterator();
935 while (it2.isNext()) {
938 double x=xp[0],y=xp[1];
939 if (x>-1 && y>-1 && x<1 && y<1)
941 domain.template getProp<3>(p)[0] = (-y)*exp(-10*((x)*(x)+(y)*(y)));
942 domain.template getProp<3>(p)[1] = (x)*exp(-10*((x)*(x)+(y)*(y)));;
945 domain.template getProp<3>(p)[0] = 0.0;
946 domain.template getProp<3>(p)[1] = 0.0;
959 Dxx.deallocate(domain);
960 Dyy.deallocate(domain);
990BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Laplacian second order on h (spacing)
Class for Creating the DCPSE Operator For the function approximation objects and computes DCPSE Kerne...
Test structure used for several test.
auto get() -> decltype(boost::fusion::at_c< i >(data))
getter method for a general property i
This class implement the point shape in an N-dimensional space.
Class for cpu time benchmarking.
void stop()
Stop the timer.
void start()
Start the timer.