From daf36c056aaa80932671887acb89f48774a548d1 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <i-bird@localhost.localdomain>
Date: Fri, 2 Sep 2016 00:30:58 +0200
Subject: [PATCH] Make ghost put test stringer

---
 CHANGELOG.md                         |   4 +-
 script/install_PETSC.sh              |   7 +-
 src/Vector/vector_dist_unit_test.hpp | 129 +++++++++++++++++++--------
 3 files changed, 100 insertions(+), 40 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b1d6ca34..e5b701ba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,8 +8,8 @@ All notable changes to this project will be documented in this file.
 - Full-Support for complex property on vector-dist (Serialization) + example
 
 ### Fixed
-- Installation in case of MPI preinstalled PETSC fail
-- vector_dist with negative domain
+- Installation PETSC installation fail in case of preinstalled MPI
+- vector_dist with negative domain (Now supported)
 - Grid 1D fixing
 
 ### Changed
diff --git a/script/install_PETSC.sh b/script/install_PETSC.sh
index cbc08d16..a420fc28 100755
--- a/script/install_PETSC.sh
+++ b/script/install_PETSC.sh
@@ -57,6 +57,9 @@ fi
 
 if [ -d "$1/MPI" ]; then
   configure_trilinos_options="$configure_trilinos_options -D MPI_BASE_DIR=$1/MPI "
+  mpi_dir="$1/MPI"
+else
+  mpi_dir=$(dirname "$(dirname "$(which mpic++)")")
 fi
 
 ### It seem that the PETSC --download-packege option has several problems and cannot produce
@@ -286,9 +289,9 @@ fi
 tar -xf petsc-lite-3.6.4.tar.gz
 cd petsc-3.6.4
 
-echo "./configure --with-cxx-dialect=C++11 --with-mpi-dir=$1/MPI  $configure_options  --prefix=$1/PETSC"
+echo "./configure --with-cxx-dialect=C++11 --with-mpi-dir=$mpi_dir  $configure_options  --prefix=$1/PETSC"
 
-./configure --with-cxx-dialect=C++11 $petsc_openmp --with-mpi-dir=$1/MPI  $configure_options --with-mumps-lib="$MUMPS_extra_lib"  --prefix=$1/PETSC
+./configure --with-cxx-dialect=C++11 $petsc_openmp --with-mpi-dir=$mpi_dir  $configure_options --with-mumps-lib="$MUMPS_extra_lib"  --prefix=$1/PETSC
 make all test
 make install
 
diff --git a/src/Vector/vector_dist_unit_test.hpp b/src/Vector/vector_dist_unit_test.hpp
index e4fa814e..bd6d9c6a 100644
--- a/src/Vector/vector_dist_unit_test.hpp
+++ b/src/Vector/vector_dist_unit_test.hpp
@@ -1632,62 +1632,119 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost_put )
 		// sync the ghost
 		vd.ghost_get<0>();
 
-		auto NN = vd.getCellList(1.3/k);
-		float a = 1.0f*k*k;
+		{
+			auto NN = vd.getCellList(1.3/k);
+			float a = 1.0f*k*k;
 
-		// run trough all the particles + ghost
+			// run trough all the particles + ghost
 
-		auto it2 = vd.getDomainIterator();
+			auto it2 = vd.getDomainIterator();
 
-		while (it2.isNext())
-		{
-			// particle p
-			auto p = it2.get();
-			Point<3,float> xp = vd.getPos(p);
+			while (it2.isNext())
+			{
+				// particle p
+				auto p = it2.get();
+				Point<3,float> xp = vd.getPos(p);
 
-			// Get an iterator over the neighborhood particles of p
-			auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(vd.getPos(p)));
+				// Get an iterator over the neighborhood particles of p
+				auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(vd.getPos(p)));
 
-			// For each neighborhood particle ...
-			while (Np.isNext())
-			{
-				auto q = Np.get();
-				Point<3,float> xq = vd.getPos(q);
+				// For each neighborhood particle ...
+				while (Np.isNext())
+				{
+					auto q = Np.get();
+					Point<3,float> xq = vd.getPos(q);
 
-				float dist = xp.distance(xq);
+					float dist = xp.distance(xq);
 
-				if (dist < 1.0/k)
-					vd.getProp<0>(q) += a*(-dist*dist+1.0/k/k);
+					if (dist < 1.0/k)
+						vd.getProp<0>(q) += a*(-dist*dist+1.0/k/k);
 
-				++Np;
+					++Np;
+				}
+
+				++it2;
 			}
 
-			++it2;
-		}
+			vd.ghost_put<add_,0>();
 
-		vd.ghost_put<add_,0>();
+			bool ret = true;
+			auto it3 = vd.getDomainIterator();
 
-		bool ret = true;
-		auto it3 = vd.getDomainIterator();
+			float constant = vd.getProp<0>(it3.get());
+			float eps = 0.001;
+
+			while (it3.isNext())
+			{
+				float constant2 = vd.getProp<0>(it3.get());
+				if (fabs(constant - constant2)/constant > eps)
+				{
+					std::cout << Point<3,float>(vd.getPos(it3.get())).toString() << "    " <<  constant2 << "/" << constant << "    " << v_cl.getProcessUnitID() << std::endl;
+					ret = false;
+					break;
+				}
 
-		float constant = vd.getProp<0>(it3.get());
-		float eps = 0.001;
+				++it3;
+			}
+			BOOST_REQUIRE_EQUAL(ret,true);
+		}
 
-		while (it3.isNext())
 		{
-			float constant2 = vd.getProp<0>(it3.get());
-			if (fabs(constant - constant2)/constant > eps)
+			auto NN = vd.getCellList(1.3/k);
+			float a = 1.0f*k*k;
+
+			// run trough all the particles + ghost
+
+			auto it2 = vd.getDomainIterator();
+
+			while (it2.isNext())
 			{
-				std::cout << Point<3,float>(vd.getPos(it3.get())).toString() << "    " <<  constant2 << "/" << constant << "    " << v_cl.getProcessUnitID() << std::endl;
-				ret = false;
-				break;
+				// particle p
+				auto p = it2.get();
+				Point<3,float> xp = vd.getPos(p);
+
+				// Get an iterator over the neighborhood particles of p
+				auto Np = NN.template getNNIterator<NO_CHECK>(NN.getCell(vd.getPos(p)));
+
+				// For each neighborhood particle ...
+				while (Np.isNext())
+				{
+					auto q = Np.get();
+					Point<3,float> xq = vd.getPos(q);
+
+					float dist = xp.distance(xq);
+
+					if (dist < 1.0/k)
+						vd.getProp<0>(q) += a*(-dist*dist+1.0/k/k);
+
+					++Np;
+				}
+
+				++it2;
 			}
 
-			++it3;
-		}
+			vd.ghost_put<add_,0>();
 
+			bool ret = true;
+			auto it3 = vd.getDomainIterator();
 
-		BOOST_REQUIRE_EQUAL(ret,true);
+			float constant = vd.getProp<0>(it3.get());
+			float eps = 0.001;
+
+			while (it3.isNext())
+			{
+				float constant2 = vd.getProp<0>(it3.get());
+				if (fabs(constant - constant2)/constant > eps)
+				{
+					std::cout << Point<3,float>(vd.getPos(it3.get())).toString() << "    " <<  constant2 << "/" << constant << "    " << v_cl.getProcessUnitID() << std::endl;
+					ret = false;
+					break;
+				}
+
+				++it3;
+			}
+			BOOST_REQUIRE_EQUAL(ret,true);
+		}
 	}
 }
 
-- 
GitLab