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_op.hpp"
19#include "../DCPSE_Solver.hpp"
20#include "Operators/Vector/vector_dist_operators.hpp"
21#include "Vector/vector_dist_subset.hpp"
22#include "../EqnsStruct.hpp"
23#include "Decomposition/Distribution/SpaceDistribution.hpp"
25BOOST_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 = 2.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 Laplacian_gpu
Lap(domain, 2, rCut, 2,support_options::N_PARTICLES);
63 DCPSE_scheme_gpu<equations2d1_gpu,
decltype(domain)> Solver( domain);
71 auto v = getV<0>(domain);
72 auto RHS = getV<1>(domain);
73 auto sol = getV<2>(domain);
74 auto anasol = getV<3>(domain);
78 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
79 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
81 Box<2, double> up_d({box.getLow(0) - spacing / 2.0, box.getHigh(1) - 8*spacing / 2.0},
82 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - 6*spacing / 2.0});
84 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
85 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
87 Box<2, double> down_u({box.getLow(0) - spacing / 2.0, box.getLow(1) + 3*spacing / 2.0},
88 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + 4*spacing / 2.0});
90 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
91 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
93 Box<2, double> left_r({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
94 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
96 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
97 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
99 Box<2, double> right_l({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
100 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
116 vtk_box.write(
"vtk_box.vtk");
118 auto it2 = domain.getDomainIterator();
120 while (it2.isNext()) {
123 domain.getProp<2>(p)=1+xp[0]*xp[0]+2*xp[1]*xp[1];
124 if (up.isInside(xp) ==
true) {
126 up_p.last().get<0>() = p.getKey();
127 domain.getProp<1>(p) = 3 + xp.
get(0)*xp.
get(0);
128 }
else if (down.isInside(xp) ==
true) {
130 dw_p.last().get<0>() = p.getKey();
131 domain.getProp<1>(p) = 1 + xp.
get(0)*xp.
get(0);
132 }
else if (left.isInside(xp) ==
true) {
134 l_p.last().get<0>() = p.getKey();
135 domain.getProp<1>(p) = 1 + 2*xp.
get(1)*xp.
get(1);
136 }
else if (right.isInside(xp) ==
true) {
138 r_p.last().get<0>() = p.getKey();
139 domain.getProp<1>(p) = 2 + 2*xp.
get(1)*xp.
get(1);
142 bulk.last().get<0>() = p.getKey();
152 Solver.impose(eq1, bulk, 6);
153 Solver.impose(v, up_p, RHS);
154 Solver.impose(v, dw_p, RHS);
162 it2 = domain.getDomainIterator();
164 while (it2.isNext()) {
166 if (fabs(domain.getProp<0>(p) - domain.getProp<2>(p)) >= worst1) {
167 worst1 = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
170 domain.getProp<1>(p) = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
175 domain.write(
"particles");
176 BOOST_REQUIRE(worst1 < 0.03);
181 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin_anal) {
184 const size_t sz[2] = {81,81};
186 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
187 double spacing = box.getHigh(0) / (sz[0] - 1);
189 double rCut = 3.1 * spacing;
190 BOOST_TEST_MESSAGE(
"Init vector_dist...");
192 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
196 BOOST_TEST_MESSAGE(
"Init domain...");
198 auto it = domain.getGridIterator(sz);
199 while (it.isNext()) {
203 double x = key.get(0) * it.getSpacing(0);
204 domain.getLastPos()[0] = x;
205 double y = key.get(1) * it.getSpacing(1);
206 domain.getLastPos()[1] = y;
214 const size_t sz2[2] = {40,40};
215 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});
218 auto it = domain.getDomainIterator();
226 if (bx.isInside(xp) ==
true)
236 auto it2 = domain.getGridIterator(sz2);
237 while (it2.isNext()) {
240 auto key = it2.get();
241 double x = key.get(0) * spacing/2.0 + 0.25 + spacing/4.0;
242 domain.getLastPos()[0] = x;
243 double y = key.get(1) * spacing/2.0 + 0.25 + spacing/4.0;
244 domain.getLastPos()[1] = y;
253 const size_t sz2[2] = {40,40};
254 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});
257 auto it = domain.getDomainIterator();
265 if (bx.isInside(xp) ==
true)
275 auto it2 = domain.getGridIterator(sz2);
276 while (it2.isNext()) {
279 auto key = it2.get();
280 double x = key.get(0) * spacing/4.0 + 0.25 + 21*spacing/8.0;
281 domain.getLastPos()[0] = x;
282 double y = key.get(1) * spacing/4.0 + 0.25 + 21*spacing/8.0;
283 domain.getLastPos()[1] = y;
291 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
294 domain.ghost_get<0>();
296 Derivative_x_gpu Dx(domain, 2, rCut/3.0 ,1.9,support_options::N_PARTICLES);
297 Derivative_y_gpu Dy(domain, 2, rCut/3.0,1.9,support_options::N_PARTICLES);
298 Laplacian_gpu
Lap(domain, 2, rCut/3.0 ,1.9,support_options::N_PARTICLES);
307 auto v = getV<0>(domain);
308 auto RHS=getV<1>(domain);
309 auto sol = getV<2>(domain);
310 auto anasol = getV<3>(domain);
311 auto err = getV<4>(domain);
312 auto DCPSE_sol=getV<5>(domain);
316 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
317 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
319 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
320 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
322 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
323 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
325 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
326 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
340 auto it2 = domain.getDomainIterator();
342 while (it2.isNext()) {
345 if (up.isInside(xp) ==
true) {
347 up_p.last().get<0>() = p.getKey();
348 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
349 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
350 }
else if (down.isInside(xp) ==
true) {
352 dw_p.last().get<0>() = p.getKey();
353 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
354 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
356 }
else if (left.isInside(xp) ==
true) {
358 l_p.last().get<0>() = p.getKey();
359 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
360 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
362 }
else if (right.isInside(xp) ==
true) {
364 r_p.last().get<0>() = p.getKey();
365 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
366 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
370 bulk.last().get<0>() = p.getKey();
371 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
372 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
377 domain.ghost_get<1,3>();
379 DCPSE_scheme_gpu<equations2d1_gpu,
decltype(domain)> Solver( domain);
380 auto Poisson =
Lap(v);
384 Solver.impose(D_y, up_p, 0);
385 Solver.impose(D_x, r_p, 0);
386 Solver.impose(v, dw_p, 0);
387 Solver.impose(v, l_p, 0);
391 solver.setPreconditioner(PCBJACOBI);
392 solver.setRestart(500);
394 Solver.solve_with_solver(solver,sol);
398 domain.ghost_get<2>();
401 domain.ghost_get<5>();
405 v=abs(DCPSE_sol-RHS);
407 for(
int j=0;j<bulk.
size();j++)
408 {
auto p=bulk.get<0>(j);
409 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
410 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
412 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
419 BOOST_REQUIRE(worst1 < 0.03);
429 BOOST_AUTO_TEST_CASE(dcpse_poisson_Dirichlet_anal) {
432 const size_t sz[2] = {81,81};
434 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
435 double spacing = box.getHigh(0) / (sz[0] - 1);
437 double rCut = 3.1 * spacing;
438 BOOST_TEST_MESSAGE(
"Init vector_dist...");
440 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
444 BOOST_TEST_MESSAGE(
"Init domain...");
446 auto it = domain.getGridIterator(sz);
447 while (it.isNext()) {
451 double x = key.get(0) * it.getSpacing(0);
452 domain.getLastPos()[0] = x;
453 double y = key.get(1) * it.getSpacing(1);
454 domain.getLastPos()[1] = y;
458 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
461 domain.ghost_get<0>();
463 Derivative_x_gpu Dx(domain, 2, rCut,1.9,support_options::RADIUS);
464 Derivative_y_gpu Dy(domain, 2, rCut,1.9,support_options::RADIUS);
465 Laplacian_gpu
Lap(domain, 2, rCut, 1.9,support_options::RADIUS);
475 auto v = getV<0>(domain);
476 auto RHS=getV<1>(domain);
477 auto sol = getV<2>(domain);
478 auto anasol = getV<3>(domain);
479 auto err = getV<4>(domain);
480 auto DCPSE_sol=getV<5>(domain);
484 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
485 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
487 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
488 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
490 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
491 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
493 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
494 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
508 auto it2 = domain.getDomainIterator();
510 while (it2.isNext()) {
513 if (up.isInside(xp) ==
true) {
515 up_p.last().get<0>() = p.getKey();
516 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
517 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
519 bulkF.last().get<0>() = p.getKey();
520 }
else if (down.isInside(xp) ==
true) {
522 dw_p.last().get<0>() = p.getKey();
523 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
524 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
526 bulkF.last().get<0>() = p.getKey();
528 }
else if (left.isInside(xp) ==
true) {
530 l_p.last().get<0>() = p.getKey();
531 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
532 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
534 bulkF.last().get<0>() = p.getKey();
536 }
else if (right.isInside(xp) ==
true) {
538 r_p.last().get<0>() = p.getKey();
539 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
540 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
542 bulkF.last().get<0>() = p.getKey();
546 bulk.last().get<0>() = p.getKey();
547 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
548 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
550 bulkF.last().get<0>() = p.getKey();
554 DCPSE_scheme_gpu<equations2d1_gpu,
decltype(domain)> Solver( domain);
555 auto Poisson =
Lap(v);
567 for (
int j = 0; j < up_p.
size(); j++) {
568 auto p = up_p.get<0>(j);
569 domain.getProp<5>(p) = 0;
571 for (
int j = 0; j < dw_p.
size(); j++) {
572 auto p = dw_p.get<0>(j);
573 domain.getProp<5>(p) = 0;
575 for (
int j = 0; j < l_p.
size(); j++) {
576 auto p = l_p.get<0>(j);
577 domain.getProp<5>(p) = 0;
579 for (
int j = 0; j < r_p.
size(); j++) {
580 auto p = r_p.get<0>(j);
581 domain.getProp<5>(p) = 0;
586 v=abs(DCPSE_sol-RHS);
588 for(
int j=0;j<bulkF.
size();j++)
589 {
auto p=bulkF.get<0>(j);
590 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
591 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
593 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
598 BOOST_REQUIRE(worst1 < 0.03);
604 BOOST_AUTO_TEST_CASE(dcpse_poisson_Periodic) {
608 const size_t sz[2] = {31,31};
610 size_t bc[2] = {PERIODIC, NON_PERIODIC};
611 double spacing = box.getHigh(0) / (sz[0] - 1);
613 double rCut = 3.1 * spacing;
614 BOOST_TEST_MESSAGE(
"Init vector_dist...");
616 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
619 BOOST_TEST_MESSAGE(
"Init domain...");
621 auto it = domain.getGridIterator(sz);
622 while (it.isNext()) {
626 double x = key.get(0) * it.getSpacing(0);
627 domain.getLastPos()[0] = x;
628 double y = key.get(1) * it.getSpacing(1)*0.99999;
629 domain.getLastPos()[1] = y;
633 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
636 domain.ghost_get<0>();
639 Laplacian_gpu
Lap(domain, 2, rCut, 1.9, support_options::RADIUS);
641 DCPSE_scheme_gpu<equations2d1p_gpu,
decltype(domain)> Solver( domain);
649 auto v = getV<0>(domain);
650 auto RHS=getV<1>(domain);
651 auto sol = getV<2>(domain);
652 auto anasol = getV<3>(domain);
653 auto err = getV<4>(domain);
654 auto u = getV<5>(domain);
658 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
659 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
661 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
662 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
664 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
665 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
667 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
668 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
682 auto it2 = domain.getDomainIterator();
684 while (it2.isNext()) {
688 if (up.isInside(xp) ==
true) {
690 up_p.last().get<0>() = p.getKey();
691 domain.getProp<1>(p) = 0;
692 }
else if (down.isInside(xp) ==
true) {
694 dw_p.last().get<0>() = p.getKey();
695 domain.getProp<1>(p) = 0;
698 bulk.last().get<0>() = p.getKey();
699 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);
705 domain.ghost_get<1>();
706 auto Poisson = -
Lap(v);
708 Solver.impose(v, up_p, 0);
709 Solver.impose(v, dw_p, 0);
712 domain.ghost_get<0>();
716 for(
int j=0;j<bulk.
size();j++)
717 {
auto p=bulk.get<0>(j);
718 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
719 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
721 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
725 BOOST_REQUIRE(worst1 < 1.0);
731 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin) {
735 const size_t sz[2] = {31,31};
737 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
738 double spacing = box.getHigh(0) / (sz[0] - 1);
740 double rCut = 2.0 * spacing;
741 BOOST_TEST_MESSAGE(
"Init vector_dist...");
743 vector_dist_gpu<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
747 BOOST_TEST_MESSAGE(
"Init domain...");
749 auto it = domain.getGridIterator(sz);
750 while (it.isNext()) {
754 double x = key.get(0) * it.getSpacing(0);
755 domain.getLastPos()[0] = x;
756 double y = key.get(1) * it.getSpacing(1);
757 domain.getLastPos()[1] = y;
761 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
764 domain.ghost_get<0>();
766 Derivative_y_gpu Dy(domain, 2, rCut,2,support_options::N_PARTICLES);
767 Laplacian_gpu
Lap(domain, 2, rCut, 3,support_options::N_PARTICLES);
769 DCPSE_scheme_gpu<equations2d1_gpu,
decltype(domain)> Solver(domain);
777 auto v = getV<0>(domain);
778 auto sol = getV<2>(domain);
779 auto anasol = getV<3>(domain);
780 auto err = getV<4>(domain);
781 auto u = getV<5>(domain);
785 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
786 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
788 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
789 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
791 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
792 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
794 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
795 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
809 auto it2 = domain.getDomainIterator();
811 while (it2.isNext()) {
815 if (up.isInside(xp) ==
true) {
817 up_p.last().get<0>() = p.getKey();
818 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
819 }
else if (down.isInside(xp) ==
true) {
821 dw_p.last().get<0>() = p.getKey();
822 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
823 }
else if (left.isInside(xp) ==
true) {
825 l_p.last().get<0>() = p.getKey();
826 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
827 }
else if (right.isInside(xp) ==
true) {
829 r_p.last().get<0>() = p.getKey();
830 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
833 bulk.last().get<0>() = p.getKey();
834 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);
841 pet_sol.setPreconditioner(PCNONE);
843 auto Poisson =
Lap(v);
848 Solver.impose(v, l_p, 0);
849 Solver.impose(v, r_p, 0);
851 Solver.solve_with_solver(pet_sol,sol);
852 domain.ghost_get<2>();
857 for(
int j=0;j<bulk.
size();j++)
858 {
auto p=bulk.get<0>(j);
859 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
860 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
862 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
866 BOOST_REQUIRE(worst1 < 1.0);
877 BOOST_AUTO_TEST_CASE(dcpse_poisson_Neumann) {
881 const size_t sz[2] = {31,31};
883 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
884 double spacing = box.getHigh(0) / (sz[0] - 1);
885 double rCut = 3.1 * spacing;
887 BOOST_TEST_MESSAGE(
"Init vector_dist...");
893 BOOST_TEST_MESSAGE(
"Init domain...");
895 auto it = domain.getGridIterator(sz);
896 while (it.isNext()) {
901 double x = key.get(0) * it.getSpacing(0);
902 domain.getLastPos()[0] = x;
903 double y = key.get(1) * it.getSpacing(1);
904 domain.getLastPos()[1] = y;
908 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
911 domain.ghost_get<0>();
913 Derivative_x_gpu Dx(domain, 2, rCut,1.9,support_options::N_PARTICLES);
914 Derivative_y_gpu Dy(domain, 2, rCut,1.9,support_options::N_PARTICLES);
915 Laplacian_gpu
Lap(domain, 2, rCut, 1.9,support_options::N_PARTICLES);
918 solver.setRestart(500);
919 solver.setSolver(KSPGMRES);
920 solver.setPreconditioner(PCSVD);
928 auto v = getV<0>(domain);
930 auto sol = getV<2>(domain);
931 auto anasol = getV<3>(domain);
932 auto err = getV<4>(domain);
936 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
937 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
939 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
940 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
942 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
943 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
945 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
946 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
960 auto it2 = domain.getDomainIterator();
962 while (it2.isNext()) {
966 if (up.isInside(xp) ==
true) {
968 up_p.last().get<0>() = p.getKey();
969 domain.getProp<1>(p) = sin(5*xp.
get(0));
970 }
else if (down.isInside(xp) ==
true) {
972 dw_p.last().get<0>() = p.getKey();
973 domain.getProp<1>(p) = sin(5*xp.
get(0));
974 }
else if (left.isInside(xp) ==
true) {
976 l_p.last().get<0>() = p.getKey();
977 domain.getProp<1>(p) = sin(5*xp.
get(0));
978 }
else if (right.isInside(xp) ==
true) {
980 r_p.last().get<0>() = p.getKey();
981 domain.getProp<1>(p) = sin(5*xp.
get(0));
984 bulk.last().get<0>() = p.getKey();
985 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);
991 DCPSE_scheme_gpu<equations2d1_gpu,
decltype(domain)> Solver(domain,options_solver::LAGRANGE_MULTIPLIER);
992 auto Poisson = -
Lap(v);
1000 Solver.solve_with_solver(solver,sol);
1003 domain.ghost_get<2>();
1005 double worst1 = 0.0;
1007 for(
int j=0;j<bulk.
size();j++)
1008 {
auto p=bulk.get<0>(j);
1009 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
1010 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
1012 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
1016 BOOST_REQUIRE(worst1 < 1.0);
1022 BOOST_AUTO_TEST_CASE(dcpse_slice_solver) {
1025 const size_t sz[2] = {31,31};
1027 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
1028 double spacing = box.getHigh(0) / (sz[0] - 1);
1029 double rCut = 3.1 * spacing;
1031 BOOST_TEST_MESSAGE(
"Init vector_dist...");
1033 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);
1037 BOOST_TEST_MESSAGE(
"Init domain...");
1039 auto it = domain.getGridIterator(sz);
1040 while (it.isNext()) {
1043 auto key = it.get();
1044 double x = key.get(0) * it.getSpacing(0);
1045 domain.getLastPos()[0] = x;
1046 double y = key.get(1) * it.getSpacing(1);
1047 domain.getLastPos()[1] = y;
1051 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
1054 domain.ghost_get<0>();
1056 Derivative_x Dx(domain, 2, rCut,1.9,support_options::RADIUS);
1057 Derivative_y Dy(domain, 2, rCut,1.9,support_options::RADIUS);
1058 Laplacian
Lap(domain, 2, rCut,1.9,support_options::RADIUS);
1067 auto v = getV<0>(domain);
1068 auto RHS=getV<1>(domain);
1069 auto sol = getV<2>(domain);
1070 auto anasol = getV<3>(domain);
1071 auto err = getV<4>(domain);
1072 auto DCPSE_sol=getV<5>(domain);
1076 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
1077 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
1079 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
1080 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
1082 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1083 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1085 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1086 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1101 auto it2 = domain.getDomainIterator();
1103 while (it2.isNext()) {
1106 if (up.isInside(xp) ==
true) {
1108 up_p.last().get<0>() = p.getKey();
1109 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1110 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1112 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1113 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1116 }
else if (down.isInside(xp) ==
true) {
1118 dw_p.last().get<0>() = p.getKey();
1119 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1120 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1122 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1123 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1125 }
else if (left.isInside(xp) ==
true) {
1127 l_p.last().get<0>() = p.getKey();
1128 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1129 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1131 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1132 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1134 }
else if (right.isInside(xp) ==
true) {
1136 r_p.last().get<0>() = p.getKey();
1137 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1138 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1140 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1141 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1145 bulk.last().get<0>() = p.getKey();
1146 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1147 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1149 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1150 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1160 DCPSE_scheme_gpu<equations2d2_gpu,
decltype(domain)> Solver( domain);
1161 auto Poisson0 =
Lap(v[0]);
1162 auto Poisson1 =
Lap(v[1]);
1165 Solver.impose(Poisson0, bulk, RHS[0],
vx);
1166 Solver.impose(Poisson1, bulk, RHS[1],vy);
1167 Solver.impose(v[0], up_p, RHS[0],
vx);
1168 Solver.impose(v[1], up_p, RHS[1],vy);
1169 Solver.impose(v[0], r_p, RHS[0],
vx);
1170 Solver.impose(v[1], r_p, RHS[1],vy);
1171 Solver.impose(v[0], dw_p, RHS[0],
vx);
1172 Solver.impose(v[1], dw_p, RHS[1],vy);
1173 Solver.impose(v[0], l_p, RHS[0],
vx);
1174 Solver.impose(v[1], l_p, RHS[1],vy);
1175 Solver.solve(sol[0],sol[1]);
1177 double worst1 = 0.0;
1178 double worst2 = 0.0;
1183 for(
int j=0;j<bulk.
size();j++)
1184 {
auto p=bulk.get<0>(j);
1185 if (fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]) >= worst1) {
1186 worst1 = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1188 domain.getProp<4>(p)[0] = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1191 for(
int j=0;j<bulk.
size();j++)
1192 {
auto p=bulk.get<0>(j);
1193 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]) >= worst2) {
1194 worst2 = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1196 domain.getProp<4>(p)[1] = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1202 BOOST_REQUIRE(worst1 < 0.03);
1203 BOOST_REQUIRE(worst2 < 0.03);
1208BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Laplacian second order on h (spacing)
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Implementation of 1-D std::vector like structure.
In case T does not match the PETSC precision compilation create a stub structure.