From 9d3ee844780ab1246c4898ee33cd78f590dfeb48 Mon Sep 17 00:00:00 2001 From: "GITLAB-RUNNER03\\runner" <petes@irmb.tu-bs.de> Date: Tue, 29 Jun 2021 11:13:40 +0200 Subject: [PATCH] Use std::filesystem in gpu binaries --- apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp | 57 +++++++------------ .../LBM/DrivenCavity/configDrivenCavity.txt | 1 + .../Parameter/ParameterTest.cpp | 22 +++---- 3 files changed, 33 insertions(+), 47 deletions(-) diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index f6043d351..710d5c87f 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -8,6 +8,7 @@ #include <fstream> #include <exception> #include <memory> +#include <filesystem> #include "mpi.h" @@ -96,10 +97,6 @@ const real dt = (real)1.0e-3; //0.5e-3; const uint nx = 64; -//std::string path("F:/Work/Computations/out/DrivenCavity/"); //LEGOLAS -//std::string path("D:/out/DrivenCavity"); //Mollok -std::string path("/home/sopeters/Computations/out/DrivenCavity64_unified"); // phoenix - std::string simulationName("DrivenCavityChim"); const uint timeStepOut = 10000; @@ -171,7 +168,6 @@ void multipleLevel(const std::string& configPath) para->setDevices(std::vector<uint>{(uint)0}); - para->setOutputPath( path ); para->setOutputPrefix( simulationName ); para->setFName(para->getOutputPath() + "/" + para->getOutputPrefix()); @@ -341,39 +337,26 @@ void multipleLevel(const std::string& configPath) int main( int argc, char* argv[]) { MPI_Init(&argc, &argv); - std::string str, str2; - if ( argv != NULL ) + + try + { + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("configDrivenCavity.txt"); + + multipleLevel(filePath.string()); + } + catch (const std::bad_alloc& e) + { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } + catch (const std::exception& e) + { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } + catch (...) { - //str = static_cast<std::string>(argv[0]); - - try - { - ////////////////////////////////////////////////////////////////////////// - - std::string targetPath; - - targetPath = __FILE__; - - targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); - - std::cout << targetPath << std::endl; - - multipleLevel(targetPath + "configDrivenCavity.txt"); - - ////////////////////////////////////////////////////////////////////////// - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; } MPI_Finalize(); diff --git a/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt b/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt index a3d6622d5..246e6f728 100644 --- a/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt +++ b/apps/gpu/LBM/DrivenCavity/configDrivenCavity.txt @@ -9,6 +9,7 @@ ################################################## #Path="E:/DrivenCavity/results" #Path="F:/Work/Computations/out/DrivenCavity/" +Path = C:/out/ #Prefix="DrivenCavity" #WriteGrid=true ################################################## diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp index da7844839..ec2e2e356 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp @@ -1,6 +1,8 @@ #include <gmock/gmock.h> +#include <iostream> #include <string> +#include <filesystem> #include "Parameter.h" #include <basics/config/ConfigurationFile.h> @@ -17,12 +19,12 @@ auto RealEq = [](auto value) { TEST(ParameterTest, passingEmptyFileWithoutPath_ShouldThrow) { - vf::basics::ConfigurationFile config; - std::string targetPath = __FILE__; - targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); - targetPath += "parameterTest_emptyfile.cfg"; + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("parameterTest_emptyfile.cfg"); - config.load(targetPath); + vf::basics::ConfigurationFile config; + config.load(filePath.string()); EXPECT_THROW(Parameter para(config, 1, 0), std::runtime_error); } @@ -32,12 +34,12 @@ TEST(ParameterTest, passingEmptyFileWithoutPath_ShouldThrow) TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor) { - vf::basics::ConfigurationFile config; - std::string targetPath = __FILE__; - targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); - targetPath += "parameterTest.cfg"; + // assuming that the config files is stored parallel to this file. + std::filesystem::path filePath = __FILE__; + filePath.replace_filename("parameterTest.cfg"); - config.load(targetPath); + vf::basics::ConfigurationFile config; + config.load(filePath.string()); Parameter para(config, 1, 0); -- GitLab