14 #define BOOST_TEST_DYN_LINK 16 #include "util/util_debug.hpp" 17 #include <boost/test/unit_test.hpp> 19 #include "../DCPSE_op.hpp" 20 #include "../DCPSE_Solver.hpp" 21 #include "Operators/Vector/vector_dist_operators.hpp" 22 #include "Vector/vector_dist_subset.hpp" 23 #include "../EqnsStruct.hpp" 24 #include "util/SphericalHarmonics.hpp" 32 BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests3)
33 BOOST_AUTO_TEST_CASE(dcpse_op_vec3d) {
36 size_t edgeSemiSize = 21;
37 const size_t sz[3] = {edgeSemiSize, edgeSemiSize,edgeSemiSize};
39 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC, NON_PERIODIC};
40 double spacing = box.getHigh(0) / (sz[0] - 1);
41 double rCut = 3.1 * spacing;
43 BOOST_TEST_MESSAGE(
"Init vector_dist...");
44 double sigma2 = spacing * spacing/ (2 * 4);
46 vector_dist<3, double, aggregate<double, VectorS<3, double>,
VectorS<3, double>,
VectorS<3, double>,
VectorS<3, double>,double,
double>> domain(
50 BOOST_TEST_MESSAGE(
"Init domain...");
52 auto it = domain.getGridIterator(sz);
55 double minNormOne = 999;
59 mem_id k0 = key.get(0);
60 double x = k0 * spacing;
61 domain.getLastPos()[0] = x;
62 mem_id k1 = key.get(1);
63 double y = k1 * spacing;
64 domain.getLastPos()[1] = y;
65 mem_id k2 = key.get(2);
66 double z = k2 * spacing;
67 domain.getLastPos()[2] = z;
69 domain.template getLastProp<0>() = sin(domain.getLastPos()[0]) + sin(domain.getLastPos()[1]) + sin(domain.getLastPos()[2]) ;
70 domain.template getLastProp<1>()[0] = cos(domain.getLastPos()[0]);
71 domain.template getLastProp<1>()[1] = cos(domain.getLastPos()[1]) ;
72 domain.template getLastProp<1>()[2] = cos(domain.getLastPos()[2]);
74 domain.template getLastProp<2>()[0] = 0;
75 domain.template getLastProp<2>()[1] = 0;
76 domain.template getLastProp<3>()[0] = 0;
77 domain.template getLastProp<3>()[1] = 0;
78 domain.template getLastProp<3>()[2] = 0;
80 domain.template getLastProp<4>()[0] = -cos(domain.getLastPos()[0]) * sin(domain.getLastPos()[0]);
81 domain.template getLastProp<4>()[1] = -cos(domain.getLastPos()[1]) * sin(domain.getLastPos()[1]);
82 domain.template getLastProp<4>()[2] = -cos(domain.getLastPos()[2]) * sin(domain.getLastPos()[2]);
91 domain.template getLastProp<5>() = cos(domain.getLastPos()[0]) * cos(domain.getLastPos()[0])+cos(domain.getLastPos()[1]) * cos(domain.getLastPos()[1])+cos(domain.getLastPos()[2]) * cos(domain.getLastPos()[2]) ;
95 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
98 domain.ghost_get<0>();
100 Advection Adv(domain, 2, rCut, 1.9,support_options::RADIUS);
101 auto v = getV<1>(domain);
102 auto P = getV<0>(domain);
103 auto dv = getV<3>(domain);
104 auto dP = getV<6>(domain);
110 domain.ghost_get<1>();
112 auto it2 = domain.getDomainIterator();
116 while (it2.isNext()) {
119 if (fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]) > worst1) {
120 worst1 = fabs(domain.getProp<3>(p)[1] - domain.getProp<4>(p)[1]);
127 BOOST_REQUIRE(worst1 < 0.03);
135 auto it3 = domain.getDomainIterator();
139 while (it3.isNext()) {
141 if (fabs(domain.getProp<6>(p) - domain.getProp<5>(p)) > worst2) {
142 worst2 = fabs(domain.getProp<6>(p) - domain.getProp<5>(p));
148 domain.deleteGhost();
149 BOOST_REQUIRE(worst2 < 0.03);
154 BOOST_AUTO_TEST_CASE(dcpse_poisson_dirichlet_anal3d) {
158 const size_t sz[3] = {grd_sz,grd_sz,grd_sz};
160 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC,NON_PERIODIC};
161 double spacing = box.getHigh(0) / (sz[0] - 1);
163 double rCut = 3.1 * spacing;
164 BOOST_TEST_MESSAGE(
"Init vector_dist...");
166 vector_dist<3, double, aggregate<double,double,double,double,double,double>> domain(0, box, bc, ghost);
170 BOOST_TEST_MESSAGE(
"Init domain...");
172 auto it = domain.getGridIterator(sz);
173 while (it.isNext()) {
176 double x = key.get(0) * it.getSpacing(0);
177 domain.getLastPos()[0] = x;
178 double y = key.get(1) * it.getSpacing(1);
179 domain.getLastPos()[1] = y;
180 double z = key.get(2) * it.getSpacing(2);
181 domain.getLastPos()[2] = z;
185 BOOST_TEST_MESSAGE(
"Sync domain across processors...");
188 domain.ghost_get<0>();
190 Derivative_x Dx(domain, 2, rCut,1.9,support_options::RADIUS);
191 Derivative_y Dy(domain, 2, rCut,1.9,support_options::RADIUS);
192 Laplacian
Lap(domain, 2, rCut,1.3,support_options::RADIUS);
202 auto v = getV<0>(domain);
203 auto RHS=getV<1>(domain);
204 auto sol = getV<2>(domain);
205 auto anasol = getV<3>(domain);
206 auto err = getV<4>(domain);
207 auto DCPSE_sol=getV<5>(domain);
210 {box.getLow(0) - spacing / 2.0, box.getHigh(1) - spacing / 2.0, box.getLow(2) - spacing / 2.0},
211 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0, box.getHigh(2) + spacing / 2.0});
214 {box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0, box.getLow(2) - spacing / 2.0},
215 {box.getHigh(0) + spacing / 2.0, box.getLow(1) + spacing / 2.0, box.getHigh(2) + spacing / 2.0});
218 {box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0, box.getLow(2) - spacing / 2.0},
219 {box.getLow(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0, box.getHigh(2) + spacing / 2.0});
222 {box.getHigh(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0, box.getLow(2) - spacing / 2.0},
223 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0, box.getHigh(2) + spacing / 2.0});
226 {box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0, box.getLow(2) - spacing / 2.0},
227 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0, box.getLow(2) + spacing / 2.0});
230 {box.getLow(0) - spacing / 2.0, box.getLow(1) - spacing / 2.0, box.getHigh(2) - spacing / 2.0},
231 {box.getHigh(0) + spacing / 2.0, box.getHigh(1) + spacing / 2.0, box.getHigh(2) + spacing / 2.0});
243 auto Particles=domain;
244 auto it2 = Particles.getDomainIterator();
246 while (it2.isNext()) {
249 domain.getProp<1>(p) = -3.0*M_PI*M_PI*sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1))*sin(M_PI*xp.
get(2));
250 domain.getProp<3>(p) = sin(M_PI*xp.
get(0))*sin(M_PI*xp.
get(1))*sin(M_PI*xp.
get(2));
251 if (front.isInside(xp) ==
true) {
253 front_p.last().get<0>() = p.getKey();
254 }
else if (back.isInside(xp) ==
true) {
256 back_p.last().get<0>() = p.getKey();
257 }
else if (left.isInside(xp) ==
true) {
259 left_p.last().get<0>() = p.getKey();
260 }
else if (right.isInside(xp) ==
true) {
262 right_p.last().get<0>() = p.getKey();
263 }
else if (up.isInside(xp) ==
true) {
265 up_p.last().get<0>() = p.getKey();
266 }
else if (down.isInside(xp) ==
true) {
268 down_p.last().get<0>() = p.getKey();
271 bulk.last().get<0>() = p.getKey();
277 DCPSE_scheme<
equations3d1,decltype(domain)> Solver( domain);
278 auto Poisson =
Lap(v);
293 v=abs(DCPSE_sol-RHS);
295 for(
int j=0;j<bulk.
size();j++)
296 {
auto p=bulk.get<0>(j);
297 if (fabs(domain.getProp<3>(p) - domain.getProp<2>(p)) >= worst1) {
298 worst1 = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
300 domain.getProp<4>(p) = fabs(domain.getProp<3>(p) - domain.getProp<2>(p));
306 BOOST_REQUIRE(worst1 < 0.031);
629 BOOST_AUTO_TEST_SUITE_END()
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Laplacian second order on h (spacing)
This class represent an N-dimensional box.
Test structure used for several test.
Implementation of 1-D std::vector like structure.