8#ifndef SRC_VECTOR_VECTOR_DIST_DLB_TEST_HPP_
9#define SRC_VECTOR_VECTOR_DIST_DLB_TEST_HPP_
11#include "DLB/LB_Model.hpp"
12#include "Vector/vector_dist.hpp"
14BOOST_AUTO_TEST_SUITE( vector_dist_dlb_test )
16template<
typename vector_type>
25 for(
size_t i = 0 ; i < 50000 ; i++)
33 vd0.
getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3;
35 vd0.
getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3;
37 vd0.
getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3;
40 vd1.
getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
42 vd1.
getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
44 vd1.
getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.1;
47 vd2.
getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
49 vd2.
getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
51 vd2.
getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.2;
54 vd3.
getLastPos()[0] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
56 vd3.
getLastPos()[1] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
58 vd3.
getLastPos()[2] = ((float)rand())/RAND_MAX * 0.3 + 0.3;
63 vd0.template ghost_get<>();
65 vd1.template ghost_get<>();
67 vd2.template ghost_get<>();
69 vd3.template ghost_get<>();
104 for (
size_t i = 0 ; i < loads.
size() ; i++)
107 float load_fc = loads.get(i);
109 BOOST_REQUIRE_CLOSE(load_f,load_fc,7.0);
114 for (
size_t i = 0 ; i < 25 ; i++)
125 vd0.
getPos(p)[0] += v.get(0) * 0.09;
126 vd0.
getPos(p)[1] += v.get(1) * 0.09;
127 vd0.
getPos(p)[2] += v.get(2) * 0.09;
139 vd1.
getPos(p)[0] += v.get(0) * 0.06;
140 vd1.
getPos(p)[1] += v.get(1) * 0.06;
141 vd1.
getPos(p)[2] += v.get(2) * 0.06;
153 vd2.
getPos(p)[0] += v.get(0) * 0.06;
154 vd2.
getPos(p)[1] += v.get(1) * 0.06;
155 vd2.
getPos(p)[2] += v.get(2) * 0.06;
167 vd3.
getPos(p)[0] += v.get(0) * 0.06;
168 vd3.
getPos(p)[1] += v.get(1) * 0.06;
169 vd3.
getPos(p)[2] += v.get(2) * 0.06;
199 vd0.template ghost_get<>();
200 vd1.template ghost_get<>();
201 vd2.template ghost_get<>();
202 vd3.template ghost_get<>();
216 for (
size_t i = 0 ; i < loads.
size() ; i++)
219 float load_fc = loads.get(i);
221 BOOST_REQUIRE_CLOSE(load_f,load_fc,10.0);
226template<
typename vector_type>
void test_dlb_vector()
235 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
243 for(
size_t i = 0 ; i < 50000 ; i++)
247 vd.getLastPos()[0] = ((double)rand())/RAND_MAX * 0.3;
248 vd.getLastPos()[1] = ((double)rand())/RAND_MAX * 0.3;
249 vd.getLastPos()[2] = ((double)rand())/RAND_MAX * 0.3;
254 vd.template ghost_get<>();
258 auto VV = vd.getVerlet(0.01);
262 auto it = vd.getDomainIterator();
268 vd.template getProp<0>(p) = VV.getNNPart(p.getKey());
277 vd.addComputationCosts(md);
278 vd.getDecomposition().decompose();
281 vd.addComputationCosts(md);
284 size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
288 for (
size_t i = 0 ; i < loads.
size() ; i++)
290 double load_f = load;
291 double load_fc = loads.get(i);
293 BOOST_REQUIRE_CLOSE(load_f,load_fc,7.0);
296 BOOST_REQUIRE(vd.size_local() != 0);
300 for (
size_t i = 0 ; i < 25 ; i++)
304 auto it = vd.getDomainIterator();
310 vd.getPos(p)[0] += v.get(0) * 0.09;
311 vd.getPos(p)[1] += v.get(1) * 0.09;
312 vd.getPos(p)[2] += v.get(2) * 0.09;
319 vd.template ghost_get<>();
321 auto VV2 = vd.getVerlet(0.01);
323 auto it2 = vd.getDomainIterator();
330 match &= vd.template getProp<0>(p) == VV2.getNNPart(p.getKey());
335 BOOST_REQUIRE_EQUAL(match,
true);
338 vd.addComputationCosts(md);
339 vd.getDecomposition().redecompose(200);
342 BOOST_REQUIRE(vd.size_local() != 0);
344 vd.template ghost_get<>();
346 vd.addComputationCosts(md);
349 size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
353 for (
size_t i = 0 ; i < loads.
size() ; i++)
355 double load_f = load;
356 double load_fc = loads.get(i);
358 BOOST_REQUIRE_CLOSE(load_f,load_fc,10.0);
364template<
typename vector_type>
void test_dlb_multi_phase_vector()
373 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
380 mp_test_template(vd0,vd1,vd2,vd3);
385template<
typename vector_type>
void test_dlb_multi_phase_v_vector()
394 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
405 auto & vd0 = v_phases.get(0);
406 auto & vd1 = v_phases.get(1);
407 auto & vd2 = v_phases.get(2);
408 auto & vd3 = v_phases.get(3);
410 mp_test_template(vd0,vd1,vd2,vd3);
413BOOST_AUTO_TEST_CASE( vector_dist_dlb )
415 test_dlb_vector<vector_dist<3,double,aggregate<double>>>();
418BOOST_AUTO_TEST_CASE( vector_dist_dlb_multi_phase_test_part )
420 test_dlb_multi_phase_vector<vector_dist<3,float,aggregate<float>>>();
423BOOST_AUTO_TEST_CASE( vector_dist_dlb_multi_phase_v_test_part )
425 test_dlb_multi_phase_v_vector<vector_dist<3,float,aggregate<float>>>();
428BOOST_AUTO_TEST_CASE( vector_dist_dlb_metis_test_part )
436BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
This class decompose a space into sub-sub-domains and distribute them across processors.
This class implement the point shape in an N-dimensional space.
void execute()
Execute all the requests.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
vect_dist_key_dx get()
Get the actual key.
auto getPos(vect_dist_key_dx vec_key) -> decltype(v_pos.template get< 0 >(vec_key.getKey()))
Get the position of an element.
vector_dist_iterator getDomainIterator() const
Get an iterator that traverse the particles in the domain.
void finalizeComputationCosts(Model md=Model(), size_t ts=1)
Add the computation cost on the decomposition coming from the particles.
void map(size_t opt=NONE)
It move all the particles that does not belong to the local processor to the respective processor.
void initializeComputationCosts()
Initialize the computational cost.
auto getLastPos() -> decltype(v_pos.template get< 0 >(0))
Get the position of the last element.
void add()
Add local particle.
void addComputationCosts(const self &vd, Model md=Model())
Add the computation cost on the decomposition coming from the particles.
Decomposition & getDecomposition()
Get the decomposition.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...