From a7a38f8cbe342e1d2c249d096a18f8a0da52d596 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <incardon@mpi-cbg.de>
Date: Thu, 22 Sep 2016 21:48:36 +0200
Subject: [PATCH] Adding test and fixing test compilation

---
 src/Vector/vector_dist_comm.hpp      |  3 +-
 src/Vector/vector_dist_unit_test.hpp | 46 ++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/Vector/vector_dist_comm.hpp b/src/Vector/vector_dist_comm.hpp
index ca70fd99..fa00ed67 100644
--- a/src/Vector/vector_dist_comm.hpp
+++ b/src/Vector/vector_dist_comm.hpp
@@ -749,6 +749,7 @@ public:
 	 *
 	 */
 	vector_dist_comm(const vector_dist_comm<dim,St,prop,Decomposition,Memory> & v)
+	:v_cl(create_vcluster()),dec(create_vcluster())
 	{
 		this->operator=(v);
 	}
@@ -1043,7 +1044,7 @@ public:
 	 */
 	vector_dist_comm<dim,St,prop,Decomposition,Memory> & operator=(vector_dist_comm<dim,St,prop,Decomposition,Memory> && vc)
 	{
-		dec.swap(vc.dec);
+		dec = vc.dec;
 
 		return *this;
 	}
diff --git a/src/Vector/vector_dist_unit_test.hpp b/src/Vector/vector_dist_unit_test.hpp
index a4ef5334..88a7275a 100644
--- a/src/Vector/vector_dist_unit_test.hpp
+++ b/src/Vector/vector_dist_unit_test.hpp
@@ -1771,6 +1771,52 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_put )
 	}
 }
 
+BOOST_AUTO_TEST_CASE( vector_of_vector_dist )
+{
+	Vcluster & v_cl = create_vcluster();
+
+	if (v_cl.getProcessingUnits() > 48)
+		return;
+
+	// Boundary conditions
+	size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
+
+	// Box
+	Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
+
+	// ghost
+	Ghost<3,float> ghost(0.1);
+
+	openfpm::vector< vector_dist<3,float, aggregate<double,double>> > phases;
+
+	// first phase
+	phases.add( vector_dist<3,float, aggregate<double,double>>(4096,box,bc,ghost) );
+
+	// The other 3 phases
+	phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),4096) );
+	phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),4096) );
+	phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),4096) );
+
+	phases.get(0).map();
+	phases.get(0).ghost_get<>();
+	phases.get(1).map();
+	phases.get(1).ghost_get<>();
+	phases.get(2).map();
+	phases.get(2).ghost_get<>();
+	phases.get(3).map();
+	phases.get(3).ghost_get<>();
+
+	size_t cnt = 0;
+
+	for (size_t i = 0 ; i < phases.size() ; i++)
+		cnt += phases.get(i).size_local();
+
+	v_cl.sum(cnt);
+	v_cl.execute();
+
+	BOOST_REQUIRE_EQUAL(cnt,4*4096ul);
+}
+
 #include "vector_dist_cell_list_tests.hpp"
 #include "vector_dist_NN_tests.hpp"
 #include "vector_dist_complex_prp_unit_test.hpp"
-- 
GitLab