9#define DISABLE_MPI_WRITTERS
11#define BOOST_TEST_DYN_LINK
12#include <boost/test/unit_test.hpp>
13#include "SparseGrid/SparseGrid.hpp"
14#include "NN/CellList/CellDecomposer.hpp"
17#include "SparseGrid_chunk_copy.hpp"
19BOOST_AUTO_TEST_SUITE( sparse_grid_chunk_copy_test )
23 typedef boost::mpl::vector<boost::mpl::int_<64>,
25 boost::mpl::int_<4>> type;
27 typedef boost::mpl::vector<boost::mpl::int_<6>,
29 boost::mpl::int_<2>>
shift;
31 typedef boost::mpl::vector<boost::mpl::int_<6>,
33 boost::mpl::int_<11>> shift_c;
35 typedef boost::mpl::int_<2048> size;
38BOOST_AUTO_TEST_CASE( sparse_grid_chunk_test )
44 double chunk_with_border[66*10*6];
45 unsigned char mask[66*10*6];
47 memset(chunk_with_border,0,
sizeof(
double)*66*10*6);
55 memset(&h.
mask[0],0xFF,4096);
57 for (
int i = 0 ; i < test_chunking3::size::value ; i++)
58 {chunks.template get<0>(0)[i] = i;}
66 for (
int k = 1 ; k < 9 ; k++)
68 for (
int j = 1 ; j < 65 ; j++)
70 BOOST_REQUIRE_EQUAL(chunk_with_border[k*66+j],chunks.template get<0>(0)[3*64*8 + (k-1)*64 + (j-1)]);
74 for (
int k = 1 ; k < 9 ; k++)
76 for (
int j = 1 ; j < 65 ; j++)
78 BOOST_REQUIRE_EQUAL(chunk_with_border[5*66*10+k*66+j],chunks.template get<0>(0)[(k-1)*64 + (j-1)]);
83 memset(chunk_with_border,0,
sizeof(
double)*66*10*6);
90 for (
int i = 1 ; i < 5 ; i++)
92 for (
int j = 1 ; j < 65 ; j++)
94 BOOST_REQUIRE_EQUAL(chunk_with_border[i*66*10+j],chunks.template get<0>(0)[(i-1)*64*8 + 7*64 + (j-1)]);
98 for (
int i = 1 ; i < 5 ; i++)
100 for (
int j = 1 ; j < 65 ; j++)
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)]);
106 memset(chunk_with_border,0,
sizeof(
double)*66*10*6);
113 for (
int i = 1 ; i < 5 ; i++)
115 for (
int j = 1 ; j < 9 ; j++)
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]);
121 for (
int i = 1 ; i < 5 ; i++)
123 for (
int j = 1 ; j < 9 ; j++)
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]);
131 memset(chunk_with_border,0,
sizeof(
double)*66*10*6);
139 for (
int k = 1 ; k < 65 ; k++)
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)]);
144 for (
int k = 1 ; k < 65 ; k++)
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)]);
150 for (
int k = 1 ; k < 65 ; k++)
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)]);
155 for (
int k = 1 ; k < 65 ; k++)
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)]);
162BOOST_AUTO_TEST_CASE( sparse_grid_chunk_test_2 )
168 double chunk_with_border[68*12*8];
169 unsigned char mask[68*12*8];
171 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
179 memset(&h.
mask[0],0xFF,4096);
181 for (
int i = 0 ; i < test_chunking3::size::value ; i++)
182 {chunks.template get<0>(0)[i] = i;}
190 for (
int s = 0 ; s < 2 ; s++)
192 for (
int k = 2 ; k < 10 ; k++)
194 for (
int j = 2 ; j < 66 ; j++)
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)]);
201 for (
int s = 0 ; s < 2 ; s++)
203 for (
int k = 2 ; k < 10 ; k++)
205 for (
int j = 2 ; j < 66 ; j++)
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)]);
212 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
219 for (
int s = 0 ; s < 2 ; s++)
221 for (
int i = 2 ; i < 6 ; i++)
223 for (
int j = 2 ; j < 66 ; j++)
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)]);
231 for (
int s = 0 ; s < 2 ; s++)
233 for (
int i = 2 ; i < 6 ; i++)
235 for (
int j = 2 ; j < 66 ; j++)
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)]);
242 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
249 for (
int s = 0 ; s < 2 ; s++)
251 for (
int i = 2 ; i < 6 ; i++)
253 for (
int j = 2 ; j < 10 ; j++)
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]);
260 for (
int s = 0 ; s < 2 ; s++)
262 for (
int i = 2 ; i < 6 ; i++)
264 for (
int j = 2 ; j < 10 ; j++)
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]);
273 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
281 for (
int k = 2 ; k < 66 ; k++)
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)]);
289 for (
int k = 2 ; k < 66 ; k++)
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)]);
298 for (
int k = 2 ; k < 66 ; k++)
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)]);
306 for (
int k = 2 ; k < 66 ; k++)
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)]);
316 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
324 for (
int j = 2 ; j < 10 ; j++)
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]);
332 for (
int j = 2 ; j < 10 ; j++)
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]);
341 for (
int j = 2 ; j < 10 ; j++)
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]);
349 for (
int j = 2 ; j < 10 ; j++)
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]);
359 memset(chunk_with_border,0,
sizeof(
double)*68*12*8);
491BOOST_AUTO_TEST_CASE( sparse_grid_chunk_missalign_copy_test )
493 unsigned char mp[16*16*16];
494 short int mp_off[16*16*16];
502 construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src,box_dst,vk);
504 size_t sz[3] = {16,16,16};
507 for (
int i = 0 ; i < 16 ; i++)
509 for (
int j = 0 ; j < 16 ; j++)
511 for (
int k = 0 ; k < 16 ; k++)
513 size_t id = g_sm.Lin(k,j,i);
515 BOOST_REQUIRE_EQUAL(mp[
id],13);
516 BOOST_REQUIRE_EQUAL(mp_off[
id],
id);
521 BOOST_REQUIRE_EQUAL(vk.size(),1);
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);
527 BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
535 construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src2,box_dst2,vk);
537 for (
int i = 0 ; i < 16 ; i++)
539 for (
int j = 0 ; j < 16 ; j++)
541 for (
int k = 0 ; k < 16 ; k++)
543 size_t id = g_sm.Lin(i,j,k);
547 BOOST_REQUIRE_EQUAL(mp[
id],13);
548 BOOST_REQUIRE_EQUAL(mp_off[
id],
id+1);
553 BOOST_REQUIRE_EQUAL(mp[
id],14);
554 BOOST_REQUIRE_EQUAL(mp_off[
id],j*16+i*16*16);
560 BOOST_REQUIRE_EQUAL(vk.size(),1);
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);
567 BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
578 construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src3,box_dst3,vk);
580 for (
int i = 0 ; i < 16 ; i++)
582 for (
int j = 0 ; j < 16 ; j++)
584 for (
int k = 0 ; k < 16 ; k++)
586 size_t id = g_sm.Lin(i,j,k);
590 BOOST_REQUIRE_EQUAL(mp[
id],13);
591 BOOST_REQUIRE_EQUAL(mp_off[
id],
id+1);
596 BOOST_REQUIRE_EQUAL(mp[
id],14);
597 BOOST_REQUIRE_EQUAL(mp_off[
id],j*16+i*16*16);
603 BOOST_REQUIRE_EQUAL(vk.size(),2);
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);
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);
613 BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
623 construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src4,box_dst4,vk);
625 for (
int i = 0 ; i < 16 ; i++)
627 for (
int j = 0 ; j < 16 ; j++)
629 for (
int k = 0 ; k < 16 ; k++)
631 size_t id = g_sm.Lin(i,j,k);
637 BOOST_REQUIRE_EQUAL(mp[
id],13);
638 BOOST_REQUIRE_EQUAL(mp_off[
id],k+1+(j+1)*16+i*16*16);
642 BOOST_REQUIRE_EQUAL(mp[
id],16);
643 BOOST_REQUIRE_EQUAL(mp_off[
id],k+1+i*16*16);
651 BOOST_REQUIRE_EQUAL(mp[
id],14);
652 BOOST_REQUIRE_EQUAL(mp_off[
id],(j+1)*16+i*16*16);
656 BOOST_REQUIRE_EQUAL(mp[
id],17);
657 BOOST_REQUIRE_EQUAL(mp_off[
id],i*16*16);
664 BOOST_REQUIRE_EQUAL(vk.size(),4);
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);
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);
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);
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);
690 construct_chunk_missalign_map<3,16*16*16,default_chunking<3>>(mp,mp_off,box_src5,box_dst5,vk);
692 for (
int i = 0 ; i < 16 ; i++)
694 for (
int j = 0 ; j < 16 ; j++)
696 for (
int k = 0 ; k < 16 ; k++)
698 size_t id = g_sm.Lin(i,j,k);
702 BOOST_REQUIRE_EQUAL(mp[
id],12);
703 BOOST_REQUIRE_EQUAL(mp_off[
id],15+j*16+i*16*16);
708 BOOST_REQUIRE_EQUAL(mp[
id],13);
709 BOOST_REQUIRE_EQUAL(mp_off[
id],(k-1)+j*16+i*16*16);
715 BOOST_REQUIRE_EQUAL(vk.size(),1);
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);
722 BOOST_REQUIRE_EQUAL(vk.get(0).i,0);
725BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Implementation of 1-D std::vector like structure.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...