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