From dc67afff3b12c9587d05593ed0c7aa5352358508 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <incardon@mpi-cbg.de>
Date: Thu, 2 Jul 2020 18:19:40 +0200
Subject: [PATCH] Toward subset

---
 openfpm_numerics                  |  2 +-
 src/Vector/vector_dist.hpp        | 49 +++++++++++++++++++++++++++++++
 src/Vector/vector_dist_subset.hpp | 48 +++++++++++++++++++++++++++---
 3 files changed, 94 insertions(+), 5 deletions(-)

diff --git a/openfpm_numerics b/openfpm_numerics
index 9c7fd13a7..8865e41b8 160000
--- a/openfpm_numerics
+++ b/openfpm_numerics
@@ -1 +1 @@
-Subproject commit 9c7fd13a7b6735c2384430bb96abb1596ec6b6ea
+Subproject commit 8865e41b8572cf0a8385562947c1f630dfcfff7c
diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp
index c73ac7aa5..922853071 100644
--- a/src/Vector/vector_dist.hpp
+++ b/src/Vector/vector_dist.hpp
@@ -568,6 +568,16 @@ public:
 		return g_m;
 	}
 
+	/*! \brief return the local size of the vector
+	 *
+	 * \return local size
+	 *
+	 */
+	size_t size_local_orig() const
+	{
+		return g_m;
+	}
+
 	/*! \brief return the local size of the vector
 	 *
 	 * \return local size
@@ -632,6 +642,40 @@ public:
 		return v_pos.template get<0>(vec_key);
 	}
 
+	/*! \brief Get the position of an element
+	 *
+	 * see the vector_dist iterator usage to get an element key
+	 *
+	 * \param vec_key element
+	 *
+	 * \return the position of the element in space
+	 *
+	 */
+	inline auto getPosOrig(vect_dist_key_dx vec_key) const -> decltype(v_pos.template get<0>(vec_key.getKey()))
+	{
+#ifdef SE_CLASS3
+		check_for_pos_nan_inf<prop::max_prop_real,prop::max_prop>(*this,vec_key.getKey());
+#endif
+		return v_pos.template get<0>(vec_key.getKey());
+	}
+
+	/*! \brief Get the position of an element
+	 *
+	 * see the vector_dist iterator usage to get an element key
+	 *
+	 * \param vec_key element
+	 *
+	 * \return the position of the element in space
+	 *
+	 */
+	inline auto getPosOrig(size_t vec_key) -> decltype(v_pos.template get<0>(vec_key))
+	{
+#ifdef SE_CLASS3
+		check_for_pos_nan_inf<prop::max_prop_real,prop::max_prop>(*this,vec_key);
+#endif
+		return v_pos.template get<0>(vec_key);
+	}
+
 	/*! \brief Get the position of an element
 	 *
 	 * see the vector_dist iterator usage to get an element key
@@ -1031,6 +1075,11 @@ public:
 
 ////////////////////////////////////////////////////////////////
 
+	vect_dist_key_dx getOriginKey(vect_dist_key_dx vec_key)
+	{
+		return vec_key;
+	}
+
 	/*! \brief Construct a cell list symmetric based on a cut of radius
 	 *
 	 * \tparam CellL CellList type to construct
diff --git a/src/Vector/vector_dist_subset.hpp b/src/Vector/vector_dist_subset.hpp
index 2763691c5..6a214d2e3 100644
--- a/src/Vector/vector_dist_subset.hpp
+++ b/src/Vector/vector_dist_subset.hpp
@@ -82,6 +82,16 @@ public:
         return g_m;
     }
 
+    /*! \brief return the local size of the original vector
+ *
+ * \return local size
+ *
+ */
+    size_t size_local_orig() const
+    {
+        return vd.size_local();
+    }
+
 #ifndef ONLY_READWRITE_GETTER
 
     /*! \brief Get the position of an element
@@ -112,6 +122,34 @@ public:
         return vd.getPos(vect_dist_key_dx(pid.template get<0>(vec_key.getKey())));
     }
 
+    /*! \brief Get the position of an element
+     *
+     * see the vector_dist iterator usage to get an element key
+     *
+     * \param vec_key element
+     *
+     * \return the position of the element in space
+     *
+     */
+    inline auto getPosOrig(vect_dist_key_dx vec_key) -> decltype(vd.getPos(vec_key))
+    {
+        return vd.getPos(vec_key.getKey());
+    }
+
+    /*! \brief Get the position of an element
+     *
+     * see the vector_dist iterator usage to get an element key
+     *
+     * \param vec_key element
+     *
+     * \return the position of the element in space
+     *
+     */
+    inline auto getPosOrig(vect_dist_key_dx vec_key) const -> decltype(vd.getPos(vec_key))
+    {
+        return vd.getPos(vec_key.getKey());
+    }
+
     /*! \brief Get the property of an element
  *
  * see the vector_dist iterator usage to get an element key
@@ -143,6 +181,11 @@ public:
     }
 
 
+	vect_dist_key_dx getOriginKey(vect_dist_key_dx vec_key)
+	{
+		return vect_dist_key_dx(pid.template get<0>(vec_key.getKey()));
+	}
+
 #endif
 
     /*! \brief Get an iterator that traverse the particles in the domain
@@ -176,9 +219,6 @@ public:
 		if (no_se3 == false)
 		{se3.getNN();}
 #endif
-#ifdef SE_CLASS1
-		check_ghost_compatible_rcut(r_cut);
-#endif
 
 		// Get ghost and anlarge by 1%
 		Ghost<dim,St> g = vd.getDecomposition().getGhost();
@@ -236,7 +276,7 @@ public:
 
 			Point<dim,St> pos = getPos(key);
 
-			cell_list.add(pos, key.getKey());
+			cell_list.add(pos,pid.template get<0>(key.getKey()));
 
 			++it;
 		}
-- 
GitLab