From 7fd38ee413229eb7be14e7b064028453ae4f0938 Mon Sep 17 00:00:00 2001
From: "LEGOLAS\\lenz" <lenz@irmb.tu-bs.de>
Date: Thu, 4 Jun 2020 16:40:31 +0200
Subject: [PATCH] fixes some bugs for new updateGrid27 function, especially
 initialization of boundary condition coutners

---
 .../Calculation/UpdateGrid27.cpp              |  6 ++--
 .../Calculation/UpdateGrid27.h                | 28 ++++++++++++++++++-
 src/VirtualFluids_GPU/LBM/LB.h                |  8 +++---
 src/VirtualFluids_GPU/LBM/Simulation.cpp      |  8 ++++--
 src/VirtualFluids_GPU/Parameter/Parameter.h   |  4 +--
 .../gridGeneratorTest/gridGeneratorTest.cpp   | 18 ++++++------
 6 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/src/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp b/src/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp
index 440576fe6..d4f388512 100644
--- a/src/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp
+++ b/src/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp
@@ -1259,7 +1259,7 @@ void coarseToFine(Parameter* para, int level)
 
 
 
-
+/*
 
 void updateGrid27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, std::vector<std::shared_ptr<PorousMedia>> pm, int level, int max_level, unsigned int t, std::vector < SPtr< Kernel>> kernels)
 {
@@ -2842,7 +2842,7 @@ void updateGrid27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaMa
 		 //////////////////////////////////////////////////////////////////////////////////
 		 ////Calculation of cp
 		 //////////////////////////////////////////////////////////////////////////////////
-		 //if (/*(para->getParD(level)->numberOfPointsCpTop > 0)*/ (level == 5) && (t > para->getTStartOut()))
+		 //if ((para->getParD(level)->numberOfPointsCpTop > 0) (level == 5) && (t > para->getTStartOut()))
 		 //{
 			// ////////////////////////////////////////////////////////////////////////////////
 			// //Level 7
@@ -3256,5 +3256,5 @@ void updateGrid27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaMa
    }
 }
 
-
+*/
 
diff --git a/src/VirtualFluids_GPU/Calculation/UpdateGrid27.h b/src/VirtualFluids_GPU/Calculation/UpdateGrid27.h
index 1cbd11ad6..5d404e612 100644
--- a/src/VirtualFluids_GPU/Calculation/UpdateGrid27.h
+++ b/src/VirtualFluids_GPU/Calculation/UpdateGrid27.h
@@ -10,6 +10,32 @@
 
 class Kernel;
 
-extern "C" void updateGrid27(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, std::vector<std::shared_ptr<PorousMedia>> pm, int level, int max_level, unsigned int t, std::vector < SPtr< Kernel>> kernels);
+extern "C" void updateGrid27(Parameter* para, 
+                             Communicator* comm, 
+                             CudaMemoryManager* cudaManager, 
+                             std::vector<std::shared_ptr<PorousMedia>>& pm, 
+                             int level,
+                             unsigned int t, 
+                             std::vector < SPtr< Kernel>>& kernels);
+
+extern "C" void collision(Parameter* para, std::vector<std::shared_ptr<PorousMedia>>& pm, int level, unsigned int t, std::vector < SPtr< Kernel>>& kernels);
+
+extern "C" void collisionPorousMedia(Parameter* para, std::vector<std::shared_ptr<PorousMedia>>& pm, int level);
+
+extern "C" void collisionAdvectionDiffusion(Parameter* para, int level);
+
+extern "C" void exchangeMultiGPU(Parameter* para, Communicator* comm, CudaMemoryManager* cudaManager, int level);
+
+extern "C" void postCollisionBC(Parameter* para, int level, unsigned int t);
+
+extern "C" void swapBetweenEvenAndOddTimestep(Parameter* para, int level);
+
+extern "C" void calcMacroscopicQuantities(Parameter* para, int level);
+
+extern "C" void preCollisionBC(Parameter* para, CudaMemoryManager* cudaManager, int level, unsigned int t);
+
+extern "C" void fineToCoarse(Parameter* para, int level);
+
+extern "C" void coarseToFine(Parameter* para, int level);
 
 #endif
diff --git a/src/VirtualFluids_GPU/LBM/LB.h b/src/VirtualFluids_GPU/LBM/LB.h
index e19395c8a..4ce6b1ff2 100644
--- a/src/VirtualFluids_GPU/LBM/LB.h
+++ b/src/VirtualFluids_GPU/LBM/LB.h
@@ -166,7 +166,7 @@ typedef struct QforBC{
    real* qread;
    real* q27[27];
    real* q19[19];
-   int kQ;
+   int kQ=0;
    int kArray;
    real *Vx, *Vy, *Vz, *deltaVz, *RhoBC;
 }QforBoundaryConditions;
