diff --git a/src/gpu/VirtualFluids_GPU/LBM/LB.h b/src/gpu/VirtualFluids_GPU/LBM/LB.h index bea4a1683afb078e6f3eb3afbc22528b399b6cce..dd443b469431effe2432cfac94146d322771d8fa 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/LB.h +++ b/src/gpu/VirtualFluids_GPU/LBM/LB.h @@ -112,7 +112,8 @@ struct InitCondition bool printFiles {false}; bool doRestart {false}; bool doCheckPoint {false}; - bool readGeo, isGeo, isProp, isCp; + bool readGeo {false}; + bool isGeo, isProp, isCp; bool GeometryValues {false}; bool is2ndOrderMoments {false}; bool is3rdOrderMoments {false}; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index 8c3a4c510b2c8896bb9049d728ed13df265f2a4f..61b5daf689e36d7b6e4e7f615591aa538b24030c 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -65,6 +65,7 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) this->setOutputPath(configData.getValue<std::string>("Path")); else throw std::runtime_error("<Path> need to be defined in config file!"); + ////////////////////////////////////////////////////////////////////////// if (configData.contains("Prefix")) this->setOutputPrefix(configData.getValue<std::string>("Prefix")); @@ -136,16 +137,16 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) this->setTimeCalcMedEnd(configData.getValue<int>("TimeEndCalcMedian")); ////////////////////////////////////////////////////////////////////////// if (configData.contains("PressInID")) - this->setTOut(configData.getValue<int>("PressInID")); + this->setPressInID(configData.getValue<int>("PressInID")); ////////////////////////////////////////////////////////////////////////// if (configData.contains("PressOutID")) - this->setTStartOut(configData.getValue<int>("PressOutID")); + this->setPressOutID(configData.getValue<int>("PressOutID")); ////////////////////////////////////////////////////////////////////////// if (configData.contains("PressInZ")) - this->setTimeCalcMedStart(configData.getValue<int>("PressInZ")); + this->setPressInZ(configData.getValue<int>("PressInZ")); ////////////////////////////////////////////////////////////////////////// if (configData.contains("PressOutZ")) - this->setTimeCalcMedEnd(configData.getValue<int>("PressOutZ")); + this->setPressOutZ(configData.getValue<int>("PressOutZ")); ////////////////////////////////////////////////////////////////////////// //second component diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2f77401742ae5c958ad30f6bdc53955544a42303 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp @@ -0,0 +1,61 @@ +#include <gmock/gmock.h> + +#include <string> + +#include "Parameter.h" +#include <basics/config/ConfigurationFile.h> + + +auto RealEq = [](auto value) { +#ifdef VF_DOUBLE_ACCURACY + return testing::DoubleEq(value); +#else + return testing::FloatEq(value); +#endif +}; + + +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"; + + config.load(targetPath); + + EXPECT_THROW(Parameter para(config, 1, 0), std::runtime_error); +} + +TEST(ParameterTest, check_outputPath) +{ + vf::basics::ConfigurationFile config; + std::string targetPath = __FILE__; + targetPath = targetPath.substr(0, targetPath.find_last_of('/') + 1); + targetPath += "parameterTest.cfg"; + + config.load(targetPath); + + Parameter para(config, 1, 0); + + // this two parameters need to be defined in each config file + EXPECT_THAT(para.getOutputPath(), testing::Eq("/output/path")); + EXPECT_THAT(para.getgeoVec(), testing::Eq("/path/to/grid/geoVec.dat")); + // ... all grid files could be tested as well + + // test optional parameter + EXPECT_THAT(para.getMaxDev(), testing::Eq(2)); + EXPECT_THAT(para.getDevices(), testing::ElementsAreArray({2,3})); + EXPECT_THAT(para.getOutputPrefix(), testing::Eq("MyPrefix")); + EXPECT_THAT(para.getPrintFiles(), testing::Eq(true)); + EXPECT_THAT(para.getIsGeometryValues(), testing::Eq(true)); + EXPECT_THAT(para.getCalc2ndOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalc3rdOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalcHighOrderMoments(), testing::Eq(true)); + EXPECT_THAT(para.getCalcMedian(), testing::Eq(true)); + EXPECT_THAT(para.getCalcCp(), testing::Eq(true)); + EXPECT_THAT(para.getCalcDragLift(), testing::Eq(true)); +} + + + diff --git a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg new file mode 100644 index 0000000000000000000000000000000000000000..38d63cc29303d113b2cc37f93513920cdd55e3d9 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg @@ -0,0 +1,16 @@ +# this two parameters need to be defined in each config file +Path = /output/path +GridPath = /path/to/grid + +# optional parameter +NumberOfDevices = 2 +Devices = 2 3 +Prefix = MyPrefix +WriteGrid = true +GeometryValues = true +calc2ndOrderMoments = true +calc3rdOrderMoments = true +calcHigherOrderMoments = true +calcMedian = true +calcCp = true +calcDrafLift = true \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest_emptyfile.cfg b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest_emptyfile.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391