From 3fe1169fdbc0151f761b3c3933508a6769752bd0 Mon Sep 17 00:00:00 2001
From: Tomas Sobotik <sobotto4@fjfi.cvut.cz>
Date: Wed, 29 Apr 2015 08:55:46 +0200
Subject: [PATCH] Fixes of CPU code

---
 .../tnlParallelEikonalSolver_impl.h           |  8 +++-
 .../parallelGodunovEikonal2D_impl.h           | 46 +++++++++----------
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/examples/hamilton-jacobi-parallel/tnlParallelEikonalSolver_impl.h b/examples/hamilton-jacobi-parallel/tnlParallelEikonalSolver_impl.h
index 926f8053b8..59cc75a286 100644
--- a/examples/hamilton-jacobi-parallel/tnlParallelEikonalSolver_impl.h
+++ b/examples/hamilton-jacobi-parallel/tnlParallelEikonalSolver_impl.h
@@ -25,7 +25,7 @@ template< typename SchemeHost, typename SchemeDevice, typename Device>
 tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int>::tnlParallelEikonalSolver()
 {
 	cout << "a" << endl;
-	this->device = tnlCudaDevice;
+	this->device = tnlHostDevice;
 
 #ifdef HAVE_CUDA
 	if(this->device == tnlCudaDevice)
@@ -243,7 +243,7 @@ void tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int>::ru
 		else
 			end=false;
 #ifdef HAVE_OPENMP
-#pragma omp parallel for num_threads(3) schedule(dynamic)
+#pragma omp parallel for num_threads(4) schedule(dynamic)
 #endif
 		for(int i = 0; i < this->subgridValues.getSize(); i++)
 		{
@@ -859,6 +859,9 @@ tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int>::runSubg
 	{
 		if(u[0]*u[i] <= 0.0)
 			tmp=true;
+		int centreGID = (this->n*(subGridID / this->gridRows)+ (this->n >> 1))*(this->n*this->gridCols) + this->n*(subGridID % this->gridRows) + (this->n >> 1);
+		if(this->unusedCell[centreGID] == 0 || boundaryCondition == 0)
+			tmp = true;
 	}
 	//if(this->currentStep + 3 < getSubgridValue(subGridID))
 		//tmp = true;
@@ -1003,6 +1006,7 @@ tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int>::runSubg
 	solution.setLike(u);
     for( int i = 0; i < u.getSize(); i ++ )
   	{
+    	solution[i]=u[i];
    	}
 	return solution;
 }
diff --git a/src/operators/godunov-eikonal/parallelGodunovEikonal2D_impl.h b/src/operators/godunov-eikonal/parallelGodunovEikonal2D_impl.h
index 628d65d688..965d8d22d0 100644
--- a/src/operators/godunov-eikonal/parallelGodunovEikonal2D_impl.h
+++ b/src/operators/godunov-eikonal/parallelGodunovEikonal2D_impl.h
@@ -178,36 +178,36 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
 		   else *//*if(boundaryCondition & 4)
 			   xf = 0.0;
 		   else /**/if(coordinates.x() == mesh.getDimensions().x() - 1)
-			   xf = negativePart((u[mesh.template getCellNextToCell<-1,0>( cellIndex )] - u[cellIndex])/hx);
+			   xf = negativePart((u[mesh.template getCellNextToCell<-1,0>( cellIndex )] - u[cellIndex])*ihx);
 		   else
-			   xf = negativePart((u[mesh.template getCellNextToCell<1,0>( cellIndex )] - u[cellIndex])/hx);
+			   xf = negativePart((u[mesh.template getCellNextToCell<1,0>( cellIndex )] - u[cellIndex])*ihx);
 
 	/**/ /*  if(boundaryCondition & 4)
-			   xb = (u[cellIndex] - u[mesh.getCellXPredecessor( cellIndex )])/hx;
+			   xb = (u[cellIndex] - u[mesh.getCellXPredecessor( cellIndex )])*ihx;
 		   else *//*if(boundaryCondition & 2)
 			   xb = 0.0;
 		   else /**/if(coordinates.x() == 0)
-			   xb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<+1,0>( cellIndex )])/hx);
+			   xb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<+1,0>( cellIndex )])*ihx);
 		   else
-			   xb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<-1,0>( cellIndex )])/hx);
+			   xb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<-1,0>( cellIndex )])*ihx);
 
 	/**/  /* if(boundaryCondition & 1)
-			   yf = (u[mesh.getCellYSuccessor( cellIndex )] - u[cellIndex])/hy;
+			   yf = (u[mesh.getCellYSuccessor( cellIndex )] - u[cellIndex])*ihy;
 		   else *//*if(boundaryCondition & 8)
 			   yf = 0.0;
 		   else /**/if(coordinates.y() == mesh.getDimensions().y() - 1)
