126#include "Vector/vector_dist.hpp"
130__global__
void print_data_particle_50(
float * scalar,
float * vector,
float *
tensor,
int capacity)
132 int p = threadIdx.x + blockIdx.x * blockDim.x;
136 printf(
"Scalar particle %d = %f\n",p,scalar[p]);
138 printf(
"Vector particle %d = %f\n",p,vector[p]);
139 printf(
"Vector particle %d = %f\n",p,vector[p + capacity]);
141 printf(
"Tensor particle %d = %f\n",p,
tensor[p + (0*2 + 0)*capacity]);
142 printf(
"Tensor particle %d = %f\n",p,
tensor[p + (0*2 + 1)*capacity]);
143 printf(
"Tensor particle %d = %f\n",p,
tensor[p + (1*2 + 0)*capacity]);
144 printf(
"Tensor particle %d = %f\n",p,
tensor[p + (1*2 + 1)*capacity]);
150int main(
int argc,
char* argv[])
153 openfpm_init(&argc,&argv);
159 size_t bc[2]={PERIODIC,PERIODIC};
166 auto it = vd.getDomainIterator();
173 vd.getPos(p)[0] = (float)rand() / RAND_MAX;
176 vd.getPos(p)[1] = (float)rand() / RAND_MAX;
178 vd.template getProp<0>(p) = vd.getPos(p)[0] + vd.getPos(p)[1];
180 vd.template getProp<1>(p)[0] = vd.getPos(p)[0];
181 vd.template getProp<1>(p)[1] = vd.getPos(p)[1];
183 vd.template getProp<2>(p)[0][0] = vd.getPos(p)[0];
184 vd.template getProp<2>(p)[0][1] = vd.getPos(p)[1];
185 vd.template getProp<2>(p)[1][0] = vd.getPos(p)[0] + vd.getPos(p)[1];
186 vd.template getProp<2>(p)[1][1] = vd.getPos(p)[1] - vd.getPos(p)[0];
198 std::cout <<
"First particle property 0, address: " << &vd.template getProp<0>(0) << std::endl;
199 std::cout <<
"First particle property 1, address: " << &vd.template getProp<1>(0)[0] << std::endl;
200 std::cout <<
"First particle property 2, address: " << &vd.template getProp<2>(0)[0][0] << std::endl;
206 std::cout <<
"Capacity internal vector: " << vd.getPropVector().capacity() << std::endl;
208 std::cout <<
"First particle property 1 component 0, address: " << &vd.template getProp<1>(0)[0] << std::endl;
209 std::cout <<
"First particle property 1 component 1, address: " << &vd.template getProp<1>(0)[1] << std::endl;
211 std::cout <<
"First particle property 2 component 00, address: " << &vd.template getProp<2>(0)[0][0] << std::endl;
212 std::cout <<
"First particle property 2 component 01, address: " << &vd.template getProp<2>(0)[0][1] << std::endl;
213 std::cout <<
"First particle property 2 component 10, address: " << &vd.template getProp<2>(0)[1][0] << std::endl;
214 std::cout <<
"First particle property 2 component 11, address: " << &vd.template getProp<2>(0)[1][1] << std::endl;
216 std::cout <<
"Second particle property 1 component 0, address: " << &vd.template getProp<1>(1)[0] << std::endl;
217 std::cout <<
"Second particle property 1 component 1, address: " << &vd.template getProp<1>(1)[1] << std::endl;
219 std::cout <<
"Second particle property 2 component 00, address: " << &vd.template getProp<2>(1)[0][0] << std::endl;
220 std::cout <<
"Second particle property 2 component 01, address: " << &vd.template getProp<2>(1)[0][1] << std::endl;
221 std::cout <<
"Second particle property 2 component 10, address: " << &vd.template getProp<2>(1)[1][0] << std::endl;
222 std::cout <<
"Second particle property 2 component 11, address: " << &vd.template getProp<2>(1)[1][1] << std::endl;
226 std::cout << std::endl;
230 vd.template hostToDeviceProp<0,1,2>();
232 CUDA_LAUNCH_DIM3(print_data_particle_50,100,1,(
float *)vd.getPropVector().template getDeviceBuffer<0>(),
233 (
float *)vd.getPropVector().template getDeviceBuffer<1>(),
234 (
float *)vd.getPropVector().template getDeviceBuffer<2>(),
235 vd.getPropVector().capacity());
244int main(
int argc,
char* argv[])
This class represent an N-dimensional box.