1#include "Vector/vector_dist.hpp"
2#include "data_type/aggregate.hpp"
3#include "Decomposition/CartDecomposition.hpp"
4#include "VCluster/VCluster.hpp"
40void serial_to_parallel(std::vector<my_particle> & parts,
43 auto & v_cl = create_vcluster();
46 if (v_cl.getProcessUnitID() == 0)
48 for (
size_t i = 0 ; i < parts.size() ; i++)
52 pparts.getLastPos()[0] = parts[i].x[0];
53 pparts.getLastPos()[1] = parts[i].x[1];
55 pparts.getLastProp<0>() = parts[i].prop0;
56 pparts.getLastProp<1>() = parts[i].prop1;
61 pparts.addComputationCosts();
62 pparts.getDecomposition().decompose();
70void parallel_to_serial(std::vector<my_particle> & parts,
73 auto & v_cl = create_vcluster();
77 auto & pos = pparts.getPosVector();
78 auto & prp = pparts.getPropVector();
80 std::remove_reference<
decltype(pos)>::type pos_collect;
81 std::remove_reference<
decltype(prp)>::type prp_collect;
84 v_cl.SGather(pos,pos_collect,0);
85 v_cl.SGather(prp,prp_collect,0);
87 if (v_cl.getProcessUnitID() == 0)
91 for (
size_t i = 0 ; i < pos_collect.size() ; i++)
95 p.
x[0] = pos_collect.get<POS_>(i)[0];
96 p.x[1] = pos_collect.get<POS_>(i)[1];
98 p.prop0 = prp_collect.get<0>(i);
99 p.prop1 = prp_collect.get<1>(i);
108int main(
int argc,
char* argv[])
126 openfpm_init(&argc,&argv);
150 std::vector<my_particle> parts;
159 for (
size_t i = 0 ; i < 100 ; i++)
163 p.
x[0] = 2.0*(double)rand()/RAND_MAX;
164 p.
x[1] = 3.0*(double)rand()/RAND_MAX;
227 size_t bc[2] = {PERIODIC,PERIODIC};
234 for (
size_t i = 0 ; i < 100 ; i++)
241 serial_to_parallel(parts,pparts);
245 auto it = pparts.getDomainIterator();
251 pparts.getPos(key)[0] += 0.01;
252 pparts.getPos(key)[1] += 0.01;
254 pparts.getProp<0>(key) = i*i;
255 pparts.getProp<1>(key) = i;
260 pparts.write_frame(
"output",i);
266 parallel_to_serial(parts,pparts);
275 for (
size_t i = 0 ; i < parts.size() ; i++)
277 parts[i].x[0] += 0.01;
278 parts[i].x[1] += 0.01;
280 parts[i].prop0 = i*i;
This class represent an N-dimensional box.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Out-of-bound policy kill the program.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...