From 9a7007c0eb2c326ef08ecfd4507dc472923544b9 Mon Sep 17 00:00:00 2001 From: Anna Wellmann <a.wellmann@tu-bs.de> Date: Wed, 19 Apr 2023 06:56:53 +0000 Subject: [PATCH] Small changes to ConfigurationFile and calls to this class --- .../gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp | 5 +++-- apps/gpu/LBM/MusselOyster/MusselOyster.cpp | 5 +++-- apps/gpu/LBM/SphereGPU/Sphere.cpp | 1 + apps/gpu/LBM/SphereScaling/SphereScaling.cpp | 5 +++-- src/basics/config/ConfigurationFile.cpp | 3 ++- src/basics/config/ConfigurationFile.h | 8 ++++---- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp b/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp index 5a1ad9800..acab426b4 100755 --- a/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp +++ b/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp @@ -60,7 +60,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(vf::basics::ConfigurationFile& config) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); @@ -516,8 +516,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/DrivenCavityMultiGPU/configDrivenCavityMultiGPU.txt"); - multipleLevel(config); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/apps/gpu/LBM/MusselOyster/MusselOyster.cpp b/apps/gpu/LBM/MusselOyster/MusselOyster.cpp index 5b6456c49..b583633b5 100644 --- a/apps/gpu/LBM/MusselOyster/MusselOyster.cpp +++ b/apps/gpu/LBM/MusselOyster/MusselOyster.cpp @@ -84,7 +84,7 @@ const std::string simulationName("MusselOyster"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(vf::basics::ConfigurationFile& config) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { vf::gpu::Communicator &communicator = vf::gpu::Communicator::getInstance(); @@ -583,8 +583,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/MusselOyster/configMusselOyster.txt"); - multipleLevel(config); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/apps/gpu/LBM/SphereGPU/Sphere.cpp b/apps/gpu/LBM/SphereGPU/Sphere.cpp index 3c4a7fb92..707c3ab9c 100644 --- a/apps/gpu/LBM/SphereGPU/Sphere.cpp +++ b/apps/gpu/LBM/SphereGPU/Sphere.cpp @@ -102,6 +102,7 @@ int main(int argc, char *argv[]) GridScalingFactory scalingFactory = GridScalingFactory(); vf::basics::ConfigurationFile config; if (useConfigFile) { + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/SphereGPU/config.txt"); para = std::make_shared<Parameter>(&config); } else { diff --git a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp index d7b6ddbe8..da80302e9 100755 --- a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp +++ b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp @@ -63,7 +63,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(vf::basics::ConfigurationFile& config) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); @@ -657,8 +657,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { + VF_LOG_INFO("For the default config path to work, execute the app from the project root."); vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/SphereScaling/config.txt"); - multipleLevel(config); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/src/basics/config/ConfigurationFile.cpp b/src/basics/config/ConfigurationFile.cpp index 6e6ba21c0..547468cd2 100644 --- a/src/basics/config/ConfigurationFile.cpp +++ b/src/basics/config/ConfigurationFile.cpp @@ -8,6 +8,7 @@ #include <fstream> #include <iostream> #include <stdlib.h> +#include <filesystem> #include <basics/utilities/UbException.h> @@ -26,7 +27,7 @@ bool ConfigurationFile::load(const std::string& file) if (!inFile.good()) { - UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file "+file+"!")); + UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file " + file + "! Your current directory is " + std::filesystem::current_path().string() + ".")); } while (inFile.good() && ! inFile.eof()) diff --git a/src/basics/config/ConfigurationFile.h b/src/basics/config/ConfigurationFile.h index aed29f31e..8ca12306e 100644 --- a/src/basics/config/ConfigurationFile.h +++ b/src/basics/config/ConfigurationFile.h @@ -70,20 +70,20 @@ public: template<class T> T getValue(const std::string& key, T defaultValue) const; - static ConfigurationFile loadConfig(int argc, char *argv[], std::filesystem::path configPath = "./config.txt") + static ConfigurationFile loadConfig(int argc, char *argv[], std::string configPath = "./config.txt") { // the config file's default path can be replaced by passing a command line argument if (argc > 1) { configPath = argv[1]; - VF_LOG_INFO("Using command line argument for config path: {}", configPath.string()); + VF_LOG_INFO("Using command line argument for config path: {}", configPath); } else { - VF_LOG_INFO("Using default config path: {}", configPath.string()); + VF_LOG_INFO("Using default config path: {}", configPath); } vf::basics::ConfigurationFile config; - config.load(configPath.string()); + config.load(configPath); return config; } -- GitLab