OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
grid_util_test.hpp
1 /*
2  * grid_util_test.hpp
3  *
4  * Created on: Jul 18, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef SRC_GRID_GRID_UTIL_TEST_HPP_
9 #define SRC_GRID_GRID_UTIL_TEST_HPP_
10 
11 #include "map_grid.hpp"
12 #include "Point_test.hpp"
13 #include "grid_key.hpp"
14 
20 template<unsigned int dim, typename T> void fill_grid(T & grid)
21 {
22  typedef Point_test<float> P;
23 
24  auto key_it = grid.getIterator();
25 
26  while (key_it.isNext())
27  {
28  grid_key_dx<dim> kk = key_it.get();
29 
30  grid.template get<P::x>(kk) = grid.getGrid().LinId(kk);
31  grid.template get<P::y>(kk) = grid.getGrid().LinId(kk)+1;
32  grid.template get<P::z>(kk) = grid.getGrid().LinId(kk)+2;
33  grid.template get<P::s>(kk) = grid.getGrid().LinId(kk)+3;
34 
35  grid.template get<P::v>(kk)[0] = grid.getGrid().LinId(kk)+123;
36  grid.template get<P::v>(kk)[1] = grid.getGrid().LinId(kk)+124;
37  grid.template get<P::v>(kk)[2] = grid.getGrid().LinId(kk)+125;
38 
39  grid.template get<P::t>(kk)[0][0] = grid.getGrid().LinId(kk)+567;
40  grid.template get<P::t>(kk)[0][1] = grid.getGrid().LinId(kk)+568;
41  grid.template get<P::t>(kk)[0][2] = grid.getGrid().LinId(kk)+569;
42  grid.template get<P::t>(kk)[1][0] = grid.getGrid().LinId(kk)+570;
43  grid.template get<P::t>(kk)[1][1] = grid.getGrid().LinId(kk)+571;
44  grid.template get<P::t>(kk)[1][2] = grid.getGrid().LinId(kk)+572;
45  grid.template get<P::t>(kk)[2][0] = grid.getGrid().LinId(kk)+573;
46  grid.template get<P::t>(kk)[2][1] = grid.getGrid().LinId(kk)+574;
47  grid.template get<P::t>(kk)[2][2] = grid.getGrid().LinId(kk)+575;
48 
49  ++key_it;
50  }
51 }
52 
53 
54 
55 #endif /* SRC_GRID_GRID_UTIL_TEST_HPP_ */
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:302
Test structure used for several test.
Definition: Point_test.hpp:72