diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index a4e322ad6d6e383072f28ac34ca25799a73a2ff4..e14fbc0e4a297fbe4505ee1f8aef16c30c95758a 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -173,7 +173,7 @@ void multipleLevel(const std::string& configPath) para->setDevices(std::vector<uint>{(uint)0}); - para->setOutputPath( path ); + para->setOutputPath( path ); // optional, default is output/ para->setOutputPrefix( simulationName ); diff --git a/src/gpu/VirtualFluids_GPU/LBM/LB.h b/src/gpu/VirtualFluids_GPU/LBM/LB.h index ea37fcc0725dd5c6a0d2d10cdb23a9ab767066a7..90736528b32c8c0ad5ad6f14d30cc8d05743d87a 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/LB.h +++ b/src/gpu/VirtualFluids_GPU/LBM/LB.h @@ -78,7 +78,9 @@ struct InitCondition std::vector<int> GridX, GridY, GridZ, DistX, DistY, DistZ; std::vector<real> scaleLBMtoSI, translateLBMtoSI; std::vector<real> minCoordX, minCoordY, minCoordZ, maxCoordX, maxCoordY, maxCoordZ; - std::string fname, oPath; + std::string fname; + std::string oPath {"output/"}; + std::string gridPath = {"grid/"}; std::string oPrefix {"MyFile"}; std::string geometryFileC, geometryFileM, geometryFileF; std::string kFull, geoFull, geoVec, coordX, coordY, coordZ, neighborX, neighborY, neighborZ, neighborWSB, scaleCFC, scaleCFF, scaleFCC, scaleFCF, scaleOffsetCF, scaleOffsetFC; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index 95f2e535e7e157e19e6573db9f2a6788618a01a3..06c849b796df5a68f089dedd15808dd4f1c5fc2c 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -44,13 +44,22 @@ #include "Parameter/CudaStreamManager.h" -Parameter::Parameter(const vf::basics::ConfigurationFile &configData, int numberOfProcesses, int myId) +Parameter::Parameter(int numberOfProcesses, int myId) { ic.numprocs = numberOfProcesses; ic.myid = myId; + initGridPaths(); + initGridDist(); + initMultiKernel(); + // initLBMSimulationParameter(); +} +Parameter::Parameter(const vf::basics::ConfigurationFile &configData, int numberOfProcesses, int myId): Parameter(numberOfProcesses, myId) +{ readConfigData(configData); - // initLBMSimulationParameter(); + initGridPaths(); + initGridDist(); + initMultiKernel(); } Parameter::~Parameter() = default; @@ -246,72 +255,10 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) ////////////////////////////////////////////////////////////////////////// - std::string gridPath{ "" }; if (configData.contains("GridPath")) - gridPath = configData.getValue<std::string>("GridPath"); - else - throw std::runtime_error("GridPath has to be defined in config file!"); + this->setGridPath(configData.getValue<std::string>("GridPath")); - if (this->getNumprocs() == 1) - gridPath += "/"; - else - gridPath += "/" + StringUtil::toString(this->getMyID()) + "/"; - - // ////////////////////////////////////////////////////////////////////////// - this->setFName(this->getOutputPath() + "/" + this->getOutputPrefix()); - ////////////////////////////////////////////////////////////////////////// - this->setgeoVec(gridPath + "geoVec.dat"); - this->setcoordX(gridPath + "coordX.dat"); - this->setcoordY(gridPath + "coordY.dat"); - this->setcoordZ(gridPath + "coordZ.dat"); - this->setneighborX(gridPath + "neighborX.dat"); - this->setneighborY(gridPath + "neighborY.dat"); - this->setneighborZ(gridPath + "neighborZ.dat"); - this->setneighborWSB(gridPath + "neighborWSB.dat"); - this->setscaleCFC(gridPath + "scaleCFC.dat"); - this->setscaleCFF(gridPath + "scaleCFF.dat"); - this->setscaleFCC(gridPath + "scaleFCC.dat"); - this->setscaleFCF(gridPath + "scaleFCF.dat"); - this->setscaleOffsetCF(gridPath + "offsetVecCF.dat"); - this->setscaleOffsetFC(gridPath + "offsetVecFC.dat"); - this->setgeomBoundaryBcQs(gridPath + "geomBoundaryQs.dat"); - this->setgeomBoundaryBcValues(gridPath + "geomBoundaryValues.dat"); - this->setinletBcQs(gridPath + "inletBoundaryQs.dat"); - this->setinletBcValues(gridPath + "inletBoundaryValues.dat"); - this->setoutletBcQs(gridPath + "outletBoundaryQs.dat"); - this->setoutletBcValues(gridPath + "outletBoundaryValues.dat"); - this->settopBcQs(gridPath + "topBoundaryQs.dat"); - this->settopBcValues(gridPath + "topBoundaryValues.dat"); - this->setbottomBcQs(gridPath + "bottomBoundaryQs.dat"); - this->setbottomBcValues(gridPath + "bottomBoundaryValues.dat"); - this->setfrontBcQs(gridPath + "frontBoundaryQs.dat"); - this->setfrontBcValues(gridPath + "frontBoundaryValues.dat"); - this->setbackBcQs(gridPath + "backBoundaryQs.dat"); - this->setbackBcValues(gridPath + "backBoundaryValues.dat"); - this->setnumberNodes(gridPath + "numberNodes.dat"); - this->setLBMvsSI(gridPath + "LBMvsSI.dat"); - this->setmeasurePoints(gridPath + "measurePoints.dat"); - this->setpropellerValues(gridPath + "propellerValues.dat"); - this->setcpTop(gridPath + "cpTop.dat"); - this->setcpBottom(gridPath + "cpBottom.dat"); - this->setcpBottom2(gridPath + "cpBottom2.dat"); - this->setConcentration(gridPath + "conc.dat"); - this->setStreetVelocity(gridPath + "streetVector.dat"); - ////////////////////////////////////////////////////////////////////////// - // Normals - Geometry - this->setgeomBoundaryNormalX(gridPath + "geomBoundaryNormalX.dat"); - this->setgeomBoundaryNormalY(gridPath + "geomBoundaryNormalY.dat"); - this->setgeomBoundaryNormalZ(gridPath + "geomBoundaryNormalZ.dat"); - // Normals - Inlet - this->setInflowBoundaryNormalX(gridPath + "inletBoundaryNormalX.dat"); - this->setInflowBoundaryNormalY(gridPath + "inletBoundaryNormalY.dat"); - this->setInflowBoundaryNormalZ(gridPath + "inletBoundaryNormalZ.dat"); - // Normals - Outlet - this->setOutflowBoundaryNormalX(gridPath + "outletBoundaryNormalX.dat"); - this->setOutflowBoundaryNormalY(gridPath + "outletBoundaryNormalY.dat"); - this->setOutflowBoundaryNormalZ(gridPath + "outletBoundaryNormalZ.dat"); - ////////////////////////////////////////////////////////////////////////// - // //Forcing + // Forcing real forcingX = 0.0; real forcingY = 0.0; real forcingZ = 0.0; @@ -357,28 +304,6 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) if (configData.contains("endXHotWall")) this->setEndXHotWall(configData.getValue<real>("endXHotWall")); - ////////////////////////////////////////////////////////////////////////// - // for Multi GPU - if (this->getNumprocs() > 1) { - ////////////////////////////////////////////////////////////////////////// - // 3D domain decomposition - std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; - std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; - for (int i = 0; i < this->getNumprocs(); i++) { - sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); - sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); - sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); - recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); - recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); - recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); - } - this->setPossNeighborFilesX(sendProcNeighborsX, "send"); - this->setPossNeighborFilesY(sendProcNeighborsY, "send"); - this->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); - this->setPossNeighborFilesX(recvProcNeighborsX, "recv"); - this->setPossNeighborFilesY(recvProcNeighborsY, "recv"); - this->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); - } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Restart @@ -397,14 +322,6 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) if (configData.contains("NOGL")) setMaxLevel(configData.getValue<int>("NOGL")); - this->setGridX(std::vector<int>(this->getMaxLevel() + 1, 32)); - this->setGridY(std::vector<int>(this->getMaxLevel() + 1, 32)); - this->setGridZ(std::vector<int>(this->getMaxLevel() + 1, 32)); - - this->setDistX(std::vector<int>(this->getMaxLevel() + 1, 32)); - this->setDistY(std::vector<int>(this->getMaxLevel() + 1, 32)); - this->setDistZ(std::vector<int>(this->getMaxLevel() + 1, 32)); - if (configData.contains("GridX")) this->setGridX(configData.getVector<int>("GridX")); @@ -433,17 +350,130 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) if (configData.contains("MultiKernelLevel")) this->setMultiKernelLevel(configData.getVector<int>("MultiKernelLevel")); - else if (this->getMultiKernelOn()) { + + if (configData.contains("MultiKernelName")) + this->setMultiKernel(configData.getVector<std::string>("MultiKernelName")); +} + +void Parameter::initGridPaths(){ + std::string gridPath = this->getGridPath(); + + // add missing slash to gridPath + if (gridPath.back() != '/') + { + gridPath += "/"; + this->setGridPath(gridPath); + } + + // for multi-gpu add process id + if (this->getNumprocs() > 1){ + gridPath += StringUtil::toString(this->getMyID()) + "/"; + this->setGridPath(gridPath); + } + + this->setFName(this->getOutputPath() + "/" + this->getOutputPrefix()); + + ////////////////////////////////////////////////////////////////////////// + + this->setgeoVec(gridPath + "geoVec.dat"); + this->setcoordX(gridPath + "coordX.dat"); + this->setcoordY(gridPath + "coordY.dat"); + this->setcoordZ(gridPath + "coordZ.dat"); + this->setneighborX(gridPath + "neighborX.dat"); + this->setneighborY(gridPath + "neighborY.dat"); + this->setneighborZ(gridPath + "neighborZ.dat"); + this->setneighborWSB(gridPath + "neighborWSB.dat"); + this->setscaleCFC(gridPath + "scaleCFC.dat"); + this->setscaleCFF(gridPath + "scaleCFF.dat"); + this->setscaleFCC(gridPath + "scaleFCC.dat"); + this->setscaleFCF(gridPath + "scaleFCF.dat"); + this->setscaleOffsetCF(gridPath + "offsetVecCF.dat"); + this->setscaleOffsetFC(gridPath + "offsetVecFC.dat"); + this->setgeomBoundaryBcQs(gridPath + "geomBoundaryQs.dat"); + this->setgeomBoundaryBcValues(gridPath + "geomBoundaryValues.dat"); + this->setinletBcQs(gridPath + "inletBoundaryQs.dat"); + this->setinletBcValues(gridPath + "inletBoundaryValues.dat"); + this->setoutletBcQs(gridPath + "outletBoundaryQs.dat"); + this->setoutletBcValues(gridPath + "outletBoundaryValues.dat"); + this->settopBcQs(gridPath + "topBoundaryQs.dat"); + this->settopBcValues(gridPath + "topBoundaryValues.dat"); + this->setbottomBcQs(gridPath + "bottomBoundaryQs.dat"); + this->setbottomBcValues(gridPath + "bottomBoundaryValues.dat"); + this->setfrontBcQs(gridPath + "frontBoundaryQs.dat"); + this->setfrontBcValues(gridPath + "frontBoundaryValues.dat"); + this->setbackBcQs(gridPath + "backBoundaryQs.dat"); + this->setbackBcValues(gridPath + "backBoundaryValues.dat"); + this->setnumberNodes(gridPath + "numberNodes.dat"); + this->setLBMvsSI(gridPath + "LBMvsSI.dat"); + this->setmeasurePoints(gridPath + "measurePoints.dat"); + this->setpropellerValues(gridPath + "propellerValues.dat"); + this->setcpTop(gridPath + "cpTop.dat"); + this->setcpBottom(gridPath + "cpBottom.dat"); + this->setcpBottom2(gridPath + "cpBottom2.dat"); + this->setConcentration(gridPath + "conc.dat"); + this->setStreetVelocity(gridPath + "streetVector.dat"); + + ////////////////////////////////////////////////////////////////////////// + // Normals - Geometry + this->setgeomBoundaryNormalX(gridPath + "geomBoundaryNormalX.dat"); + this->setgeomBoundaryNormalY(gridPath + "geomBoundaryNormalY.dat"); + this->setgeomBoundaryNormalZ(gridPath + "geomBoundaryNormalZ.dat"); + // Normals - Inlet + this->setInflowBoundaryNormalX(gridPath + "inletBoundaryNormalX.dat"); + this->setInflowBoundaryNormalY(gridPath + "inletBoundaryNormalY.dat"); + this->setInflowBoundaryNormalZ(gridPath + "inletBoundaryNormalZ.dat"); + // Normals - Outlet + this->setOutflowBoundaryNormalX(gridPath + "outletBoundaryNormalX.dat"); + this->setOutflowBoundaryNormalY(gridPath + "outletBoundaryNormalY.dat"); + this->setOutflowBoundaryNormalZ(gridPath + "outletBoundaryNormalZ.dat"); + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + // for Multi GPU + if (this->getNumprocs() > 1) { + + // 3D domain decomposition + std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; + std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; + for (int i = 0; i < this->getNumprocs(); i++) { + sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); + sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); + sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); + recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); + recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); + recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); + } + this->setPossNeighborFilesX(sendProcNeighborsX, "send"); + this->setPossNeighborFilesY(sendProcNeighborsY, "send"); + this->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); + this->setPossNeighborFilesX(recvProcNeighborsX, "recv"); + this->setPossNeighborFilesY(recvProcNeighborsY, "recv"); + this->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); + + ////////////////////////////////////////////////////////////////////////// + } +} + +void Parameter::initGridDist(){ + this->setGridX(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setGridY(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setGridZ(std::vector<int>(this->getMaxLevel() + 1, 32)); + + this->setDistX(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setDistY(std::vector<int>(this->getMaxLevel() + 1, 32)); + this->setDistZ(std::vector<int>(this->getMaxLevel() + 1, 32)); +} + +void Parameter::initMultiKernel(){ + if (this->getMultiKernelOn() && this->getMultiKernelLevel().empty()) { std::vector<int> tmp; for (int i = 0; i < this->getMaxLevel() + 1; i++) { tmp.push_back(i); } this->setMultiKernelLevel(tmp); } - - if (configData.contains("MultiKernelName")) - this->setMultiKernel(configData.getVector<std::string>("MultiKernelName")); - else if (this->getMultiKernelOn()) { + + if (this->getMultiKernelOn() && this->getMultiKernel().empty()) { std::vector<std::string> tmp; for (int i = 0; i < this->getMaxLevel() + 1; i++) { tmp.push_back("CumulantK17Comp"); @@ -713,14 +743,16 @@ void Parameter::setOutputPath(std::string oPath) } void Parameter::setOutputPrefix(std::string oPrefix) { - // std::string test = fname; ic.oPrefix = oPrefix; } void Parameter::setFName(std::string fname) { - // std::string test = fname; ic.fname = fname; } +void Parameter::setGridPath(std::string gridPath) +{ + ic.gridPath = gridPath; +} void Parameter::setPrintFiles(bool printfiles) { ic.printFiles = printfiles; @@ -1774,6 +1806,10 @@ std::string Parameter::getFName() { return ic.fname; } +std::string Parameter::getGridPath() +{ + return ic.gridPath; +} bool Parameter::getPrintFiles() { return ic.printFiles; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index 6ce3b10935a4371b934f63336f18755ab12b7dd1..754e178c07d90ab3fbcc47fa676c8cbd745c04c4 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -381,6 +381,7 @@ class VIRTUALFLUIDS_GPU_EXPORT Parameter { public: Parameter(const vf::basics::ConfigurationFile &configData, int numberOfProcesses, int myId); + Parameter(int numberOfProcesses, int myId); ~Parameter(); void initLBMSimulationParameter(); @@ -436,6 +437,7 @@ public: void setOutputPath(std::string oPath); void setOutputPrefix(std::string oPrefix); void setFName(std::string fname); + void setGridPath(std::string gridPath); void setGeometryFileC(std::string GeometryFileC); void setGeometryFileM(std::string GeometryFileM); void setGeometryFileF(std::string GeometryFileF); @@ -655,6 +657,7 @@ public: std::string getOutputPath(); std::string getOutputPrefix(); std::string getFName(); + std::string getGridPath(); std::string getGeometryFileC(); std::string getGeometryFileM(); std::string getGeometryFileF(); @@ -861,7 +864,11 @@ public: private: void readConfigData(const vf::basics::ConfigurationFile &configData); + void initGridPaths(); + void initGridDist(); + void initMultiKernel(); +private: bool compOn{ false }; bool diffOn{ false }; bool isF3{ false };