diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp index d5645b22971d4fc8dc1cac923dba4cbc3ea5a733..af1e123e513e56dd4d500fee1f98bbd05c5f6240 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridProvider.cpp @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -32,11 +32,10 @@ //======================================================================================= #include "GridProvider.h" -#include "Parameter/Parameter.h" #include "GPU/CudaMemoryManager.h" -#include "GridReaderGenerator/GridGenerator.h" #include "GridGenerator/grid/GridBuilder/GridBuilder.h" - +#include "GridReaderGenerator/GridGenerator.h" +#include "Parameter/Parameter.h" SPtr<GridProvider> GridProvider::makeGridGenerator(SPtr<GridBuilder> builder, SPtr<Parameter> para, SPtr<CudaMemoryManager> cudaMemoryManager) { @@ -55,35 +54,30 @@ void GridProvider::setNumberOfNodes(const int numberOfNodes) const void GridProvider::setInitalNodeValues(const int numberOfNodes) const { - for (int j = 1; j <= numberOfNodes; j++) - { - const real coordX = para->getParH()->coordinateX[j]; - const real coordY = para->getParH()->coordinateY[j]; - const real coordZ = para->getParH()->coordinateZ[j]; + for (int j = 1; j <= numberOfNodes; j++) { + const real coordX = para->getParH()->coordinateX[j]; + const real coordY = para->getParH()->coordinateY[j]; + const real coordZ = para->getParH()->coordinateZ[j]; + + real rho, vx, vy, vz; - real rho, vx, vy, vz; + // call functor object with initial condition + if (para->getInitialCondition()) { + para->getInitialCondition()(coordX, coordY, coordZ, rho, vx, vy, vz); + } else { + rho = real(0.0); + vx = real(0.0); + vy = real(0.0); + vz = real(0.0); + } - // call functor object with initial condition - if (para->getInitialCondition()) - { - para->getInitialCondition()(coordX, coordY, coordZ, rho, vx, vy, vz); - } - else - { - rho = real(0.0); - vx = real(0.0); - vy = real(0.0); - vz = real(0.0); - } - - para->getParH()->rho[j] = rho; - para->getParH()->velocityX[j] = vx; - para->getParH()->velocityY[j] = vy; - para->getParH()->velocityZ[j] = vz; + para->getParH()->rho[j] = rho; + para->getParH()->velocityX[j] = vx; + para->getParH()->velocityY[j] = vy; + para->getParH()->velocityZ[j] = vz; } } - void GridProvider::setVelocitySize(int size) const { para->getParH()->numberOfInflowBCnodes = size; @@ -102,7 +96,4 @@ void GridProvider::freeMemoryOnHost() cudaMemoryManager->cudaFreeSP(); } -void GridProvider::cudaCopyDataToHost() -{ - cudaMemoryManager->cudaCopyDataToHost(); -} +void GridProvider::cudaCopyDataToHost() { cudaMemoryManager->cudaCopyDataToHost(); } diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index 5574f4f6a9876e66bc1ef424a99c2597721b7165..75458df1c59a3a032b634cd12cd24ff2fd456a80 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -1,28 +1,28 @@ //======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ // \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -// This file is part of VirtualFluids. VirtualFluids is free software: you can +// 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 +// 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 +// +// 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/>. // @@ -31,232 +31,221 @@ //! \author Martin Schoenherr //======================================================================================= #include "GridGenerator.h" -#include <sstream> #include <iostream> +#include <sstream> -#include "LBM/LB.h" +#include "GPU/CudaMemoryManager.h" +#include "GridGenerator/grid/GridBuilder/GridBuilder.h" #include "LBM/D3Q27.h" +#include "LBM/LB.h" #include "Parameter/Parameter.h" -#include "GridGenerator/grid/GridBuilder/GridBuilder.h" -#include "GPU/CudaMemoryManager.h" #include "utilities/math/Math.h" GridGenerator::GridGenerator(SPtr<GridBuilder> builder, SPtr<Parameter> para, SPtr<CudaMemoryManager> cudaMemoryManager) { - this->builder = builder; - this->para = para; + this->builder = builder; + this->para = para; this->cudaMemoryManager = cudaMemoryManager; } -GridGenerator::~GridGenerator() -{ - -} +GridGenerator::~GridGenerator() {} void GridGenerator::allocArrays_CoordNeighborGeo() { - int numberOfNodesGlobal = 0; - std::cout << "Number of Nodes: " << std::endl; - - const int numberOfNodes = builder->getNumberOfNodes(0) + 1; - numberOfNodesGlobal += numberOfNodes; - - setNumberOfNodes(numberOfNodes); - - cudaMemoryManager->cudaAllocCoord(); + int numberOfNodesGlobal = 0; + std::cout << "Number of Nodes: " << std::endl; + + const int numberOfNodes = builder->getNumberOfNodes(0) + 1; + numberOfNodesGlobal += numberOfNodes; + + setNumberOfNodes(numberOfNodes); + + cudaMemoryManager->cudaAllocCoord(); cudaMemoryManager->cudaAllocSP(); - cudaMemoryManager->cudaAllocNeighborWSB(); + cudaMemoryManager->cudaAllocNeighborWSB(); - builder->getNodeValues( - para->getParH()->coordinateX, - para->getParH()->coordinateY, - para->getParH()->coordinateZ, - para->getParH()->neighborX, - para->getParH()->neighborY, - para->getParH()->neighborZ, - para->getParH()->neighborInverse, - para->getParH()->typeOfGridNode, - 0); + builder->getNodeValues( + para->getParH()->coordinateX, + para->getParH()->coordinateY, + para->getParH()->coordinateZ, + para->getParH()->neighborX, + para->getParH()->neighborY, + para->getParH()->neighborZ, + para->getParH()->neighborInverse, + para->getParH()->typeOfGridNode, 0); - setInitalNodeValues(numberOfNodes); + setInitalNodeValues(numberOfNodes); cudaMemoryManager->cudaCopyNeighborWSB(); cudaMemoryManager->cudaCopySP(); cudaMemoryManager->cudaCopyCoord(); - 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_BoundaryValues() { - std::cout << "------read BoundaryValues------" << std::endl; + std::cout << "------read BoundaryValues------" << std::endl; int blocks = 0; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const auto numberOfSlipValues = int(builder->getSlipSize(0)); - std::cout << "size slip: " << numberOfSlipValues << std::endl; + std::cout << "size slip: " << numberOfSlipValues << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - blocks = (numberOfSlipValues / para->getParH()->numberofthreads) + 1; + blocks = (numberOfSlipValues / para->getParH()->numberofthreads) + 1; para->getParH()->slipBC.kArray = blocks * para->getParH()->numberofthreads; para->getParD()->slipBC.kArray = para->getParH()->slipBC.kArray; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH()->numberOfSlipBCnodes = numberOfSlipValues; para->getParD()->numberOfSlipBCnodes = numberOfSlipValues; - if (numberOfSlipValues > 1) - { - cudaMemoryManager->cudaAllocSlipBC(); + if (numberOfSlipValues > 1) { + cudaMemoryManager->cudaAllocSlipBC(); - builder->getSlipValues(para->getParH()->slipBC.NormalX, para->getParH()->slipBC.NormalY, para->getParH()->slipBC.NormalY, para->getParH()->slipBC.k, 0); + builder->getSlipValues( + para->getParH()->slipBC.NormalX, + para->getParH()->slipBC.NormalY, + para->getParH()->slipBC.NormalY, + para->getParH()->slipBC.k, 0); - cudaMemoryManager->cudaCopySlipBC(); + cudaMemoryManager->cudaCopySlipBC(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const auto numberOfVelocityValues = int(builder->getVelocitySize(0)); std::cout << "size velocity: " << numberOfVelocityValues << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - blocks = (numberOfVelocityValues / para->getParH()->numberofthreads) + 1; + blocks = (numberOfVelocityValues / para->getParH()->numberofthreads) + 1; para->getParH()->inflowBC.kArray = blocks * para->getParH()->numberofthreads; para->getParD()->inflowBC.kArray = para->getParH()->inflowBC.kArray; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH()->numberOfInflowBCnodes = numberOfVelocityValues; para->getParD()->numberOfInflowBCnodes = numberOfVelocityValues; - if (numberOfVelocityValues > 1) - { + if (numberOfVelocityValues > 1) { cudaMemoryManager->cudaAllocVeloBC(); - builder->getVelocityValues(para->getParH()->inflowBC.Vx, para->getParH()->inflowBC.Vy, para->getParH()->inflowBC.Vz, para->getParH()->inflowBC.k, 0); + builder->getVelocityValues( + para->getParH()->inflowBC.Vx, + para->getParH()->inflowBC.Vy, + para->getParH()->inflowBC.Vz, + para->getParH()->inflowBC.k, 0); cudaMemoryManager->cudaCopyVeloBC(); } - } - void GridGenerator::allocArrays_BoundaryQs() { - std::cout << "------read BoundaryQs-------" << std::endl; + std::cout << "------read BoundaryQs-------" << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const auto numberOfSlipNodes = int(builder->getSlipSize(0)); - if (numberOfSlipNodes > 0) - { - std::cout << "size velocity: " << numberOfSlipNodes << std::endl; + if (numberOfSlipNodes > 0) { + std::cout << "size velocity: " << numberOfSlipNodes << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH()->slipBC.q27[0]; - unsigned int sizeQ = para->getParH()->numberOfSlipBCnodes; + // preprocessing + real *QQ = para->getParH()->slipBC.q27[0]; + unsigned int sizeQ = para->getParH()->numberOfSlipBCnodes; QforBoundaryConditions Q; - Q.q27[dirE ] = &QQ[dirE *sizeQ]; - Q.q27[dirW ] = &QQ[dirW *sizeQ]; - Q.q27[dirN ] = &QQ[dirN *sizeQ]; - Q.q27[dirS ] = &QQ[dirS *sizeQ]; - Q.q27[dirT ] = &QQ[dirT *sizeQ]; - Q.q27[dirB ] = &QQ[dirB *sizeQ]; - Q.q27[dirNE ] = &QQ[dirNE *sizeQ]; - Q.q27[dirSW ] = &QQ[dirSW *sizeQ]; - Q.q27[dirSE ] = &QQ[dirSE *sizeQ]; - Q.q27[dirNW ] = &QQ[dirNW *sizeQ]; - Q.q27[dirTE ] = &QQ[dirTE *sizeQ]; - Q.q27[dirBW ] = &QQ[dirBW *sizeQ]; - Q.q27[dirBE ] = &QQ[dirBE *sizeQ]; - Q.q27[dirTW ] = &QQ[dirTW *sizeQ]; - Q.q27[dirTN ] = &QQ[dirTN *sizeQ]; - Q.q27[dirBS ] = &QQ[dirBS *sizeQ]; - Q.q27[dirBN ] = &QQ[dirBN *sizeQ]; - Q.q27[dirTS ] = &QQ[dirTS *sizeQ]; - Q.q27[dirREST] = &QQ[dirREST*sizeQ]; - Q.q27[dirTNE ] = &QQ[dirTNE *sizeQ]; - Q.q27[dirTSW ] = &QQ[dirTSW *sizeQ]; - Q.q27[dirTSE ] = &QQ[dirTSE *sizeQ]; - Q.q27[dirTNW ] = &QQ[dirTNW *sizeQ]; - Q.q27[dirBNE ] = &QQ[dirBNE *sizeQ]; - Q.q27[dirBSW ] = &QQ[dirBSW *sizeQ]; - Q.q27[dirBSE ] = &QQ[dirBSE *sizeQ]; - Q.q27[dirBNW ] = &QQ[dirBNW *sizeQ]; + Q.q27[dirE] = &QQ[dirE * sizeQ]; + Q.q27[dirW] = &QQ[dirW * sizeQ]; + Q.q27[dirN] = &QQ[dirN * sizeQ]; + Q.q27[dirS] = &QQ[dirS * sizeQ]; + Q.q27[dirT] = &QQ[dirT * sizeQ]; + Q.q27[dirB] = &QQ[dirB * sizeQ]; + Q.q27[dirNE] = &QQ[dirNE * sizeQ]; + Q.q27[dirSW] = &QQ[dirSW * sizeQ]; + Q.q27[dirSE] = &QQ[dirSE * sizeQ]; + Q.q27[dirNW] = &QQ[dirNW * sizeQ]; + Q.q27[dirTE] = &QQ[dirTE * sizeQ]; + Q.q27[dirBW] = &QQ[dirBW * sizeQ]; + Q.q27[dirBE] = &QQ[dirBE * sizeQ]; + Q.q27[dirTW] = &QQ[dirTW * sizeQ]; + Q.q27[dirTN] = &QQ[dirTN * sizeQ]; + Q.q27[dirBS] = &QQ[dirBS * sizeQ]; + Q.q27[dirBN] = &QQ[dirBN * sizeQ]; + Q.q27[dirTS] = &QQ[dirTS * sizeQ]; + Q.q27[dirREST] = &QQ[dirREST * sizeQ]; + Q.q27[dirTNE] = &QQ[dirTNE * sizeQ]; + Q.q27[dirTSW] = &QQ[dirTSW * sizeQ]; + Q.q27[dirTSE] = &QQ[dirTSE * sizeQ]; + Q.q27[dirTNW] = &QQ[dirTNW * sizeQ]; + Q.q27[dirBNE] = &QQ[dirBNE * sizeQ]; + Q.q27[dirBSW] = &QQ[dirBSW * sizeQ]; + Q.q27[dirBSE] = &QQ[dirBSE * sizeQ]; + Q.q27[dirBNW] = &QQ[dirBNW * sizeQ]; builder->getSlipQs(Q.q27, 0); - cudaMemoryManager->cudaCopySlipBC(); + cudaMemoryManager->cudaCopySlipBC(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const auto numberOfVelocityNodes = int(builder->getVelocitySize(0)); - if (numberOfVelocityNodes > 0) - { - std::cout << "size velocity: " << numberOfVelocityNodes << std::endl; + if (numberOfVelocityNodes > 0) { + std::cout << "size velocity: " << numberOfVelocityNodes << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //preprocessing - real* QQ = para->getParH()->inflowBC.q27[0]; - unsigned int sizeQ = para->getParH()->numberOfInflowBCnodes; + // preprocessing + real *QQ = para->getParH()->inflowBC.q27[0]; + unsigned int sizeQ = para->getParH()->numberOfInflowBCnodes; QforBoundaryConditions Q; - Q.q27[dirE ] = &QQ[dirE *sizeQ]; - Q.q27[dirW ] = &QQ[dirW *sizeQ]; - Q.q27[dirN ] = &QQ[dirN *sizeQ]; - Q.q27[dirS ] = &QQ[dirS *sizeQ]; - Q.q27[dirT ] = &QQ[dirT *sizeQ]; - Q.q27[dirB ] = &QQ[dirB *sizeQ]; - Q.q27[dirNE ] = &QQ[dirNE *sizeQ]; - Q.q27[dirSW ] = &QQ[dirSW *sizeQ]; - Q.q27[dirSE ] = &QQ[dirSE *sizeQ]; - Q.q27[dirNW ] = &QQ[dirNW *sizeQ]; - Q.q27[dirTE ] = &QQ[dirTE *sizeQ]; - Q.q27[dirBW ] = &QQ[dirBW *sizeQ]; - Q.q27[dirBE ] = &QQ[dirBE *sizeQ]; - Q.q27[dirTW ] = &QQ[dirTW *sizeQ]; - Q.q27[dirTN ] = &QQ[dirTN *sizeQ]; - Q.q27[dirBS ] = &QQ[dirBS *sizeQ]; - Q.q27[dirBN ] = &QQ[dirBN *sizeQ]; - Q.q27[dirTS ] = &QQ[dirTS *sizeQ]; - Q.q27[dirREST] = &QQ[dirREST*sizeQ]; - Q.q27[dirTNE ] = &QQ[dirTNE *sizeQ]; - Q.q27[dirTSW ] = &QQ[dirTSW *sizeQ]; - Q.q27[dirTSE ] = &QQ[dirTSE *sizeQ]; - Q.q27[dirTNW ] = &QQ[dirTNW *sizeQ]; - Q.q27[dirBNE ] = &QQ[dirBNE *sizeQ]; - Q.q27[dirBSW ] = &QQ[dirBSW *sizeQ]; - Q.q27[dirBSE ] = &QQ[dirBSE *sizeQ]; - Q.q27[dirBNW ] = &QQ[dirBNW *sizeQ]; + Q.q27[dirE] = &QQ[dirE * sizeQ]; + Q.q27[dirW] = &QQ[dirW * sizeQ]; + Q.q27[dirN] = &QQ[dirN * sizeQ]; + Q.q27[dirS] = &QQ[dirS * sizeQ]; + Q.q27[dirT] = &QQ[dirT * sizeQ]; + Q.q27[dirB] = &QQ[dirB * sizeQ]; + Q.q27[dirNE] = &QQ[dirNE * sizeQ]; + Q.q27[dirSW] = &QQ[dirSW * sizeQ]; + Q.q27[dirSE] = &QQ[dirSE * sizeQ]; + Q.q27[dirNW] = &QQ[dirNW * sizeQ]; + Q.q27[dirTE] = &QQ[dirTE * sizeQ]; + Q.q27[dirBW] = &QQ[dirBW * sizeQ]; + Q.q27[dirBE] = &QQ[dirBE * sizeQ]; + Q.q27[dirTW] = &QQ[dirTW * sizeQ]; + Q.q27[dirTN] = &QQ[dirTN * sizeQ]; + Q.q27[dirBS] = &QQ[dirBS * sizeQ]; + Q.q27[dirBN] = &QQ[dirBN * sizeQ]; + Q.q27[dirTS] = &QQ[dirTS * sizeQ]; + Q.q27[dirREST] = &QQ[dirREST * sizeQ]; + Q.q27[dirTNE] = &QQ[dirTNE * sizeQ]; + Q.q27[dirTSW] = &QQ[dirTSW * sizeQ]; + Q.q27[dirTSE] = &QQ[dirTSE * sizeQ]; + Q.q27[dirTNW] = &QQ[dirTNW * sizeQ]; + Q.q27[dirBNE] = &QQ[dirBNE * sizeQ]; + Q.q27[dirBSW] = &QQ[dirBSW * sizeQ]; + Q.q27[dirBSE] = &QQ[dirBSE * sizeQ]; + Q.q27[dirBNW] = &QQ[dirBNW * sizeQ]; builder->getVelocityQs(Q.q27, 0); - cudaMemoryManager->cudaCopyVeloBC(); + cudaMemoryManager->cudaCopyVeloBC(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::cout << "-----finish BoundaryQs------" << std::endl; } - - - std::string GridGenerator::verifyNeighborIndices() const { std::ostringstream oss; oss << "---------report start---------\n"; oss << "Checking neighbor indices in grid \n"; - int invalidNodes = 0; + int invalidNodes = 0; int wrongNeighbors = 0; - int stopperNodes = 0; + int stopperNodes = 0; for (uint index = 0; index < para->getParH()->numberOfNodes; index++) oss << verifyNeighborIndex(index, invalidNodes, stopperNodes, wrongNeighbors); - oss << "invalid nodes found: " << invalidNodes << "\n"; oss << "wrong neighbors found: " << wrongNeighbors << "\n"; oss << "stopper nodes found : " << stopperNodes << "\n"; @@ -264,13 +253,13 @@ std::string GridGenerator::verifyNeighborIndices() const return oss.str(); } -std::string GridGenerator::verifyNeighborIndex(int index , int &invalidNodes, int &stopperNodes, int &wrongNeighbors) const +std::string GridGenerator::verifyNeighborIndex(int index, int &invalidNodes, int &stopperNodes, + int &wrongNeighbors) const { std::ostringstream oss; const int geo = para->getParH()->typeOfGridNode[index]; - if (geo == 16) - { + if (geo == 16) { stopperNodes++; return ""; } @@ -281,27 +270,27 @@ std::string GridGenerator::verifyNeighborIndex(int index , int &invalidNodes, in real delta = para->getParH()->coordinateX[2] - para->getParH()->coordinateX[1]; - real maxX = para->getParH()->coordinateX[para->getParH()->numberOfNodes - 1] - delta; - real maxY = para->getParH()->coordinateY[para->getParH()->numberOfNodes - 1] - delta; - real maxZ = para->getParH()->coordinateZ[para->getParH()->numberOfNodes - 1] - delta; + real maxX = para->getParH()->coordinateX[para->getParH()->numberOfNodes - 1] - delta; + real maxY = para->getParH()->coordinateY[para->getParH()->numberOfNodes - 1] - delta; + real maxZ = para->getParH()->coordinateZ[para->getParH()->numberOfNodes - 1] - delta; real realNeighborX = vf::Math::lessEqual(x + delta, maxX) ? x + delta : para->getParH()->coordinateX[1]; real realNeighborY = vf::Math::lessEqual(y + delta, maxY) ? y + delta : para->getParH()->coordinateY[1]; real realNeighborZ = vf::Math::lessEqual(z + delta, maxZ) ? z + delta : para->getParH()->coordinateZ[1]; - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborX[index], realNeighborX, y, z, "X"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborY[index], x, realNeighborY, z, "Y"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[index], x, y, realNeighborZ, "Z"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborX[index], realNeighborX, y, z, "X"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborY[index], x, realNeighborY, z, "Y"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[index], x, y, realNeighborZ, "Z"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborY[this->para->getParH()->neighborX[index]], realNeighborX, realNeighborY, z, "XY"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborX[index]], realNeighborX, y, realNeighborZ, "XZ"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborY[index]], x, realNeighborY, realNeighborZ, "YZ"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborY[this->para->getParH()->neighborX[index]], realNeighborX, realNeighborY, z, "XY"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborX[index]], realNeighborX, y, realNeighborZ, "XZ"); + oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborY[index]], x, realNeighborY, realNeighborZ, "YZ"); - oss << checkNeighbor(x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborY[this->para->getParH()->neighborX[index]]], realNeighborX, realNeighborY, realNeighborZ, "XYZ"); + oss << checkNeighbor( x, y, z, index, wrongNeighbors, this->para->getParH()->neighborZ[this->para->getParH()->neighborY[this->para->getParH()->neighborX[index]]], realNeighborX, realNeighborY, realNeighborZ, "XYZ"); return oss.str(); } -std::string GridGenerator::checkNeighbor(real x, real y, real z, int index, int& numberOfWrongNeihgbors, int neighborIndex, real neighborX, real neighborY, real neighborZ, std::string direction) const +std::string GridGenerator::checkNeighbor(real x, real y, real z, int index, int &numberOfWrongNeihgbors, int neighborIndex, real neighborX, real neighborY, real neighborZ, std::string direction) const { std::ostringstream oss(""); @@ -309,13 +298,14 @@ std::string GridGenerator::checkNeighbor(real x, real y, real z, int index, int& real neighborCoordY = para->getParH()->coordinateY[neighborIndex]; real neighborCoordZ = para->getParH()->coordinateZ[neighborIndex]; - const bool neighborValid = vf::Math::equal(neighborX, neighborCoordX) && vf::Math::equal(neighborY, neighborCoordY) && vf::Math::equal(neighborZ, neighborCoordZ); + const bool neighborValid = vf::Math::equal(neighborX, neighborCoordX) && + vf::Math::equal(neighborY, neighborCoordY) && vf::Math::equal(neighborZ, neighborCoordZ); if (!neighborValid) { - oss << "NeighborX invalid from: (" << x << ", " << y << ", " << z << "), index: " << index << ", " - << direction << " neighborIndex: " << neighborIndex << - ", actual neighborCoords : (" << neighborCoordX << ", " << neighborCoordY << ", " << neighborCoordZ << - "), expected neighborCoords : (" << neighborX << ", " << neighborY << ", " << neighborZ << ")\n"; + oss << "NeighborX invalid from: (" << x << ", " << y << ", " << z << "), index: " + << index << ", " << direction << " neighborIndex: " << neighborIndex + << ", actual neighborCoords : (" << neighborCoordX << ", " << neighborCoordY << ", " << neighborCoordZ + << "), expected neighborCoords : (" << neighborX << ", " << neighborY << ", " << neighborZ << ")\n"; numberOfWrongNeihgbors++; } return oss.str();