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"
18BOOST_AUTO_TEST_SUITE( grid_dist_id_dlb_test )
20template<
typename gr
id,
typename vector>
21void 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);
107 std::cout <<
"Error " << gdist.template get<0>(p) <<
" != " << gkey.get(0) <<
" " << gdist.template get<1>(p) <<
" != " << gkey.get(1) <<
" " << gdist.template get<2>(p) <<
" != " << gkey.get(2) << std::endl;
114 BOOST_REQUIRE_EQUAL(check,
true);
118 double t2 = 6.28*(double)(i+1)/n_step;
119 double t = 6.28*(double)i/n_step;
121 v[0] = 0.7*fabs(sin(
t2)) - 0.7*fabs(sin(t));
122 v[1] = 0.7*fabs(sin(1.7*
t2)) - 0.7*fabs(sin(1.7*t));
123 v[2] = 0.7*fabs(sin(2.5*
t2)) - 0.7*fabs(sin(2.5*t));
125 auto it2 = vd.getDomainIterator();
131 vd.getPos(p)[0] += v[0];
132 vd.getPos(p)[1] += v[1];
133 vd.getPos(p)[2] += v[2];
147 float x0 = fabs(sin(t));
148 float y0 = fabs(cos(t));
149 float z0 = fabs(sin(3.0*t));
151 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);
154 double distributionTol()
160template<
typename gr
id,
typename vector>
161void test_vector_grid_dlb_resolution()
168 size_t sz[3] = {37,37,37};
170 grid gdist(sz,domain3,g,DEC_GRAN(128));
174 bck.template get<0>() = -57;
175 bck.template get<1>() = -90;
176 bck.template get<2>() = -123;
178 gdist.setBackgroundValue(bck);
182 auto it = gdist.getGridIterator();
186 auto p = it.get_dist();
187 auto gkey = it.
get();
189 gdist.template insert<0>(p) = gkey.get(0);
190 gdist.template insert<1>(p) = gkey.get(1);
191 gdist.template insert<2>(p) = gkey.get(2);
200 for (
size_t i = 0; i < n_step ; i++)
202 gdlb.t = (float)i/n_step;
203 gdist.addComputationCosts(gdlb);
204 gdist.getDecomposition().decompose();
207 gdist.write_frame(
"sgrid",i);
212 auto it = gdist.getDomainIterator();
218 auto gkey = it.getGKey(p);
220 check &= gdist.template get<0>(p) == gkey.get(0);
221 check &= gdist.template get<1>(p) == gkey.get(1);
222 check &= gdist.template get<2>(p) == gkey.get(2);
227 BOOST_REQUIRE_EQUAL(check,
true);
231BOOST_AUTO_TEST_CASE( grid_dist_dlb_test )
236 test_vector_grid_dlb<grid_sparse,particles>();
239BOOST_AUTO_TEST_CASE( grid_dist_dlb_test_resolution )
244 test_vector_grid_dlb_resolution<grid_sparse,particles>();
247BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This is a distributed grid.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
__device__ __host__ boost::mpl::at< type, boost::mpl::int_< i > >::type & get()
get the properties i
It model an expression expr1 * expr2.