diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index 705c50ecf38707fe817dfbd408035196da8a7c78..8bfffe395d88abc11a2f69ea6e48513b15322d7b 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -17,7 +17,7 @@ using namespace vf::lbm::dir; GridGenerator::GridGenerator(std::shared_ptr<GridBuilder> builder, std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager, vf::gpu::Communicator& communicator) { - this->builder = builder; + this->builder = builder; this->para = para; this->cudaMemoryManager = cudaMemoryManager; this->indexRearrangement = std::make_unique<IndexRearrangementForStreams>(para, builder, communicator); @@ -46,22 +46,22 @@ void GridGenerator::initalGridInformations() void GridGenerator::allocArrays_CoordNeighborGeo() { const uint numberOfLevels = builder->getNumberOfGridLevels(); - std::cout << "Number of Level: " << numberOfLevels << std::endl; - int numberOfNodesGlobal = 0; - std::cout << "Number of Nodes: " << std::endl; - - for (uint level = 0; level < numberOfLevels; level++) - { - const int numberOfNodesPerLevel = builder->getNumberOfNodes(level) + 1; - numberOfNodesGlobal += numberOfNodesPerLevel; - std::cout << "Level " << level << " = " << numberOfNodesPerLevel << " Nodes" << std::endl; - - setNumberOfNodes(numberOfNodesPerLevel, level); - - cudaMemoryManager->cudaAllocCoord(level); + std::cout << "Number of Level: " << numberOfLevels << std::endl; + int numberOfNodesGlobal = 0; + std::cout << "Number of Nodes: " << std::endl; + + for (uint level = 0; level < numberOfLevels; level++) + { + const int numberOfNodesPerLevel = builder->getNumberOfNodes(level) + 1; + numberOfNodesGlobal += numberOfNodesPerLevel; + std::cout << "Level " << level << " = " << numberOfNodesPerLevel << " Nodes" << std::endl; + + setNumberOfNodes(numberOfNodesPerLevel, level); + + cudaMemoryManager->cudaAllocCoord(level); cudaMemoryManager->cudaAllocSP(level); //cudaMemoryManager->cudaAllocF3SP(level); - cudaMemoryManager->cudaAllocNeighborWSB(level); + cudaMemoryManager->cudaAllocNeighborWSB(level); if(para->getUseTurbulentViscosity()) cudaMemoryManager->cudaAllocTurbulentViscosity(level); @@ -69,18 +69,18 @@ void GridGenerator::allocArrays_CoordNeighborGeo() if(para->getIsBodyForce()) cudaMemoryManager->cudaAllocBodyForce(level); - builder->getNodeValues( - para->getParH(level)->coordinateX, - para->getParH(level)->coordinateY, - para->getParH(level)->coordinateZ, - para->getParH(level)->neighborX, - para->getParH(level)->neighborY, - para->getParH(level)->neighborZ, - para->getParH(level)->neighborInverse, - para->getParH(level)->typeOfGridNode, - level); + builder->getNodeValues( + para->getParH(level)->coordinateX, + para->getParH(level)->coordinateY, + para->getParH(level)->coordinateZ, + para->getParH(level)->neighborX, + para->getParH(level)->neighborY, + para->getParH(level)->neighborZ, + para->getParH(level)->neighborInverse, + para->getParH(level)->typeOfGridNode, + level); - setInitalNodeValues(numberOfNodesPerLevel, level); + setInitalNodeValues(numberOfNodesPerLevel, level); cudaMemoryManager->cudaCopyNeighborWSB(level); cudaMemoryManager->cudaCopySP(level); @@ -89,9 +89,9 @@ void GridGenerator::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaCopyBodyForce(level); //std::cout << verifyNeighborIndices(level); - } - std::cout << "Number of Nodes: " << numberOfNodesGlobal << std::endl; - std::cout << "-----finish Coord, Neighbor, Geo------" << std::endl; + } + std::cout << "Number of Nodes: " << numberOfNodesGlobal << std::endl; + std::cout << "-----finish Coord, Neighbor, Geo------" << std::endl; } void GridGenerator::allocArrays_fluidNodeIndices() { @@ -114,7 +114,7 @@ void GridGenerator::allocArrays_fluidNodeIndicesBorder() { void GridGenerator::allocArrays_BoundaryValues() { - std::cout << "------read BoundaryValues------" << std::endl; + std::cout << "------read BoundaryValues------" << std::endl; for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfPressureValues = int(builder->getPressureSize(level)); @@ -205,27 +205,27 @@ void GridGenerator::allocArrays_BoundaryValues() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // advection - diffusion stuff if (para->getDiffOn()==true){ - ////////////////////////////////////////////////////////////////////////// - para->getParH(level)->TempVel.kTemp = numberOfVelocityValues; - //cout << "Groesse kTemp = " << para->getParH(i)->TempPress.kTemp << endl; - std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; - std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + para->getParH(level)->TempVel.kTemp = numberOfVelocityValues; + //cout << "Groesse kTemp = " << para->getParH(i)->TempPress.kTemp << endl; + std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; + std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; + ////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaAllocTempVeloBC(level); - //cout << "nach alloc " << endl; - ////////////////////////////////////////////////////////////////////////// - for (int m = 0; m < numberOfVelocityValues; m++) - { - para->getParH(level)->TempVel.temp[m] = para->getTemperatureInit(); - para->getParH(level)->TempVel.tempPulse[m] = para->getTemperatureBC(); - para->getParH(level)->TempVel.velo[m] = para->getVelocity(); - para->getParH(level)->TempVel.k[m] = para->getParH(level)->velocityBC.k[m]; - } - ////////////////////////////////////////////////////////////////////////// - //cout << "vor copy " << endl; + //cout << "nach alloc " << endl; + ////////////////////////////////////////////////////////////////////////// + for (int m = 0; m < numberOfVelocityValues; m++) + { + para->getParH(level)->TempVel.temp[m] = para->getTemperatureInit(); + para->getParH(level)->TempVel.tempPulse[m] = para->getTemperatureBC(); + para->getParH(level)->TempVel.velo[m] = para->getVelocity(); + para->getParH(level)->TempVel.k[m] = para->getParH(level)->velocityBC.k[m]; + } + ////////////////////////////////////////////////////////////////////////// + //cout << "vor copy " << endl; cudaMemoryManager->cudaCopyTempVeloBCHD(level); - //cout << "nach copy " << endl; - ////////////////////////////////////////////////////////////////////////// + //cout << "nach copy " << endl; + ////////////////////////////////////////////////////////////////////////// } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } @@ -268,29 +268,29 @@ void GridGenerator::allocArrays_BoundaryValues() ////T�st //for (int m = 0; m < temp4; m++) //{ - // para->getParH(i)->geometryBC.Vx[m] = para->getVelocity();//0.035f; - // para->getParH(i)->geometryBC.Vy[m] = 0.0f;//para->getVelocity();//0.0f; - // para->getParH(i)->geometryBC.Vz[m] = 0.0f; + // para->getParH(i)->geometryBC.Vx[m] = para->getVelocity();//0.035f; + // para->getParH(i)->geometryBC.Vy[m] = 0.0f;//para->getVelocity();//0.0f; + // para->getParH(i)->geometryBC.Vz[m] = 0.0f; //} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaCopyGeomValuesBC(i); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// advection - diffusion stuff //if (para->getDiffOn()==true){ - // ////////////////////////////////////////////////////////////////////////// - // para->getParH(i)->Temp.kTemp = temp4; - // cout << "Groesse kTemp = " << para->getParH(i)->Temp.kTemp << std::endl; - // ////////////////////////////////////////////////////////////////////////// - // para->cudaAllocTempNoSlipBC(i); - // ////////////////////////////////////////////////////////////////////////// - // for (int m = 0; m < temp4; m++) - // { - // para->getParH(i)->Temp.temp[m] = para->getTemperatureInit(); - // para->getParH(i)->Temp.k[m] = para->getParH(i)->geometryBC.k[m]; - // } - // ////////////////////////////////////////////////////////////////////////// - // para->cudaCopyTempNoSlipBCHD(i); - // ////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// + // para->getParH(i)->Temp.kTemp = temp4; + // cout << "Groesse kTemp = " << para->getParH(i)->Temp.kTemp << std::endl; + // ////////////////////////////////////////////////////////////////////////// + // para->cudaAllocTempNoSlipBC(i); + // ////////////////////////////////////////////////////////////////////////// + // for (int m = 0; m < temp4; m++) + // { + // para->getParH(i)->Temp.temp[m] = para->getTemperatureInit(); + // para->getParH(i)->Temp.k[m] = para->getParH(i)->geometryBC.k[m]; + // } + // ////////////////////////////////////////////////////////////////////////// + // para->cudaCopyTempNoSlipBCHD(i); + // ////////////////////////////////////////////////////////////////////////// //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } @@ -731,11 +731,11 @@ void GridGenerator::initalValuesDomainDecompostion() void GridGenerator::allocArrays_BoundaryQs() { - std::cout << "------read BoundaryQs-------" << std::endl; + std::cout << "------read BoundaryQs-------" << std::endl; for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { - int numberOfPressureValues = (int)builder->getPressureSize(i); + const auto numberOfPressureValues = (int)builder->getPressureSize(i); if (numberOfPressureValues > 0) { std::cout << "size Pressure: " << i << " : " << numberOfPressureValues << std::endl; @@ -745,33 +745,7 @@ void GridGenerator::allocArrays_BoundaryQs() real* QQ = para->getParH(i)->pressureBC.q27[0]; unsigned int sizeQ = para->getParH(i)->pressureBC.numberOfBCnodes; QforBoundaryConditions Q; - Q.q27[E] = &QQ[E *sizeQ]; - Q.q27[W] = &QQ[W *sizeQ]; - Q.q27[N] = &QQ[N *sizeQ]; - Q.q27[S] = &QQ[S *sizeQ]; - Q.q27[T] = &QQ[T *sizeQ]; - Q.q27[B] = &QQ[B *sizeQ]; - Q.q27[NE] = &QQ[NE *sizeQ]; - Q.q27[SW] = &QQ[SW *sizeQ]; - Q.q27[SE] = &QQ[SE *sizeQ]; - Q.q27[NW] = &QQ[NW *sizeQ]; - Q.q27[TE] = &QQ[TE *sizeQ]; - Q.q27[BW] = &QQ[BW *sizeQ]; - Q.q27[BE] = &QQ[BE *sizeQ]; - Q.q27[TW] = &QQ[TW *sizeQ]; - Q.q27[TN] = &QQ[TN *sizeQ]; - Q.q27[BS] = &QQ[BS *sizeQ]; - Q.q27[BN] = &QQ[BN *sizeQ]; - Q.q27[TS] = &QQ[TS *sizeQ]; - Q.q27[REST] = &QQ[REST*sizeQ]; - Q.q27[TNE] = &QQ[TNE *sizeQ]; - Q.q27[TSW] = &QQ[TSW *sizeQ]; - Q.q27[TSE] = &QQ[TSE *sizeQ]; - Q.q27[TNW] = &QQ[TNW *sizeQ]; - Q.q27[BNE] = &QQ[BNE *sizeQ]; - Q.q27[BSW] = &QQ[BSW *sizeQ]; - Q.q27[BSE] = &QQ[BSE *sizeQ]; - Q.q27[BNW] = &QQ[BNW *sizeQ]; + getPointersToBoundaryConditions(Q, QQ, sizeQ); builder->getPressureQs(Q.q27, i); @@ -818,33 +792,7 @@ void GridGenerator::allocArrays_BoundaryQs() real* QQ = para->getParH(i)->slipBC.q27[0]; unsigned int sizeQ = para->getParH(i)->slipBC.numberOfBCnodes; QforBoundaryConditions Q; - Q.q27[E] = &QQ[E *sizeQ]; - Q.q27[W] = &QQ[W *sizeQ]; - Q.q27[N] = &QQ[N *sizeQ]; - Q.q27[S] = &QQ[S *sizeQ]; - Q.q27[T] = &QQ[T *sizeQ]; - Q.q27[B] = &QQ[B *sizeQ]; - Q.q27[NE] = &QQ[NE *sizeQ]; - Q.q27[SW] = &QQ[SW *sizeQ]; - Q.q27[SE] = &QQ[SE *sizeQ]; - Q.q27[NW] = &QQ[NW *sizeQ]; - Q.q27[TE] = &QQ[TE *sizeQ]; - Q.q27[BW] = &QQ[BW *sizeQ]; - Q.q27[BE] = &QQ[BE *sizeQ]; - Q.q27[TW] = &QQ[TW *sizeQ]; - Q.q27[TN] = &QQ[TN *sizeQ]; - Q.q27[BS] = &QQ[BS *sizeQ]; - Q.q27[BN] = &QQ[BN *sizeQ]; - Q.q27[TS] = &QQ[TS *sizeQ]; - Q.q27[REST] = &QQ[REST*sizeQ]; - Q.q27[TNE] = &QQ[TNE *sizeQ]; - Q.q27[TSW] = &QQ[TSW *sizeQ]; - Q.q27[TSE] = &QQ[TSE *sizeQ]; - Q.q27[TNW] = &QQ[TNW *sizeQ]; - Q.q27[BNE] = &QQ[BNE *sizeQ]; - Q.q27[BSW] = &QQ[BSW *sizeQ]; - Q.q27[BSE] = &QQ[BSE *sizeQ]; - Q.q27[BNW] = &QQ[BNW *sizeQ]; + getPointersToBoundaryConditions(Q, QQ, sizeQ); builder->getSlipQs(Q.q27, i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -864,33 +812,7 @@ void GridGenerator::allocArrays_BoundaryQs() real* QQ = para->getParH(i)->stressBC.q27[0]; unsigned int sizeQ = para->getParH(i)->stressBC.numberOfBCnodes; QforBoundaryConditions Q; - Q.q27[E] = &QQ[E *sizeQ]; - Q.q27[W] = &QQ[W *sizeQ]; - Q.q27[N] = &QQ[N *sizeQ]; - Q.q27[S] = &QQ[S *sizeQ]; - Q.q27[T] = &QQ[T *sizeQ]; - Q.q27[B] = &QQ[B *sizeQ]; - Q.q27[NE] = &QQ[NE *sizeQ]; - Q.q27[SW] = &QQ[SW *sizeQ]; - Q.q27[SE] = &QQ[SE *sizeQ]; - Q.q27[NW] = &QQ[NW *sizeQ]; - Q.q27[TE] = &QQ[TE *sizeQ]; - Q.q27[BW] = &QQ[BW *sizeQ]; - Q.q27[BE] = &QQ[BE *sizeQ]; - Q.q27[TW] = &QQ[TW *sizeQ]; - Q.q27[TN] = &QQ[TN *sizeQ]; - Q.q27[BS] = &QQ[BS *sizeQ]; - Q.q27[BN] = &QQ[BN *sizeQ]; - Q.q27[TS] = &QQ[TS *sizeQ]; - Q.q27[REST] = &QQ[REST*sizeQ]; - Q.q27[TNE] = &QQ[TNE *sizeQ]; - Q.q27[TSW] = &QQ[TSW *sizeQ]; - Q.q27[TSE] = &QQ[TSE *sizeQ]; - Q.q27[TNW] = &QQ[TNW *sizeQ]; - Q.q27[BNE] = &QQ[BNE *sizeQ]; - Q.q27[BSW] = &QQ[BSW *sizeQ]; - Q.q27[BSE] = &QQ[BSE *sizeQ]; - Q.q27[BNW] = &QQ[BNW *sizeQ]; + getPointersToBoundaryConditions(Q, QQ, sizeQ); builder->getStressQs(Q.q27, i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -910,34 +832,7 @@ void GridGenerator::allocArrays_BoundaryQs() real* QQ = para->getParH(i)->velocityBC.q27[0]; unsigned int sizeQ = para->getParH(i)->velocityBC.numberOfBCnodes; QforBoundaryConditions Q; - Q.q27[E] = &QQ[E *sizeQ]; - Q.q27[W] = &QQ[W *sizeQ]; - Q.q27[N] = &QQ[N *sizeQ]; - Q.q27[S] = &QQ[S *sizeQ]; - Q.q27[T] = &QQ[T *sizeQ]; - Q.q27[B] = &QQ[B *sizeQ]; - Q.q27[NE] = &QQ[NE *sizeQ]; - Q.q27[SW] = &QQ[SW *sizeQ]; - Q.q27[SE] = &QQ[SE *sizeQ]; - Q.q27[NW] = &QQ[NW *sizeQ]; - Q.q27[TE] = &QQ[TE *sizeQ]; - Q.q27[BW] = &QQ[BW *sizeQ]; - Q.q27[BE] = &QQ[BE *sizeQ]; - Q.q27[TW] = &QQ[TW *sizeQ]; - Q.q27[TN] = &QQ[TN *sizeQ]; - Q.q27[BS] = &QQ[BS *sizeQ]; - Q.q27[BN] = &QQ[BN *sizeQ]; - Q.q27[TS] = &QQ[TS *sizeQ]; - Q.q27[REST] = &QQ[REST*sizeQ]; - Q.q27[TNE] = &QQ[TNE *sizeQ]; - Q.q27[TSW] = &QQ[TSW *sizeQ]; - Q.q27[TSE] = &QQ[TSE *sizeQ]; - Q.q27[TNW] = &QQ[TNW *sizeQ]; - Q.q27[BNE] = &QQ[BNE *sizeQ]; - Q.q27[BSW] = &QQ[BSW *sizeQ]; - Q.q27[BSE] = &QQ[BSE *sizeQ]; - Q.q27[BNW] = &QQ[BNW *sizeQ]; - + getPointersToBoundaryConditions(Q, QQ, sizeQ); builder->getVelocityQs(Q.q27, i); if (para->getDiffOn()) { @@ -993,37 +888,11 @@ void GridGenerator::allocArrays_BoundaryQs() real* QQ = para->getParH(i)->geometryBC.q27[0]; unsigned int sizeQ = para->getParH(i)->geometryBC.numberOfBCnodes; QforBoundaryConditions Q; - Q.q27[E] = &QQ[E *sizeQ]; - Q.q27[W] = &QQ[W *sizeQ]; - Q.q27[N] = &QQ[N *sizeQ]; - Q.q27[S] = &QQ[S *sizeQ]; - Q.q27[T] = &QQ[T *sizeQ]; - Q.q27[B] = &QQ[B *sizeQ]; - Q.q27[NE] = &QQ[NE *sizeQ]; - Q.q27[SW] = &QQ[SW *sizeQ]; - Q.q27[SE] = &QQ[SE *sizeQ]; - Q.q27[NW] = &QQ[NW *sizeQ]; - Q.q27[TE] = &QQ[TE *sizeQ]; - Q.q27[BW] = &QQ[BW *sizeQ]; - Q.q27[BE] = &QQ[BE *sizeQ]; - Q.q27[TW] = &QQ[TW *sizeQ]; - Q.q27[TN] = &QQ[TN *sizeQ]; - Q.q27[BS] = &QQ[BS *sizeQ]; - Q.q27[BN] = &QQ[BN *sizeQ]; - Q.q27[TS] = &QQ[TS *sizeQ]; - Q.q27[REST] = &QQ[REST*sizeQ]; - Q.q27[TNE] = &QQ[TNE *sizeQ]; - Q.q27[TSW] = &QQ[TSW *sizeQ]; - Q.q27[TSE] = &QQ[TSE *sizeQ]; - Q.q27[TNW] = &QQ[TNW *sizeQ]; - Q.q27[BNE] = &QQ[BNE *sizeQ]; - Q.q27[BSW] = &QQ[BSW *sizeQ]; - Q.q27[BSE] = &QQ[BSE *sizeQ]; - Q.q27[BNW] = &QQ[BNW *sizeQ]; + getPointersToBoundaryConditions(Q, QQ, sizeQ); ////////////////////////////////////////////////////////////////// builder->getGeometryQs(Q.q27, i); - //QDebugWriter::writeQValues(Q, para->getParH(i)->geometryBC.k, para->getParH(i)->geometryBC.numberOfBCnodes, "M:/TestGridGeneration/results/GeomGPU.dat"); + //QDebugWriter::writeQValues(Q, para->getParH(i)->geometryBC.k, para->getParH(i)->geometryBC.numberOfBCnodes, "M:/TestGridGeneration/results/GeomGPU.dat"); ////////////////////////////////////////////////////////////////// for (int node_i = 0; node_i < numberOfGeometryNodes; node_i++) { @@ -1031,10 +900,10 @@ void GridGenerator::allocArrays_BoundaryQs() } //for(int test = 0; test < 3; test++) //{ - // for (int tmp = 0; tmp < 27; tmp++) - // { - // cout <<"Kuhs: " << Q.q27[tmp][test] << std::endl; - // } + // for (int tmp = 0; tmp < 27; tmp++) + // { + // cout <<"Kuhs: " << Q.q27[tmp][test] << std::endl; + // } //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1063,7 +932,7 @@ void GridGenerator::allocArrays_BoundaryQs() } - std::cout << "-----finish BoundaryQs------" << std::endl; + std::cout << "-----finish BoundaryQs------" << std::endl; } void GridGenerator::allocArrays_OffsetScale() @@ -1098,10 +967,10 @@ void GridGenerator::allocArrays_OffsetScale() para->getParD(level)->mem_size_kFC_off = sizeof(real)* para->getParD(level)->K_FC; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //alloc - cudaMemoryManager->cudaAllocInterfaceCF(level); - cudaMemoryManager->cudaAllocInterfaceFC(level); - cudaMemoryManager->cudaAllocInterfaceOffCF(level); - cudaMemoryManager->cudaAllocInterfaceOffFC(level); + cudaMemoryManager->cudaAllocInterfaceCF(level); + cudaMemoryManager->cudaAllocInterfaceFC(level); + cudaMemoryManager->cudaAllocInterfaceOffCF(level); + cudaMemoryManager->cudaAllocInterfaceOffFC(level); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //init builder->getOffsetCF(para->getParH(level)->offCF.xOffCF, para->getParH(level)->offCF.yOffCF, para->getParH(level)->offCF.zOffCF, level); @@ -1116,49 +985,49 @@ void GridGenerator::allocArrays_OffsetScale() } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy - cudaMemoryManager->cudaCopyInterfaceCF(level); - cudaMemoryManager->cudaCopyInterfaceFC(level); - cudaMemoryManager->cudaCopyInterfaceOffCF(level); - cudaMemoryManager->cudaCopyInterfaceOffFC(level); + cudaMemoryManager->cudaCopyInterfaceCF(level); + cudaMemoryManager->cudaCopyInterfaceFC(level); + cudaMemoryManager->cudaCopyInterfaceOffCF(level); + cudaMemoryManager->cudaCopyInterfaceOffFC(level); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } void GridGenerator::setDimensions() { - //std::vector<int> localGridNX(1); - //std::vector<int> localGridNY(1); - //std::vector<int> localGridNZ(1); + //std::vector<int> localGridNX(1); + //std::vector<int> localGridNY(1); + //std::vector<int> localGridNZ(1); - //builder->getDimensions(localGridNX[0], localGridNY[0], localGridNZ[0], 0); + //builder->getDimensions(localGridNX[0], localGridNY[0], localGridNZ[0], 0); - //para->setGridX(localGridNX); - //para->setGridY(localGridNY); - //para->setGridZ(localGridNZ); + //para->setGridX(localGridNX); + //para->setGridY(localGridNY); + //para->setGridZ(localGridNZ); } void GridGenerator::setBoundingBox() { - std::vector<int> localGridNX(1); - std::vector<int> localGridNY(1); - std::vector<int> localGridNZ(1); - builder->getDimensions(localGridNX[0], localGridNY[0], localGridNZ[0], 0); - - std::vector<real> minX, maxX, minY, maxY, minZ, maxZ; - minX.push_back(0); - minY.push_back(0); - minZ.push_back(0); - - maxX.push_back((real)localGridNX[0]); - maxY.push_back((real)localGridNY[0]); - maxZ.push_back((real)localGridNZ[0]); - - para->setMinCoordX(minX); - para->setMinCoordY(minY); - para->setMinCoordZ(minZ); - para->setMaxCoordX(maxX); - para->setMaxCoordY(maxY); - para->setMaxCoordZ(maxZ); + std::vector<int> localGridNX(1); + std::vector<int> localGridNY(1); + std::vector<int> localGridNZ(1); + builder->getDimensions(localGridNX[0], localGridNY[0], localGridNZ[0], 0); + + std::vector<real> minX, maxX, minY, maxY, minZ, maxZ; + minX.push_back(0); + minY.push_back(0); + minZ.push_back(0); + + maxX.push_back((real)localGridNX[0]); + maxY.push_back((real)localGridNY[0]); + maxZ.push_back((real)localGridNZ[0]); + + para->setMinCoordX(minX); + para->setMinCoordY(minY); + para->setMinCoordZ(minZ); + para->setMaxCoordX(maxX); + para->setMaxCoordY(maxY); + para->setMaxCoordZ(maxZ); } void GridGenerator::initPeriodicNeigh(std::vector<std::vector<std::vector<uint> > > periodV, std::vector<std::vector<uint> > periodIndex, std::string way) @@ -1258,3 +1127,33 @@ std::string GridGenerator::checkNeighbor(int level, real x, real y, real z, int } return oss.str(); } + +void GridGenerator::getPointersToBoundaryConditions(QforBoundaryConditions& boundaryConditionStruct, real* subgridDistances, const unsigned int numberOfBCnodes){ + boundaryConditionStruct.q27[E] = &subgridDistances[E * numberOfBCnodes]; + boundaryConditionStruct.q27[W] = &subgridDistances[W * numberOfBCnodes]; + boundaryConditionStruct.q27[N] = &subgridDistances[N * numberOfBCnodes]; + boundaryConditionStruct.q27[S] = &subgridDistances[S * numberOfBCnodes]; + boundaryConditionStruct.q27[T] = &subgridDistances[T * numberOfBCnodes]; + boundaryConditionStruct.q27[B] = &subgridDistances[B * numberOfBCnodes]; + boundaryConditionStruct.q27[NE] = &subgridDistances[NE * numberOfBCnodes]; + boundaryConditionStruct.q27[SW] = &subgridDistances[SW * numberOfBCnodes]; + boundaryConditionStruct.q27[SE] = &subgridDistances[SE * numberOfBCnodes]; + boundaryConditionStruct.q27[NW] = &subgridDistances[NW * numberOfBCnodes]; + boundaryConditionStruct.q27[TE] = &subgridDistances[TE * numberOfBCnodes]; + boundaryConditionStruct.q27[BW] = &subgridDistances[BW * numberOfBCnodes]; + boundaryConditionStruct.q27[BE] = &subgridDistances[BE * numberOfBCnodes]; + boundaryConditionStruct.q27[TW] = &subgridDistances[TW * numberOfBCnodes]; + boundaryConditionStruct.q27[TN] = &subgridDistances[TN * numberOfBCnodes]; + boundaryConditionStruct.q27[BS] = &subgridDistances[BS * numberOfBCnodes]; + boundaryConditionStruct.q27[BN] = &subgridDistances[BN * numberOfBCnodes]; + boundaryConditionStruct.q27[TS] = &subgridDistances[TS * numberOfBCnodes]; + boundaryConditionStruct.q27[REST] = &subgridDistances[REST* numberOfBCnodes]; + boundaryConditionStruct.q27[TNE] = &subgridDistances[TNE * numberOfBCnodes]; + boundaryConditionStruct.q27[TSW] = &subgridDistances[TSW * numberOfBCnodes]; + boundaryConditionStruct.q27[TSE] = &subgridDistances[TSE * numberOfBCnodes]; + boundaryConditionStruct.q27[TNW] = &subgridDistances[TNW * numberOfBCnodes]; + boundaryConditionStruct.q27[BNE] = &subgridDistances[BNE * numberOfBCnodes]; + boundaryConditionStruct.q27[BSW] = &subgridDistances[BSW * numberOfBCnodes]; + boundaryConditionStruct.q27[BSE] = &subgridDistances[BSE * numberOfBCnodes]; + boundaryConditionStruct.q27[BNW] = &subgridDistances[BNW * numberOfBCnodes]; +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h index 991c59ca63dd77da974c044db363de16ebf6ff23..3603a88b3b1dc855cc9f729d720d26e230b200d8 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GridGenerator.h +//! \ingroup DataStructureInitializer +//! \author Martin Schoenherr +//======================================================================================= #ifndef GridReaderGenerator_H #define GridReaderGenerator_H @@ -13,56 +45,62 @@ class Parameter; class GridBuilder; class IndexRearrangementForStreams; +//! \class GridGenerator derived class of GridProvider +//! \brief mapping the grid of grid generator to data structure for simulation class GridGenerator - : public GridProvider + : public GridProvider { private: - std::vector<std::string> channelDirections; - std::vector<std::string> channelBoundaryConditions; + //! \brief string vector with channel direction + std::vector<std::string> channelDirections; + //! \brief string vector with channel direction (boundary conditions) + std::vector<std::string> channelBoundaryConditions; - std::shared_ptr<GridBuilder> builder; + std::shared_ptr<GridBuilder> builder; std::unique_ptr<IndexRearrangementForStreams> indexRearrangement; public: VIRTUALFLUIDS_GPU_EXPORT GridGenerator(std::shared_ptr<GridBuilder> builder, std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager, vf::gpu::Communicator& communicator); - VIRTUALFLUIDS_GPU_EXPORT virtual ~GridGenerator(); + VIRTUALFLUIDS_GPU_EXPORT virtual ~GridGenerator(); - void allocArrays_CoordNeighborGeo() override; + //! \brief allocates and initialized the data structures for Coordinates and node types + void allocArrays_CoordNeighborGeo() override; + //! \brief allocates and initialized the values at the boundary conditions void allocArrays_BoundaryValues() override; - - void allocArrays_BoundaryQs() override; + //! \brief allocates and initialized the sub-grid distances at the boundary conditions + void allocArrays_BoundaryQs() override; void allocArrays_OffsetScale() override; void allocArrays_fluidNodeIndices() override; void allocArrays_fluidNodeIndicesBorder() override; - virtual void setDimensions() override; - virtual void setBoundingBox() override; + virtual void setDimensions() override; + virtual void setBoundingBox() override; - virtual void initPeriodicNeigh(std::vector<std::vector<std::vector<unsigned int> > > periodV, std::vector<std::vector<unsigned int> > periodIndex, std::string way) override; - + virtual void initPeriodicNeigh(std::vector<std::vector<std::vector<unsigned int> > > periodV, std::vector<std::vector<unsigned int> > periodIndex, std::string way) override; + private: - void setPressureValues(int channelSide) const; - void setPressRhoBC(int sizePerLevel, int level, int channelSide) const; - - void setVelocityValues(int channelSide) const; - void setVelocity(int level, int sizePerLevel, int channelSide) const; - - void setOutflowValues(int channelSide) const; - void setOutflow(int level, int sizePerLevel, int channelSide) const; - - void setPressQs(int channelSide) const; - void setVelocityQs(int channelSide) const; - void setOutflowQs(int channelSide) const; - void setNoSlipQs(int channelSide) const; - void setGeoQs() const; - void modifyQElement(int channelSide, unsigned int level) const; - - void initalQStruct(QforBoundaryConditions& Q,int channelSide, unsigned int level) const; - void printQSize(std::string bc,int channelSide, unsigned int level) const; - void setSizeNoSlip(int channelSide, unsigned int level) const; - void setSizeGeoQs(unsigned int level) const; - void setQ27Size(QforBoundaryConditions &Q, real* QQ, unsigned int sizeQ) const; - bool hasQs(int channelSide, unsigned int level) const; + void setPressureValues(int channelSide) const; + void setPressRhoBC(int sizePerLevel, int level, int channelSide) const; + + void setVelocityValues(int channelSide) const; + void setVelocity(int level, int sizePerLevel, int channelSide) const; + + void setOutflowValues(int channelSide) const; + void setOutflow(int level, int sizePerLevel, int channelSide) const; + + void setPressQs(int channelSide) const; + void setVelocityQs(int channelSide) const; + void setOutflowQs(int channelSide) const; + void setNoSlipQs(int channelSide) const; + void setGeoQs() const; + void modifyQElement(int channelSide, unsigned int level) const; + + void initalQStruct(QforBoundaryConditions& Q,int channelSide, unsigned int level) const; + void printQSize(std::string bc,int channelSide, unsigned int level) const; + void setSizeNoSlip(int channelSide, unsigned int level) const; + void setSizeGeoQs(unsigned int level) const; + void setQ27Size(QforBoundaryConditions &Q, real* QQ, unsigned int sizeQ) const; + bool hasQs(int channelSide, unsigned int level) const; void initalValuesDomainDecompostion(); public: @@ -70,10 +108,26 @@ public: private: + //! \brief verifies if there are invalid nodes, stopper nodes or wrong neighbors std::string verifyNeighborIndices(int level) const; - std::string verifyNeighborIndex(int level, int index, int &invalidNodes, int &stopperNodes, int &wrongNeighbors) const; + //! \brief verifies single neighbor index + //! \param index type integer + //! \param invalidNodes reference to invalid nodes + //! \param stopperNodes reference to stopper nodes + //! \param wrongNeighbors reference to wrong neighbors + std::string verifyNeighborIndex(int level, int index , int &invalidNodes, int &stopperNodes, int &wrongNeighbors) const; + //! \brief check the neighbors + //! \param x,y,z lattice node position + //! \param numberOfWrongNeighbors reference to the number of wrong neighbors + //! \param neighborIndex index of neighbor node + //! \param neighborX,neighborY,neighborZ neighbor lattice node position + //! \param direction type string std::string checkNeighbor(int level, real x, real y, real z, int index, int& numberOfWrongNeihgbors, int neighborIndex, real neighborX, real neighborY, real neighborZ, std::string direction) const; - + //! \brief create the pointers in the struct for the BoundaryConditions from the boundary condition array + //! \param boundaryConditionStruct is a struct containing information about the boundary condition + //! \param subgridDistances is a pointer to an array containing the subgrid distances + //! \param numberOfBCnodes is the number of lattice nodes in the boundary condition + static void getPointersToBoundaryConditions(QforBoundaryConditions& boundaryConditionStruct, real* subgridDistances, const unsigned int numberOfBCnodes); }; #endif