8 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
9 #define BOOST_MPL_LIMIT_VECTOR_SIZE 40
13 #define BOOST_TEST_DYN_LINK
15 #include "util/util_debug.hpp"
16 #include <boost/test/unit_test.hpp>
18 #include "DCPSE/DCPSE_op/DCPSE_op.hpp"
19 #include "DCPSE/DCPSE_op/DCPSE_Solver.hpp"
20 #include "Operators/Vector/vector_dist_operators.hpp"
21 #include "Vector/vector_dist_subset.hpp"
22 #include "DCPSE/DCPSE_op/EqnsStruct.hpp"
23 #include "Decomposition/Distribution/SpaceDistribution.hpp"
25 BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests_cu)
27 BOOST_AUTO_TEST_CASE(dcpse_op_solver) {
30 const size_t sz[2] = {31, 31};
32 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
33 double spacing = box.getHigh(0) / (sz[0] - 1);
35 double rCut = 4.0 * spacing;
36 BOOST_TEST_MESSAGE(
"Init vector_dist...");
42 BOOST_TEST_MESSAGE(
"Init domain...");
44 auto it = domain.getGridIterator(sz);
49 double x = key.get(0) * it.getSpacing(0);
50 domain.getLastPos()[0] = x;
51 double y = key.get(1) * it.getSpacing(1);
52 domain.getLastPos()[1] = y;
56 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
59 domain.ghost_get<0>();
61 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
63 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
65 DCPSE_scheme_gpu<equations2d1_gpu,decltype(domain)> Solver( domain);
73 auto v = getV<0>(domain);
74 auto RHS = getV<1>(domain);
75 auto sol = getV<2>(domain);
76 auto anasol = getV<3>(domain);
80 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
81 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
83 Box<2, double> up_d({box.getLow(0) - spacing / 2.0, box.getHigh(1) - 8*spacing / 2.0},
84 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - 6*spacing / 2.0});
86 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
87 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
89 Box<2, double> down_u({box.getLow(0) - spacing / 2.0, box.getLow(1) + 3*spacing / 2.0},
90 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + 4*spacing / 2.0});
92 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
93 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
95 Box<2, double> left_r({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
96 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
98 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
99 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
101 Box<2, double> right_l({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
102 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
118 vtk_box.write(
"vtk_box.vtk");
120 auto it2 = domain.getDomainIterator();
122 while (it2.isNext()) {
125 domain.getProp<2>(p)=1+xp[0]*xp[0]+2*xp[1]*xp[1];
126 if (up.isInside(xp) ==
true) {
128 up_p.last().get<0>() = p.getKey();
129 domain.getProp<1>(p) = 3 + xp.
get(0)*xp.
get(0);
130 }
else if (down.isInside(xp) ==
true) {
132 dw_p.last().get<0>() = p.getKey();
133 domain.getProp<1>(p) = 1 + xp.
get(0)*xp.
get(0);
134 }
else if (left.isInside(xp) ==
true) {
136 l_p.last().get<0>() = p.getKey();
137 domain.getProp<1>(p) = 1 + 2*xp.
get(1)*xp.
get(1);
138 }
else if (right.isInside(xp) ==
true) {
140 r_p.last().get<0>() = p.getKey();
141 domain.getProp<1>(p) = 2 + 2*xp.
get(1)*xp.
get(1);
144 bulk.last().get<0>() = p.getKey();
154 Solver.impose(eq1, bulk, 6);
155 Solver.impose(v, up_p, RHS);
156 Solver.impose(v, dw_p, RHS);
164 it2 = domain.getDomainIterator();
166 while (it2.isNext()) {
168 if (fabs(domain.getProp<0>(p) - domain.getProp<2>(p)) >= worst1) {
169 worst1 = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
172 domain.getProp<1>(p) = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
177 domain.write(
"particles");
178 BOOST_REQUIRE(worst1 < 0.03);
183 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin_anal) {
186 const size_t sz[2] = {81,81};
188 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
189 double spacing = box.getHigh(0) / (sz[0] - 1);
191 double rCut = 3.1 * spacing;
192 BOOST_TEST_MESSAGE(
"Init vector_dist...");
194 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
198 BOOST_TEST_MESSAGE(
"Init domain...");
200 auto it = domain.getGridIterator(sz);
201 while (it.isNext()) {
205 double x = key.get(0) * it.getSpacing(0);
206 domain.getLastPos()[0] = x;
207 double y = key.get(1) * it.getSpacing(1);
208 domain.getLastPos()[1] = y;
216 const size_t sz2[2] = {40,40};
217 Box<2,double> bx({0.25 + it.getSpacing(0)/4.0,0.25 + it.getSpacing(0)/4.0},{sz2[0]*it.getSpacing(0)/2.0 + 0.25 + it.getSpacing(0)/4.0, sz2[1]*it.getSpacing(0)/2.0 + 0.25 + it.getSpacing(0)/4.0});
220 auto it = domain.getDomainIterator();
228 if (bx.isInside(xp) ==
true)
238 auto it2 = domain.getGridIterator(sz2);
239 while (it2.isNext()) {
242 auto key = it2.get();
243 double x = key.get(0) * spacing/2.0 + 0.25 + spacing/4.0;
244 domain.getLastPos()[0] = x;
245 double y = key.get(1) * spacing/2.0 + 0.25 + spacing/4.0;
246 domain.getLastPos()[1] = y;
255 const size_t sz2[2] = {40,40};
256 Box<2,double> bx({0.25 + 21.0*spacing/8.0,0.25 + 21.0*spacing/8.0},{sz2[0]*spacing/4.0 + 0.25 + 21.0*spacing/8.0, sz2[1]*spacing/4.0 + 0.25 + 21*spacing/8.0});
259 auto it = domain.getDomainIterator();
267 if (bx.isInside(xp) ==
true)
277 auto it2 = domain.getGridIterator(sz2);
278 while (it2.isNext()) {
281 auto key = it2.get();
282 double x = key.get(0) * spacing/4.0 + 0.25 + 21*spacing/8.0;
283 domain.getLastPos()[0] = x;
284 double y = key.get(1) * spacing/4.0 + 0.25 + 21*spacing/8.0;
285 domain.getLastPos()[1] = y;
293 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
296 domain.ghost_get<0>();
298 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
300 Derivative_x_gpu<decltype(verletList)> Dx(domain, verletList, 2, rCut, support_options::RADIUS);
301 Derivative_y_gpu<decltype(verletList)> Dy(domain, verletList, 2, rCut, support_options::RADIUS);
302 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
311 auto v = getV<0>(domain);
312 auto RHS=getV<1>(domain);
313 auto sol = getV<2>(domain);
314 auto anasol = getV<3>(domain);
315 auto err = getV<4>(domain);
316 auto DCPSE_sol=getV<5>(domain);
320 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
321 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
323 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
324 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
326 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
327 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
329 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
330 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
344 auto it2 = domain.getDomainIterator();
346 while (it2.isNext()) {
349 if (up.isInside(xp) ==
true) {
351 up_p.last().get<0>() = p.getKey();
352 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
353 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
354 }
else if (down.isInside(xp) ==
true) {
356 dw_p.last().get<0>() = p.getKey();
357 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
358 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
360 }
else if (left.isInside(xp) ==
true) {
362 l_p.last().get<0>() = p.getKey();
363 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
364 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
366 }
else if (right.isInside(xp) ==
true) {
368 r_p.last().get<0>() = p.getKey();
369 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
370 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
374 bulk.last().get<0>() = p.getKey();
375 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
376 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
381 domain.ghost_get<1,3>();
383 DCPSE_scheme_gpu<equations2d1_gpu,decltype(domain)> Solver( domain);
384 auto Poisson =
Lap(v);
388 Solver.impose(D_y, up_p, 0);
389 Solver.impose(D_x, r_p, 0);
390 Solver.impose(v, dw_p, 0);
391 Solver.impose(v, l_p, 0);
398 Solver.solve_with_solver(solver,sol);
402 domain.ghost_get<2>();
405 domain.ghost_get<5>();
409 v=abs(DCPSE_sol-RHS);
411 for(
int j=0;j<bulk.
size();j++)
412 {
auto p=bulk.get<0>(j);
413 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
414 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
416 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
423 BOOST_REQUIRE(worst1 < 0.03);
433 BOOST_AUTO_TEST_CASE(dcpse_poisson_Dirichlet_anal) {
436 const size_t sz[2] = {81,81};
438 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
439 double spacing = box.getHigh(0) / (sz[0] - 1);
441 double rCut = 3.1 * spacing;
442 BOOST_TEST_MESSAGE(
"Init vector_dist...");
444 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
448 BOOST_TEST_MESSAGE(
"Init domain...");
450 auto it = domain.getGridIterator(sz);
451 while (it.isNext()) {
455 double x = key.get(0) * it.getSpacing(0);
456 domain.getLastPos()[0] = x;
457 double y = key.get(1) * it.getSpacing(1);
458 domain.getLastPos()[1] = y;
462 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
465 domain.ghost_get<0>();
467 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
469 Derivative_x_gpu<decltype(verletList)> Dx(domain, verletList, 2, rCut, support_options::RADIUS);
470 Derivative_y_gpu<decltype(verletList)> Dy(domain, verletList, 2, rCut, support_options::RADIUS);
471 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
481 auto v = getV<0>(domain);
482 auto RHS=getV<1>(domain);
483 auto sol = getV<2>(domain);
484 auto anasol = getV<3>(domain);
485 auto err = getV<4>(domain);
486 auto DCPSE_sol=getV<5>(domain);
490 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
491 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
493 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
494 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
496 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
497 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
499 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
500 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
514 auto it2 = domain.getDomainIterator();
516 while (it2.isNext()) {
519 if (up.isInside(xp) ==
true) {
521 up_p.last().get<0>() = p.getKey();
522 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
523 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
525 bulkF.last().get<0>() = p.getKey();
526 }
else if (down.isInside(xp) ==
true) {
528 dw_p.last().get<0>() = p.getKey();
529 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
530 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
532 bulkF.last().get<0>() = p.getKey();
534 }
else if (left.isInside(xp) ==
true) {
536 l_p.last().get<0>() = p.getKey();
537 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
538 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
540 bulkF.last().get<0>() = p.getKey();
542 }
else if (right.isInside(xp) ==
true) {
544 r_p.last().get<0>() = p.getKey();
545 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
546 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
548 bulkF.last().get<0>() = p.getKey();
552 bulk.last().get<0>() = p.getKey();
553 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
554 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
556 bulkF.last().get<0>() = p.getKey();
560 DCPSE_scheme_gpu<equations2d1_gpu,decltype(domain)> Solver( domain);
561 auto Poisson =
Lap(v);
573 for (
int j = 0; j < up_p.
size(); j++) {
574 auto p = up_p.get<0>(j);
575 domain.getProp<5>(p) = 0;
577 for (
int j = 0; j < dw_p.
size(); j++) {
578 auto p = dw_p.get<0>(j);
579 domain.getProp<5>(p) = 0;
581 for (
int j = 0; j < l_p.
size(); j++) {
582 auto p = l_p.get<0>(j);
583 domain.getProp<5>(p) = 0;
585 for (
int j = 0; j < r_p.
size(); j++) {
586 auto p = r_p.get<0>(j);
587 domain.getProp<5>(p) = 0;
592 v=abs(DCPSE_sol-RHS);
594 for(
int j=0;j<bulkF.
size();j++)
595 {
auto p=bulkF.get<0>(j);
596 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
597 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
599 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
604 BOOST_REQUIRE(worst1 < 0.03);
610 BOOST_AUTO_TEST_CASE(dcpse_poisson_Periodic) {
614 const size_t sz[2] = {31,31};
616 size_t bc[2] = {PERIODIC, NON_PERIODIC};
617 double spacing = box.getHigh(0) / (sz[0] - 1);
619 double rCut = 3.1 * spacing;
620 BOOST_TEST_MESSAGE(
"Init vector_dist...");
622 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
625 BOOST_TEST_MESSAGE(
"Init domain...");
627 auto it = domain.getGridIterator(sz);
628 while (it.isNext()) {
632 double x = key.get(0) * it.getSpacing(0);
633 domain.getLastPos()[0] = x;
634 double y = key.get(1) * it.getSpacing(1)*0.99999;
635 domain.getLastPos()[1] = y;
639 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
642 domain.ghost_get<0>();
644 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
646 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
648 DCPSE_scheme_gpu<equations2d1p_gpu,decltype(domain)> Solver( domain);
656 auto v = getV<0>(domain);
657 auto RHS=getV<1>(domain);
658 auto sol = getV<2>(domain);
659 auto anasol = getV<3>(domain);
660 auto err = getV<4>(domain);
661 auto u = getV<5>(domain);
665 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
666 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
668 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
669 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
671 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
672 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
674 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
675 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
689 auto it2 = domain.getDomainIterator();
691 while (it2.isNext()) {
695 if (up.isInside(xp) ==
true) {
697 up_p.last().get<0>() = p.getKey();
698 domain.getProp<1>(p) = 0;
699 }
else if (down.isInside(xp) ==
true) {
701 dw_p.last().get<0>() = p.getKey();
702 domain.getProp<1>(p) = 0;
705 bulk.last().get<0>() = p.getKey();
706 domain.getProp<1>(p) = xp.
get(0)*sin(5*M_PI*xp.
get(1))+exp(-((xp.
get(0)-0.5)*(xp.
get(0)-0.5)+(xp.
get(1)-0.5)*(xp.
get(1)-0.5))/0.02);
712 domain.ghost_get<1>();
713 auto Poisson = -
Lap(v);
715 Solver.impose(v, up_p, 0);
716 Solver.impose(v, dw_p, 0);
719 domain.ghost_get<0>();
723 for(
int j=0;j<bulk.
size();j++)
724 {
auto p=bulk.get<0>(j);
725 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
726 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
728 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
732 BOOST_REQUIRE(worst1 < 1.0);
738 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin) {
742 const size_t sz[2] = {31,31};
744 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
745 double spacing = box.getHigh(0) / (sz[0] - 1);
747 double rCut = 3.1 * spacing;
748 BOOST_TEST_MESSAGE(
"Init vector_dist...");
750 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
754 BOOST_TEST_MESSAGE(
"Init domain...");
756 auto it = domain.getGridIterator(sz);
757 while (it.isNext()) {
761 double x = key.get(0) * it.getSpacing(0);
762 domain.getLastPos()[0] = x;
763 double y = key.get(1) * it.getSpacing(1);
764 domain.getLastPos()[1] = y;
768 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
771 domain.ghost_get<0>();
773 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
775 Derivative_y_gpu<decltype(verletList)> Dy(domain, verletList, 2, rCut, support_options::RADIUS);
776 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
778 DCPSE_scheme_gpu<equations2d1_gpu,decltype(domain)> Solver(domain);
786 auto v = getV<0>(domain);
787 auto sol = getV<2>(domain);
788 auto anasol = getV<3>(domain);
789 auto err = getV<4>(domain);
790 auto u = getV<5>(domain);
794 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
795 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
797 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
798 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
800 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
801 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
803 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
804 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
818 auto it2 = domain.getDomainIterator();
820 while (it2.isNext()) {
824 if (up.isInside(xp) ==
true) {
826 up_p.last().get<0>() = p.getKey();
827 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
828 }
else if (down.isInside(xp) ==
true) {
830 dw_p.last().get<0>() = p.getKey();
831 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
832 }
else if (left.isInside(xp) ==
true) {
834 l_p.last().get<0>() = p.getKey();
835 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
836 }
else if (right.isInside(xp) ==
true) {
838 r_p.last().get<0>() = p.getKey();
839 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
842 bulk.last().get<0>() = p.getKey();
843 domain.getProp<1>(p) = -10.0*exp(-((xp.
get(0)-0.5)*(xp.
get(0)-0.5)+(xp.
get(1)-0.5)*(xp.
get(1)-0.5))/0.02);
852 auto Poisson =
Lap(v);
857 Solver.impose(v, l_p, 0);
858 Solver.impose(v, r_p, 0);
860 Solver.solve_with_solver(pet_sol,sol);
861 domain.ghost_get<2>();
866 for(
int j=0;j<bulk.
size();j++)
867 {
auto p=bulk.get<0>(j);
868 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
869 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
871 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
875 BOOST_REQUIRE(worst1 < 1.0);
886 BOOST_AUTO_TEST_CASE(dcpse_poisson_Neumann) {
890 const size_t sz[2] = {31,31};
892 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
893 double spacing = box.getHigh(0) / (sz[0] - 1);
894 double rCut = 3.1 * spacing;
896 BOOST_TEST_MESSAGE(
"Init vector_dist...");
902 BOOST_TEST_MESSAGE(
"Init domain...");
904 auto it = domain.getGridIterator(sz);
905 while (it.isNext()) {
910 double x = key.get(0) * it.getSpacing(0);
911 domain.getLastPos()[0] = x;
912 double y = key.get(1) * it.getSpacing(1);
913 domain.getLastPos()[1] = y;
917 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
920 domain.ghost_get<0>();
922 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
924 Derivative_x_gpu<decltype(verletList)> Dx(domain, verletList, 2, rCut, support_options::RADIUS);
925 Derivative_y_gpu<decltype(verletList)> Dy(domain, verletList, 2, rCut, support_options::RADIUS);
926 Laplacian_gpu<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
939 auto v = getV<0>(domain);
941 auto sol = getV<2>(domain);
942 auto anasol = getV<3>(domain);
943 auto err = getV<4>(domain);
947 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
948 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
950 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
951 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
953 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
954 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
956 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
957 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
971 auto it2 = domain.getDomainIterator();
973 while (it2.isNext()) {
977 if (up.isInside(xp) ==
true) {
979 up_p.last().get<0>() = p.getKey();
980 domain.getProp<1>(p) = sin(5*xp.
get(0));
981 }
else if (down.isInside(xp) ==
true) {
983 dw_p.last().get<0>() = p.getKey();
984 domain.getProp<1>(p) = sin(5*xp.
get(0));
985 }
else if (left.isInside(xp) ==
true) {
987 l_p.last().get<0>() = p.getKey();
988 domain.getProp<1>(p) = sin(5*xp.
get(0));
989 }
else if (right.isInside(xp) ==
true) {
991 r_p.last().get<0>() = p.getKey();
992 domain.getProp<1>(p) = sin(5*xp.
get(0));
995 bulk.last().get<0>() = p.getKey();
996 domain.getProp<1>(p) = -10*exp(-((xp.
get(0)-0.5)*(xp.
get(0)-0.5)+(xp.
get(1)-0.5)*(xp.
get(1)-0.5))/0.02);
1002 DCPSE_scheme_gpu<equations2d1_gpu,decltype(domain)> Solver(domain,options_solver::LAGRANGE_MULTIPLIER);
1003 auto Poisson = -
Lap(v);
1011 Solver.solve_with_solver(solver,sol);
1014 domain.ghost_get<2>();
1016 double worst1 = 0.0;
1018 for(
int j=0;j<bulk.
size();j++)
1019 {
auto p=bulk.get<0>(j);
1020 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
1021 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
1023 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
1027 BOOST_REQUIRE(worst1 < 1.0);
1033 BOOST_AUTO_TEST_CASE(dcpse_slice_solver) {
1036 const size_t sz[2] = {31,31};
1038 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
1039 double spacing = box.getHigh(0) / (sz[0] - 1);
1040 double rCut = 3.1 * spacing;
1042 BOOST_TEST_MESSAGE(
"Init vector_dist...");
1044 vector_dist_gpu<2, double, aggregate<VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>,
VectorS<2, double>>> domain(0, box, bc, ghost);
1048 BOOST_TEST_MESSAGE(
"Init domain...");
1050 auto it = domain.getGridIterator(sz);
1051 while (it.isNext()) {
1054 auto key = it.get();
1055 double x = key.get(0) * it.getSpacing(0);
1056 domain.getLastPos()[0] = x;
1057 double y = key.get(1) * it.getSpacing(1);
1058 domain.getLastPos()[1] = y;
1062 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
1065 domain.ghost_get<0>();
1067 auto verletList = domain.template getVerlet<VL_NON_SYMMETRIC|VL_SKIP_REF_PART>(rCut);
1069 Derivative_x<decltype(verletList)> Dx(domain, verletList, 2, rCut, support_options::RADIUS);
1070 Derivative_y<decltype(verletList)> Dy(domain, verletList, 2, rCut, support_options::RADIUS);
1071 Laplacian<decltype(verletList)>
Lap(domain, verletList, 2, rCut, support_options::RADIUS);
1080 auto v = getV<0>(domain);
1081 auto RHS=getV<1>(domain);
1082 auto sol = getV<2>(domain);
1083 auto anasol = getV<3>(domain);
1084 auto err = getV<4>(domain);
1085 auto DCPSE_sol=getV<5>(domain);
1089 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
1090 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
1092 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
1093 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
1095 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1096 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1098 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1099 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1114 auto it2 = domain.getDomainIterator();
1116 while (it2.isNext()) {
1119 if (up.isInside(xp) ==
true) {
1121 up_p.last().get<0>() = p.getKey();
1122 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1123 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1125 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1126 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1129 }
else if (down.isInside(xp) ==
true) {
1131 dw_p.last().get<0>() = p.getKey();
1132 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1133 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1135 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1136 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1138 }
else if (left.isInside(xp) ==
true) {
1140 l_p.last().get<0>() = p.getKey();
1141 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1142 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1144 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1145 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1147 }
else if (right.isInside(xp) ==
true) {
1149 r_p.last().get<0>() = p.getKey();
1150 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1151 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1153 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1154 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1158 bulk.last().get<0>() = p.getKey();
1159 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1160 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1162 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1163 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1173 DCPSE_scheme_gpu<equations2d2_gpu,decltype(domain)> Solver( domain);
1174 auto Poisson0 =
Lap(v[0]);
1175 auto Poisson1 =
Lap(v[1]);
1178 Solver.impose(Poisson0, bulk, RHS[0],
vx);
1179 Solver.impose(Poisson1, bulk, RHS[1],vy);
1180 Solver.impose(v[0], up_p, RHS[0],
vx);
1181 Solver.impose(v[1], up_p, RHS[1],vy);
1182 Solver.impose(v[0], r_p, RHS[0],
vx);
1183 Solver.impose(v[1], r_p, RHS[1],vy);
1184 Solver.impose(v[0], dw_p, RHS[0],
vx);
1185 Solver.impose(v[1], dw_p, RHS[1],vy);
1186 Solver.impose(v[0], l_p, RHS[0],
vx);
1187 Solver.impose(v[1], l_p, RHS[1],vy);
1188 Solver.solve(sol[0],sol[1]);
1190 double worst1 = 0.0;
1191 double worst2 = 0.0;
1196 for(
int j=0;j<bulk.
size();j++)
1197 {
auto p=bulk.get<0>(j);
1198 if (fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]) >= worst1) {
1199 worst1 = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1201 domain.getProp<4>(p)[0] = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1204 for(
int j=0;j<bulk.
size();j++)
1205 {
auto p=bulk.get<0>(j);
1206 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]) >= worst2) {
1207 worst2 = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1209 domain.getProp<4>(p)[1] = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1215 BOOST_REQUIRE(worst1 < 0.03);
1216 BOOST_REQUIRE(worst2 < 0.03);
1221 BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Laplacian second order on h (spacing)
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Implementation of 1-D std::vector like structure.
This class is able to do Matrix inversion in parallel with PETSC solvers.
void setPreconditioner(PCType type)
Set the preconditioner of the linear solver.
void setSolver(KSPType type)
Set the Petsc solver.
void setRestart(PetscInt n)
For GMRES based method, the number of Krylov directions to orthogonalize against.