@@ -175,7 +175,7 @@ typedef struct QforBC{
 typedef struct TempforBC{
    int* k;
    real* temp;
-   int kTemp;
+   int kTemp=0;
 }TempforBoundaryConditions;
 
 //BCTempVel
@@ -184,7 +184,7 @@ typedef struct TempVelforBC{
    real* temp;
    real* tempPulse;
    real* velo;
-   int kTemp;
+   int kTemp=0;
 }TempVelforBoundaryConditions;
 
 //BCTempPress
@@ -192,7 +192,7 @@ typedef struct TempPressforBC{
    int* k;
    real* temp;
    real* velo;
-   int kTemp;
+   int kTemp=0;
 }TempPressforBoundaryConditions;
 
 //measurePoints
diff --git a/src/VirtualFluids_GPU/LBM/Simulation.cpp b/src/VirtualFluids_GPU/LBM/Simulation.cpp
index dd8b0fe58..04a36ef72 100644
--- a/src/VirtualFluids_GPU/LBM/Simulation.cpp
+++ b/src/VirtualFluids_GPU/LBM/Simulation.cpp
@@ -434,6 +434,10 @@ void Simulation::run()
 	////////////////////////////////////////////////////////////////////////////////
 	for(t=para->getTStart();t<=para->getTEnd();t++)
 	{
+        updateGrid27(para.get(), comm, cudaManager.get(), pm, 0, t, kernels);
+
+        /*
+
 		getLastCudaError("before starting a kernel we get an execution failed");
 		if (para->getMaxLevel()>=1)
         {
@@ -1192,7 +1196,7 @@ void Simulation::run()
 
 		  //////////////////////////////////////////////////////////////////////////////////
 		  ////calculate the new forcing
-		  //if (((t%10) == 0) && (t >= 10)/*((t%para->getTStartOut()) == 0) && (t >= para->getTStartOut())*/)
+		  //if (((t%10) == 0) && (t >= 10)((t%para->getTStartOut()) == 0) && (t >= para->getTStartOut()))
 		  //{
 			 // forceCalculator->calcPIDControllerForForce(para);
 			 // forceCalculator->printForcing(para);
@@ -1950,7 +1954,7 @@ void Simulation::run()
 	  }
 	  //////////////////////////////////////////////////////////////////////////////////
 
-
+      */
 
 
 	  ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/VirtualFluids_GPU/Parameter/Parameter.h b/src/VirtualFluids_GPU/Parameter/Parameter.h
index 0cf62b35d..176886832 100644
--- a/src/VirtualFluids_GPU/Parameter/Parameter.h
+++ b/src/VirtualFluids_GPU/Parameter/Parameter.h
@@ -159,7 +159,7 @@ struct ParameterStruct{
 
 	//BC's////////////////////
 	QforBoundaryConditions  QWall,   Qinflow,      Qoutflow,      QSlip;
-	unsigned int            kQ,      kInflowQ,     kOutflowQ,     kSlipQ;
+	unsigned int            kQ=0,      kInflowQ=0,     kOutflowQ=0,     kSlipQ=0;
 	unsigned int            kQread,  kInflowQread, kOutflowQread, kSlipQread;
 
 	QforBoundaryConditions  QpressX0,QpressX1,QpressY0,QpressY1,QpressZ0,QpressZ1;
@@ -171,7 +171,7 @@ struct ParameterStruct{
 	QforBoundaryConditions  QOutflowNormalX, QOutflowNormalY, QOutflowNormalZ;
 	QforBoundaryConditions  QInlet, QOutlet, QPeriodic;
 	unsigned int            kInletQread, kOutletQread;
-	unsigned int            kPressQ, kPressQread;
+	unsigned int            kPressQ=0, kPressQread;
 	//testRoundoffError
 	Distributions27         kDistTestRE;
 
diff --git a/targets/apps/LBM/gridGeneratorTest/gridGeneratorTest.cpp b/targets/apps/LBM/gridGeneratorTest/gridGeneratorTest.cpp
index 866770733..c67827ffe 100644
--- a/targets/apps/LBM/gridGeneratorTest/gridGeneratorTest.cpp
+++ b/targets/apps/LBM/gridGeneratorTest/gridGeneratorTest.cpp
@@ -184,10 +184,10 @@ void multipleLevel(const std::string& configPath)
         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         {
             real dx = 1.0 / 16.0;
-            real vx = 0.0125;
+            real vx = 0.05;
 
             real D = 1.0;
-            real Re = 1140000;
+            real Re = 11400;
 
             para->setOutputPath( "F:/Work/Computations/out/Sphere/" );
             para->setOutputPrefix( "Sphere" );
@@ -206,7 +206,7 @@ void multipleLevel(const std::string& configPath)
 
             para->setUseWale(false);
 
-            para->setMainKernel(kernelMapper->getEnum("CumulantK20Comp"));
+            para->setMainKernel(kernelMapper->getEnum("CumulantK15Comp"));
 
             //////////////////////////////////////////////////////////////////////////
 
@@ -218,18 +218,18 @@ void multipleLevel(const std::string& configPath)
 
             Object* sphere = new Sphere( 0, 0, 0, 0.5*D );
 
-            gridBuilder->addCoarseGrid(-2.0*D, -5.5*D, -5.5*D,
-                                        9.0*D,  5.5*D,  5.5*D, dx);  // DrivAer
+            gridBuilder->addCoarseGrid(-2.0*D, -2.5*D, -2.5*D,
+                                        9.0*D,  2.5*D,  2.5*D, dx);  // DrivAer
 
             //gridBuilder->setNumberOfLayers(10,8);
             //gridBuilder->addGrid(SphereSTL, 2);
             
             gridBuilder->setNumberOfLayers(4,8);
-            gridBuilder->addGrid(sphereRef_1_STL, 3);
-            gridBuilder->addGrid(sphereRef_2_STL, 4);
+            gridBuilder->addGrid(sphereRef_1_STL, 1);
+            //gridBuilder->addGrid(sphereRef_2_STL, 4);
 
-            gridBuilder->setNumberOfLayers(10,8);
-            gridBuilder->addGrid(sphere, 5);
+            //gridBuilder->setNumberOfLayers(10,8);
+            //gridBuilder->addGrid(sphere, 5);
 
 
         
-- 
GitLab