From 88bfcb88bbae8fe14e6563bcb9b04421e61efb0b Mon Sep 17 00:00:00 2001
From: Pietro Incardona <incardon@mpi-cbg.de>
Date: Wed, 22 Feb 2017 15:20:28 +0100
Subject: [PATCH] Fixing example compilation

---
 example/Vector/0_simple/main.cpp   |  7 +++++--
 example/Vector/1_celllist/main.cpp | 24 +++++++++++++++---------
 example/Vector/7_SPH_dlb/main.cpp  | 10 +++++++++-
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/example/Vector/0_simple/main.cpp b/example/Vector/0_simple/main.cpp
index 0439d956f..bcb7903fe 100644
--- a/example/Vector/0_simple/main.cpp
+++ b/example/Vector/0_simple/main.cpp
@@ -330,7 +330,7 @@ int main(int argc, char* argv[])
 	 * generate a VTK file. VTK has two format one is the ASCII that is human readable but produce
 	 * bigger file the other is the binary that produce not-human readable files, but smaller
 	 * and more efficent files to read for Paraview. In order to create a Binary VTK file use the
-	 * option VTK_
+	 * option VTK_WRITER in combination with FORMAT_BINARY
 	 *
 	 * \snippet Vector/0_simple/main.cpp vtk
 	 *
@@ -346,8 +346,11 @@ int main(int argc, char* argv[])
 
 	//! \cond [vtk] \endcond
 
+	// save vtk format (vtk is always the default)
 	vd.write("particles");
-	vd.write("particles",VTK_WRITE_BINARY);
+
+	// save in vtk binary format
+	vd.write("particles_bin",VTK_WRITER | FORMAT_BINARY);
 
 	//! \cond [vtk] \endcond
 
diff --git a/example/Vector/1_celllist/main.cpp b/example/Vector/1_celllist/main.cpp
index 96aa95f74..28c4a6fe1 100644
--- a/example/Vector/1_celllist/main.cpp
+++ b/example/Vector/1_celllist/main.cpp
@@ -310,26 +310,28 @@ int main(int argc, char* argv[])
 
 	//! \cond [verletlist] \endcond
 
-	openfpm::vector<openfpm::vector<size_t>> verlet;
-	vd.getVerletDeprecated(verlet,r_cut);
+	auto verlet = vd.getVerlet(r_cut);
+
+	auto it3 = vd.getDomainIterator();
 
 	// For each particle i verlet.size() == Number of particles
-	for (size_t i = 0 ; i < verlet.size() ; i++)
+	while (it3.isNext())
 	{
+		auto p = it3.get();
 
 		// get the position of the particle i
-		Point<3,float> xp = vd.getPos(i);
+		Point<3,float> xp = vd.getPos(p);
 
-		// get the Neighborhood of i
-		openfpm::vector<size_t> & NN = verlet.get(i);
+		// get the Neighborhood of p
+		auto NNp = verlet.getNNIterator(p.getKey());
 
 		// for each neighborhood j of particle to i
-		for (size_t j = 0 ; j < NN.size() ; j++)
+		while (NNp.isNext())
 		{
-			size_t p = NN.get(j);
+			size_t q = NNp.get();
 
 			// Get the position of the particle neighborhood if i
-			Point<3,float> xq = vd.getPos(p);
+			Point<3,float> xq = vd.getPos(q);
 
 			// Calculate the distance vector between p and q
 			Point<3,float> f = (xp - xq);
@@ -352,7 +354,11 @@ int main(int argc, char* argv[])
 			vd.template getProp<2>(p)[2][0] += (xp.get(2) - xq.get(2)) * (xp.get(0) - xq.get(0));
 			vd.template getProp<2>(p)[2][1] += (xp.get(2) - xq.get(2)) * (xp.get(1) - xq.get(1));
 			vd.template getProp<2>(p)[2][2] += (xp.get(2) - xq.get(2)) * (xp.get(2) - xq.get(2));
+
+			++NNp;
 		}
+
+		++it3;
 	}
 
 	//! \cond [verletlist] \endcond
diff --git a/example/Vector/7_SPH_dlb/main.cpp b/example/Vector/7_SPH_dlb/main.cpp
index 535912b44..5adaa1235 100644
--- a/example/Vector/7_SPH_dlb/main.cpp
+++ b/example/Vector/7_SPH_dlb/main.cpp
@@ -204,7 +204,10 @@ typedef vector_dist<3,double,aggregate<size_t,double,  double,    double,     do
 
 struct ModelCustom
 {
-	template<typename Decomposition, typename vector> inline void addComputation(Decomposition & dec, const vector & vd, size_t v, size_t p)
+	template<typename Decomposition, typename vector> inline void addComputation(Decomposition & dec,
+			                                                                     const vector & vd,
+																				 size_t v,
+																				 size_t p)
 	{
 		if (vd.template getProp<type>(p) == FLUID)
 			dec.addComputationCost(v,4);
@@ -216,6 +219,11 @@ struct ModelCustom
 	{
 		dec.setSubSubDomainComputationCost(v, dec.getSubSubDomainComputationCost(v) * dec.getSubSubDomainComputationCost(v));
 	}
+
+	double distributionTol()
+	{
+		return 1.01;
+	}
 };
 
 /*! \cond [model custom] \endcond */
-- 
GitLab