diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index f6043d3511db7da4fd68c934ab8d8bdccfff3651..710d5c87fcf05cbe27747f50d8685b9f3467fe17 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 a3d6622d50700e554dcf3429f0c51e07f5c83ead..246e6f72841c23957e85bb5d69a449af8d178822 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 da7844839cca4c467c3e529d62e9e40a7fb06728..ec2e2e3569ec9b9cf9cb863e9900bf249ceb7f00 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);