diff --git a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp index 569a5da6cb0fd62abd24095f7bce27e00b119944..28359d06b5e26d54ea0a2b35f8cbb5f356010b54 100644 --- a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp +++ b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp @@ -1,53 +1,53 @@ #define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> #include <math.h> -#include <string> +#include <memory> #include <sstream> -#include <iostream> #include <stdexcept> -#include <fstream> -#include <exception> -#include <memory> +#include <string> #include "mpi.h" ////////////////////////////////////////////////////////////////////////// #include "basics/Core/DataTypes.h" -#include "basics/PointerDefinitions.h" #include "basics/Core/VectorTypes.h" +#include "basics/PointerDefinitions.h" #include "basics/Core/LbmOrGks.h" +#include "basics/Core/Logger/Logger.h" #include "basics/Core/StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" -#include "basics/Core/Logger/Logger.h" ////////////////////////////////////////////////////////////////////////// +#include "GridGenerator/grid/BoundaryConditions/Side.h" #include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" #include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/BoundaryConditions/Side.h" #include "GridGenerator/grid/GridFactory.h" -#include "geometries/Sphere/Sphere.h" -#include "geometries/Cuboid/Cuboid.h" #include "geometries/Conglomerate/Conglomerate.h" +#include "geometries/Cuboid/Cuboid.h" +#include "geometries/Sphere/Sphere.h" #include "geometries/TriangularMesh/TriangularMesh.h" -#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" #include "GridGenerator/io/GridVTKWriter/GridVTKWriter.h" #include "GridGenerator/io/STLReaderWriter/STLReader.h" #include "GridGenerator/io/STLReaderWriter/STLWriter.h" +#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" ////////////////////////////////////////////////////////////////////////// -#include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" -#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" #include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" #include "VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h" -#include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" #include "VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.h" #include "VirtualFluids_GPU/PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h" @@ -58,7 +58,6 @@ #include "utilities/communication.h" - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -85,7 +84,7 @@ std::string stlPath("/home/y0078217/STL/Sphere/"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(const std::string& configPath) +void multipleLevel(const std::string &configPath) { logging::Logger::addStream(&std::cout); logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); @@ -97,62 +96,62 @@ void multipleLevel(const std::string& configPath) gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - vf::gpu::Communicator* comm = vf::gpu::Communicator::getInstanz(); + + vf::gpu::Communicator *comm = vf::gpu::Communicator::getInstanz(); vf::basics::ConfigurationFile config; std::cout << configPath << std::endl; config.load(configPath); SPtr<Parameter> para = std::make_shared<Parameter>(config, comm->getNummberOfProcess(), comm->getPID()); - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool useGridGenerator = true; - bool useLevels = true; - std::string scalingType = "strong"; // "strong" // "weak" + bool useGridGenerator = true; + bool useLevels = true; + std::string scalingType = "strong"; // "strong" // "weak" // para->setUseStreams(true); // set in config // para->useReducedCommunicationAfterFtoC = true; // set in config if (para->getNumprocs() == 1) { - para->useReducedCommunicationAfterFtoC = false; + para->useReducedCommunicationAfterFtoC = false; } if (scalingType != "weak" && scalingType != "strong") std::cerr << "unknown scaling type" << std::endl; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::string gridPath(gridPathParent); // only for GridGenerator, for GridReader the gridPath needs to be set in the config file + std::string gridPath( + gridPathParent); // only for GridGenerator, for GridReader the gridPath needs to be set in the config file real dxGrid = (real)0.2; - real vxLB = (real)0.0005; // LB units - real viscosityLB = 0.001; //(vxLB * dxGrid) / Re; + real vxLB = (real)0.0005; // LB units + real viscosityLB = 0.001; //(vxLB * dxGrid) / Re; para->setVelocity(vxLB); para->setViscosity(viscosityLB); - para->setVelocityRatio((real) 58.82352941); - para->setViscosityRatio((real) 0.058823529); - para->setDensityRatio((real) 998.0); + para->setVelocityRatio((real)58.82352941); + para->setViscosityRatio((real)0.058823529); + para->setDensityRatio((real)998.0); *logging::out << logging::Logger::INFO_HIGH << "velocity LB [dx/dt] = " << vxLB << " \n"; *logging::out << logging::Logger::INFO_HIGH << "viscosity LB [dx^2/dt] = " << viscosityLB << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "velocity real [m/s] = " << vxLB * para->getVelocityRatio()<< " \n"; - *logging::out << logging::Logger::INFO_HIGH << "viscosity real [m^2/s] = " << viscosityLB * para->getViscosityRatio() << "\n"; + *logging::out << logging::Logger::INFO_HIGH << "velocity real [m/s] = " << vxLB * para->getVelocityRatio() << " \n"; + *logging::out << logging::Logger::INFO_HIGH + << "viscosity real [m^2/s] = " << viscosityLB * para->getViscosityRatio() << "\n"; *logging::out << logging::Logger::INFO_HIGH << "dxGrid = " << dxGrid << "\n"; *logging::out << logging::Logger::INFO_HIGH << "useGridGenerator = " << useGridGenerator << "\n"; *logging::out << logging::Logger::INFO_HIGH << "useStreams = " << para->getUseStreams() << "\n"; *logging::out << logging::Logger::INFO_HIGH << "number of processes = " << para->getNumprocs() << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "para->useReducedCommunicationAfterFtoC = " << para->useReducedCommunicationAfterFtoC << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "scalingType = " << scalingType << "\n"; - + *logging::out << logging::Logger::INFO_HIGH + << "para->useReducedCommunicationAfterFtoC = " << para->useReducedCommunicationAfterFtoC << "\n"; + *logging::out << logging::Logger::INFO_HIGH << "scalingType = " << scalingType << "\n"; + // para->setTOut(10); // para->setTEnd(10); @@ -172,8 +171,7 @@ void multipleLevel(const std::string& configPath) else para->setMaxLevel(1); - - //para->setMainKernel("CumulantK17CompChim"); + // para->setMainKernel("CumulantK17CompChim"); para->setMainKernel("CumulantK17CompChimStream"); *logging::out << logging::Logger::INFO_HIGH << "Kernel: " << para->getMainKernel() << "\n"; @@ -183,26 +181,22 @@ void multipleLevel(const std::string& configPath) // } else if (para->getNumprocs() == 2) { // para->setDevices(std::vector<uint>{ 2u, 3u }); // para->setMaxDev(2); - // } else + // } else // para->setDevices(std::vector<uint>{ 0u }); // para->setMaxDev(1); - - ////////////////////////////////////////////////////////////////////////// - if (useGridGenerator) { real sideLengthCube; - if (useLevels){ + if (useLevels) { if (scalingType == "strong") sideLengthCube = 76.0; // Phoenix: strong scaling with two levels = 76.0 else if (scalingType == "weak") sideLengthCube = 70.0; // Phoenix: weak scaling with two levels = 70.0 - } - else + } else sideLengthCube = 92.0; // Phoenix: 86.0 - real xGridMin = 0.0; + real xGridMin = 0.0; real xGridMax = sideLengthCube; real yGridMin = 0.0; real yGridMax = sideLengthCube; @@ -220,9 +214,9 @@ void multipleLevel(const std::string& configPath) if (comm->getNummberOfProcess() == 2) { real zSplit = 0.5 * sideLengthCube; - - if (scalingType == "weak"){ - zSplit = zGridMax; + + if (scalingType == "weak") { + zSplit = zGridMax; zGridMax = zGridMax + sideLengthCube; } @@ -236,23 +230,28 @@ void multipleLevel(const std::string& configPath) } if (useLevels) { - if (scalingType == "strong"){ - gridBuilder->addGrid(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); - } else if (scalingType == "weak"){ - gridBuilder->addGrid(new Cuboid( -0.5*dCubeLev1, -0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, - 0.5*dCubeLev1, 0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1),1); + if (scalingType == "strong") { + gridBuilder->addGrid( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + 1); + } else if (scalingType == "weak") { + gridBuilder->addGrid(new Cuboid(-0.5 * dCubeLev1, -0.5 * dCubeLev1, + sideLengthCube - 0.5 * dCubeLev1, 0.5 * dCubeLev1, + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), + 1); } } - if (scalingType == "weak"){ + if (scalingType == "weak") { if (useLevels) { gridBuilder->addGeometry(new Sphere(0.0, 0.0, sideLengthCube, dSphere)); - }else{ + } else { TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_2GPU.stl"); gridBuilder->addGeometry(sphereSTL); - } + } } else if (scalingType == "strong") { - gridBuilder->addGeometry(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + gridBuilder->addGeometry( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } if (generatePart == 0) @@ -263,7 +262,7 @@ void multipleLevel(const std::string& configPath) std::make_shared<BoundingBox>(xGridMin, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! - + if (generatePart == 0) { gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 1); @@ -283,23 +282,23 @@ void multipleLevel(const std::string& configPath) gridBuilder->setVelocityBoundaryCondition(SideType::MZ, vxLB, 0.0, 0.0); if (generatePart == 1) gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs // gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); ////////////////////////////////////////////////////////////////////////// - + } else if (comm->getNummberOfProcess() == 4) { - real ySplit= 0.5 * sideLengthCube; - real zSplit= 0.5 * sideLengthCube; + real ySplit = 0.5 * sideLengthCube; + real zSplit = 0.5 * sideLengthCube; if (scalingType == "weak") { - ySplit = yGridMax; - yGridMax = yGridMax + (yGridMax-yGridMin); - zSplit = zGridMax; - zGridMax = zGridMax + (zGridMax-zGridMin); + ySplit = yGridMax; + yGridMax = yGridMax + (yGridMax - yGridMin); + zSplit = zGridMax; + zGridMax = zGridMax + (zGridMax - zGridMin); } if (generatePart == 0) { - gridBuilder->addCoarseGrid(xGridMin, yGridMin, zGridMin, xGridMax , ySplit + overlap, + gridBuilder->addCoarseGrid(xGridMin, yGridMin, zGridMin, xGridMax, ySplit + overlap, zSplit + overlap, dxGrid); } if (generatePart == 1) { @@ -316,23 +315,29 @@ void multipleLevel(const std::string& configPath) } if (useLevels) { - if (scalingType == "strong"){ - gridBuilder->addGrid(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); - } else if (scalingType == "weak"){ - gridBuilder->addGrid(new Cuboid( -0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, - 0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1),1); + if (scalingType == "strong") { + gridBuilder->addGrid( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + 1); + } else if (scalingType == "weak") { + gridBuilder->addGrid(new Cuboid(-0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + sideLengthCube - 0.5 * dCubeLev1, 0.5 * dCubeLev1, + sideLengthCube + 0.5 * dCubeLev1, + sideLengthCube + 0.5 * dCubeLev1), + 1); } } - if (scalingType == "weak"){ + if (scalingType == "weak") { if (useLevels) { gridBuilder->addGeometry(new Sphere(0.0, sideLengthCube, sideLengthCube, dSphere)); - }else{ + } else { TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_4GPU.stl"); gridBuilder->addGeometry(sphereSTL); - } + } } else if (scalingType == "strong") { - gridBuilder->addGeometry(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + gridBuilder->addGeometry( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } if (generatePart == 0) @@ -348,10 +353,9 @@ void multipleLevel(const std::string& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xGridMin, xGridMax, ySplit, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); - + if (generatePart == 0) { gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 1); @@ -388,14 +392,14 @@ void multipleLevel(const std::string& configPath) } if (generatePart == 2) { gridBuilder->setVelocityBoundaryCondition(SideType::MY, vxLB, 0.0, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); } if (generatePart == 3) { gridBuilder->setVelocityBoundaryCondition(SideType::PY, vxLB, 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); } gridBuilder->setVelocityBoundaryCondition(SideType::MX, vxLB, 0.0, 0.0); - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs // gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); ////////////////////////////////////////////////////////////////////////// } else if (comm->getNummberOfProcess() == 8) { @@ -403,13 +407,13 @@ void multipleLevel(const std::string& configPath) real ySplit = 0.5 * sideLengthCube; real zSplit = 0.5 * sideLengthCube; - if (scalingType == "weak") { - xSplit = xGridMax; - xGridMax = xGridMax + (xGridMax-xGridMin); - ySplit = yGridMax; - yGridMax = yGridMax + (yGridMax-yGridMin); - zSplit = zGridMax; - zGridMax = zGridMax + (zGridMax-zGridMin); + if (scalingType == "weak") { + xSplit = xGridMax; + xGridMax = xGridMax + (xGridMax - xGridMin); + ySplit = yGridMax; + yGridMax = yGridMax + (yGridMax - yGridMin); + zSplit = zGridMax; + zGridMax = zGridMax + (zGridMax - zGridMin); } if (generatePart == 0) { @@ -446,25 +450,31 @@ void multipleLevel(const std::string& configPath) } if (useLevels) { - if (scalingType == "strong"){ - gridBuilder->addGrid(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); - } else if (scalingType == "weak"){ - gridBuilder->addGrid(new Cuboid( sideLengthCube-0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, - sideLengthCube+0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1),1); + if (scalingType == "strong") { + gridBuilder->addGrid( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + 1); + } else if (scalingType == "weak") { + gridBuilder->addGrid( + new Cuboid(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + sideLengthCube - 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, + sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), + 1); } } - if (scalingType == "weak"){ + if (scalingType == "weak") { if (useLevels) { gridBuilder->addGeometry(new Sphere(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); - }else{ + } else { TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_8GPU.stl"); gridBuilder->addGeometry(sphereSTL); - } + } } else if (scalingType == "strong") { - gridBuilder->addGeometry(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + gridBuilder->addGeometry( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } - + if (generatePart == 0) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xGridMin, xSplit, yGridMin, ySplit, zGridMin, zSplit)); @@ -592,52 +602,55 @@ void multipleLevel(const std::string& configPath) if (generatePart == 6) { gridBuilder->setVelocityBoundaryCondition(SideType::MY, vxLB, 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs } if (generatePart == 7) { gridBuilder->setVelocityBoundaryCondition(SideType::PY, vxLB, 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs } // gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// } if (para->getKernelNeedsFluidNodeIndicesToRun()) gridBuilder->findFluidNodes(para->getUseStreams()); // gridBuilder->writeGridsToVtk(outPath + "grid/part" + // std::to_string(generatePart) + "_"); gridBuilder->writeGridsToVtk(outPath + - // std::to_string(generatePart) + "/grid/"); gridBuilder->writeArrows(outPath + + // std::to_string(generatePart) + "/grid/"); gridBuilder->writeArrows(outPath + // std::to_string(generatePart) + " /arrow"); - SimulationFileWriter::write(gridPath + std::to_string(generatePart) + "/", gridBuilder, - FILEFORMAT::BINARY); + SimulationFileWriter::write(gridPath + std::to_string(generatePart) + "/", gridBuilder, FILEFORMAT::BINARY); } else { gridBuilder->addCoarseGrid(xGridMin, yGridMin, zGridMin, xGridMax, yGridMax, zGridMax, dxGrid); if (useLevels) { - gridBuilder->setNumberOfLayers(10, 8); - if(scalingType == "strong"){ - gridBuilder->addGrid(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); + gridBuilder->setNumberOfLayers(10, 8); + if (scalingType == "strong") { + gridBuilder->addGrid( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); } else if (scalingType == "weak") - gridBuilder->addGrid(new Cuboid( sideLengthCube-0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, sideLengthCube-0.5*dCubeLev1, - sideLengthCube+0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1, sideLengthCube+0.5*dCubeLev1),1); + gridBuilder->addGrid(new Cuboid(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + sideLengthCube - 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, + sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), + 1); } - - if (scalingType == "weak"){ - if(useLevels){ + + if (scalingType == "weak") { + if (useLevels) { gridBuilder->addGeometry(new Sphere(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); - }else{ - TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_1GPU.stl"); - gridBuilder->addGeometry(sphereSTL); + } else { + TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_1GPU.stl"); + gridBuilder->addGeometry(sphereSTL); } } else { - gridBuilder->addGeometry(new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + gridBuilder->addGeometry( + new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! - + gridBuilder->setPeriodicBoundaryCondition(false, false, false); ////////////////////////////////////////////////////////////////////////// gridBuilder->setVelocityBoundaryCondition(SideType::PY, vxLB, 0.0, 0.0); @@ -645,7 +658,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setVelocityBoundaryCondition(SideType::MX, vxLB, 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::MZ, vxLB, 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vxLB, 0.0, 0.0); - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); // set pressure BC after velocity BCs // gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); ////////////////////////////////////////////////////////////////////////// @@ -656,9 +669,9 @@ void multipleLevel(const std::string& configPath) // gridBuilder->writeArrows ("E:/temp/MusselOyster/" + "/arrow"); SimulationFileWriter::write(gridPath, gridBuilder, FILEFORMAT::BINARY); - } + } } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); @@ -668,10 +681,10 @@ void multipleLevel(const std::string& configPath) else { gridGenerator = GridProvider::makeGridReader(FILEFORMAT::BINARY, para, cudaMemoryManager); } - + Simulation sim; - SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); - SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + SPtr<KernelFactoryImp> kernelFactory = KernelFactoryImp::getInstance(); SPtr<PreProcessorFactoryImp> preProcessorFactory = PreProcessorFactoryImp::getInstance(); sim.setFactories(kernelFactory, preProcessorFactory); sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); @@ -679,24 +692,21 @@ void multipleLevel(const std::string& configPath) sim.free(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - } -int main( int argc, char* argv[]) +int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); std::string str, str2, configFile; - if ( argv != NULL ) - { - - try - { + if (argv != NULL) { + + try { ////////////////////////////////////////////////////////////////////////// - std::string targetPath; + std::string targetPath; - targetPath = __FILE__; + targetPath = __FILE__; if (argc == 2) { configFile = argv[1]; @@ -709,30 +719,24 @@ int main( int argc, char* argv[]) targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); #endif - std::cout << targetPath << std::endl; + std::cout << targetPath << std::endl; - if (configFile.size()==0) { + if (configFile.size() == 0) { configFile = targetPath + "config.txt"; - } + } - multipleLevel(configFile); + multipleLevel(configFile); ////////////////////////////////////////////////////////////////////////// - } - catch (const std::bad_alloc& e) - { + } catch (const std::bad_alloc &e) { *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (const std::exception& e) - { + } catch (const std::exception &e) { *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (...) - { + } catch (...) { *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; } } - MPI_Finalize(); - return 0; + MPI_Finalize(); + return 0; } diff --git a/gpu.cmake b/gpu.cmake index 26eafd6ac44dda71480554d6995ba7cbfa342a06..af4bdca383f1314820adeaf0c6738feeb7c004f4 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -44,10 +44,10 @@ IF (BUILD_VF_GPU) #add_subdirectory(apps/gpu/LBM/gridGeneratorTest) #add_subdirectory(apps/gpu/LBM/TGV_3D) #add_subdirectory(apps/gpu/LBM/TGV_3D_MultiGPU) - #add_subdirectory(apps/gpu/LBM/SphereScaling) + add_subdirectory(apps/gpu/LBM/SphereScaling) #add_subdirectory(apps/gpu/LBM/DrivenCavityMultiGPU) - add_subdirectory(apps/gpu/LBM/MusselOyster) - # add_subdirectory(apps/gpu/LBM/Poiseuille) + #add_subdirectory(apps/gpu/LBM/MusselOyster) + #add_subdirectory(apps/gpu/LBM/Poiseuille) ELSE() MESSAGE( STATUS "exclude Virtual Fluids GPU." ) ENDIF()