OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
DCPSE_op_test_temporal.cu
1/*
2 * DCPSE_op_test_temporal.cpp
3 *
4 * Created on: Sep 15, 2020
5 * Author: i-bird
6 */
7#include "config.h"
8#ifdef HAVE_EIGEN
9#ifdef HAVE_PETSC
10
11#ifndef DCPSE_OP_TEST_TEMPORAL_CPP_
12#define DCPSE_OP_TEST_TEMPORAL_CPP_
13
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
17#include "Operators/Vector/vector_dist_operators.hpp"
18#include "../DCPSE_op.hpp"
19
20BOOST_AUTO_TEST_SUITE(temporal_test_suite_cu)
21 BOOST_AUTO_TEST_CASE(temporal_test)
22 {
23 size_t grd_sz = 12;
24 double boxsize = 10;
25 const size_t sz[3] = {grd_sz, grd_sz, grd_sz};
26 Box<3, double> box({0, 0, 0}, {boxsize, boxsize, boxsize});
27 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC, NON_PERIODIC};
28 double Lx = box.getHigh(0);
29 double Ly = box.getHigh(1);
30 double Lz = box.getHigh(2);
31 double spacing = box.getHigh(0) / (sz[0] - 1);
32 double rCut = 3.9 * spacing;
33 double rCut2 = 3.9 * spacing;
34 int ord = 2;
35 int ord2 = 2;
36 double sampling_factor = 4.0;
37 double sampling_factor2 = 2.4;
38 Ghost<3, double> ghost(rCut);
39 auto &v_cl = create_vcluster();
40
41 vector_dist_gpu<3, double, aggregate<double,VectorS<3, double>,double[3][3],double,VectorS<3,double>,double[3][3]> > Particles(0, box, bc, ghost);
42
43 auto it = Particles.getGridIterator(sz);
44 while (it.isNext())
45 {
46 Particles.add();
47 auto key = it.get();
48 double x = key.get(0) * it.getSpacing(0);
49 Particles.getLastPos()[0] = x;
50 double y = key.get(1) * it.getSpacing(1);
51 Particles.getLastPos()[1] = y;
52 double z = key.get(2) * it.getSpacing(1);
53 Particles.getLastPos()[2] = z;
54 ++it;
55 }
56
57 Particles.map();
58 Particles.ghost_get<0>();
59
60 constexpr int x = 0;
61 constexpr int y = 1;
62 constexpr int z = 2;
63
64
65 constexpr int sScalar = 0;
66 constexpr int sVector = 1;
67 constexpr int sTensor = 2;
68 constexpr int dScalar = 3;
69 constexpr int dVector = 4;
70 constexpr int dTensor = 5;
71 auto Pos = getV<PROP_POS>(Particles);
72 auto sS = getV<sScalar>(Particles);
73 auto sV = getV<sVector>(Particles);
74 auto sT = getV<sTensor>(Particles);
75 auto dS = getV<dScalar>(Particles);
76 auto dV = getV<dVector>(Particles);
77 auto dT = getV<dTensor>(Particles);
78
79 //Particles_subset.write("Pars");
80 Derivative_x_gpu Dx(Particles, ord, rCut, sampling_factor, support_options::RADIUS), Bulk_Dx(Particles, ord,
81 rCut, sampling_factor,
82 support_options::RADIUS);
83 texp_v<double> TVx,TdxVx;
86
87
88 auto it3 = Particles.getDomainIterator();
89
90 sS = 5;
91 sV[0] = 1;
92 sV[1] = 2;
93 sV[2] = 3;
94 sT[0][0] = 1;
95 sT[0][1] = 2;
96 sT[0][2] = 3;
97 sT[1][0] = 4;
98 sT[1][1] = 5;
99 sT[1][2] = 6;
100 sT[2][0] = 7;
101 sT[2][1] = 8;
102 sT[2][2] = 9;
103 TVx=sS;
104 dS = TVx;
105
106 {
107 auto it3 = Particles.getDomainIterator();
108
109 bool match = true;
110 while (it3.isNext())
111 {
112 auto key = it3.get();
113
114 match &= Particles.template getProp<sScalar>(key) == Particles.template getProp<dScalar>(key);
115
116 ++it3;
117 }
118
119 BOOST_REQUIRE_EQUAL(match,true);
120 }
121
122
123 TVx=sS*sS;
124 dS = TVx;
125
126 {
127 auto it3 = Particles.getDomainIterator();
128
129 bool match = true;
130 while (it3.isNext())
131 {
132 auto key = it3.get();
133
134 match &= Particles.template getProp<sScalar>(key)*Particles.template getProp<sScalar>(key) == Particles.template getProp<dScalar>(key);
135
136 ++it3;
137 }
138
139 BOOST_REQUIRE_EQUAL(match,true);
140 }
141
142 TVx=sV[0];
143 dS = TVx;
144
145 {
146 auto it3 = Particles.getDomainIterator();
147
148 bool match = true;
149 while (it3.isNext())
150 {
151 auto key = it3.get();
152
153 match &= Particles.template getProp<sVector>(key)[0] == Particles.template getProp<dScalar>(key);
154
155 ++it3;
156 }
157 BOOST_REQUIRE_EQUAL(match,true);
158 }
159
160 TVx=sT[0][0];
161 dS = TVx;
162 {
163 auto it3 = Particles.getDomainIterator();
164
165 bool match = true;
166 while (it3.isNext())
167 {
168 auto key = it3.get();
169
170 match &= Particles.template getProp<sVector>(key)[0] == Particles.template getProp<dScalar>(key);
171
172 ++it3;
173 }
174 BOOST_REQUIRE_EQUAL(match,true);
175 }
176
177 TV=sV;
178 dV=TV;
179
180 {
181 auto it3 = Particles.getDomainIterator();
182
183 bool match = true;
184 while (it3.isNext())
185 {
186 auto key = it3.get();
187
188 match &= Particles.template getProp<sVector>(key)[0] == Particles.template getProp<dVector>(key)[0];
189 match &= Particles.template getProp<sVector>(key)[1] == Particles.template getProp<dVector>(key)[1];
190 match &= Particles.template getProp<sVector>(key)[2] == Particles.template getProp<dVector>(key)[2];
191
192 ++it3;
193 }
194 BOOST_REQUIRE_EQUAL(match,true);
195 }
196
197 TV=0.5*sV+sV;
198 dV=TV;
199 //Pol_bulk = dPol + (0.5 * dt) * k1;
200 {
201 auto it3 = Particles.getDomainIterator();
202
203 bool match = true;
204 while (it3.isNext())
205 {
206 auto key = it3.get();
207 double x1=Particles.template getProp<sVector>(key)[0];
208 double y1=Particles.template getProp<dVector>(key)[0];
209 double x2=Particles.template getProp<sVector>(key)[1];
210 double y2=Particles.template getProp<dVector>(key)[1];
211 double x3=Particles.template getProp<sVector>(key)[2];
212 double y3=Particles.template getProp<dVector>(key)[2];
213
214 match &= 1.5*Particles.template getProp<sVector>(key)[0] == Particles.template getProp<dVector>(key)[0];
215 match &= 1.5*Particles.template getProp<sVector>(key)[1] == Particles.template getProp<dVector>(key)[1];
216 match &= 1.5*Particles.template getProp<sVector>(key)[2] == Particles.template getProp<dVector>(key)[2];
217
218 ++it3;
219 }
220 BOOST_REQUIRE_EQUAL(match,true);
221 }
222
223 TV=sV;
224 dV=pmul(TV,TV);
225 //Pol_bulk = dPol + (0.5 * dt) * k1;
226 {
227 auto it3 = Particles.getDomainIterator();
228
229 bool match = true;
230 while (it3.isNext())
231 {
232 auto key = it3.get();
233 double x1=Particles.template getProp<sVector>(key)[0];
234 double y1=Particles.template getProp<dVector>(key)[0];
235 double x2=Particles.template getProp<sVector>(key)[1];
236 double y2=Particles.template getProp<dVector>(key)[1];
237 double x3=Particles.template getProp<sVector>(key)[2];
238 double y3=Particles.template getProp<dVector>(key)[2];
239
240 match &= Particles.template getProp<sVector>(key)[0]*Particles.template getProp<sVector>(key)[0] == Particles.template getProp<dVector>(key)[0];
241 match &= Particles.template getProp<sVector>(key)[1]*Particles.template getProp<sVector>(key)[1] == Particles.template getProp<dVector>(key)[1];
242 match &= Particles.template getProp<sVector>(key)[2]*Particles.template getProp<sVector>(key)[2] == Particles.template getProp<dVector>(key)[2];
243
244 ++it3;
245 }
246 //THERE IS A BUG HERE IT IS SUMMING THE VECTORS.
247 BOOST_REQUIRE_EQUAL(match,true);
248 }
249
250/*
251 TdxVx=Dx(sV[x]);
252 TT[0][0] = Dx(sV[x]);*/
253
254 }
255
256BOOST_AUTO_TEST_SUITE_END()
257
258#endif /* DCPSE_OP_TEST_TEMPORAL_CPP_ */
259#endif
260#endif
This class represent an N-dimensional box.
Definition Box.hpp:61
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
Main class that encapsulate a vector properties operand to be used for expressions construction.
Distributed vector.