10#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
11#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_surface_op.hpp"
19#include "../DCPSE_Solver.hpp"
20#include "Operators/Vector/vector_dist_operators.hpp"
21#include "Vector/vector_dist_subset.hpp"
23#include "util/SphericalHarmonics.hpp"
25BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests)
26 BOOST_AUTO_TEST_CASE(dcpse_surface_simple) {
27 double boxP1{-1.5}, boxP2{1.5};
28 double boxSize{boxP2 - boxP1};
31 double grid_spacing{boxSize/(sz[0]-1)};
32 double rCut{3.9 * grid_spacing};
35 size_t bc[2] = {NON_PERIODIC,NON_PERIODIC};
37 auto &v_cl=create_vcluster();
41 BOOST_TEST_MESSAGE(
"Init domain...");
44 if (v_cl.rank() == 0) {
45 for (
int i = 0; i < n; ++i) {
46 double xp = -1.5+i*grid_spacing;
48 Sparticles.getLastPos()[0] = xp;
49 Sparticles.getLastPos()[1] = 0;
50 Sparticles.getLastProp<3>() = std::sin(xp);
51 Sparticles.getLastProp<2>()[0] = 0;
52 Sparticles.getLastProp<2>()[1] = 1.0;
53 Sparticles.getLastProp<1>() = -std::sin(xp);
54 Sparticles.getLastSubset(0);
59 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
61 Sparticles.ghost_get<0,3>();
64 SurfaceDerivative_xx<2> SDxx(Sparticles, 2, rCut,grid_spacing);
65 SurfaceDerivative_yy<2> SDyy(Sparticles, 2, rCut,grid_spacing);
68 auto INICONC = getV<3>(Sparticles);
69 auto CONC = getV<0>(Sparticles);
70 auto TEMP = getV<4>(Sparticles);
71 auto normal = getV<2>(Sparticles);
73 CONC=SDxx(INICONC)+SDyy(INICONC);
78 auto it2 = Sparticles.getDomainIterator();
80 while (it2.isNext()) {
82 if (fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p)) > worst) {
83 worst = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
88 Sparticles.deleteGhost();
91 BOOST_REQUIRE(worst < 0.03);
93 BOOST_AUTO_TEST_CASE(dcpse_surface_circle) {
95 double boxP1{-1.5}, boxP2{1.5};
96 double boxSize{boxP2 - boxP1};
98 auto &v_cl=create_vcluster();
101 size_t sz[2] = {n,n};
102 double grid_spacing{boxSize/(sz[0]-1)};
103 double rCut{5.1 * grid_spacing};
106 size_t bc[2] = {NON_PERIODIC,NON_PERIODIC};
108 vector_dist_ws<2, double, aggregate<double,double,double[2],double,double[2],double>> Sparticles(0, domain,bc,ghost);
110 BOOST_TEST_MESSAGE(
"Init domain...");
113 const double radius{1.0};
114 std::array<double,2> center{0.0,0.0};
116 const double pi{3.14159265358979323846};
120 double dtheta{2*pi/double(n)};
121 if (v_cl.rank() == 0) {
122 for (
int i = 0; i < n; ++i) {
123 coord[0] = center[0] + radius * std::cos(theta);
124 coord[1] = center[1] + radius * std::sin(theta);
126 Sparticles.getLastPos()[0] = coord[0];
127 Sparticles.getLastPos()[1] = coord[1];
128 Sparticles.getLastProp<3>() = std::sin(theta);
129 Sparticles.getLastProp<2>()[0] = std::cos(theta);
130 Sparticles.getLastProp<2>()[1] = std::sin(theta);
131 Sparticles.getLastProp<1>() = -std::sin(theta);;
132 Sparticles.getLastSubset(0);
138 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
140 Sparticles.ghost_get<0,3>();
143 SurfaceDerivative_xx<2> SDxx(Sparticles, 2, rCut,grid_spacing);
144 SurfaceDerivative_yy<2> SDyy(Sparticles, 2, rCut,grid_spacing);
148 auto INICONC = getV<3>(Sparticles);
149 auto CONC = getV<0>(Sparticles);
150 auto TEMP = getV<4>(Sparticles);
151 auto normal = getV<2>(Sparticles);
153 CONC=SDxx(INICONC)+SDyy(INICONC);
162 auto it2 = Sparticles.getDomainIterator();
164 while (it2.isNext()) {
166 Sparticles.getProp<5>(p) = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
167 if (fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p)) > worst) {
168 worst = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
172 Sparticles.deleteGhost();
175 BOOST_REQUIRE(worst < 0.03);
177 BOOST_AUTO_TEST_CASE(dcpse_surface_solver_circle) {
178 double boxP1{-1.5}, boxP2{1.5};
179 double boxSize{boxP2 - boxP1};
181 auto &v_cl=create_vcluster();
188 size_t sz[2] = {n,n};
189 double grid_spacing{boxSize/(sz[0]-1)};
190 double rCut{3.9 * grid_spacing};
193 size_t bc[2] = {NON_PERIODIC,NON_PERIODIC};
195 vector_dist_ws<2, double, aggregate<double,double,double[2],double,double[2],double>> Sparticles(0, domain,bc,ghost);
197 BOOST_TEST_MESSAGE(
"Init domain...");
200 const double radius{1.0};
201 std::array<double,2> center{0.0,0.0};
203 const double pi{3.14159265358979323846};
207 double dtheta{2*pi/double(n)};
208 if (v_cl.rank() == 0) {
209 for (
int i = 0; i < n; ++i) {
210 coord[0] = center[0] + radius * std::cos(theta);
211 coord[1] = center[1] + radius * std::sin(theta);
213 Sparticles.getLastPos()[0] = coord[0];
214 Sparticles.getLastPos()[1] = coord[1];
215 Sparticles.getLastProp<3>() = -openfpm::math::intpowlog(k,2)*std::sin(k*theta);
216 Sparticles.getLastProp<2>()[0] = std::cos(theta);
217 Sparticles.getLastProp<2>()[1] = std::sin(theta);
218 Sparticles.getLastProp<1>() = std::sin(k*theta);;
219 Sparticles.getLastSubset(0);
220 if(coord[0]==1. && coord[1]==0.)
221 {Sparticles.getLastSubset(1);}
227 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
229 Sparticles.ghost_get<0>();
233 auto & bulk=Sparticles_bulk.getIds();
234 auto & boundary=Sparticles_boundary.getIds();
236 SurfaceDerivative_xx<2> SDxx(Sparticles, 2, rCut,grid_spacing);
237 SurfaceDerivative_yy<2> SDyy(Sparticles, 2, rCut,grid_spacing);
238 auto INICONC = getV<3>(Sparticles);
239 auto CONC = getV<0>(Sparticles);
240 auto TEMP = getV<4>(Sparticles);
241 auto normal = getV<2>(Sparticles);
242 auto ANASOL = getV<1>(Sparticles);
243 DCPSE_scheme<
equations2d1,
decltype(Sparticles)> Solver(Sparticles);
244 Solver.impose(SDxx(CONC)+SDyy(CONC), bulk, INICONC);
245 Solver.impose(CONC, boundary, ANASOL);
247 auto it2 = Sparticles.getDomainIterator();
249 while (it2.isNext()) {
251 Sparticles.getProp<5>(p) = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
252 if (fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p)) > worst) {
253 worst = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
257 Sparticles.deleteGhost();
260 BOOST_REQUIRE(worst < 0.03);
262BOOST_AUTO_TEST_CASE(dcpse_surface_sphere) {
263 auto & v_cl = create_vcluster();
269 double boxP1{-1.5}, boxP2{1.5};
270 double boxSize{boxP2 - boxP1};
271 size_t sz[3] = {n,n,n};
272 double grid_spacing{boxSize/(sz[0]-1)};
273 double grid_spacing_surf=grid_spacing*30;
274 double rCut{2.5 * grid_spacing_surf};
276 Box<3,double> domain{{boxP1,boxP1,boxP1},{boxP2,boxP2,boxP2}};
277 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
282 vector_dist_ws<3, double, aggregate<double,double,double[3],double,double[3],double>> Sparticles(0, domain,bc,ghost);
284 double Golden_angle=M_PI * (3.0 - sqrt(5.0));
285 if (v_cl.rank() == 0) {
288 for(
int i=1;i<n_sp;i++)
290 double y = 1.0 - (i /double(n_sp - 1.0)) * 2.0;
291 double radius = sqrt(1 - y * y);
292 double Golden_theta = Golden_angle * i;
293 double x = cos(Golden_theta) * radius;
294 double z = sin(Golden_theta) * radius;
296 Sparticles.getLastPos()[0] = x;
297 Sparticles.getLastPos()[1] = y;
298 Sparticles.getLastPos()[2] = z;
299 double rm=sqrt(x*x+y*y+z*z);
300 Sparticles.getLastProp<2>()[0] = x/rm;
301 Sparticles.getLastProp<2>()[1] = y/rm;
302 Sparticles.getLastProp<2>()[2] = z/rm;
303 Sparticles.getLastProp<4>()[0] = 1.0 ;
304 Sparticles.getLastProp<4>()[1] = std::atan2(sqrt(x*x+y*y),z);
305 Sparticles.getLastProp<4>()[2] = std::atan2(y,x);
307 {Sparticles.getLastSubset(1);}
309 {Sparticles.getLastSubset(0);}
315 Sparticles.ghost_get<3>();
319 auto &bulkIds=Sparticles_bulk.getIds();
320 auto &bdrIds=Sparticles_boundary.getIds();
321 std::unordered_map<const lm,double,key_hash,key_equal> Alm;
324 for(
int l=0;l<=K;l++){
325 for(
int m=-l;m<=l;m++){
326 Alm[std::make_tuple(l,m)]=0;
329 Alm[std::make_tuple(1,0)]=1;
330 auto it2 = Sparticles.getDomainIterator();
331 while (it2.isNext()) {
340 Sparticles.getProp<3>(p)=openfpm::math::sumY_Scalar<K>(xP[0],xP[1],xP[2],Alm);
341 Sparticles.getProp<1>(p)=-(K)*(K+1)*openfpm::math::sumY_Scalar<K>(xP[0],xP[1],xP[2],Alm);
344 auto f=getV<3>(Sparticles);
345 auto Df=getV<0>(Sparticles);
347 SurfaceDerivative_xx<2> Sdxx{Sparticles,2,rCut,grid_spacing_surf};
348 SurfaceDerivative_yy<2> Sdyy{Sparticles,2,rCut,grid_spacing_surf};
349 SurfaceDerivative_zz<2> Sdzz{Sparticles,2,rCut,grid_spacing_surf};
360 Sparticles.ghost_get<3>();
361 Df=(Sdxx(f)+Sdyy(f)+Sdzz(f));
363 auto it3 = Sparticles.getDomainIterator();
365 while (it3.isNext()) {
368 if (fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p)) > worst) {
369 worst = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
373 Sparticles.deleteGhost();
376 BOOST_REQUIRE(worst < 0.03);
380BOOST_AUTO_TEST_CASE(dcpse_surface_sphere_old) {
381 auto & v_cl = create_vcluster();
387 double boxP1{-1.5}, boxP2{1.5};
388 double boxSize{boxP2 - boxP1};
389 size_t sz[3] = {n,n,n};
390 double grid_spacing{boxSize/(sz[0]-1)};
391 double grid_spacing_surf=grid_spacing*30;
392 double rCut{2.5 * grid_spacing_surf};
394 Box<3,double> domain{{boxP1,boxP1,boxP1},{boxP2,boxP2,boxP2}};
395 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
400 vector_dist_ws<3, double, aggregate<double,double,double[3],double,double[3],double>> Sparticles(0, domain,bc,ghost);
402 double Golden_angle=M_PI * (3.0 - sqrt(5.0));
403 if (v_cl.rank() == 0) {
406 std::unordered_map<const lm,double,key_hash,key_equal> Alm;
409 for(
int l=0;l<=K;l++){
410 for(
int m=-l;m<=l;m++){
411 Alm[std::make_tuple(l,m)]=0;
414 Alm[std::make_tuple(1,0)]=1;
415 for(
int i=1;i<n_sp;i++)
417 double y = 1.0 - (i /double(n_sp - 1.0)) * 2.0;
418 double radius = sqrt(1 - y * y);
419 double Golden_theta = Golden_angle * i;
420 double x = cos(Golden_theta) * radius;
421 double z = sin(Golden_theta) * radius;
423 Sparticles.getLastPos()[0] = x;
424 Sparticles.getLastPos()[1] = y;
425 Sparticles.getLastPos()[2] = z;
426 double rm=sqrt(x*x+y*y+z*z);
427 Sparticles.getLastProp<2>()[0] = x/rm;
428 Sparticles.getLastProp<2>()[1] = y/rm;
429 Sparticles.getLastProp<2>()[2] = z/rm;
430 Sparticles.getLastProp<4>()[0] = 1.0 ;
431 Sparticles.getLastProp<4>()[1] = std::atan2(sqrt(x*x+y*y),z);
432 Sparticles.getLastProp<4>()[2] = std::atan2(y,x);
433 double m1=openfpm::math::sumY_Scalar<K>(1.0,std::atan2(sqrt(x*x+y*y),z),std::atan2(y,x),Alm);
434 double m2=-(K)*(K+1)*openfpm::math::sumY_Scalar<K>(1.0,std::atan2(sqrt(x*x+y*y),z),std::atan2(y,x),Alm);
435 Sparticles.getLastProp<3>()=m1;
436 Sparticles.getLastProp<1>()=m2;
437 Sparticles.getLastSubset(0);
438 for(
int j=1;j<=2;++j){
440 Sparticles.getLastPos()[0] = x+j*grid_spacing_surf*x/rm;
441 Sparticles.getLastPos()[1] = y+j*grid_spacing_surf*y/rm;
442 Sparticles.getLastPos()[2] = z+j*grid_spacing_surf*z/rm;
443 Sparticles.getLastProp<3>()=m1;
444 Sparticles.getLastSubset(1);
447 Sparticles.getLastPos()[0] = x-j*grid_spacing_surf*x/rm;
448 Sparticles.getLastPos()[1] = y-j*grid_spacing_surf*y/rm;
449 Sparticles.getLastPos()[2] = z-j*grid_spacing_surf*z/rm;
450 Sparticles.getLastProp<3>()=m1;
451 Sparticles.getLastSubset(1);
459 Sparticles.ghost_get<3>();
464 auto &bulkIds=Sparticles_bulk.getIds();
465 auto &bdrIds=Sparticles_boundary.getIds();
480 auto f=getV<3>(Sparticles);
481 auto Df=getV<0>(Sparticles);
486 Derivative_xx Sdxx{Sparticles,2,rCut};
488 Derivative_yy Sdyy{Sparticles,2,rCut};
490 Derivative_zz Sdzz{Sparticles,2,rCut};
505 Sparticles.ghost_get<3>();
506 Df=(Sdxx(f)+Sdyy(f)+Sdzz(f));
510 for (
int j = 0; j < bulkIds.size(); j++) {
511 auto p = bulkIds.get<0>(j);
513 if (fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p)) > worst) {
514 worst = fabs(Sparticles.getProp<1>(p) - Sparticles.getProp<0>(p));
517 Sparticles.deleteGhost();
520 BOOST_REQUIRE(worst < 0.03);
634 BOOST_AUTO_TEST_CASE(dcpse_surface_adaptive) {
637 const size_t sz[3] = {81,81,1};
639 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC,NON_PERIODIC};
640 double spacing = box.getHigh(0) / (sz[0] - 1);
642 double rCut = 3.1 * spacing;
643 BOOST_TEST_MESSAGE(
"Init vector_dist...");
645 vector_dist<3, double, aggregate<double,double,double,double,double,double,double[3]>> domain(0, box, bc, ghost);
649 BOOST_TEST_MESSAGE(
"Init domain...");
651 auto it = domain.getGridIterator(sz);
652 while (it.isNext()) {
656 double x = key.get(0) * it.getSpacing(0);
657 domain.getLastPos()[0] = x;
658 double y = key.get(1) * it.getSpacing(1);
659 domain.getLastPos()[1] = y;
661 domain.getLastPos()[2] = 0;
669 const size_t sz2[3] = {40,40,1};
670 Box<3,double> bx({0.25 + it.getSpacing(0)/4.0,0.25 + it.getSpacing(0)/4.0,-0.5},{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,0.5});
673 auto it = domain.getDomainIterator();
681 if (bx.isInside(xp) ==
true)
691 auto it2 = domain.getGridIterator(sz2);
692 while (it2.isNext()) {
695 auto key = it2.get();
696 double x = key.get(0) * spacing/2.0 + 0.25 + spacing/4.0;
697 domain.getLastPos()[0] = x;
698 double y = key.get(1) * spacing/2.0 + 0.25 + spacing/4.0;
699 domain.getLastPos()[1] = y;
700 domain.getLastPos()[2] = 0;
709 const size_t sz2[3] = {40,40,1};
710 Box<3,double> bx({0.25 + 21.0*spacing/8.0,0.25 + 21.0*spacing/8.0,-5},{sz2[0]*spacing/4.0 + 0.25 + 21.0*spacing/8.0, sz2[1]*spacing/4.0 + 0.25 + 21*spacing/8.0,5});
713 auto it = domain.getDomainIterator();
721 if (bx.isInside(xp) ==
true)
731 auto it2 = domain.getGridIterator(sz2);
732 while (it2.isNext()) {
734 auto key = it2.get();
735 double x = key.get(0) * spacing/4.0 + 0.25 + 21*spacing/8.0;
736 domain.getLastPos()[0] = x;
737 double y = key.get(1) * spacing/4.0 + 0.25 + 21*spacing/8.0;
738 domain.getLastPos()[1] = y;
739 domain.getLastPos()[2] = 0;
747 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
750 domain.ghost_get<0>();
759 auto v = getV<0>(domain);
760 auto RHS=getV<1>(domain);
761 auto sol = getV<2>(domain);
762 auto anasol = getV<3>(domain);
763 auto err = getV<4>(domain);
764 auto DCPSE_sol=getV<5>(domain);
768 Box<3, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0,-5},
769 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0,5});
771 Box<3, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0,-5},
772 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0,5});
774 Box<3, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0,-5},
775 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0,5});
777 Box<3, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0,-5},
778 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0,5});
791 auto it2 = domain.getDomainIterator();
793 while (it2.isNext()) {
796 if (up.isInside(xp) ==
true) {
798 up_p.last().get<0>() = p.getKey();
799 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
800 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
801 }
else if (down.isInside(xp) ==
true) {
803 dw_p.last().get<0>() = p.getKey();
804 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
805 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
807 }
else if (left.isInside(xp) ==
true) {
809 l_p.last().get<0>() = p.getKey();
810 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
811 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
813 }
else if (right.isInside(xp) ==
true) {
815 r_p.last().get<0>() = p.getKey();
816 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
817 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
821 bulk.last().get<0>() = p.getKey();
822 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
823 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
825 domain.getProp<6>(p)[0] = 0;
826 domain.getProp<6>(p)[1] = 0;
827 domain.getProp<6>(p)[2] = 1;
832 domain.ghost_get<1,2,3>();
833 SurfaceDerivative_xx<6> Dxx(domain, 2, rCut,3.9,support_options::ADAPTIVE);
849 SurfaceDerivative_yy<6> Dyy(domain, 2, rCut,3.9,support_options::ADAPTIVE);
850 SurfaceDerivative_zz<6> Dzz(domain, 2, rCut,3.9,support_options::ADAPTIVE);
852 Dxx.save(domain,
"Sdxx_test");
853 Dyy.save(domain,
"Sdyy_test");
854 Dzz.save(domain,
"Sdzz_test");
856 domain.ghost_get<2>();
857 sol=Dxx(anasol)+Dyy(anasol)+Dzz(anasol);
858 domain.ghost_get<5>();
862 for(
int j=0;j<bulk.
size();j++)
863 {
auto p=bulk.get<0>(j);
864 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) >= worst1) {
865 worst1 = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
867 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
873 BOOST_REQUIRE(worst1 < 0.03);
878 BOOST_AUTO_TEST_CASE(dcpse_surface_adaptive_load) {
881 const size_t sz[3] = {81,81,1};
883 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC,NON_PERIODIC};
884 double spacing = box.getHigh(0) / (sz[0] - 1);
886 double rCut = 3.1 * spacing;
887 BOOST_TEST_MESSAGE(
"Init vector_dist...");
889 vector_dist<3, double, aggregate<double,double,double,double,double,double,double[3]>> domain(0, box, bc, ghost);
893 BOOST_TEST_MESSAGE(
"Init domain...");
895 auto it = domain.getGridIterator(sz);
896 while (it.isNext()) {
900 double x = key.get(0) * it.getSpacing(0);
901 domain.getLastPos()[0] = x;
902 double y = key.get(1) * it.getSpacing(1);
903 domain.getLastPos()[1] = y;
905 domain.getLastPos()[2] = 0;
913 const size_t sz2[3] = {40,40,1};
914 Box<3,double> bx({0.25 + it.getSpacing(0)/4.0,0.25 + it.getSpacing(0)/4.0,-0.5},{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,0.5});
917 auto it = domain.getDomainIterator();
925 if (bx.isInside(xp) ==
true)
935 auto it2 = domain.getGridIterator(sz2);
936 while (it2.isNext()) {
939 auto key = it2.get();
940 double x = key.get(0) * spacing/2.0 + 0.25 + spacing/4.0;
941 domain.getLastPos()[0] = x;
942 double y = key.get(1) * spacing/2.0 + 0.25 + spacing/4.0;
943 domain.getLastPos()[1] = y;
944 domain.getLastPos()[2] = 0;
953 const size_t sz2[3] = {40,40,1};
954 Box<3,double> bx({0.25 + 21.0*spacing/8.0,0.25 + 21.0*spacing/8.0,-5},{sz2[0]*spacing/4.0 + 0.25 + 21.0*spacing/8.0, sz2[1]*spacing/4.0 + 0.25 + 21*spacing/8.0,5});
957 auto it = domain.getDomainIterator();
965 if (bx.isInside(xp) ==
true)
975 auto it2 = domain.getGridIterator(sz2);
976 while (it2.isNext()) {
979 auto key = it2.get();
980 double x = key.get(0) * spacing/4.0 + 0.25 + 21*spacing/8.0;
981 domain.getLastPos()[0] = x;
982 double y = key.get(1) * spacing/4.0 + 0.25 + 21*spacing/8.0;
983 domain.getLastPos()[1] = y;
984 domain.getLastPos()[2] = 0;
992 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
995 domain.ghost_get<0>();
1004 auto v = getV<0>(domain);
1005 auto RHS=getV<1>(domain);
1006 auto sol = getV<2>(domain);
1007 auto anasol = getV<3>(domain);
1008 auto err = getV<4>(domain);
1009 auto DCPSE_sol=getV<5>(domain);
1013 Box<3, double> up({box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0,-5},
1014 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0,5});
1016 Box<3, double> down({box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0,-5},
1017 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0,5});
1019 Box<3, double> left({box.getLow(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0,-5},
1020 {box.getLow(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0,5});
1022 Box<3, double> right({box.getHigh(0) - spacing / 2.0, box.getLow(1) + spacing / 2.0,-5},
1023 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) - spacing / 2.0,5});
1037 auto it2 = domain.getDomainIterator();
1039 while (it2.isNext()) {
1042 if (up.isInside(xp) ==
true) {
1044 up_p.last().get<0>() = p.getKey();
1045 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1046 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1047 }
else if (down.isInside(xp) ==
true) {
1049 dw_p.last().get<0>() = p.getKey();
1050 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1051 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1053 }
else if (left.isInside(xp) ==
true) {
1055 l_p.last().get<0>() = p.getKey();
1056 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1057 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1059 }
else if (right.isInside(xp) ==
true) {
1061 r_p.last().get<0>() = p.getKey();
1062 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1063 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1067 bulk.last().get<0>() = p.getKey();
1068 domain.getProp<1>(p) = -2*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1069 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1));
1071 domain.getProp<6>(p)[0] = 0;
1072 domain.getProp<6>(p)[1] = 0;
1073 domain.getProp<6>(p)[2] = 1;
1078 domain.ghost_get<1,2,3>();
1079 SurfaceDerivative_xx<6> Dxx(domain, 2, rCut,3.9,support_options::LOAD);
1080 SurfaceDerivative_yy<6> Dyy(domain, 2, rCut,3.9,support_options::LOAD);
1081 SurfaceDerivative_zz<6> Dzz(domain, 2, rCut,3.9,support_options::LOAD);
1082 Dxx.load(domain,
"Sdxx_test");
1083 Dyy.load(domain,
"Sdyy_test");
1084 Dzz.load(domain,
"Sdzz_test");
1086 domain.ghost_get<2>();
1087 sol=Dxx(anasol)+Dyy(anasol)+Dzz(anasol);
1088 domain.ghost_get<5>();
1090 double worst1 = 0.0;
1092 for(
int j=0;j<bulk.
size();j++)
1093 {
auto p=bulk.get<0>(j);
1094 if (fabs(domain.getProp<1>(p) - domain.getProp<2>(p)) >= worst1) {
1095 worst1 = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
1097 domain.getProp<4>(p) = fabs(domain.getProp<1>(p) - domain.getProp<2>(p));
1104 BOOST_REQUIRE(worst1 < 0.03);
1109BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
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.
Class for cpu time benchmarking.
void start()
Start the timer.
Specify the general characteristic of system to solve.