OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
SparseGrid_chunk_copy_unit_tests.cpp
1 /*
2  * SparseGrid_chunk_copy_unit_tests.cpp
3  *
4  * Created on: Mar 18, 2020
5  * Author: i-bird
6  */
7 
8 
9 #define DISABLE_MPI_WRITTERS
10 
11 #define BOOST_TEST_DYN_LINK
12 #include <boost/test/unit_test.hpp>
13 #include "SparseGrid/SparseGrid.hpp"
14 #include "NN/CellList/CellDecomposer.hpp"
15 #include <math.h>
16 //#include "util/debug.hpp"
17 #include "SparseGrid_chunk_copy.hpp"
18 
19 BOOST_AUTO_TEST_SUITE( sparse_grid_chunk_copy_test )
20 
22 {
23  typedef boost::mpl::vector<boost::mpl::int_<64>,
24  boost::mpl::int_<8>,
25  boost::mpl::int_<4>> type;
26 
27  typedef boost::mpl::vector<boost::mpl::int_<6>,
28  boost::mpl::int_<3>,
29  boost::mpl::int_<2>> shift;
30 
31  typedef boost::mpl::vector<boost::mpl::int_<6>,
32  boost::mpl::int_<9>,
33  boost::mpl::int_<11>> shift_c;
34 
35  typedef boost::mpl::int_<2048> size;
36 };
37 
38 BOOST_AUTO_TEST_CASE( sparse_grid_chunk_test )
39 {
40  typedef aggregate<double> T;
41 
42  typedef typename v_transform_two_v2<Ft_chunk,boost::mpl::int_<test_chunking3::size::value>,typename T::type>::type chunk_def;
43 
44  double chunk_with_border[66*10*6];
45  unsigned char mask[66*10*6];
46 
47  memset(chunk_with_border,0,sizeof(double)*66*10*6);
48 
51  chunks.resize(1);
52 
53  mheader<4096> h;
54 
55  memset(&h.mask[0],0xFF,4096);
56 
57  for (int i = 0 ; i < test_chunking3::size::value ; i++)
58  {chunks.template get<0>(0)[i] = i;}
59 
60  // Ok now copy XY
61 
62  copy_xy_3<0,0,1,test_chunking3,true>::copy<3,0,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
63  copy_xy_3<0,0,1,test_chunking3,true>::copy<0,5,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
64 
65  // check
66  for (int k = 1 ; k < 9 ; k++)
67  {
68  for (int j = 1 ; j < 65 ; j++)
69  {
70  BOOST_REQUIRE_EQUAL(chunk_with_border[k*66+j],chunks.template get<0>(0)[3*64*8 + (k-1)*64 + (j-1)]);
71  }
72  }
73 
74  for (int k = 1 ; k < 9 ; k++)
75  {
76  for (int j = 1 ; j < 65 ; j++)
77  {
78  BOOST_REQUIRE_EQUAL(chunk_with_border[5*66*10+k*66+j],chunks.template get<0>(0)[(k-1)*64 + (j-1)]);
79  }
80  }
81 
82 
83  memset(chunk_with_border,0,sizeof(double)*66*10*6);
84  // OK now copy XZ
85 
86  copy_xz_3<0,0,1,test_chunking3,true>::copy<7,0,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
87  copy_xz_3<0,0,1,test_chunking3,true>::copy<0,9,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
88 
89  // check
90  for (int i = 1 ; i < 5 ; i++)
91  {
92  for (int j = 1 ; j < 65 ; j++)
93  {
94  BOOST_REQUIRE_EQUAL(chunk_with_border[i*66*10+j],chunks.template get<0>(0)[(i-1)*64*8 + 7*64 + (j-1)]);
95  }
96  }
97 
98  for (int i = 1 ; i < 5 ; i++)
99  {
100  for (int j = 1 ; j < 65 ; j++)
101  {
102  BOOST_REQUIRE_EQUAL(chunk_with_border[i*66*10+9*66+j],chunks.template get<0>(0)[(i-1)*64*8 + 0*64 + (j-1)]);
103  }
104  }
105 
106  memset(chunk_with_border,0,sizeof(double)*66*10*6);
107  // OK now copy YZ
108 
109  copy_yz_3<0,0,1,test_chunking3,true>::copy<63,0,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
110  copy_yz_3<0,0,1,test_chunking3,true>::copy<0,65,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
111 
112  // check
113  for (int i = 1 ; i < 5 ; i++)
114  {
115  for (int j = 1 ; j < 9 ; j++)
116  {
117  BOOST_REQUIRE_EQUAL(chunk_with_border[i*66*10+j*66],chunks.template get<0>(0)[(i-1)*64*8 + (j-1)*64 + 63]);
118  }
119  }
120 
121  for (int i = 1 ; i < 5 ; i++)
122  {
123  for (int j = 1 ; j < 9 ; j++)
124  {
125  BOOST_REQUIRE_EQUAL(chunk_with_border[i*66*10+j*66+65],chunks.template get<0>(0)[(i-1)*64*8 + (j-1)*64]);
126  }
127  }
128 
129  // OK now copy x
130 
131  memset(chunk_with_border,0,sizeof(double)*66*10*6);
132 
133  copy_x_3<0,0,1,test_chunking3,false>::copy<3,0,7,0,66*10*6>(chunk_with_border,chunks.get(0));
134  copy_x_3<0,0,1,test_chunking3,false>::copy<0,5,7,0,66*10*6>(chunk_with_border,chunks.get(0));
135  copy_x_3<0,0,1,test_chunking3,false>::copy<3,0,0,9,66*10*6>(chunk_with_border,chunks.get(0));
136  copy_x_3<0,0,1,test_chunking3,false>::copy<0,5,0,9,66*10*6>(chunk_with_border,chunks.get(0));
137 
138  // check
139  for (int k = 1 ; k < 65 ; k++)
140  {
141  BOOST_REQUIRE_EQUAL(chunk_with_border[0*66*10+0*66+k],chunks.template get<0>(0)[3*64*8 + 7*64 + (k-1)]);
142  }
143 
144  for (int k = 1 ; k < 65 ; k++)
145  {
146  BOOST_REQUIRE_EQUAL(chunk_with_border[5*66*10+0*66+k],chunks.template get<0>(0)[0*64*8 + 7*64+(k-1)]);
147  }
148 
149  // check
150  for (int k = 1 ; k < 65 ; k++)
151  {
152  BOOST_REQUIRE_EQUAL(chunk_with_border[0*66*10+9*66+k],chunks.template get<0>(0)[3*64*8 + 0*64 + (k-1)]);
153  }
154 
155  for (int k = 1 ; k < 65 ; k++)
156  {
157  BOOST_REQUIRE_EQUAL(chunk_with_border[5*66*10+9*66+k],chunks.template get<0>(0)[0*64*8 + 0*64 + (k-1)]);
158  }
159 }
160 
161 
162 BOOST_AUTO_TEST_CASE( sparse_grid_chunk_test_2 )
163 {
164  typedef aggregate<double> T;
165 
166  typedef typename v_transform_two_v2<Ft_chunk,boost::mpl::int_<test_chunking3::size::value>,typename T::type>::type chunk_def;
167 
168  double chunk_with_border[68*12*8];
169  unsigned char mask[68*12*8];
170 
171  memset(chunk_with_border,0,sizeof(double)*68*12*8);
172 
175 
176  chunks.resize(1);
177 
178  mheader<4096> h;
179  memset(&h.mask[0],0xFF,4096);
180 
181  for (int i = 0 ; i < test_chunking3::size::value ; i++)
182  {chunks.template get<0>(0)[i] = i;}
183 
184  // Ok now copy XY
185 
186  copy_xy_3<0,0,2,test_chunking3,true>::copy<2,0,68*12*8>(chunk_with_border,mask,h,chunks.get(0));
187  copy_xy_3<0,0,2,test_chunking3,true>::copy<0,6,68*12*8>(chunk_with_border,mask,h,chunks.get(0));
188 
189  // check
190  for (int s = 0 ; s < 2 ; s++)
191  {
192  for (int k = 2 ; k < 10 ; k++)
193  {
194  for (int j = 2 ; j < 66 ; j++)
195  {
196  BOOST_REQUIRE_EQUAL(chunk_with_border[s*68*12 + k*68+j],chunks.template get<0>(0)[s*64*8 + 2*64*8 + (k-2)*64 + (j-2)]);
197  }
198  }
199  }
200 
201  for (int s = 0 ; s < 2 ; s++)
202  {
203  for (int k = 2 ; k < 10 ; k++)
204  {
205  for (int j = 2 ; j < 66 ; j++)
206  {
207  BOOST_REQUIRE_EQUAL(chunk_with_border[(6+s)*68*12 + k*68+j],chunks.template get<0>(0)[s*64*8 + 0*64*8 + (k-2)*64 + (j-2)]);
208  }
209  }
210  }
211 
212  memset(chunk_with_border,0,sizeof(double)*68*12*8);
213  // OK now copy XZ
214 
215  copy_xz_3<0,0,2,test_chunking3,true>::copy<6,0,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
216  copy_xz_3<0,0,2,test_chunking3,true>::copy<0,10,66*10*6>(chunk_with_border,mask,h,chunks.get(0));
217 
218  // check
219  for (int s = 0 ; s < 2 ; s++)
220  {
221  for (int i = 2 ; i < 6 ; i++)
222  {
223  for (int j = 2 ; j < 66 ; j++)
224  {
225  BOOST_REQUIRE_EQUAL(chunk_with_border[i*68*12 + (0+s)*68 +j],chunks.template get<0>(0)[(i-2)*64*8 + (6+s)*64 + (j-2)]);
226  }
227  }
228  }
229 
230  // check
231  for (int s = 0 ; s < 2 ; s++)
232  {
233  for (int i = 2 ; i < 6 ; i++)
234  {
235  for (int j = 2 ; j < 66 ; j++)
236  {
237  BOOST_REQUIRE_EQUAL(chunk_with_border[i*68*12 + (10+s)*68 +j],chunks.template get<0>(0)[(i-2)*64*8 + (0+s)*64 + (j-2)]);
238  }
239  }
240  }
241 
242  memset(chunk_with_border,0,sizeof(double)*68*12*8);
243  // OK now copy YZ
244 
245  copy_yz_3<0,0,2,test_chunking3,true>::copy<62,0,68*12*8>(chunk_with_border,mask,h,chunks.get(0));
246  copy_yz_3<0,0,2,test_chunking3,true>::copy<0,66,68*12*8>(chunk_with_border,mask,h,chunks.get(0));
247 
248  // check
249  for (int s = 0 ; s < 2 ; s++)
250  {
251  for (int i = 2 ; i < 6 ; i++)
252  {
253  for (int j = 2 ; j < 10 ; j++)
254  {
255  BOOST_REQUIRE_EQUAL(chunk_with_border[i*68*12+j*68+s],chunks.template get<0>(0)[(i-2)*64*8 + (j-2)*64 + 62+s]);
256  }
257  }
258  }
259 
260  for (int s = 0 ; s < 2 ; s++)
261  {
262  for (int i = 2 ; i < 6 ; i++)
263  {
264  for (int j = 2 ; j < 10 ; j++)
265  {
266  BOOST_REQUIRE_EQUAL(chunk_with_border[i*68*12+j*68+s+66],chunks.template get<0>(0)[(i-2)*64*8 + (j-2)*64 + 0+s]);
267  }
268  }
269  }
270 
271  // OK now copy x
272 
273  memset(chunk_with_border,0,sizeof(double)*68*12*8);
274 
275  copy_x_3<0,0,2,test_chunking3,false>::copy<2,0,6,0,68*12*8>(chunk_with_border,chunks.get(0));
276  copy_x_3<0,0,2,test_chunking3,false>::copy<0,6,6,0,68*12*8>(chunk_with_border,chunks.get(0));
277  copy_x_3<0,0,2,test_chunking3,false>::copy<2,0,0,10,68*12*8>(chunk_with_border,chunks.get(0));
278  copy_x_3<0,0,2,test_chunking3,false>::copy<0,6,0,10,68*12*8>(chunk_with_border,chunks.get(0));
279 
280  // check
281  for (int k = 2 ; k < 66 ; k++)
282  {
283  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+0*68+k],chunks.template get<0>(0)[2*64*8 + 6*64 + (k-2)]);
284  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+0*68+k],chunks.template get<0>(0)[3*64*8 + 6*64 + (k-2)]);
285  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+1*68+k],chunks.template get<0>(0)[2*64*8 + 7*64 + (k-2)]);
286  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+1*68+k],chunks.template get<0>(0)[3*64*8 + 7*64 + (k-2)]);
287  }
288 
289  for (int k = 2 ; k < 66 ; k++)
290  {
291  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+0*68+k],chunks.template get<0>(0)[0*64*8 + 6*64 + (k-2)]);
292  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+0*68+k],chunks.template get<0>(0)[1*64*8 + 6*64 + (k-2)]);
293  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+1*68+k],chunks.template get<0>(0)[0*64*8 + 7*64 + (k-2)]);
294  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+1*68+k],chunks.template get<0>(0)[1*64*8 + 7*64 + (k-2)]);
295  }
296 
297  // check
298  for (int k = 2 ; k < 66 ; k++)
299  {
300  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+10*68+k],chunks.template get<0>(0)[2*64*8 + 0*64 + (k-2)]);
301  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+10*68+k],chunks.template get<0>(0)[3*64*8 + 0*64 + (k-2)]);
302  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+11*68+k],chunks.template get<0>(0)[2*64*8 + 1*64 + (k-2)]);
303  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+11*68+k],chunks.template get<0>(0)[3*64*8 + 1*64 + (k-2)]);
304  }
305 
306  for (int k = 2 ; k < 66 ; k++)
307  {
308  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+10*68+k],chunks.template get<0>(0)[0*64*8 + 0*64 + (k-2)]);
309  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+10*68+k],chunks.template get<0>(0)[1*64*8 + 0*64 + (k-2)]);
310  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+11*68+k],chunks.template get<0>(0)[0*64*8 + 1*64 + (k-2)]);
311  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+11*68+k],chunks.template get<0>(0)[1*64*8 + 1*64 + (k-2)]);
312  }
313 
314  // OK now copy y
315 
316  memset(chunk_with_border,0,sizeof(double)*68*12*8);
317 
318  copy_y_3<0,0,2,test_chunking3,false>::copy<2,0,62,0,68*12*8>(chunk_with_border,chunks.get(0));
319  copy_y_3<0,0,2,test_chunking3,false>::copy<0,6,62,0,68*12*8>(chunk_with_border,chunks.get(0));
320  copy_y_3<0,0,2,test_chunking3,false>::copy<2,0,0,66,68*12*8>(chunk_with_border,chunks.get(0));
321  copy_y_3<0,0,2,test_chunking3,false>::copy<0,6,0,66,68*12*8>(chunk_with_border,chunks.get(0));
322 
323  // check
324  for (int j = 2 ; j < 10 ; j++)
325  {
326  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+0],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 62]);
327  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+0],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 62]);
328  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+1],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 63]);
329  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+1],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 63]);
330  }
331 
332  for (int j = 2 ; j < 10 ; j++)
333  {
334  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+0],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 62]);
335  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+0],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 62]);
336  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+1],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 63]);
337  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+1],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 63]);
338  }
339 
340  // check
341  for (int j = 2 ; j < 10 ; j++)
342  {
343  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+66],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 0]);
344  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+66],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 0]);
345  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+j*68+67],chunks.template get<0>(0)[2*64*8 + (j-2)*64 + 1]);
346  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+j*68+67],chunks.template get<0>(0)[3*64*8 + (j-2)*64 + 1]);
347  }
348 
349  for (int j = 2 ; j < 10 ; j++)
350  {
351  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+j*68+66],chunks.template get<0>(0)[0*64*8 + (j-2)*64 + 0]);
352  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+j*68+66],chunks.template get<0>(0)[1*64*8 + (j-2)*64 + 0]);
353  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+j*68+67],chunks.template get<0>(0)[0*64*8 + (j-2)*64 + 1]);
354  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+j*68+67],chunks.template get<0>(0)[1*64*8 + (j-2)*64 + 1]);
355  }
356 
357  // OK now copy Z
358 
359  memset(chunk_with_border,0,sizeof(double)*68*12*8);
360 
361  copy_z_3<0,0,2,test_chunking3,false>::copy<6,0,62,0,68*12*8>(chunk_with_border,chunks.get(0));
362  copy_z_3<0,0,2,test_chunking3,false>::copy<0,10,62,0,68*12*8>(chunk_with_border,chunks.get(0));
363  copy_z_3<0,0,2,test_chunking3,false>::copy<6,0,0,66,68*12*8>(chunk_with_border,chunks.get(0));
364  copy_z_3<0,0,2,test_chunking3,false>::copy<0,10,0,66,68*12*8>(chunk_with_border,chunks.get(0));
365 
366  // check
367 /* for (int j = 2 ; j < 6 ; j++)
368  {
369  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+0*68+0],chunks.template get<0>(0)[(j-2)*64*8 + 6*64 + 62]);
370  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+1*68+0],chunks.template get<0>(0)[(j-2)*64*8 + 7*64 + 62]);
371  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+0*68+1],chunks.template get<0>(0)[(j-2)*64*8 + 6*64 + 63]);
372  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+1*68+1],chunks.template get<0>(0)[(j-2)*64*8 + 7*64 + 63]);
373  }*/
374 
375 /* for (int j = 2 ; j < 6 ; j++)
376  {
377  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+10*68+0],chunks.template get<0>(0)[(j-2)*64*8 + 0*64 + 62]);
378  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+11*68+0],chunks.template get<0>(0)[(j-2)*64*8 + 1*64 + 62]);
379  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+10*68+1],chunks.template get<0>(0)[(j-2)*64*8 + 0*64 + 63]);
380  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+11*68+1],chunks.template get<0>(0)[(j-2)*64*8 + 1*64 + 63]);
381  }
382 
383  // check
384  for (int j = 2 ; j < 6 ; j++)
385  {
386  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+0*68+66],chunks.template get<0>(0)[(j-2)*64*8 + 6*64 + 0]);
387  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+1*68+66],chunks.template get<0>(0)[(j-2)*64*8 + 7*64 + 0]);
388  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+0*68+67],chunks.template get<0>(0)[(j-2)*64*8 + 6*64 + 1]);
389  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+1*68+67],chunks.template get<0>(0)[(j-2)*64*8 + 7*64 + 1]);
390  }
391 
392  for (int j = 2 ; j < 6 ; j++)
393  {
394  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+10*68+66],chunks.template get<0>(0)[(j-2)*64*8 + 0*64 + 0]);
395  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+11*68+66],chunks.template get<0>(0)[(j-2)*64*8 + 1*64 + 0]);
396  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+10*68+67],chunks.template get<0>(0)[(j-2)*64*8 + 0*64 + 1]);
397  BOOST_REQUIRE_EQUAL(chunk_with_border[j*68*12+11*68+67],chunks.template get<0>(0)[(j-2)*64*8 + 1*64 + 1]);
398  }*/
399 
400  // Copy corner
401 
402 /* memset(chunk_with_border,0,sizeof(double)*68*12*8);
403 
404  copy_corner_3<0,0,2,test_chunking3,false>::copy<2,0,6,0,62,0,68*12*8>(chunk_with_border,chunks.get(0));
405  copy_corner_3<0,0,2,test_chunking3,false>::copy<2,0,6,0,0,66,68*12*8>(chunk_with_border,chunks.get(0));
406  copy_corner_3<0,0,2,test_chunking3,false>::copy<2,0,0,10,62,0,68*12*8>(chunk_with_border,chunks.get(0));
407  copy_corner_3<0,0,2,test_chunking3,false>::copy<2,0,0,10,0,66,68*12*8>(chunk_with_border,chunks.get(0));
408 
409  copy_corner_3<0,0,2,test_chunking3,false>::copy<0,6,6,0,62,0,68*12*8>(chunk_with_border,chunks.get(0));
410  copy_corner_3<0,0,2,test_chunking3,false>::copy<0,6,6,0,0,66,68*12*8>(chunk_with_border,chunks.get(0));
411  copy_corner_3<0,0,2,test_chunking3,false>::copy<0,6,0,10,62,0,68*12*8>(chunk_with_border,chunks.get(0));
412  copy_corner_3<0,0,2,test_chunking3,false>::copy<0,6,0,10,0,66,68*12*8>(chunk_with_border,chunks.get(0));
413 
414 
415  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+0*68+0],chunks.template get<0>(0)[2*64*8 + 6*64 + 62]);
416  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+0*68+1],chunks.template get<0>(0)[2*64*8 + 6*64 + 63]);
417  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+1*68+0],chunks.template get<0>(0)[2*64*8 + 7*64 + 62]);
418  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+1*68+1],chunks.template get<0>(0)[2*64*8 + 7*64 + 63]);
419  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+0*68+0],chunks.template get<0>(0)[3*64*8 + 6*64 + 62]);
420  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+0*68+1],chunks.template get<0>(0)[3*64*8 + 6*64 + 63]);
421  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+1*68+0],chunks.template get<0>(0)[3*64*8 + 7*64 + 62]);
422  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+1*68+1],chunks.template get<0>(0)[3*64*8 + 7*64 + 63]);
423 
424  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+0*68+66],chunks.template get<0>(0)[2*64*8 + 6*64 + 0]);
425  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+0*68+67],chunks.template get<0>(0)[2*64*8 + 6*64 + 1]);
426  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+1*68+66],chunks.template get<0>(0)[2*64*8 + 7*64 + 0]);
427  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+1*68+67],chunks.template get<0>(0)[2*64*8 + 7*64 + 1]);
428  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+0*68+66],chunks.template get<0>(0)[3*64*8 + 6*64 + 0]);
429  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+0*68+67],chunks.template get<0>(0)[3*64*8 + 6*64 + 1]);
430  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+1*68+66],chunks.template get<0>(0)[3*64*8 + 7*64 + 0]);
431  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+1*68+67],chunks.template get<0>(0)[3*64*8 + 7*64 + 1]);
432 
433  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+10*68+0],chunks.template get<0>(0)[2*64*8 + 0*64 + 62]);
434  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+10*68+1],chunks.template get<0>(0)[2*64*8 + 0*64 + 63]);
435  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+11*68+0],chunks.template get<0>(0)[2*64*8 + 1*64 + 62]);
436  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+11*68+1],chunks.template get<0>(0)[2*64*8 + 1*64 + 63]);
437  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+10*68+0],chunks.template get<0>(0)[3*64*8 + 0*64 + 62]);
438  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+10*68+1],chunks.template get<0>(0)[3*64*8 + 0*64 + 63]);
439  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+11*68+0],chunks.template get<0>(0)[3*64*8 + 1*64 + 62]);
440  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+11*68+1],chunks.template get<0>(0)[3*64*8 + 1*64 + 63]);
441 
442  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+10*68+66],chunks.template get<0>(0)[2*64*8 + 0*64 + 0]);
443  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+10*68+67],chunks.template get<0>(0)[2*64*8 + 0*64 + 1]);
444  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+11*68+66],chunks.template get<0>(0)[2*64*8 + 1*64 + 0]);
445  BOOST_REQUIRE_EQUAL(chunk_with_border[0*68*12+11*68+67],chunks.template get<0>(0)[2*64*8 + 1*64 + 1]);
446  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+10*68+66],chunks.template get<0>(0)[3*64*8 + 0*64 + 0]);
447  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+10*68+67],chunks.template get<0>(0)[3*64*8 + 0*64 + 1]);
448  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+11*68+66],chunks.template get<0>(0)[3*64*8 + 1*64 + 0]);
449  BOOST_REQUIRE_EQUAL(chunk_with_border[1*68*12+11*68+67],chunks.template get<0>(0)[3*64*8 + 1*64 + 1]);
450 
452 
453  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+0*68+0],chunks.template get<0>(0)[0*64*8 + 6*64 + 62]);
454  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+0*68+1],chunks.template get<0>(0)[0*64*8 + 6*64 + 63]);
455  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+1*68+0],chunks.template get<0>(0)[0*64*8 + 7*64 + 62]);
456  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+1*68+1],chunks.template get<0>(0)[0*64*8 + 7*64 + 63]);
457  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+0*68+0],chunks.template get<0>(0)[1*64*8 + 6*64 + 62]);
458  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+0*68+1],chunks.template get<0>(0)[1*64*8 + 6*64 + 63]);
459  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+1*68+0],chunks.template get<0>(0)[1*64*8 + 7*64 + 62]);
460  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+1*68+1],chunks.template get<0>(0)[1*64*8 + 7*64 + 63]);
461 
462  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+0*68+66],chunks.template get<0>(0)[0*64*8 + 6*64 + 0]);
463  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+0*68+67],chunks.template get<0>(0)[0*64*8 + 6*64 + 1]);
464  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+1*68+66],chunks.template get<0>(0)[0*64*8 + 7*64 + 0]);
465  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+1*68+67],chunks.template get<0>(0)[0*64*8 + 7*64 + 1]);
466  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+0*68+66],chunks.template get<0>(0)[1*64*8 + 6*64 + 0]);
467  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+0*68+67],chunks.template get<0>(0)[1*64*8 + 6*64 + 1]);
468  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+1*68+66],chunks.template get<0>(0)[1*64*8 + 7*64 + 0]);
469  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+1*68+67],chunks.template get<0>(0)[1*64*8 + 7*64 + 1]);
470 
471  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+10*68+0],chunks.template get<0>(0)[0*64*8 + 0*64 + 62]);
472  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+10*68+1],chunks.template get<0>(0)[0*64*8 + 0*64 + 63]);
473  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+11*68+0],chunks.template get<0>(0)[0*64*8 + 1*64 + 62]);
474  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+11*68+1],chunks.template get<0>(0)[0*64*8 + 1*64 + 63]);
475  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+10*68+0],chunks.template get<0>(0)[1*64*8 + 0*64 + 62]);
476  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+10*68+1],chunks.template get<0>(0)[1*64*8 + 0*64 + 63]);
477  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+11*68+0],chunks.template get<0>(0)[1*64*8 + 1*64 + 62]);
478  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+11*68+1],chunks.template get<0>(0)[1*64*8 + 1*64 + 63]);
479 
480  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+10*68+66],chunks.template get<0>(0)[0*64*8 + 0*64 + 0]);
481  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+10*68+67],chunks.template get<0>(0)[0*64*8 + 0*64 + 1]);
482  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+11*68+66],chunks.template get<0>(0)[0*64*8 + 1*64 + 0]);
483  BOOST_REQUIRE_EQUAL(chunk_with_border[6*68*12+11*68+67],chunks.template get<0>(0)[0*64*8 + 1*64 + 1]);
484  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+10*68+66],chunks.template get<0>(0)[1*64*8 + 0*64 + 0]);
485  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+10*68+67],chunks.template get<0>(0)[1*64*8 + 0*64 + 1]);
486  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+11*68+66],chunks.template get<0>(0)[1*64*8 + 1*64 + 0]);
487  BOOST_REQUIRE_EQUAL(chunk_with_border[7*68*12+11*68+67],chunks.template get<0>(0)[1*64*8 + 1*64 + 1]);*/
488 }
489 
490 
491 BOOST_AUTO_TEST_CASE( sparse_grid_chunk_missalign_copy_test )
492 {
493  unsigned char mp[16*16*16];
494  short int mp_off[16*16*16];
495 
496  // Aligned
497  Box<3,long int> box_src({17,19,3},{18,100,100});
498  Box<3,long int> box_dst({33,19,3},{34,100,100});
499 
501 
502  construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src,box_dst,vk);
503 
504  size_t sz[3] = {16,16,16};
505  grid_sm<3,void> g_sm(sz);
506 
507  for (int i = 0 ; i < 16 ; i++)
508  {
509  for (int j = 0 ; j < 16 ; j++)
510  {
511  for (int k = 0 ; k < 16 ; k++)
512  {
513  size_t id = g_sm.Lin(k,j,i);
514 
515  BOOST_REQUIRE_EQUAL(mp[id],13);
516  BOOST_REQUIRE_EQUAL(mp_off[id],id);
517  }
518  }
519  }
520 
521  BOOST_REQUIRE_EQUAL(vk.size(),1);
522 
523  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(0),0);
524  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(1),0);
525  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(2),0);
526 
527  BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
528 
529  // Miss-Aligned
530  Box<3,long int> box_src2({17,19,3},{18,100,100});
531  Box<3,long int> box_dst2({34,19,3},{35,100,100});
532 
533  vk.clear();
534 
535  construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src2,box_dst2,vk);
536 
537  for (int i = 0 ; i < 16 ; i++)
538  {
539  for (int j = 0 ; j < 16 ; j++)
540  {
541  for (int k = 0 ; k < 16 ; k++)
542  {
543  size_t id = g_sm.Lin(i,j,k);
544 
545  if (k < 15)
546  {
547  BOOST_REQUIRE_EQUAL(mp[id],13);
548  BOOST_REQUIRE_EQUAL(mp_off[id],id+1);
549  }
550 
551  if (k == 15)
552  {
553  BOOST_REQUIRE_EQUAL(mp[id],14);
554  BOOST_REQUIRE_EQUAL(mp_off[id],j*16+i*16*16);
555  }
556  }
557  }
558  }
559 
560  BOOST_REQUIRE_EQUAL(vk.size(),1);
561 
562  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(0),0);
563  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(1),0);
564  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(2),0);
565 
566 
567  BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
568 
569 
570  // Miss-Aligned with 2 entry
571 
572  // Miss-Aligned
573  Box<3,long int> box_src3({17,19,3},{30,100,100});
574  Box<3,long int> box_dst3({34,19,3},{47,100,100});
575 
576  vk.clear();
577 
578  construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src3,box_dst3,vk);
579 
580  for (int i = 0 ; i < 16 ; i++)
581  {
582  for (int j = 0 ; j < 16 ; j++)
583  {
584  for (int k = 0 ; k < 16 ; k++)
585  {
586  size_t id = g_sm.Lin(i,j,k);
587 
588  if (k < 15)
589  {
590  BOOST_REQUIRE_EQUAL(mp[id],13);
591  BOOST_REQUIRE_EQUAL(mp_off[id],id+1);
592  }
593 
594  if (k == 15)
595  {
596  BOOST_REQUIRE_EQUAL(mp[id],14);
597  BOOST_REQUIRE_EQUAL(mp_off[id],j*16+i*16*16);
598  }
599  }
600  }
601  }
602 
603  BOOST_REQUIRE_EQUAL(vk.size(),2);
604 
605  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(0),0);
606  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(1),0);
607  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(2),0);
608 
609  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(0),1);
610  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(1),0);
611  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(2),0);
612 
613  BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
614 
615  // Miss-Aligned xy with 4 entry
616 
617  // Miss-Aligned
618  Box<3,long int> box_src4({17,19,3},{30,100,100});
619  Box<3,long int> box_dst4({34,20,3},{47,101,100});
620 
621  vk.clear();
622 
623  construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src4,box_dst4,vk);
624 
625  for (int i = 0 ; i < 16 ; i++)
626  {
627  for (int j = 0 ; j < 16 ; j++)
628  {
629  for (int k = 0 ; k < 16 ; k++)
630  {
631  size_t id = g_sm.Lin(i,j,k);
632 
633  if (k < 15)
634  {
635  if (j < 15)
636  {
637  BOOST_REQUIRE_EQUAL(mp[id],13);
638  BOOST_REQUIRE_EQUAL(mp_off[id],k+1+(j+1)*16+i*16*16);
639  }
640  else
641  {
642  BOOST_REQUIRE_EQUAL(mp[id],16);
643  BOOST_REQUIRE_EQUAL(mp_off[id],k+1+i*16*16);
644  }
645  }
646 
647  if (k == 15)
648  {
649  if (j < 15)
650  {
651  BOOST_REQUIRE_EQUAL(mp[id],14);
652  BOOST_REQUIRE_EQUAL(mp_off[id],(j+1)*16+i*16*16);
653  }
654  else
655  {
656  BOOST_REQUIRE_EQUAL(mp[id],17);
657  BOOST_REQUIRE_EQUAL(mp_off[id],i*16*16);
658  }
659  }
660  }
661  }
662  }
663 
664  BOOST_REQUIRE_EQUAL(vk.size(),4);
665 
666  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(0),0);
667  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(1),0);
668  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(2),0);
669 
670  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(0),1);
671  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(1),0);
672  BOOST_REQUIRE_EQUAL(vk.get(1).k.get(2),0);
673 
674  BOOST_REQUIRE_EQUAL(vk.get(2).k.get(0),0);
675  BOOST_REQUIRE_EQUAL(vk.get(2).k.get(1),1);
676  BOOST_REQUIRE_EQUAL(vk.get(2).k.get(2),0);
677 
678  BOOST_REQUIRE_EQUAL(vk.get(3).k.get(0),1);
679  BOOST_REQUIRE_EQUAL(vk.get(3).k.get(1),1);
680  BOOST_REQUIRE_EQUAL(vk.get(3).k.get(2),0);
681 
682  // Now check the opposite
683 
684  // Miss-Aligned
685  Box<3,long int> box_src5({17,19,3},{18,100,100});
686  Box<3,long int> box_dst5({32,19,3},{33,100,100});
687 
688  vk.clear();
689 
690  construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src5,box_dst5,vk);
691 
692  for (int i = 0 ; i < 16 ; i++)
693  {
694  for (int j = 0 ; j < 16 ; j++)
695  {
696  for (int k = 0 ; k < 16 ; k++)
697  {
698  size_t id = g_sm.Lin(i,j,k);
699 
700  if (k == 0)
701  {
702  BOOST_REQUIRE_EQUAL(mp[id],12);
703  BOOST_REQUIRE_EQUAL(mp_off[id],15+j*16+i*16*16);
704  }
705 
706  if (k > 0)
707  {
708  BOOST_REQUIRE_EQUAL(mp[id],13);
709  BOOST_REQUIRE_EQUAL(mp_off[id],(k-1)+j*16+i*16*16);
710  }
711  }
712  }
713  }
714 
715  BOOST_REQUIRE_EQUAL(vk.size(),1);
716 
717  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(0),0);
718  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(1),0);
719  BOOST_REQUIRE_EQUAL(vk.get(0).k.get(2),0);
720 
721 
722  BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
723 }
724 
725 BOOST_AUTO_TEST_SUITE_END()
Copy XZ surface in 3D.
Copy YZ surface in 3D.
Copy XY surface in 3D.
This structure contain the information of a chunk.
Copy x edge in 3D.
Copy y edge in 3D.
Copy z edge in 3D.
This class represent an N-dimensional box.
Definition: Box.hpp:60
Declaration grid_sm.
Definition: grid_sm.hpp:147
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:214
unsigned char mask[n_ele]
which elements in the chunks are set
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:202