From 0985040d5642486d9a1ef0af7e6284b114de3ee9 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <incardon@mpi-cbg.de>
Date: Wed, 19 Oct 2016 17:27:46 +0200
Subject: [PATCH] Ghost get and put example + small fixes for NO_POSITION

---
 example/Vector/0_simple/main.cpp   |  5 +++--
 example/Vector/1_celllist/main.cpp |  3 +++
 src/Vector/vector_dist_comm.hpp    | 19 ++++++++-----------
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/example/Vector/0_simple/main.cpp b/example/Vector/0_simple/main.cpp
index badf7e472..aeba11f0a 100644
--- a/example/Vector/0_simple/main.cpp
+++ b/example/Vector/0_simple/main.cpp
@@ -2,6 +2,7 @@
  *
  * \subpage Vector_0_simple
  * \subpage Vector_1_celllist
+ * \subpage Vector_1_ghost_get
  * \subpage Vector_2_expression
  * \subpage Vector_3_md
  * \subpage Vector_4_reo_root
@@ -39,7 +40,7 @@
  * </div>
  * \endhtmlonly
  *
- * ## inclusion ## {#inclusion}
+ * ## inclusion ## {#e0_v_inclusion}
  *
  * In order to use distributed vectors in our code we have to include the file Vector/vector_dist.hpp
  *
@@ -62,7 +63,7 @@ int main(int argc, char* argv[])
 	 *  Here we
 	 *  * Initialize the library
 	 *  * we create a Box that define our domain
-	 *  * An array that define out boundary conditions
+	 *  * An array that define our boundary conditions
 	 *  * A Ghost object that will define the extension of the ghost part in physical units
 	 *
 	 *
diff --git a/example/Vector/1_celllist/main.cpp b/example/Vector/1_celllist/main.cpp
index 30cbb8945..96aa95f74 100644
--- a/example/Vector/1_celllist/main.cpp
+++ b/example/Vector/1_celllist/main.cpp
@@ -173,6 +173,9 @@ int main(int argc, char* argv[])
 	 * no properties. If we want to synchronize also properties we have to specify which one.
 	 * For example with <0,1,2> here we synchronize the scalar property (0), the vector (1), and the rank 2 tensor (2)
 	 *
+	 * \warning Every ghost_get by default reset the status of the ghost so the information are lost
+	 *
+	 * \see \ref e1_gg_options
 	 *
 	 * \htmlonly
 	 * <a href="#" onclick="hide_show('vector-video-5')" >Video 1</a>
diff --git a/src/Vector/vector_dist_comm.hpp b/src/Vector/vector_dist_comm.hpp
index 4ec0a7c91..aba7582ef 100644
--- a/src/Vector/vector_dist_comm.hpp
+++ b/src/Vector/vector_dist_comm.hpp
@@ -366,12 +366,9 @@ class vector_dist_comm
 		// Create the shift boxes
 		createShiftBox();
 
-		if (opt != SKIP_LABELLING)
+		if (!(opt & SKIP_LABELLING))
 			lg_m = v_prp.size();
 
-//		v_pos.resize(lg_m);
-//		v_prp.resize(lg_m);
-
 		if (box_f.size() == 0)
 			return;
 		else
@@ -822,10 +819,11 @@ public:
 		// send vector for each processor
 		typedef openfpm::vector<prp_object> send_vector;
 
-		v_pos.resize(g_m);
+		if (!(opt & NO_POSITION))
+			v_pos.resize(g_m);
 
 		// reset the ghost part
-		if (opt != SKIP_LABELLING)
+		if (!(opt & SKIP_LABELLING))
 		{
 			v_prp.resize(g_m);
 		}
@@ -839,22 +837,21 @@ public:
 		fill_send_ghost_prp_buf<send_vector, prp_object, prp...>(v_prp,g_send_prp);
 
 		// Create and fill the send buffer for the particle position
-		if (opt != NO_POSITION)
+		if (!(opt & NO_POSITION))
 			fill_send_ghost_pos_buf(v_pos,g_pos_send);
 
 		prc_recv_get.clear();
 		recv_sz_get.clear();
 
-		if (opt == SKIP_LABELLING)
+		if (opt & SKIP_LABELLING)
 		{
 			op_ssend_gg_recv_merge opm(g_m);
-//			v_cl.SSendRecvP_op<op_ssend_recv_merge<op>
 			v_cl.SSendRecvP_op<op_ssend_gg_recv_merge,send_vector,decltype(v_prp),prp...>(g_send_prp,v_prp,prc_g_opart,opm,prc_recv_get,recv_sz_get);
 		}
 		else
 			v_cl.SSendRecvP<send_vector,decltype(v_prp),prp...>(g_send_prp,v_prp,prc_g_opart,prc_recv_get,recv_sz_get);
 
-		if (opt != NO_POSITION)
+		if (!(opt & NO_POSITION))
 		{
 			prc_recv_get.clear();
 			recv_sz_get.clear();
@@ -1071,7 +1068,7 @@ public:
 		if (v_prp.size() - lg_m != o_part_loc.size())
 		{
 			std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Local ghost particles = " << v_prp.size() - lg_m << " != " << o_part_loc.size() << std::endl;
-			std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << "Check that you did a ghost_get before a ghost_put" << std::endl;
+			std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Check that you did a ghost_get before a ghost_put" << std::endl;
 		}
 
 
-- 
GitLab