13 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS 14 #define BOOST_MPL_LIMIT_VECTOR_SIZE 40 18 #define BOOST_TEST_DYN_LINK 20 #include "util/util_debug.hpp" 21 #include <boost/test/unit_test.hpp> 23 #include "../DCPSE_op.hpp" 24 #include "../DCPSE_Solver.hpp" 25 #include "Operators/Vector/vector_dist_operators.hpp" 26 #include "Vector/vector_dist_subset.hpp" 27 #include "../EqnsStruct.hpp" 28 #include "Decomposition/Distribution/SpaceDistribution.hpp" 30 BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests)
32 BOOST_AUTO_TEST_CASE(dcpse_op_solver) {
35 const size_t sz[2] = {31, 31};
37 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
38 double spacing = box.getHigh(0) / (sz[0] - 1);
40 double rCut = 2.0 * spacing;
41 BOOST_TEST_MESSAGE(
"Init vector_dist...");
47 BOOST_TEST_MESSAGE(
"Init domain...");
49 auto it = domain.getGridIterator(sz);
54 double x = key.get(0) * it.getSpacing(0);
55 domain.getLastPos()[0] = x;
56 double y = key.get(1) * it.getSpacing(1);
57 domain.getLastPos()[1] = y;
61 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
64 domain.ghost_get<0>();
66 Laplacian
Lap(domain, 2, rCut, 2,support_options::N_PARTICLES);
68 DCPSE_scheme<
equations2d1,decltype(domain)> Solver(domain);
76 auto v = getV<0>(domain);
77 auto RHS = getV<1>(domain);
78 auto sol = getV<2>(domain);
79 auto anasol = getV<3>(domain);
83 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
84 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
86 Box<2, double> up_d({box.getLow(0) - spacing / 2.0, box.getHigh(1) - 8*spacing / 2.0},
87 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - 6*spacing / 2.0});
89 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
90 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
92 Box<2, double> down_u({box.getLow(0) - spacing / 2.0, box.getLow(1) + 3*spacing / 2.0},
93 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + 4*spacing / 2.0});
95 Box<2, double> left({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> left_r({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
99 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
101 Box<2, double> right({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});
104 Box<2, double> right_l({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
105 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
121 vtk_box.write(
"vtk_box.vtk");
123 auto it2 = domain.getDomainIterator();
125 while (it2.isNext()) {
128 domain.getProp<2>(p)=1+xp[0]*xp[0]+2*xp[1]*xp[1];
129 if (up.isInside(xp) ==
true) {
131 up_p.last().get<0>() = p.getKey();
132 domain.getProp<1>(p) = 3 + xp.
get(0)*xp.
get(0);
133 }
else if (down.isInside(xp) ==
true) {
135 dw_p.last().get<0>() = p.getKey();
136 domain.getProp<1>(p) = 1 + xp.
get(0)*xp.
get(0);
137 }
else if (left.isInside(xp) ==
true) {
139 l_p.last().get<0>() = p.getKey();
140 domain.getProp<1>(p) = 1 + 2*xp.
get(1)*xp.
get(1);
141 }
else if (right.isInside(xp) ==
true) {
143 r_p.last().get<0>() = p.getKey();
144 domain.getProp<1>(p) = 2 + 2*xp.
get(1)*xp.
get(1);
147 bulk.last().get<0>() = p.getKey();
157 Solver.impose(eq1, bulk, 6);
158 Solver.impose(v, up_p, RHS);
159 Solver.impose(v, dw_p, RHS);
167 it2 = domain.getDomainIterator();
169 while (it2.isNext()) {
171 if (fabs(domain.getProp<0>(p) - domain.getProp<2>(p)) >= worst1) {
172 worst1 = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
175 domain.getProp<1>(p) = fabs(domain.getProp<0>(p) - domain.getProp<2>(p));
180 domain.write(
"particles");
181 BOOST_REQUIRE(worst1 < 0.03);
186 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin_anal) {
189 const size_t sz[2] = {81,81};
191 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
192 double spacing = box.getHigh(0) / (sz[0] - 1);
194 double rCut = 3.1 * spacing;
195 BOOST_TEST_MESSAGE(
"Init vector_dist...");
197 vector_dist<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
201 BOOST_TEST_MESSAGE(
"Init domain...");
203 auto it = domain.getGridIterator(sz);
204 while (it.isNext()) {
208 double x = key.get(0) * it.getSpacing(0);
209 domain.getLastPos()[0] = x;
210 double y = key.get(1) * it.getSpacing(1);
211 domain.getLastPos()[1] = y;
219 const size_t sz2[2] = {40,40};
220 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});
223 auto it = domain.getDomainIterator();
231 if (bx.isInside(xp) ==
true)
241 auto it2 = domain.getGridIterator(sz2);
242 while (it2.isNext()) {
245 auto key = it2.get();
246 double x = key.get(0) * spacing/2.0 + 0.25 + spacing/4.0;
247 domain.getLastPos()[0] = x;
248 double y = key.get(1) * spacing/2.0 + 0.25 + spacing/4.0;
249 domain.getLastPos()[1] = y;
258 const size_t sz2[2] = {40,40};
259 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});
262 auto it = domain.getDomainIterator();
270 if (bx.isInside(xp) ==
true)
280 auto it2 = domain.getGridIterator(sz2);
281 while (it2.isNext()) {
284 auto key = it2.get();
285 double x = key.get(0) * spacing/4.0 + 0.25 + 21*spacing/8.0;
286 domain.getLastPos()[0] = x;
287 double y = key.get(1) * spacing/4.0 + 0.25 + 21*spacing/8.0;
288 domain.getLastPos()[1] = y;
296 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
299 domain.ghost_get<0>();
301 Derivative_x Dx(domain, 2, rCut/3.0 ,1.9,support_options::N_PARTICLES);
302 Derivative_y Dy(domain, 2, rCut/3.0,1.9,support_options::N_PARTICLES);
303 Laplacian
Lap(domain, 2, rCut/3.0 ,1.9,support_options::N_PARTICLES);
312 auto v = getV<0>(domain);
313 auto RHS=getV<1>(domain);
314 auto sol = getV<2>(domain);
315 auto anasol = getV<3>(domain);
316 auto err = getV<4>(domain);
317 auto DCPSE_sol=getV<5>(domain);
321 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
322 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
324 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
325 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
327 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
328 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
330 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
331 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
345 auto it2 = domain.getDomainIterator();
347 while (it2.isNext()) {
350 if (up.isInside(xp) ==
true) {
352 up_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));
355 }
else if (down.isInside(xp) ==
true) {
357 dw_p.last().get<0>() = p.getKey();
358 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
359 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
361 }
else if (left.isInside(xp) ==
true) {
363 l_p.last().get<0>() = p.getKey();
364 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
365 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
367 }
else if (right.isInside(xp) ==
true) {
369 r_p.last().get<0>() = p.getKey();
370 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
371 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
375 bulk.last().get<0>() = p.getKey();
376 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
377 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
382 domain.ghost_get<1,3>();
384 DCPSE_scheme<
equations2d1,decltype(domain)> Solver( domain);
385 auto Poisson =
Lap(v);
389 Solver.impose(D_y, up_p, 0);
390 Solver.impose(D_x, r_p, 0);
391 Solver.impose(v, dw_p, 0);
392 Solver.impose(v, l_p, 0);
399 Solver.solve_with_solver(solver,sol);
403 domain.ghost_get<2>();
406 domain.ghost_get<5>();
410 v=abs(DCPSE_sol-RHS);
412 for(
int j=0;j<bulk.
size();j++)
413 {
auto p=bulk.get<0>(j);
414 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
415 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
417 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
424 BOOST_REQUIRE(worst1 < 0.03);
434 BOOST_AUTO_TEST_CASE(dcpse_poisson_Dirichlet_anal) {
437 const size_t sz[2] = {81,81};
439 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
440 double spacing = box.getHigh(0) / (sz[0] - 1);
442 double rCut = 3.1 * spacing;
443 BOOST_TEST_MESSAGE(
"Init vector_dist...");
445 vector_dist<2, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
449 BOOST_TEST_MESSAGE(
"Init domain...");
451 auto it = domain.getGridIterator(sz);
452 while (it.isNext()) {
456 double x = key.get(0) * it.getSpacing(0);
457 domain.getLastPos()[0] = x;
458 double y = key.get(1) * it.getSpacing(1);
459 domain.getLastPos()[1] = y;
463 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
466 domain.ghost_get<0>();
468 Derivative_x Dx(domain, 2, rCut,1.9,support_options::RADIUS);
469 Derivative_y Dy(domain, 2, rCut,1.9,support_options::RADIUS);
470 Laplacian
Lap(domain, 2, rCut, 1.9,support_options::RADIUS);
480 auto v = getV<0>(domain);
481 auto RHS=getV<1>(domain);
482 auto sol = getV<2>(domain);
483 auto anasol = getV<3>(domain);
484 auto err = getV<4>(domain);
485 auto DCPSE_sol=getV<5>(domain);
489 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
490 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
492 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
493 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
495 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
496 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
498 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
499 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
513 auto it2 = domain.getDomainIterator();
515 while (it2.isNext()) {
518 if (up.isInside(xp) ==
true) {
520 up_p.last().get<0>() = p.getKey();
521 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
522 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
524 bulkF.last().get<0>() = p.getKey();
525 }
else if (down.isInside(xp) ==
true) {
527 dw_p.last().get<0>() = p.getKey();
528 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
529 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
531 bulkF.last().get<0>() = p.getKey();
533 }
else if (left.isInside(xp) ==
true) {
535 l_p.last().get<0>() = p.getKey();
536 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
537 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
539 bulkF.last().get<0>() = p.getKey();
541 }
else if (right.isInside(xp) ==
true) {
543 r_p.last().get<0>() = p.getKey();
544 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
545 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
547 bulkF.last().get<0>() = p.getKey();
551 bulk.last().get<0>() = p.getKey();
552 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
553 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
555 bulkF.last().get<0>() = p.getKey();
559 DCPSE_scheme<
equations2d1,decltype(domain)> Solver( domain);
560 auto Poisson =
Lap(v);
572 for (
int j = 0; j < up_p.
size(); j++) {
573 auto p = up_p.get<0>(j);
574 domain.getProp<5>(p) = 0;
576 for (
int j = 0; j < dw_p.
size(); j++) {
577 auto p = dw_p.get<0>(j);
578 domain.getProp<5>(p) = 0;
580 for (
int j = 0; j < l_p.
size(); j++) {
581 auto p = l_p.get<0>(j);
582 domain.getProp<5>(p) = 0;
584 for (
int j = 0; j < r_p.
size(); j++) {
585 auto p = r_p.get<0>(j);
586 domain.getProp<5>(p) = 0;
591 v=abs(DCPSE_sol-RHS);
593 for(
int j=0;j<bulkF.
size();j++)
594 {
auto p=bulkF.get<0>(j);
595 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
596 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
598 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
603 BOOST_REQUIRE(worst1 < 0.03);
609 BOOST_AUTO_TEST_CASE(dcpse_poisson_Periodic) {
613 const size_t sz[2] = {31,31};
615 size_t bc[2] = {PERIODIC, NON_PERIODIC};
616 double spacing = box.getHigh(0) / (sz[0] - 1);
618 double rCut = 3.1 * spacing;
619 BOOST_TEST_MESSAGE(
"Init vector_dist...");
621 vector_dist<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
624 BOOST_TEST_MESSAGE(
"Init domain...");
626 auto it = domain.getGridIterator(sz);
627 while (it.isNext()) {
631 double x = key.get(0) * it.getSpacing(0);
632 domain.getLastPos()[0] = x;
633 double y = key.get(1) * it.getSpacing(1)*0.99999;
634 domain.getLastPos()[1] = y;
638 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
641 domain.ghost_get<0>();
644 Laplacian
Lap(domain, 2, rCut, 1.9, support_options::RADIUS);
646 DCPSE_scheme<
equations2d1p,decltype(domain)> Solver( domain);
654 auto v = getV<0>(domain);
655 auto RHS=getV<1>(domain);
656 auto sol = getV<2>(domain);
657 auto anasol = getV<3>(domain);
658 auto err = getV<4>(domain);
659 auto u = getV<5>(domain);
663 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
664 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
666 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
667 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
669 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
670 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
672 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
673 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
687 auto it2 = domain.getDomainIterator();
689 while (it2.isNext()) {
693 if (up.isInside(xp) ==
true) {
695 up_p.last().get<0>() = p.getKey();
696 domain.getProp<1>(p) = 0;
697 }
else if (down.isInside(xp) ==
true) {
699 dw_p.last().get<0>() = p.getKey();
700 domain.getProp<1>(p) = 0;
703 bulk.last().get<0>() = p.getKey();
704 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);
710 domain.ghost_get<1>();
711 auto Poisson = -
Lap(v);
713 Solver.impose(v, up_p, 0);
714 Solver.impose(v, dw_p, 0);
717 domain.ghost_get<0>();
721 for(
int j=0;j<bulk.
size();j++)
722 {
auto p=bulk.get<0>(j);
723 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
724 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
726 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
730 BOOST_REQUIRE(worst1 < 1.0);
736 BOOST_AUTO_TEST_CASE(dcpse_poisson_Robin) {
740 const size_t sz[2] = {31,31};
742 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
743 double spacing = box.getHigh(0) / (sz[0] - 1);
745 double rCut = 2.0 * spacing;
746 BOOST_TEST_MESSAGE(
"Init vector_dist...");
748 vector_dist<2, double, aggregate<double,double,double,double,double,VectorS<2, double>>> domain(0, box, bc, ghost);
752 BOOST_TEST_MESSAGE(
"Init domain...");
754 auto it = domain.getGridIterator(sz);
755 while (it.isNext()) {
759 double x = key.get(0) * it.getSpacing(0);
760 domain.getLastPos()[0] = x;
761 double y = key.get(1) * it.getSpacing(1);
762 domain.getLastPos()[1] = y;
766 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
769 domain.ghost_get<0>();
771 Derivative_y Dy(domain, 2, rCut,2,support_options::N_PARTICLES);
772 Laplacian
Lap(domain, 2, rCut, 3,support_options::N_PARTICLES);
774 DCPSE_scheme<
equations2d1,decltype(domain)> Solver(domain);
782 auto v = getV<0>(domain);
783 auto sol = getV<2>(domain);
784 auto anasol = getV<3>(domain);
785 auto err = getV<4>(domain);
786 auto u = getV<5>(domain);
790 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
791 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
793 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
794 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
796 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
797 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
799 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
800 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
814 auto it2 = domain.getDomainIterator();
816 while (it2.isNext()) {
820 if (up.isInside(xp) ==
true) {
822 up_p.last().get<0>() = p.getKey();
823 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
824 }
else if (down.isInside(xp) ==
true) {
826 dw_p.last().get<0>() = p.getKey();
827 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
828 }
else if (left.isInside(xp) ==
true) {
830 l_p.last().get<0>() = p.getKey();
831 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
832 }
else if (right.isInside(xp) ==
true) {
834 r_p.last().get<0>() = p.getKey();
835 domain.getProp<1>(p) = sin(5.0*xp.
get(0));
838 bulk.last().get<0>() = p.getKey();
839 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);
848 auto Poisson =
Lap(v);
853 Solver.impose(v, l_p, 0);
854 Solver.impose(v, r_p, 0);
856 Solver.solve_with_solver(pet_sol,sol);
857 domain.ghost_get<2>();
862 for(
int j=0;j<bulk.
size();j++)
863 {
auto p=bulk.get<0>(j);
864 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
865 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
867 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
871 BOOST_REQUIRE(worst1 < 1.0);
882 BOOST_AUTO_TEST_CASE(dcpse_poisson_Neumann) {
886 const size_t sz[2] = {31,31};
888 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
889 double spacing = box.getHigh(0) / (sz[0] - 1);
890 double rCut = 3.1 * spacing;
892 BOOST_TEST_MESSAGE(
"Init vector_dist...");
898 BOOST_TEST_MESSAGE(
"Init domain...");
900 auto it = domain.getGridIterator(sz);
901 while (it.isNext()) {
906 double x = key.get(0) * it.getSpacing(0);
907 domain.getLastPos()[0] = x;
908 double y = key.get(1) * it.getSpacing(1);
909 domain.getLastPos()[1] = y;
913 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
916 domain.ghost_get<0>();
918 Derivative_x Dx(domain, 2, rCut,1.9,support_options::N_PARTICLES);
919 Derivative_y Dy(domain, 2, rCut,1.9,support_options::N_PARTICLES);
920 Laplacian
Lap(domain, 2, rCut, 1.9,support_options::N_PARTICLES);
932 auto v = getV<0>(domain);
934 auto sol = getV<2>(domain);
935 auto anasol = getV<3>(domain);
936 auto err = getV<4>(domain);
940 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
941 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
943 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
944 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
946 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
947 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
949 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
950 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
964 auto it2 = domain.getDomainIterator();
966 while (it2.isNext()) {
970 if (up.isInside(xp) ==
true) {
972 up_p.last().get<0>() = p.getKey();
973 domain.getProp<1>(p) = sin(5*xp.
get(0));
974 }
else if (down.isInside(xp) ==
true) {
976 dw_p.last().get<0>() = p.getKey();
977 domain.getProp<1>(p) = sin(5*xp.
get(0));
978 }
else if (left.isInside(xp) ==
true) {
980 l_p.last().get<0>() = p.getKey();
981 domain.getProp<1>(p) = sin(5*xp.
get(0));
982 }
else if (right.isInside(xp) ==
true) {
984 r_p.last().get<0>() = p.getKey();
985 domain.getProp<1>(p) = sin(5*xp.
get(0));
988 bulk.last().get<0>() = p.getKey();
989 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);
995 DCPSE_scheme<
equations2d1,decltype(domain)> Solver(domain,options_solver::LAGRANGE_MULTIPLIER);
996 auto Poisson = -
Lap(v);
1004 Solver.solve_with_solver(solver,sol);
1007 domain.ghost_get<2>();
1009 double worst1 = 0.0;
1011 for(
int j=0;j<bulk.
size();j++)
1012 {
auto p=bulk.get<0>(j);
1013 if (fabs(domain.getProp<3>(p) - domain.getProp<1>(p)) >= worst1) {
1014 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<1>(p));
1016 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<3>(p));
1020 BOOST_REQUIRE(worst1 < 1.0);
1026 BOOST_AUTO_TEST_CASE(dcpse_slice_solver) {
1029 const size_t sz[2] = {31,31};
1031 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
1032 double spacing = box.getHigh(0) / (sz[0] - 1);
1033 double rCut = 3.1 * spacing;
1035 BOOST_TEST_MESSAGE(
"Init vector_dist...");
1037 vector_dist<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);
1041 BOOST_TEST_MESSAGE(
"Init domain...");
1043 auto it = domain.getGridIterator(sz);
1044 while (it.isNext()) {
1047 auto key = it.get();
1048 double x = key.get(0) * it.getSpacing(0);
1049 domain.getLastPos()[0] = x;
1050 double y = key.get(1) * it.getSpacing(1);
1051 domain.getLastPos()[1] = y;
1055 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
1058 domain.ghost_get<0>();
1060 Derivative_x Dx(domain, 2, rCut,1.9,support_options::RADIUS);
1061 Derivative_y Dy(domain, 2, rCut,1.9,support_options::RADIUS);
1062 Laplacian
Lap(domain, 2, rCut,1.9,support_options::RADIUS);
1072 auto v = getV<0>(domain);
1073 auto RHS=getV<1>(domain);
1074 auto sol = getV<2>(domain);
1075 auto anasol = getV<3>(domain);
1076 auto err = getV<4>(domain);
1077 auto DCPSE_sol=getV<5>(domain);
1081 Box<2, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0},
1082 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0});
1084 Box<2, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0},
1085 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0});
1087 Box<2, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1088 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1090 Box<2, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0},
1091 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0});
1106 auto it2 = domain.getDomainIterator();
1108 while (it2.isNext()) {
1111 if (up.isInside(xp) ==
true) {
1113 up_p.last().get<0>() = p.getKey();
1114 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1115 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1117 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1118 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1121 }
else if (down.isInside(xp) ==
true) {
1123 dw_p.last().get<0>() = p.getKey();
1124 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1125 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1127 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1128 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1130 }
else if (left.isInside(xp) ==
true) {
1132 l_p.last().get<0>() = p.getKey();
1133 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1134 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1136 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1137 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1139 }
else if (right.isInside(xp) ==
true) {
1141 r_p.last().get<0>() = p.getKey();
1142 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1143 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1145 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1146 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1150 bulk.last().get<0>() = p.getKey();
1151 domain.getProp<1>(p)[0] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1152 domain.getProp<3>(p)[0] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1154 domain.getProp<1>(p)[1] = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1155 domain.getProp<3>(p)[1] = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1165 DCPSE_scheme<
equations2d2,decltype(domain)> Solver( domain);
1166 auto Poisson0 =
Lap(v[0]);
1167 auto Poisson1 =
Lap(v[1]);
1170 Solver.impose(Poisson0, bulk, RHS[0],
vx);
1171 Solver.impose(Poisson1, bulk, RHS[1],vy);
1172 Solver.impose(v[0], up_p, RHS[0],
vx);
1173 Solver.impose(v[1], up_p, RHS[1],vy);
1174 Solver.impose(v[0], r_p, RHS[0],
vx);
1175 Solver.impose(v[1], r_p, RHS[1],vy);
1176 Solver.impose(v[0], dw_p, RHS[0],
vx);
1177 Solver.impose(v[1], dw_p, RHS[1],vy);
1178 Solver.impose(v[0], l_p, RHS[0],
vx);
1179 Solver.impose(v[1], l_p, RHS[1],vy);
1180 Solver.solve(sol[0],sol[1]);
1182 double worst1 = 0.0;
1183 double worst2 = 0.0;
1188 for(
int j=0;j<bulk.
size();j++)
1189 {
auto p=bulk.get<0>(j);
1190 if (fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]) >= worst1) {
1191 worst1 = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1193 domain.getProp<4>(p)[0] = fabs(domain.getProp<3>(p)[0] - domain.getProp<2>(p)[0]);
1196 for(
int j=0;j<bulk.
size();j++)
1197 {
auto p=bulk.get<0>(j);
1198 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]) >= worst2) {
1199 worst2 = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1201 domain.getProp<4>(p)[1] = fabs(domain.getProp<3>(p)[1] - domain.getProp<2>(p)[1]);
1207 BOOST_REQUIRE(worst1 < 0.03);
1208 BOOST_REQUIRE(worst2 < 0.03);
1213 BOOST_AUTO_TEST_SUITE_END()
void setPreconditioner(PCType type)
Set the preconditioner of the linear solver.
Specify the general characteristic of system to solve.
This class implement the point shape in an N-dimensional space.
void setRestart(PetscInt n)
For GMRES based method, the number of Krylov directions to orthogonalize against.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This class is able to do Matrix inversion in parallel with PETSC solvers.
void setSolver(KSPType type)
Set the Petsc solver.
Laplacian second order on h (spacing)
This class represent an N-dimensional box.
Implementation of 1-D std::vector like structure.