diff --git a/src/GridGenerator/grid/Grid.cu b/src/GridGenerator/grid/Grid.cu index e19944e03959d46e86f34d4436a6310947e026c9..489b87ef7e5b09bb234768f227adde3cec0e02a6 100644 --- a/src/GridGenerator/grid/Grid.cu +++ b/src/GridGenerator/grid/Grid.cu @@ -57,8 +57,8 @@ HOST SPtr<Grid> Grid::makeShared(real startX, real startY, real startZ, real end time_t end = clock(); real time = (real)(real(end - begin) / CLOCKS_PER_SEC); - *logging::out << logging::Logger::INTERMEDIATE << "Time initial field: " + SSTR(time / 1000) + "sec\n"; - *logging::out << logging::Logger::INTERMEDIATE << "-------------------------------------------\n"; + *logging::out << logging::Logger::LOW << "Time initial field: " + SSTR(time / 1000) + "sec\n"; + *logging::out << logging::Logger::LOW << "-------------------------------------------\n"; return grid; } @@ -533,8 +533,10 @@ void Grid::setGridInterface(uint* gridInterfaceList, const uint* oldGridInterfac HOSTDEVICE void Grid::print() const { - printf("min: (%2.2f, %2.2f, %2.2f), max: (%2.2f, %2.2f, %2.2f), size: %d, delta: %2.2f\n", startX, startY, startZ, + printf("min: (%2.4f, %2.4f, %2.4f), max: (%2.4f, %2.4f, %2.4f), size: %d, delta: %2.4f\n", startX, startY, startZ, endX, endY, endZ, size, delta); + if(this->gridInterface) + this->gridInterface->print(); } std::string Grid::toString() const diff --git a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index af665b7ca527561be3f3521262b3f5af84bcc783..75c2a8d6a3179c83d93565c5e4fbf2e2c665c566 100644 --- a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -61,17 +61,13 @@ void LevelGridBuilder::verifyGridNeighbors() // std::cout << grid->verifyNeighborIndices(); } -void LevelGridBuilder::addGrid(real minX, real minY, real minZ, real maxX, real maxY, real maxZ, real delta, const std::string& device, const std::string& distribution) +VF_PUBLIC void LevelGridBuilder::addGrid(real minX, real minY, real minZ, real maxX, real maxY, real maxZ, real delta, const std::string& device, const std::string& distribution, bool periodictyX, bool periodictyY, bool periodictyZ) { const auto grid = GridFactory::makeGrid(minX, minY, minZ, maxX, maxY, maxZ, delta, device, distribution); - grids.push_back(grid); + grids.insert(grids.begin(), grid); - if(this->getNumberOfGridLevels() == 1) - grid->setPeriodicity(true, true, true); - else - grid->setPeriodicity(false, false, false); + grid->setPeriodicity(periodictyX, periodictyY, periodictyZ); - grid->print(); this->removeOverlapNodes(); } @@ -96,7 +92,12 @@ void LevelGridBuilder::removeOverlapNodes() { const uint numberOfLevels = getNumberOfGridLevels(); if(numberOfLevels > 1) - grids[numberOfLevels - 2]->removeOverlapNodes(grids[numberOfLevels - 1]); + { + grids[0]->removeOverlapNodes(grids[1]); + grids[0]->print(); + + } + } @@ -261,10 +262,10 @@ void LevelGridBuilder::getNodeValues(real *xCoords, real *yCoords, real *zCoords xCoords[nodeNumber + 1] = x; yCoords[nodeNumber + 1] = y; zCoords[nodeNumber + 1] = z; - neighborX[nodeNumber + 1] = (unsigned int)(grid.neighborIndexX[i] + 1); - neighborY[nodeNumber + 1] = (unsigned int)(grid.neighborIndexY[i] + 1); - neighborZ[nodeNumber + 1] = (unsigned int)(grid.neighborIndexZ[i] + 1); - geo[nodeNumber + 1] = (unsigned int)grid.isSolid(i) ? GEOSOLID : GEOFLUID; + neighborX[nodeNumber + 1] = uint(grid.neighborIndexX[i] + 1); + neighborY[nodeNumber + 1] = uint(grid.neighborIndexY[i] + 1); + neighborZ[nodeNumber + 1] = uint(grid.neighborIndexZ[i] + 1); + geo[nodeNumber + 1] = uint(grid.isSolid(i) ? GEOSOLID : GEOFLUID); nodeNumber++; } } diff --git a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index 376e7c35b7342a709e685d6a83fbbd13a7182524..25e38a588908ea865b5d80a84f161fda5f0c2fdc 100644 --- a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -32,7 +32,7 @@ public: VF_PUBLIC void verifyGridNeighbors(); VF_PUBLIC virtual void addGrid(real minX, real minY, real minZ, real maxX, real maxY, real maxZ, real delta, - const std::string& device, const std::string& distribution); + const std::string& device, const std::string& distribution, bool periodictyX, bool periodictyY, bool periodictyZ); VF_PUBLIC virtual void meshGeometry(std::string input, int level); diff --git a/src/GridGenerator/grid/GridInterface.cu b/src/GridGenerator/grid/GridInterface.cu index bad079e33a94364ffb3f846c3a95cc4eeae3736d..e7d01b0ace0d4a415db3683267265165c13a8646 100644 --- a/src/GridGenerator/grid/GridInterface.cu +++ b/src/GridGenerator/grid/GridInterface.cu @@ -103,11 +103,16 @@ bool GridInterface::isOnInterface(Interface& interface, const real& x, const rea return isOnXYPlanes || isOnXZPlanes || isOnYZPlanes; } -uint GridInterface::getIndexOnFinerGrid(const int& factor, const Grid* fineGrid, const real& x, const real& y, const real& z) +HOSTDEVICE uint GridInterface::getIndexOnFinerGrid(const real& factor, const Grid* fineGrid, const real& x, const real& y, const real& z) { const real xFine = x + factor * (fineGrid->delta * 0.5); const real yFine = y + factor * (fineGrid->delta * 0.5); const real zFine = z + factor * (fineGrid->delta * 0.5); - return fineGrid->transCoordToIndex(xFine, yFine, zFine); + return fineGrid->matrixIndex[fineGrid->transCoordToIndex(xFine, yFine, zFine)]; +} + +void GridInterface::print() const +{ + printf("Grid Interface - CF nodes: %d, FC nodes: %d\n", cf.numberOfEntries, fc.numberOfEntries); } diff --git a/src/GridGenerator/grid/GridInterface.cuh b/src/GridGenerator/grid/GridInterface.cuh index 04b859c14891218bedd7e19a59bb3b620d1c31a7..77ce7efca03bf76fa0e26701908bb1cb6ee0da9b 100644 --- a/src/GridGenerator/grid/GridInterface.cuh +++ b/src/GridGenerator/grid/GridInterface.cuh @@ -17,6 +17,8 @@ public: HOSTDEVICE void VF_PUBLIC findCF(const uint& index, const Grid* coarseGrid, const Grid* fineGrid); HOSTDEVICE void VF_PUBLIC findFC(const uint& index, const Grid* coarseGrid, const Grid* fineGrid); + HOSTDEVICE void VF_PUBLIC print() const; + struct Interface { uint *fine, *coarse; @@ -38,7 +40,7 @@ private: HOSTDEVICE static void findInterface(Interface& interface, const int& factor, const uint& index, const Grid* coarseGrid, const Grid* fineGrid); HOSTDEVICE static bool isOnInterface(Interface& interface, const real& x, const real& y, const real& z); - HOSTDEVICE static uint getIndexOnFinerGrid(const int& factor, const Grid* fineGrid, const real& x, const real& y, const real& z); + HOSTDEVICE static uint getIndexOnFinerGrid(const real& factor, const Grid* fineGrid, const real& x, const real& y, const real& z); }; diff --git a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp index 08ed751d2a523210ef40bf22180f3f337b23d508..ebb2ef38401d7011ca211bfbc7b38b674921f34a 100644 --- a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp +++ b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp @@ -67,13 +67,13 @@ void GridCpuStrategy::removeOverlapNodes(SPtr<Grid> grid, SPtr<Grid> finerGrid) { grid->gridInterface = new GridInterface(finerGrid.get());; - setOverlapNodesToInvalid(grid, finerGrid); + createGridInterface(grid, finerGrid); grid->removeInvalidNodes(); findForNeighborsNewIndices(grid); findForGridInterfaceNewIndices(grid); } -void GridCpuStrategy::setOverlapNodesToInvalid(SPtr<Grid> grid, SPtr<Grid> finerGrid) +void GridCpuStrategy::createGridInterface(SPtr<Grid> grid, SPtr<Grid> finerGrid) { for (uint index = 0; index < grid->size; index++) grid->createGridInterface(index, *finerGrid.get()); diff --git a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h index 652d4c5b5bd1d79538ff7819ccb17e1dfae56561..9cd9c9bf3bce5f23e72554eb94f8e6f31c2e3a39 100644 --- a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h +++ b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h @@ -35,7 +35,7 @@ protected: static void findForNeighborsNewIndices(SPtr<Grid> grid); static void findForGridInterfaceNewIndices(SPtr<Grid> grid); - static void setOverlapNodesToInvalid(SPtr<Grid> grid, SPtr<Grid> finerGrid); + static void createGridInterface(SPtr<Grid> grid, SPtr<Grid> finerGrid); }; diff --git a/src/VirtualFluids_GPU/LBM/Simulation.cpp b/src/VirtualFluids_GPU/LBM/Simulation.cpp index e3d2d32ade8a821fcad6c605c4b4d046a6b1d13a..1df792302d423dcd596a630a852cac80c8437975 100644 --- a/src/VirtualFluids_GPU/LBM/Simulation.cpp +++ b/src/VirtualFluids_GPU/LBM/Simulation.cpp @@ -612,19 +612,19 @@ void Simulation::run() } else { - //KernelKumNewCompSP27(para->getParD(0)->numberofthreads, - // para->getParD(0)->omega, - // para->getParD(0)->geoSP, - // para->getParD(0)->neighborX_SP, - // para->getParD(0)->neighborY_SP, - // para->getParD(0)->neighborZ_SP, - // para->getParD(0)->d0SP.f[0], - // para->getParD(0)->size_Mat_SP, - // para->getParD(0)->size_Array_SP, - // 0, - // para->getForcesDev(), - // para->getParD(0)->evenOrOdd); - //getLastCudaError("KernelCasSPKum27 execution failed"); + KernelKumNewCompSP27(para->getParD(0)->numberofthreads, + para->getParD(0)->omega, + para->getParD(0)->geoSP, + para->getParD(0)->neighborX_SP, + para->getParD(0)->neighborY_SP, + para->getParD(0)->neighborZ_SP, + para->getParD(0)->d0SP.f[0], + para->getParD(0)->size_Mat_SP, + para->getParD(0)->size_Array_SP, + 0, + para->getForcesDev(), + para->getParD(0)->evenOrOdd); + getLastCudaError("KernelCasSPKum27 execution failed"); //KernelKumAA2016CompSP27(para->getParD(0)->numberofthreads, // para->getParD(0)->omega, @@ -639,18 +639,18 @@ void Simulation::run() // para->getParD(0)->evenOrOdd); //getLastCudaError("KernelKumAA2016CompSP27 execution failed"); - KernelCumulantD3Q27All4(para->getParD(0)->numberofthreads, - para->getParD(0)->omega, - para->getParD(0)->geoSP, - para->getParD(0)->neighborX_SP, - para->getParD(0)->neighborY_SP, - para->getParD(0)->neighborZ_SP, - para->getParD(0)->d0SP.f[0], - para->getParD(0)->size_Mat_SP, - 0, - para->getForcesDev(), - para->getParD(0)->evenOrOdd); - getLastCudaError("KernelCumulantD3Q27All4 execution failed"); + //KernelCumulantD3Q27All4(para->getParD(0)->numberofthreads, + // para->getParD(0)->omega, + // para->getParD(0)->geoSP, + // para->getParD(0)->neighborX_SP, + // para->getParD(0)->neighborY_SP, + // para->getParD(0)->neighborZ_SP, + // para->getParD(0)->d0SP.f[0], + // para->getParD(0)->size_Mat_SP, + // 0, + // para->getForcesDev(), + // para->getParD(0)->evenOrOdd); + //getLastCudaError("KernelCumulantD3Q27All4 execution failed"); } ////////////////////////////////////////////////////////////////////////// diff --git a/targets/apps/HULC/main.cpp b/targets/apps/HULC/main.cpp index a307811234bb375589b34ae073bb256212af4c5f..a021bce38ed481b0a62e31c1ef52a68deaed4efe 100644 --- a/targets/apps/HULC/main.cpp +++ b/targets/apps/HULC/main.cpp @@ -233,18 +233,21 @@ void setParameters(std::shared_ptr<Parameter> para, std::unique_ptr<input::Input void multipleLevel(const std::string& configPath) { SPtr<LevelGridBuilder> gridBuilder(new LevelGridBuilder()); - gridBuilder->addGrid(0.0, 0.0, 0.0, 100.0, 100.0, 100.0, 1.0, "cpu", "D3Q27"); - gridBuilder->addGrid(10.25, 10.25, 10.25, 90.75, 90.75, 90.75, 0.5, "cpu", "D3Q27"); - gridBuilder->addGrid(25.375, 25.375, 25.375, 75.625, 75.625, 75.625, 0.25, "cpu", "D3Q27"); + //gridBuilder->addGrid(12.4375, 12.4375, 12.4375, 14.5625, 14.5625, 14.5625, 0.125, "cpu", "D3Q27", false, false, false); + //gridBuilder->addGrid(10.375, 10.375, 10.375, 20.625, 20.625, 20.625, 0.25, "cpu", "D3Q27", false, false, false); + gridBuilder->addGrid(5.25, 5.25, 5.25, 24.75, 24.75, 24.75, 0.5, "cpu", "D3Q27", false, false, false); + gridBuilder->addGrid(0.0, 0.0, 0.0, 30.0, 30.0, 30.0, 1.0, "cpu", "D3Q27", true, true, true); + //gridBuilder->addGrid(40.4375, 40.4375, 40.4375, 60.5625, 60.5625, 60.5625, 0.125, "cpu", "D3Q27"); - SimulationFileWriter::write("D:/GRIDGENERATION/couplingVF/periodicTaylorThreeLevel/simu/", gridBuilder, FILEFORMAT::ASCII); + //SimulationFileWriter::write("D:/GRIDGENERATION/couplingVF/periodicTaylorThreeLevel/simu/", gridBuilder, FILEFORMAT::ASCII); //gridBuilder->meshGeometry("D:/GRIDGENERATION/STL/circleBinaer.stl", 1); //gridBuilder->meshGeometry("D:/GRIDGENERATION/STL/circleBinaer.stl", 0); //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_1", 1); //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_0", 0); + //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_2", 2); SPtr<Parameter> para = Parameter::makeShared(); SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para);