From f2e1b994b832b1c441d9a423ac8f76d7e90a7e37 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <incardon@mpi-cbg.de>
Date: Fri, 7 Aug 2015 16:26:05 +0200
Subject: [PATCH] Fixing jenkins script

---
 build_pdata.sh                          |   1 +
 src/Decomposition/CartDecomposition.hpp |   2 +-
 src/Grid/grid_dist_id_unit_test.hpp     | 143 ++++++++++++++++++++++--
 3 files changed, 137 insertions(+), 9 deletions(-)

diff --git a/build_pdata.sh b/build_pdata.sh
index 61483a38..f1fb9a52 100644
--- a/build_pdata.sh
+++ b/build_pdata.sh
@@ -103,6 +103,7 @@ elif [ "$2" == "taurus" ]
 then
  echo "Compiling on taurus"
 
+ source /etc/profile
  echo "$PATH"
  module load gcc/4.8.2
  module load boost/1.55.0-gnu4.8
diff --git a/src/Decomposition/CartDecomposition.hpp b/src/Decomposition/CartDecomposition.hpp
index cdad424a..e35d3f69 100644
--- a/src/Decomposition/CartDecomposition.hpp
+++ b/src/Decomposition/CartDecomposition.hpp
@@ -222,7 +222,7 @@ private:
 	//! it contain the internal ghosts of the local processor
 	openfpm::vector<lBox_dom> loc_ghost_box;
 
-	//! Structure that contain for each sub-domain box the processor id
+	//! Structure that contain for each sub-sub-domain box the processor id
 	//! exist for efficient global communication
 	openfpm::vector<size_t> fine_s;
 
diff --git a/src/Grid/grid_dist_id_unit_test.hpp b/src/Grid/grid_dist_id_unit_test.hpp
index e7bff8ae..49780864 100644
--- a/src/Grid/grid_dist_id_unit_test.hpp
+++ b/src/Grid/grid_dist_id_unit_test.hpp
@@ -38,6 +38,10 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
 
 	Vcluster & v_cl = *global_v_cluster;
 
+	// Skip this test on big scale
+	if (v_cl.getProcessingUnits() >= 32)
+		return;
+
 	// Test several grid dimensions
 
 	for (size_t k = 1024 ; k >= 2 ; k--)
@@ -86,17 +90,18 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
 	}
 }
 
-BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
+void Test2D(const Box<2,float> & domain, long int k)
 {
-	// Domain
-	Box<2,float> domain({0.0,0.0},{1.0,1.0});
+	// 2D test
+	for ( ; k >= 2 ; k-= (k >= 66)?33:1 )
+	{
+		BOOST_TEST_CHECKPOINT( "Testing 2D grid k=" << k );
 
-	// Initialize the global VCluster
-	init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
+		if (global_v_cluster->getProcessUnitID() == 0)
+		{
+			std::cout << "Testing 2D: "<< k << "\n";
+		}
 
-	for (long int k = 1024 ; k >= 2 ; k-= (k >= 66)?33:1 )
-	{
-		BOOST_TEST_CHECKPOINT( "Testing grid k=" << k );
 		// grid size
 		size_t sz[2];
 		sz[0] = k;
@@ -182,9 +187,131 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 
 			++domg;
 		}
+	}
+}
+
+void Test3D(const Box<3,float> & domain, long int k)
+{
+	// 3D test
+	for ( ; k >= 2 ; k-= (k >= 33)?5:1 )
+	{
+		BOOST_TEST_CHECKPOINT( "Testing 3D grid k=" << k );
+		if (global_v_cluster->getProcessUnitID() == 0)
+		{
+			std::cout << "Testing 3D: "<< k << "\n";
+		}
+
+		// grid size
+		size_t sz[3];
+		sz[0] = k;
+		sz[1] = k;
+		sz[2] = k;
+
+		// Ghost
+		Ghost<3,float> g(0.01);
+
+		// Distributed grid with id decomposition
+		grid_dist_id<3, float, scalar<float>, CartDecomposition<3,float>> g_dist(sz,domain,g);
+
+		// check the consistency of the decomposition
+		bool val = g_dist.getDecomposition().check_consistency();
+		BOOST_REQUIRE_EQUAL(val,true);
+
+		// Grid sm
+		grid_sm<3,void> info(sz);
+
+		// get the domain iterator
+		size_t count = 0;
+
+		auto dom = g_dist.getDomainIterator();
+
+		while (dom.isNext())
+		{
+			auto key = dom.get();
+			auto key_g = g_dist.getGKey(key);
+
+			g_dist.template get<0>(key) = info.LinId(key_g);
+
+			// Count the point
+			count++;
+
+			++dom;
+		}
+
+		// Get the virtual cluster machine
+		Vcluster & vcl = g_dist.getVC();
+
+		// reduce
+		vcl.reduce(count);
+		vcl.execute();
+
+		// Check
+		BOOST_REQUIRE_EQUAL(count,k*k*k);
+
+		auto dom2 = g_dist.getDomainIterator();
+
+		// check that the grid store the correct information
+		while (dom2.isNext())
+		{
+			auto key = dom2.get();
+			auto key_g = g_dist.getGKey(key);
+
+			BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key),info.LinId(key_g));
+
+			++dom2;
+		}
+
+		g_dist.template ghost_get<0>();
+
+		// check that the communication is correctly completed
+
+		auto domg = g_dist.getDomainGhostIterator();
+
+		// check that the grid with the ghost past store the correct information
+		while (domg.isNext())
+		{
+			auto key = domg.get();
+			auto key_g = g_dist.getGKey(key);
+
+			// In this case the boundary condition are non periodic
+			if (g_dist.isInside(key_g))
+			{
+				if (g_dist.template get<0>(key) != info.LinId(key_g))
+				{
+					int debug = 0;
+					debug++;
+				}
+
+				BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key),info.LinId(key_g));
+			}
+
+			++domg;
+		}
 
 
 	}
+}
+
+BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
+{
+	// Domain
+	Box<2,float> domain({0.0,0.0},{1.0,1.0});
+
+	// Initialize the global VCluster
+	init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
+
+	long int k = 1024*1024*global_v_cluster->getProcessingUnits();
+	k = std::pow(k, 1/2.);
+	Test2D(domain,k);
+
+	// Domain
+	Box<3,float> domain3({0.0,0.0,0.0},{1.0,1.0,1.0});
+
+	k = 128*128*128*global_v_cluster->getProcessingUnits();
+	k = std::pow(k, 1/3.);
+	Test3D(domain3,k);
+
+	// 3D test
 
 //	g_dist.write("");
 
-- 
GitLab