-			   yf = negativePart((u[mesh.template getCellNextToCell<0,-1>( cellIndex )] - u[cellIndex])/hy);
+			   yf = negativePart((u[mesh.template getCellNextToCell<0,-1>( cellIndex )] - u[cellIndex])*ihy);
 		   else
-			   yf = negativePart((u[mesh.template getCellNextToCell<0,1>( cellIndex )] - u[cellIndex])/hy);
+			   yf = negativePart((u[mesh.template getCellNextToCell<0,1>( cellIndex )] - u[cellIndex])*ihy);
 
 	/**/  /* if(boundaryCondition & 8)
-			   yb = (u[cellIndex] - u[mesh.getCellYPredecessor( cellIndex )])/hy;
+			   yb = (u[cellIndex] - u[mesh.getCellYPredecessor( cellIndex )])*ihy;
 		   else *//*if(boundaryCondition & 1)
 			   yb = 0.0;
 		   else /**/if(coordinates.y() == 0)
-			   yb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,1>( cellIndex )])/hy);
+			   yb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,1>( cellIndex )])*ihy);
 		   else
-			   yb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,-1>( cellIndex )])/hy);
+			   yb = positivePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,-1>( cellIndex )])*ihy);
 
 		   if(xb - xf > 0.0)
 			   xf = 0.0;
@@ -228,40 +228,40 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
 	   {
 
 	/**/  /* if(boundaryCondition & 2)
-			   xf = (u[mesh.getCellXSuccessor( cellIndex )] - u[cellIndex])/hx;
+			   xf = (u[mesh.getCellXSuccessor( cellIndex )] - u[cellIndex])*ihx;
 		   else*//* if(boundaryCondition & 4)
 			   xf = 0.0;
 		   else /**/if(coordinates.x() == mesh.getDimensions().x() - 1)
-			   xf = positivePart((u[mesh.template getCellNextToCell<-1,0>( cellIndex )] - u[cellIndex])/hx);
+			   xf = positivePart((u[mesh.template getCellNextToCell<-1,0>( cellIndex )] - u[cellIndex])*ihx);
 		   else
-			   xf = positivePart((u[mesh.template getCellNextToCell<1,0>( cellIndex )] - u[cellIndex])/hx);
+			   xf = positivePart((u[mesh.template getCellNextToCell<1,0>( cellIndex )] - u[cellIndex])*ihx);
 
 	/**/  /* if(boundaryCondition & 4)
-			   xb = (u[cellIndex] - u[mesh.getCellXPredecessor( cellIndex )])/hx;
+			   xb = (u[cellIndex] - u[mesh.getCellXPredecessor( cellIndex )])*ihx;
 		   else*//* if(boundaryCondition & 2)
 			   xb = 0.0;
 		   else /**/if(coordinates.x() == 0)
-			   xb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<1,0>( cellIndex )])/hx);
+			   xb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<1,0>( cellIndex )])*ihx);
 		   else
-			   xb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<-1,0>( cellIndex )])/hx);
+			   xb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<-1,0>( cellIndex )])*ihx);
 
 	/**/ /*  if(boundaryCondition & 1)
-			   yf = (u[mesh.getCellYSuccessor( cellIndex )] - u[cellIndex])/hy;
+			   yf = (u[mesh.getCellYSuccessor( cellIndex )] - u[cellIndex])*ihy;
 		   else *//*if(boundaryCondition & 8)
 			   yf = 0.0;
 		   else /**/if(coordinates.y() == mesh.getDimensions().y() - 1)
-			   yf = positivePart((u[mesh.template getCellNextToCell<0,-1>( cellIndex )] - u[cellIndex])/hy);
+			   yf = positivePart((u[mesh.template getCellNextToCell<0,-1>( cellIndex )] - u[cellIndex])*ihy);
 		   else
-			   yf = positivePart((u[mesh.template getCellNextToCell<0,1>( cellIndex )] - u[cellIndex])/hy);
+			   yf = positivePart((u[mesh.template getCellNextToCell<0,1>( cellIndex )] - u[cellIndex])*ihy);
 
 	/**/  /* if(boundaryCondition & 8)
-			   yb = (u[cellIndex] - u[mesh.getCellYPredecessor( cellIndex )])/hy;
+			   yb = (u[cellIndex] - u[mesh.getCellYPredecessor( cellIndex )])*ihy;
 		   else*//* if(boundaryCondition & 1)
 			   yb = 0.0;
 		   else /**/if(coordinates.y() == 0)
-			   yb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,1>( cellIndex )])/hy);
+			   yb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,1>( cellIndex )])*ihy);
 		   else
-			   yb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,-1>( cellIndex )])/hy);
+			   yb = negativePart((u[cellIndex] - u[mesh.template getCellNextToCell<0,-1>( cellIndex )])*ihy);
 
 
 		   if(xb - xf > 0.0)
-- 
GitLab