Skip to content
Snippets Groups Projects
Commit 9a7007c0 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Small changes to ConfigurationFile and calls to this class

parent 9830aa11
No related branches found
No related tags found
1 merge request!219Add helper function for creating configReader
......@@ -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) {
......
......@@ -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) {
......
......@@ -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 {
......
......@@ -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) {
......
......@@ -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())
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment