9 #define BOOST_TEST_DYN_LINK 10 #include <boost/test/unit_test.hpp> 12 #include "Point_test.hpp" 13 #include "Grid/grid_dist_id.hpp" 14 #include "data_type/aggregate.hpp" 15 #include "grid_dist_id_util_tests.hpp" 16 #include "Vector/vector_dist.hpp" 18 BOOST_AUTO_TEST_SUITE( grid_dist_id_dlb_test )
20 template<
typename gr
id,
typename vector>
21 void test_vector_grid_dlb()
28 size_t sz[3] = {37,37,37};
30 grid gdist(sz,domain3,g,DEC_GRAN(128));
34 bck.template get<0>() = -57;
35 bck.template get<1>() = -90;
36 bck.template get<2>() = -123;
38 gdist.setBackgroundValue(bck);
40 vector vd(gdist.getDecomposition(),0);
44 auto it = gdist.getGridIterator();
48 auto p = it.get_dist();
51 gdist.template insert<0>(p) = gkey.get(0);
52 gdist.template insert<1>(p) = gkey.get(1);
53 gdist.template insert<2>(p) = gkey.get(2);
60 auto it2 = vd.getGridIterator(sz);
64 auto gkey = it2.get();
68 float x = 0.2*gkey.get(0)*it2.getSpacing(0) + 0.05;
69 float y = 0.2*gkey.get(1)*it2.getSpacing(1) + 0.05;
70 float z = 0.2*gkey.get(2)*it2.getSpacing(2) + 0.05;
72 vd.getLastPos()[0] = x;
73 vd.getLastPos()[1] = y;
74 vd.getLastPos()[2] = z;
80 for (
size_t i = 0; i < n_step ; i++)
83 vd.addComputationCosts();
84 vd.getDecomposition().decompose();
87 gdist.getDecomposition() = vd.getDecomposition();
93 auto it = gdist.getDomainIterator();
99 auto gkey = it.getGKey(p);
101 check &= gdist.template get<0>(p) == gkey.get(0);
102 check &= gdist.template get<1>(p) == gkey.get(1);
103 check &= gdist.template get<2>(p) == gkey.get(2);
108 BOOST_REQUIRE_EQUAL(check,
true);
112 double t2 = 6.28*(double)(i+1)/n_step;
113 double t = 6.28*(double)i/n_step;
115 v[0] = 0.7*fabs(sin(
t2)) - 0.7*fabs(sin(t));
116 v[1] = 0.7*fabs(sin(1.7*
t2)) - 0.7*fabs(sin(1.7*t));
117 v[2] = 0.7*fabs(sin(2.5*
t2)) - 0.7*fabs(sin(2.5*t));
119 auto it2 = vd.getDomainIterator();
125 vd.getPos(p)[0] += v[0];
126 vd.getPos(p)[1] += v[1];
127 vd.getPos(p)[2] += v[2];
141 float x0 = fabs(sin(t));
142 float y0 = fabs(cos(t));
143 float z0 = fabs(sin(3.0*t));
145 return 100 * exp( - ((p.
get(0) - x0)*(p.
get(0) - x0) + (p.
get(1) - y0)*(p.
get(1) - y0) + (p.
get(2) - z0)*(p.
get(2) - z0)) / 0.3);
148 double distributionTol()
154 template<
typename gr
id,
typename vector>
155 void test_vector_grid_dlb_resolution()
162 size_t sz[3] = {37,37,37};
164 grid gdist(sz,domain3,g,DEC_GRAN(128));
168 bck.template get<0>() = -57;
169 bck.template get<1>() = -90;
170 bck.template get<2>() = -123;
172 gdist.setBackgroundValue(bck);
176 auto it = gdist.getGridIterator();
180 auto p = it.get_dist();
181 auto gkey = it.
get();
183 gdist.template insert<0>(p) = gkey.get(0);
184 gdist.template insert<1>(p) = gkey.get(1);
185 gdist.template insert<2>(p) = gkey.get(2);
194 for (
size_t i = 0; i < n_step ; i++)
196 gdlb.t = (float)i/n_step;
197 gdist.addComputationCosts(gdlb);
198 gdist.getDecomposition().decompose();
201 gdist.write_frame(
"sgrid",i);
206 auto it = gdist.getDomainIterator();
212 auto gkey = it.getGKey(p);
214 check &= gdist.template get<0>(p) == gkey.get(0);
215 check &= gdist.template get<1>(p) == gkey.get(1);
216 check &= gdist.template get<2>(p) == gkey.get(2);
221 BOOST_REQUIRE_EQUAL(check,
true);
225 BOOST_AUTO_TEST_CASE( grid_dist_dlb_test )
230 test_vector_grid_dlb<grid_sparse,particles>();
233 BOOST_AUTO_TEST_CASE( grid_dist_dlb_test_resolution )
238 test_vector_grid_dlb_resolution<grid_sparse,particles>();
241 BOOST_AUTO_TEST_SUITE_END()
__device__ __host__ boost::mpl::at< type, boost::mpl::int_< i > >::type & get()
get the properties i
It model an expression expr1 * expr2.
This is a distributed grid.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...