Commit b3f1b470 authored by Pietro Incardona's avatar Pietro Incardona

Fixing vector with complex object

parent 40f0b62e
# Change Log # Change Log
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.5.0] -
### Added
- map_list map communicate particles across processors mooving the information of all the particle map_list give the possibility to
give a list of property to move from one to another processor
- Numeric: Finite Differences discretization with matrix contruction and parallel solvers
### Fixed
### Changed
## [0.4.0] - 26-05-2016 ## [0.4.0] - 26-05-2016
### Added ### Added
......
...@@ -699,7 +699,7 @@ private: ...@@ -699,7 +699,7 @@ private:
{ {
// Get the number of elements // Get the number of elements
size_t n_ele = recv_mem_gm.get(i).size() / (sizeof(Point<dim, St> ) + sizeof(prop)); size_t n_ele = recv_mem_gm.get(i).size() / (sizeof(Point<dim, St> ) + sizeof(prp_object));
// Pointer of the received positions for each near processor // Pointer of the received positions for each near processor
void * ptr_pos = (unsigned char *) recv_mem_gm.get(i).getPointer(); void * ptr_pos = (unsigned char *) recv_mem_gm.get(i).getPointer();
...@@ -707,7 +707,7 @@ private: ...@@ -707,7 +707,7 @@ private:
void * ptr_prp = (unsigned char *) recv_mem_gm.get(i).getPointer() + n_ele * sizeof(Point<dim, St> ); void * ptr_prp = (unsigned char *) recv_mem_gm.get(i).getPointer() + n_ele * sizeof(Point<dim, St> );
PtrMemory * ptr1 = new PtrMemory(ptr_pos, n_ele * sizeof(Point<dim, St> )); PtrMemory * ptr1 = new PtrMemory(ptr_pos, n_ele * sizeof(Point<dim, St> ));
PtrMemory * ptr2 = new PtrMemory(ptr_prp, n_ele * sizeof(prop)); PtrMemory * ptr2 = new PtrMemory(ptr_prp, n_ele * sizeof(prp_object));
// create vector representation to a piece of memory already allocated // create vector representation to a piece of memory already allocated
...@@ -1023,7 +1023,7 @@ public: ...@@ -1023,7 +1023,7 @@ public:
// convert the particle number to buffer size // convert the particle number to buffer size
for (size_t i = 0; i < prc_sz_r.size(); i++) for (size_t i = 0; i < prc_sz_r.size(); i++)
{ {
prc_sz_r.get(i) = prc_sz_r.get(i) * (sizeof(prop) + sizeof(Point<dim, St> )); prc_sz_r.get(i) = prc_sz_r.get(i) * (sizeof(prp_object) + sizeof(Point<dim, St> ));
} }
// Send and receive the particles // Send and receive the particles
......
...@@ -1179,6 +1179,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list ) ...@@ -1179,6 +1179,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
long int big_step = k / 4; long int big_step = k / 4;
big_step = (big_step == 0)?1:big_step; big_step = (big_step == 0)?1:big_step;
print_test("Testing 3D periodic vector with map_list k=",k);
BOOST_TEST_CHECKPOINT( "Testing 3D periodic vector with map_list k=" << k ); BOOST_TEST_CHECKPOINT( "Testing 3D periodic vector with map_list k=" << k );
//! [Create a vector of random elements on each processor 3D] //! [Create a vector of random elements on each processor 3D]
...@@ -1197,8 +1198,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list ) ...@@ -1197,8 +1198,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
// ghost2 (a little bigger because of round off error) // ghost2 (a little bigger because of round off error)
Ghost<3,float> ghost2(0.05001 / factor); Ghost<3,float> ghost2(0.05001 / factor);
typedef aggregate<float,float,std::list<int>,openfpm::vector<size_t>,openfpm::vector<Point_test<float>>> part_prop;
// Distributed vector // Distributed vector
vector_dist<3,float, aggregate<float,float,std::list<int>,openfpm::vector<size_t>> > vd(k,box,bc,ghost); vector_dist<3,float, part_prop > vd(k,box,bc,ghost);
auto it = vd.getIterator(); auto it = vd.getIterator();
...@@ -1210,6 +1213,23 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list ) ...@@ -1210,6 +1213,23 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
vd.getPos(key)[1] = ud(eg); vd.getPos(key)[1] = ud(eg);
vd.getPos(key)[2] = ud(eg); vd.getPos(key)[2] = ud(eg);
// Fill some properties randomly
vd.getProp<2>(key).push_back(1);
vd.getProp<2>(key).push_back(2);
vd.getProp<2>(key).push_back(3);
vd.getProp<2>(key).push_back(4);
vd.getProp<3>(key).add(1);
vd.getProp<3>(key).add(2);
vd.getProp<3>(key).add(3);
vd.getProp<3>(key).add(4);
vd.getProp<4>(key).add();
vd.getProp<4>(key).add();
vd.getProp<4>(key).add();
vd.getProp<4>(key).add();
++it; ++it;
} }
...@@ -1230,7 +1250,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list ) ...@@ -1230,7 +1250,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
size_t n_out = 0; size_t n_out = 0;
auto it2 = vd.getIterator(); auto it2 = vd.getIterator();
count_local_n_local<3,vector_dist<3,float, aggregate<float,float,std::list<int>,openfpm::vector<size_t>>> >(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out); count_local_n_local<3,vector_dist<3,float, part_prop>>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
// No particles should be out of domain + ghost // No particles should be out of domain + ghost
BOOST_REQUIRE_EQUAL(n_out,0ul); BOOST_REQUIRE_EQUAL(n_out,0ul);
...@@ -1252,7 +1272,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list ) ...@@ -1252,7 +1272,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
// Iterate only on the ghost particles // Iterate only on the ghost particles
auto itg = vd.getGhostIterator(); auto itg = vd.getGhostIterator();
count_local_n_local<3, vector_dist<3,float, aggregate<float,float,std::list<int>,openfpm::vector<size_t>> > >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out); count_local_n_local<3, vector_dist<3,float,part_prop> >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
// No particle on the ghost must be inside the domain // No particle on the ghost must be inside the domain
BOOST_REQUIRE_EQUAL(l_cnt,0ul); BOOST_REQUIRE_EQUAL(l_cnt,0ul);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment