diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efb8d9dd58ca1e9d91c5226595df1ba79d1dc293..0f9dc273226cd00e27d683f015e742cff46b3c39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ image: irmb/virtualfluids-python-deps stages: - build - test + - benchmark - analyze - deploy - release @@ -124,8 +125,6 @@ gcc_9_rebuild: msvc_16: stage: build - when: manual - tags: - win - gpu @@ -200,7 +199,6 @@ msvc_16_unit_tests: - gpu needs: ["msvc_16"] - when: manual before_script: - cd $CI_PROJECT_DIR/build @@ -226,6 +224,72 @@ gcc_9_python_bindings_test: script: - python3 -m unittest discover -s Python -v +############################################################################### +## Benchmark ## +############################################################################### +nvidia_test: + stage: benchmark + + needs: [] + + tags: + - gpu + - linux + + image: nvidia/cuda:11.1.1-devel-ubuntu20.04 + + script: + - echo NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES} + - nvidia-smi + +############################################################################### +gpu_numerical_tests: + stage: benchmark + + image: irmb/virtualfluids-deps-ubuntu20.04 + + when: manual + + needs: [] + + tags: + - gpu + - linux + + before_script: + - cd /tmp + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.rz.tu-bs.de/irmb/test_data.git + - export CCACHE_BASEDIR=$CI_PROJECT_DIR + - export CCACHE_DIR=$CI_PROJECT_DIR/cache + - ccache -s + - mkdir -p $CI_PROJECT_DIR/build + - cd $CI_PROJECT_DIR/build + - rm -r -f ./* + - cmake .. + -DBUILD_VF_CPU=OFF + -DBUILD_VF_GPU=ON + -DBUILD_VF_DOUBLE_ACCURACY=ON + -DBUILD_NUMERIC_TESTS=ON + -DPATH_NUMERICAL_TESTS=/tmp/test_data/numerical_tests_gpu + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache + -DCMAKE_C_COMPILER_LAUNCHER=ccache + - make -j4 + - ccache -s + + script: + - cd $CI_PROJECT_DIR + - ./build/bin/NumericalTests $CI_PROJECT_DIR/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt 2>&1 | tee -a numerical_tests_gpu_results.txt + + cache: + key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" + paths: + - $CI_PROJECT_DIR/cache + + artifacts: + paths: + - $CI_PROJECT_DIR/numerical_tests_gpu_results.txt + ############################################################################### ## Code analysis ## @@ -488,16 +552,14 @@ gcov_to_elladan: ############################################################################### # sonar-scanner runs sonar-project.properties # the reports in this file needs to match the artifacts. +# This job only run on the development branch of the parent repository, not on forks! sonar-scanner: stage: deploy only: - refs: - - develop - - when: manual + - develop@git.rz.tu-bs.de/irmb/VirtualFluids_dev variables: - SONAR_HOST_URL: "http://finrod.irmb.bau.tu-bs.de/sonarqube" + SONAR_HOST_URL: "http://gitlab-runner01.irmb.bau.tu-bs.de/sonarqube/" needs: ["cppcheck","clang-tidy","gcov_gcc_9","gcc_9_rebuild"] @@ -507,15 +569,15 @@ sonar-scanner: - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.0.0.1744-linux.zip - unzip sonar-scanner-cli-4.0.0.1744-linux.zip - cd sonar-scanner-4.0.0.1744-linux/ - - echo 'sonar.host.url=http://finrod.irmb.bau.tu-bs.de/sonarqube' >> conf/sonar-scanner.properties - - echo 'sonar.sourceEncoding=UTF-8' >> conf/sonar-scanner.properties + - echo "sonar.host.url=$SONAR_HOST_URL" >> conf/sonar-scanner.properties + - echo "sonar.sourceEncoding=UTF-8" >> conf/sonar-scanner.properties - cat conf/sonar-scanner.properties - export PATH+=:$(pwd)/bin - sonar-scanner -v script: - cd $CI_PROJECT_DIR - - sonar-scanner + - sonar-scanner -Dsonar.login=$SONAR_SECURITY_TOKEN ############################################################################### ## Release ## diff --git a/CMake/3rd/cuda.cmake b/CMake/3rd/cuda.cmake index 021dc65ab285a6803d4b6a47b2b78a3e0365ffe9..7214deaa4d2a4324668e11d9620e467719b64c27 100644 --- a/CMake/3rd/cuda.cmake +++ b/CMake/3rd/cuda.cmake @@ -11,8 +11,11 @@ function(linkCUDA) vf_get_library_name(library_name) target_include_directories(${library_name} PRIVATE ${CUDA_CUT_INCLUDE_DIR}) + target_include_directories(${library_name} PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) + + message("CUDA INCLUDE PATH: ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") # set the following properties only for specific targets # set_property(TARGET ${targetName} PROPERTY CUDA_SEPARABLE_COMPILATION ON) # set_property(TARGET ${targetName} PROPERTY CUDA_64_BIT_DEVICE_CODE ON) -endfunction() \ No newline at end of file +endfunction() diff --git a/CMake/CMakeSetCompilerFlags.cmake b/CMake/CMakeSetCompilerFlags.cmake index 4165eeff8b8cce1e89d19beffefe7507496fee49..ad9311482ed65a521f90e8210709bfd0a8351ecd 100644 --- a/CMake/CMakeSetCompilerFlags.cmake +++ b/CMake/CMakeSetCompilerFlags.cmake @@ -20,7 +20,7 @@ macro(loadMachineFile) SET(CMAKE_CONFIG_FILE "${VF_CMAKE_DIR}/cmake_config_files/${CAB_MACHINE}.config.cmake") IF(NOT EXISTS ${CMAKE_CONFIG_FILE}) - status("No configuration file found for machine: ${CAB_MACHINE}.") + status("No configuration file found for machine: ${CAB_MACHINE}.config.cmake") ELSE() status("Load configuration file ${CAB_MACHINE}.config.cmake") include(${CMAKE_CONFIG_FILE}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fd7dfff17385b7079c0d285b4f326677f65b736..1830f48173209915b23fe1abeeec8e915dcaac00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,13 @@ set (VF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) option(BUILD_VF_CPU "Build VirtualFluids cpu variant" OFF) option(BUILD_VF_GPU "Build VirtualFluids gpu variant" OFF) +# vf gpu +option(BUILD_VF_GPU "Build VirtualFluids GPU" ON ) +option(BUILD_VF_GKS "Build VirtualFluids GKS" OFF ) +option(BUILD_VF_TRAFFIC "Build VirtualFluids Traffic" OFF) +option(BUILD_JSONCPP "Builds json cpp " OFF) +option(BUILD_NUMERIC_TESTS "Build numeric tests" OFF) + option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF) option(BUILD_VF_CLANG_TIDY "Add the clang tidy checks to the targets" OFF) option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF) @@ -99,5 +106,7 @@ endif() # 3rd Party Libraries ################################################################################# if(BUILD_VF_UNIT_TESTS) - add_subdirectory(${VF_THIRD_DIR}/googletest) + if(NOT BUILD_NUMERIC_TESTS) # in this case googletest is already included. + add_subdirectory(${VF_THIRD_DIR}/googletest) + endif() endif() diff --git a/apps/gpu/tests/NumericalTests/Tests/NyTest/NyTest.cpp b/apps/gpu/tests/NumericalTests/Tests/NyTest/NyTest.cpp index e3e7932e9d77481c26d3e9ffb80ce614de0d817c..474ea1a4f4a32d244958a305001acf71e1f515ef 100644 --- a/apps/gpu/tests/NumericalTests/Tests/NyTest/NyTest.cpp +++ b/apps/gpu/tests/NumericalTests/Tests/NyTest/NyTest.cpp @@ -110,7 +110,7 @@ std::vector<double> NyTest::calcNyDiff(std::vector<double> ny) { std::vector<double> results; for (int i = 0; i < ny.size(); i++) - results.push_back(abs((ny.at(i) - viscosity) / viscosity)); + results.push_back(std::fabs((ny.at(i) - viscosity) / viscosity)); return results; } diff --git a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp index 37a34a3c3fe76d474c0dede2a3806e2af7dde420..aa2768f631b6159db4a31f09ec8bdfe48f307112 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp @@ -5,407 +5,447 @@ #include "VirtualFluids_GPU/Kernel/Utilities/Mapper/KernelMapper/KernelMapper.h" -#include <string> #include <fstream> +#include <string> #define VAL(str) #str #define TOSTRING(str) VAL(str) - std::shared_ptr<ConfigFileReader> ConfigFileReader::getNewInstance(const std::string aFilePath) { - return std::shared_ptr<ConfigFileReader>(new ConfigFileReader(aFilePath)); + return std::shared_ptr<ConfigFileReader>(new ConfigFileReader(aFilePath)); } ConfigFileReader::ConfigFileReader(const std::string aFilePath) : myFilePath(aFilePath) { - myKernelMapper = KernelMapper::getInstance(); + myKernelMapper = KernelMapper::getInstance(); + + // If PATH_NUMERICAL_TESTS is not defined, the grid definitions for the tests needs to be placed in the project root + // directories. +#ifdef PATH_NUMERICAL_TESTS + pathNumericalTests = TOSTRING(PATH_NUMERICAL_TESTS) + std::string("/"); +#else + pathNumericalTests = TOSTRING(SOURCE_ROOT) + std::string("/"); +#endif + std::cout << pathNumericalTests << "\n"; } void ConfigFileReader::readConfigFile() { - configData = std::shared_ptr<ConfigDataStruct>(new ConfigDataStruct); - std::ifstream stream = openConfigFile(myFilePath); + configData = std::shared_ptr<ConfigDataStruct>(new ConfigDataStruct); + std::ifstream stream = openConfigFile(myFilePath); - std::shared_ptr<input::Input> input = input::Input::makeInput(stream, "config"); + std::shared_ptr<input::Input> input = input::Input::makeInput(stream, "config"); - if (!checkConfigFile(input)) - exit(1); + if (!checkConfigFile(input)) + exit(1); - configData->viscosity = StringUtil::toDoubleVector(input->getValue("Viscosity")); - configData->kernelsToTest = readKernelList(input); - configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); - configData->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation"));; - configData->logFilePath = TOSTRING(PATH_NUMERICAL_TESTS) + input->getValue("FolderLogFile"); - configData->numberOfSimulations = calcNumberOfSimulations(input); + configData->viscosity = StringUtil::toDoubleVector(input->getValue("Viscosity")); + configData->kernelsToTest = readKernelList(input); + configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); + configData->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + ; + configData->logFilePath = pathNumericalTests + input->getValue("FolderLogFile"); + configData->numberOfSimulations = calcNumberOfSimulations(input); - std::shared_ptr<BasicSimulationParameterStruct> basicSimPara = makeBasicSimulationParameter(input); + std::shared_ptr<BasicSimulationParameterStruct> basicSimPara = makeBasicSimulationParameter(input); - configData->taylorGreenVortexUxParameter = makeTaylorGreenVortexUxParameter(input, basicSimPara); - configData->taylorGreenVortexUxGridInformation = makeGridInformation(input, "TaylorGreenVortexUx");; + configData->taylorGreenVortexUxParameter = makeTaylorGreenVortexUxParameter(input, basicSimPara); + configData->taylorGreenVortexUxGridInformation = makeGridInformation(input, "TaylorGreenVortexUx"); + ; - configData->taylorGreenVortexUzParameter = makeTaylorGreenVortexUzParameter(input, basicSimPara); - configData->taylorGreenVortexUzGridInformation = makeGridInformation(input, "TaylorGreenVortexUz");; + configData->taylorGreenVortexUzParameter = makeTaylorGreenVortexUzParameter(input, basicSimPara); + configData->taylorGreenVortexUzGridInformation = makeGridInformation(input, "TaylorGreenVortexUz"); + ; - configData->shearWaveParameter = makeShearWaveParameter(input, basicSimPara); - configData->shearWaveGridInformation = makeGridInformation(input, "ShearWave");; + configData->shearWaveParameter = makeShearWaveParameter(input, basicSimPara); + configData->shearWaveGridInformation = makeGridInformation(input, "ShearWave"); + ; - configData->phiTestParameter = makePhiTestParameter(input); - configData->nyTestParameter = makeNyTestParameter(input); - configData->l2NormTestParameter = makeL2NormTestParameter(input); - configData->l2NormTestBetweenKernelsParameter = makeL2NormTestBetweenKernelsParameter(input); + configData->phiTestParameter = makePhiTestParameter(input); + configData->nyTestParameter = makeNyTestParameter(input); + configData->l2NormTestParameter = makeL2NormTestParameter(input); + configData->l2NormTestBetweenKernelsParameter = makeL2NormTestBetweenKernelsParameter(input); - configData->vectorWriterInfo = makeVectorWriterInformationStruct(input); + configData->vectorWriterInfo = makeVectorWriterInformationStruct(input); - configData->logFilePara = makeLogFilePara(input); + configData->logFilePara = makeLogFilePara(input); - stream.close(); + stream.close(); } std::ifstream ConfigFileReader::openConfigFile(const std::string aFilePath) { - std::ifstream stream; - stream.open(aFilePath.c_str(), std::ios::in); - if (stream.fail()) - throw "can not open config file!\n"; + std::ifstream stream; + stream.open(aFilePath.c_str(), std::ios::in); + if (stream.fail()) + throw "can not open config file!\n"; - return stream; + return stream; } -std::shared_ptr<ConfigDataStruct> ConfigFileReader::getConfigData() -{ - return configData; -} +std::shared_ptr<ConfigDataStruct> ConfigFileReader::getConfigData() { return configData; } bool ConfigFileReader::checkConfigFile(std::shared_ptr<input::Input> input) { - std::vector<double> u0TGVux = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); - std::vector<double> amplitudeTGVux = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); - std::vector<int> basisTimeStepLengthTGVux = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); - - std::vector<double> v0TGVuz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); - std::vector<double> amplitudeTGVuz = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); - std::vector<int> basisTimeStepLengthTGVuz = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); - - std::vector<double> v0SW = StringUtil::toDoubleVector(input->getValue("v0_SW")); - std::vector<double> u0SW = StringUtil::toDoubleVector(input->getValue("u0_SW")); - std::vector<int> basisTimeStepLengthSW = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); - - if (u0TGVux.size() != amplitudeTGVux.size() || u0TGVux.size() != basisTimeStepLengthTGVux.size()) { - std::cout << "Length u0_TGV_U0 is unequal to Lenght Amplitude_TGV_U0 or BasisTimeStepLength_TGV_U0!" << std::endl << std::flush; - return false; - } else if (v0TGVuz.size() != amplitudeTGVuz.size() || v0TGVuz.size() != basisTimeStepLengthTGVuz.size()) { - std::cout << "Length v0_TGV_V0 is unequal to Lenght Amplitude_TGV_V0 or BasisTimeStepLength_TGV_V0!" << std::endl << std::flush; - return false; - } else if (u0SW.size() != v0SW.size() || u0SW.size() != basisTimeStepLengthSW.size()) { - std::cout << "Length u0_SW is unequal to Lenght v0_SW!" << std::endl << std::flush; - return false; - } - else - { - return true; - } + std::vector<double> u0TGVux = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); + std::vector<double> amplitudeTGVux = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); + std::vector<int> basisTimeStepLengthTGVux = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); + + std::vector<double> v0TGVuz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); + std::vector<double> amplitudeTGVuz = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); + std::vector<int> basisTimeStepLengthTGVuz = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); + + std::vector<double> v0SW = StringUtil::toDoubleVector(input->getValue("v0_SW")); + std::vector<double> u0SW = StringUtil::toDoubleVector(input->getValue("u0_SW")); + std::vector<int> basisTimeStepLengthSW = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); + + if (u0TGVux.size() != amplitudeTGVux.size() || u0TGVux.size() != basisTimeStepLengthTGVux.size()) { + std::cout << "Length u0_TGV_U0 is unequal to Lenght Amplitude_TGV_U0 or BasisTimeStepLength_TGV_U0!" + << std::endl + << std::flush; + return false; + } else if (v0TGVuz.size() != amplitudeTGVuz.size() || v0TGVuz.size() != basisTimeStepLengthTGVuz.size()) { + std::cout << "Length v0_TGV_V0 is unequal to Lenght Amplitude_TGV_V0 or BasisTimeStepLength_TGV_V0!" + << std::endl + << std::flush; + return false; + } else if (u0SW.size() != v0SW.size() || u0SW.size() != basisTimeStepLengthSW.size()) { + std::cout << "Length u0_SW is unequal to Lenght v0_SW!" << std::endl << std::flush; + return false; + } else { + return true; + } } -std::shared_ptr<BasicSimulationParameterStruct> ConfigFileReader::makeBasicSimulationParameter(std::shared_ptr<input::Input> input) +std::shared_ptr<BasicSimulationParameterStruct> +ConfigFileReader::makeBasicSimulationParameter(std::shared_ptr<input::Input> input) { - std::shared_ptr<BasicSimulationParameterStruct> basicSimPara = std::shared_ptr<BasicSimulationParameterStruct>(new BasicSimulationParameterStruct); + std::shared_ptr<BasicSimulationParameterStruct> basicSimPara = + std::shared_ptr<BasicSimulationParameterStruct>(new BasicSimulationParameterStruct); - basicSimPara->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); - basicSimPara->devices = StringUtil::toUintVector(input->getValue("Devices")); - return basicSimPara; + basicSimPara->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); + basicSimPara->devices = StringUtil::toUintVector(input->getValue("Devices")); + return basicSimPara; } - -std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct> > ConfigFileReader::makeTaylorGreenVortexUxParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) +std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct>> +ConfigFileReader::makeTaylorGreenVortexUxParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) { - std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); - std::vector<double> amplitude = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); - std::vector<double> u0 = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); - int l0 = StringUtil::toInt(input->getValue("l0_TGV_Ux")); - basicSimParameter->l0 = l0; - - std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct> > parameter; - for (int i = 0; i < u0.size(); i++) { - std::shared_ptr<TaylorGreenVortexUxParameterStruct> aParameter = std::shared_ptr<TaylorGreenVortexUxParameterStruct>(new TaylorGreenVortexUxParameterStruct); - aParameter->basicSimulationParameter = basicSimParameter; - - aParameter->ux = u0.at(i); - aParameter->amplitude = amplitude.at(i); - aParameter->basicTimeStepLength = basisTimeStepLength.at(i); - aParameter->l0 = l0; - aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); - aParameter->vtkFilePath = TOSTRING(PATH_NUMERICAL_TESTS) + input->getValue("FolderForVTKFileWriting"); - aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Ux")); - parameter.push_back(aParameter); - } - return parameter; + std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); + std::vector<double> amplitude = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); + std::vector<double> u0 = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); + int l0 = StringUtil::toInt(input->getValue("l0_TGV_Ux")); + basicSimParameter->l0 = l0; + + std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct>> parameter; + for (int i = 0; i < u0.size(); i++) { + std::shared_ptr<TaylorGreenVortexUxParameterStruct> aParameter = + std::shared_ptr<TaylorGreenVortexUxParameterStruct>(new TaylorGreenVortexUxParameterStruct); + aParameter->basicSimulationParameter = basicSimParameter; + + aParameter->ux = u0.at(i); + aParameter->amplitude = amplitude.at(i); + aParameter->basicTimeStepLength = basisTimeStepLength.at(i); + aParameter->l0 = l0; + aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); + aParameter->vtkFilePath = pathNumericalTests + input->getValue("FolderForVTKFileWriting"); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Ux")); + parameter.push_back(aParameter); + } + return parameter; } -std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > ConfigFileReader::makeTaylorGreenVortexUzParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) +std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct>> +ConfigFileReader::makeTaylorGreenVortexUzParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) { - std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); - std::vector<double> amplitude = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); - std::vector<double> uz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); - int l0 = StringUtil::toInt(input->getValue("l0_TGV_Uz")); - basicSimParameter->l0 = l0; - - std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > parameter; - for (int i = 0; i < uz.size(); i++) { - std::shared_ptr<TaylorGreenVortexUzParameterStruct> aParameter = std::shared_ptr<TaylorGreenVortexUzParameterStruct>(new TaylorGreenVortexUzParameterStruct); - aParameter->basicSimulationParameter = basicSimParameter; - aParameter->uz = uz.at(i); - aParameter->amplitude = amplitude.at(i); - aParameter->basicTimeStepLength = basisTimeStepLength.at(i); - aParameter->l0 = l0; - aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); - aParameter->vtkFilePath = TOSTRING(PATH_NUMERICAL_TESTS) + input->getValue("FolderForVTKFileWriting"); - aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Uz")); - parameter.push_back(aParameter); - } - return parameter; + std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); + std::vector<double> amplitude = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); + std::vector<double> uz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); + int l0 = StringUtil::toInt(input->getValue("l0_TGV_Uz")); + basicSimParameter->l0 = l0; + + std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct>> parameter; + for (int i = 0; i < uz.size(); i++) { + std::shared_ptr<TaylorGreenVortexUzParameterStruct> aParameter = + std::shared_ptr<TaylorGreenVortexUzParameterStruct>(new TaylorGreenVortexUzParameterStruct); + aParameter->basicSimulationParameter = basicSimParameter; + aParameter->uz = uz.at(i); + aParameter->amplitude = amplitude.at(i); + aParameter->basicTimeStepLength = basisTimeStepLength.at(i); + aParameter->l0 = l0; + aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); + aParameter->vtkFilePath = pathNumericalTests + input->getValue("FolderForVTKFileWriting"); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Uz")); + parameter.push_back(aParameter); + } + return parameter; } -std::vector<std::shared_ptr<ShearWaveParameterStruct> > ConfigFileReader::makeShearWaveParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) +std::vector<std::shared_ptr<ShearWaveParameterStruct>> +ConfigFileReader::makeShearWaveParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter) { - std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); - std::vector<double> uz = StringUtil::toDoubleVector(input->getValue("v0_SW")); - std::vector<double> ux = StringUtil::toDoubleVector(input->getValue("u0_SW")); - int l0 = StringUtil::toInt(input->getValue("l0_SW")); - basicSimParameter->l0 = l0; - - std::vector<std::shared_ptr<ShearWaveParameterStruct> > parameter; - for (int i = 0; i < uz.size(); i++) { - std::shared_ptr<ShearWaveParameterStruct> aParameter = std::shared_ptr<ShearWaveParameterStruct>(new ShearWaveParameterStruct); - aParameter->basicSimulationParameter = basicSimParameter; - aParameter->uz = uz.at(i); - aParameter->ux = ux.at(i); - aParameter->basicTimeStepLength = basisTimeStepLength.at(i); - aParameter->l0 = l0; - aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); - aParameter->vtkFilePath = TOSTRING(PATH_NUMERICAL_TESTS) + input->getValue("FolderForVTKFileWriting"); - aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_SW")); - parameter.push_back(aParameter); - } - return parameter; + std::vector<int> basisTimeStepLength = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); + std::vector<double> uz = StringUtil::toDoubleVector(input->getValue("v0_SW")); + std::vector<double> ux = StringUtil::toDoubleVector(input->getValue("u0_SW")); + int l0 = StringUtil::toInt(input->getValue("l0_SW")); + basicSimParameter->l0 = l0; + + std::vector<std::shared_ptr<ShearWaveParameterStruct>> parameter; + for (int i = 0; i < uz.size(); i++) { + std::shared_ptr<ShearWaveParameterStruct> aParameter = + std::shared_ptr<ShearWaveParameterStruct>(new ShearWaveParameterStruct); + aParameter->basicSimulationParameter = basicSimParameter; + aParameter->uz = uz.at(i); + aParameter->ux = ux.at(i); + aParameter->basicTimeStepLength = basisTimeStepLength.at(i); + aParameter->l0 = l0; + aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); + aParameter->vtkFilePath = pathNumericalTests + input->getValue("FolderForVTKFileWriting"); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_SW")); + parameter.push_back(aParameter); + } + return parameter; } std::shared_ptr<NyTestParameterStruct> ConfigFileReader::makeNyTestParameter(std::shared_ptr<input::Input> input) { - std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->runTest = StringUtil::toBool(input->getValue("NyTest")); - basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - - std::shared_ptr<NyTestParameterStruct> testParameter = std::shared_ptr<NyTestParameterStruct>(new NyTestParameterStruct); - testParameter->basicTestParameter = basicTestParameter; - testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Ny")); - testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Ny")); - testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny")); - - return testParameter; + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = + std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("NyTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<NyTestParameterStruct> testParameter = + std::shared_ptr<NyTestParameterStruct>(new NyTestParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Ny")); + testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Ny")); + testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny")); + + return testParameter; } std::shared_ptr<PhiTestParameterStruct> ConfigFileReader::makePhiTestParameter(std::shared_ptr<input::Input> input) { - std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->runTest = StringUtil::toBool(input->getValue("PhiTest")); - basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - - std::shared_ptr<PhiTestParameterStruct> testParameter = std::shared_ptr<PhiTestParameterStruct>(new PhiTestParameterStruct); - testParameter->basicTestParameter = basicTestParameter; - testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Phi")); - testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Phi")); - testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi")); - - return testParameter; + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = + std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("PhiTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<PhiTestParameterStruct> testParameter = + std::shared_ptr<PhiTestParameterStruct>(new PhiTestParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Phi")); + testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Phi")); + testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi")); + + return testParameter; } -std::shared_ptr<L2NormTestParameterStruct> ConfigFileReader::makeL2NormTestParameter(std::shared_ptr<input::Input> input) +std::shared_ptr<L2NormTestParameterStruct> +ConfigFileReader::makeL2NormTestParameter(std::shared_ptr<input::Input> input) { - std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormTest")); - basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - - std::shared_ptr<L2NormTestParameterStruct> testParameter = std::shared_ptr<L2NormTestParameterStruct>(new L2NormTestParameterStruct); - testParameter->basicTestParameter = basicTestParameter; - testParameter->basicTimeStep = StringUtil::toInt(input->getValue("BasicTimeStep_L2")); - testParameter->divergentTimeStep = StringUtil::toInt(input->getValue("DivergentTimeStep_L2")); - testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); - testParameter->maxDiff = StringUtil::toDoubleVector(input->getValue("MaxL2NormDiff")); - - return testParameter; + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = + std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<L2NormTestParameterStruct> testParameter = + std::shared_ptr<L2NormTestParameterStruct>(new L2NormTestParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->basicTimeStep = StringUtil::toInt(input->getValue("BasicTimeStep_L2")); + testParameter->divergentTimeStep = StringUtil::toInt(input->getValue("DivergentTimeStep_L2")); + testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); + testParameter->maxDiff = StringUtil::toDoubleVector(input->getValue("MaxL2NormDiff")); + + return testParameter; } -std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> ConfigFileReader::makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input) +std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> +ConfigFileReader::makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input) { - std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest")); - basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - - std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testParameter = std::shared_ptr<L2NormTestBetweenKernelsParameterStruct>(new L2NormTestBetweenKernelsParameterStruct); - testParameter->basicTestParameter = basicTestParameter; - testParameter->basicKernel = myKernelMapper->getEnum(input->getValue("BasicKernel_L2NormBetweenKernels")); - testParameter->kernelsToTest = readKernelList(input); - testParameter->timeSteps = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); - testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); - - bool correct = false; - for (int i = 0; i < testParameter->normalizeData.size(); i++) - if (testParameter->normalizeData.at(i) == "Amplitude" || testParameter->normalizeData.at(i) == "BasicData") - correct = true; - - - if (!correct) { - std::cout << "invalid input in ConfigFile." << std::endl << "possible data for NormalizeWith Parameter in L2-Norm Test Between Kernels Parameter:" << std::endl << "Amplitude, BasicData" << std::endl << std::endl; - exit(1); - } - - return testParameter; + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = + std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testParameter = + std::shared_ptr<L2NormTestBetweenKernelsParameterStruct>(new L2NormTestBetweenKernelsParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->basicKernel = myKernelMapper->getEnum(input->getValue("BasicKernel_L2NormBetweenKernels")); + testParameter->kernelsToTest = readKernelList(input); + testParameter->timeSteps = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); + testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); + + bool correct = false; + for (int i = 0; i < testParameter->normalizeData.size(); i++) + if (testParameter->normalizeData.at(i) == "Amplitude" || testParameter->normalizeData.at(i) == "BasicData") + correct = true; + + if (!correct) { + std::cout << "invalid input in ConfigFile." << std::endl + << "possible data for NormalizeWith Parameter in L2-Norm Test Between Kernels Parameter:" << std::endl + << "Amplitude, BasicData" << std::endl + << std::endl; + exit(1); + } + + return testParameter; } -std::vector<std::shared_ptr<GridInformationStruct> > ConfigFileReader::makeGridInformation(std::shared_ptr<input::Input> input, std::string simName) +std::vector<std::shared_ptr<GridInformationStruct>> +ConfigFileReader::makeGridInformation(std::shared_ptr<input::Input> input, std::string simName) { - int number = 32; - std::vector<std::string> valueNames; - std::vector<std::string> gridPaths; - for (int i = 1; i <= 5; i++) { - std::string aValueName = simName; - aValueName += std::to_string(number); - valueNames.push_back(aValueName); - std::string aGridpath = "GridPath"; - aGridpath += std::to_string(number); - gridPaths.push_back(aGridpath); - number *= 2; - } - - std::vector<double> lx; - std::vector<double> lz; - std::vector<std::string> gridPath; - - double nextNumber = 32.0; - - for (int i = 0; i < valueNames.size(); i++) { - if (StringUtil::toBool(input->getValue(valueNames.at(i)))) { - lx.push_back(nextNumber); - lz.push_back(nextNumber * 3.0 / 2.0); - gridPath.push_back(TOSTRING(PATH_NUMERICAL_TESTS) + input->getValue(gridPaths.at(i))); - nextNumber *= 2; - } - } - - std::vector<std::shared_ptr<GridInformationStruct> > gridInformation; - for (int i = 0; i < lx.size(); i++) { - std::shared_ptr<GridInformationStruct> aGridInformation = std::shared_ptr<GridInformationStruct> (new GridInformationStruct); - aGridInformation->numberOfGridLevels = StringUtil::toInt(input->getValue("NumberOfGridLevels")); - aGridInformation->maxLevel = aGridInformation->numberOfGridLevels - 1; - aGridInformation->gridPath = gridPath.at(i); - aGridInformation->lx = lx.at(i); - aGridInformation->lz = lz.at(i); - gridInformation.push_back(aGridInformation); - } - return gridInformation; + int number = 32; + std::vector<std::string> valueNames; + std::vector<std::string> gridPaths; + for (int i = 1; i <= 5; i++) { + std::string aValueName = simName; + aValueName += std::to_string(number); + valueNames.push_back(aValueName); + std::string aGridpath = "GridPath"; + aGridpath += std::to_string(number); + gridPaths.push_back(aGridpath); + number *= 2; + } + + std::vector<double> lx; + std::vector<double> lz; + std::vector<std::string> gridPath; + + double nextNumber = 32.0; + + for (int i = 0; i < valueNames.size(); i++) { + if (StringUtil::toBool(input->getValue(valueNames.at(i)))) { + lx.push_back(nextNumber); + lz.push_back(nextNumber * 3.0 / 2.0); + gridPath.push_back(pathNumericalTests + input->getValue(gridPaths.at(i))); + nextNumber *= 2; + } + } + + std::vector<std::shared_ptr<GridInformationStruct>> gridInformation; + for (int i = 0; i < lx.size(); i++) { + std::shared_ptr<GridInformationStruct> aGridInformation = + std::shared_ptr<GridInformationStruct>(new GridInformationStruct); + aGridInformation->numberOfGridLevels = StringUtil::toInt(input->getValue("NumberOfGridLevels")); + aGridInformation->maxLevel = aGridInformation->numberOfGridLevels - 1; + aGridInformation->gridPath = gridPath.at(i); + aGridInformation->lx = lx.at(i); + aGridInformation->lz = lz.at(i); + gridInformation.push_back(aGridInformation); + } + return gridInformation; } -std::shared_ptr<VectorWriterInformationStruct> ConfigFileReader::makeVectorWriterInformationStruct(std::shared_ptr<input::Input> input) +std::shared_ptr<VectorWriterInformationStruct> +ConfigFileReader::makeVectorWriterInformationStruct(std::shared_ptr<input::Input> input) { - std::shared_ptr<VectorWriterInformationStruct> vectorWriter = std::shared_ptr<VectorWriterInformationStruct>(new VectorWriterInformationStruct); - vectorWriter->startTimeVectorWriter = calcStartStepForToVectorWriter(input); - vectorWriter->startTimeVTKDataWriter = StringUtil::toInt(input->getValue("StartStepFileWriter")); - vectorWriter->writeVTKFiles = StringUtil::toBool(input->getValue("WriteVTKFiles")); + std::shared_ptr<VectorWriterInformationStruct> vectorWriter = + std::shared_ptr<VectorWriterInformationStruct>(new VectorWriterInformationStruct); + vectorWriter->startTimeVectorWriter = calcStartStepForToVectorWriter(input); + vectorWriter->startTimeVTKDataWriter = StringUtil::toInt(input->getValue("StartStepFileWriter")); + vectorWriter->writeVTKFiles = StringUtil::toBool(input->getValue("WriteVTKFiles")); - return vectorWriter; + return vectorWriter; } std::shared_ptr<LogFileParameterStruct> ConfigFileReader::makeLogFilePara(std::shared_ptr<input::Input> input) { - std::shared_ptr<LogFileParameterStruct> logFilePara = std::shared_ptr<LogFileParameterStruct>(new LogFileParameterStruct); - logFilePara->devices = StringUtil::toIntVector(input->getValue("Devices")); - logFilePara->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); - logFilePara->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); + std::shared_ptr<LogFileParameterStruct> logFilePara = + std::shared_ptr<LogFileParameterStruct>(new LogFileParameterStruct); + logFilePara->devices = StringUtil::toIntVector(input->getValue("Devices")); + logFilePara->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); + logFilePara->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); - return logFilePara; + return logFilePara; } std::vector<KernelType> ConfigFileReader::readKernelList(std::shared_ptr<input::Input> input) { - if (StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest"))) { - std::vector<std::string> kernelList = StringUtil::toStringVector(input->getValue("KernelsToTest")); - std::string beginnKernel = input->getValue("BasicKernel_L2NormBetweenKernels"); - bool basicKernelInKernelList = false; - for (int i = 0; i < kernelList.size(); i++) { - if (kernelList.at(i) == beginnKernel) - basicKernelInKernelList = true; - } - if (!basicKernelInKernelList) - kernelList.push_back(beginnKernel); - - std::vector<std::string> kernelNames = kernelList; - - while (kernelNames.at(0) != beginnKernel) { - kernelNames.push_back(kernelNames.at(0)); - std::vector<std::string>::iterator it = kernelNames.begin(); - kernelNames.erase(it); - } - std::vector<KernelType> kernels; - for (int i = 0; i < kernelNames.size(); i++) - kernels.push_back(myKernelMapper->getEnum(kernelNames.at(i))); - return kernels; - }else { - std::vector<std::string> kernelList = StringUtil::toStringVector(input->getValue("KernelsToTest")); - std::vector<KernelType> kernels; - for (int i = 0; i < kernelList.size(); i++) - kernels.push_back(myKernelMapper->getEnum(kernelList.at(i))); - - return kernels; - } + if (StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest"))) { + std::vector<std::string> kernelList = StringUtil::toStringVector(input->getValue("KernelsToTest")); + std::string beginnKernel = input->getValue("BasicKernel_L2NormBetweenKernels"); + bool basicKernelInKernelList = false; + for (int i = 0; i < kernelList.size(); i++) { + if (kernelList.at(i) == beginnKernel) + basicKernelInKernelList = true; + } + if (!basicKernelInKernelList) + kernelList.push_back(beginnKernel); + + std::vector<std::string> kernelNames = kernelList; + + while (kernelNames.at(0) != beginnKernel) { + kernelNames.push_back(kernelNames.at(0)); + std::vector<std::string>::iterator it = kernelNames.begin(); + kernelNames.erase(it); + } + std::vector<KernelType> kernels; + for (int i = 0; i < kernelNames.size(); i++) + kernels.push_back(myKernelMapper->getEnum(kernelNames.at(i))); + return kernels; + } else { + std::vector<std::string> kernelList = StringUtil::toStringVector(input->getValue("KernelsToTest")); + std::vector<KernelType> kernels; + for (int i = 0; i < kernelList.size(); i++) + kernels.push_back(myKernelMapper->getEnum(kernelList.at(i))); + + return kernels; + } } unsigned int ConfigFileReader::calcStartStepForToVectorWriter(std::shared_ptr<input::Input> input) { - std::vector<unsigned int> startStepsTests; - startStepsTests.push_back(StringUtil::toInt(input->getValue("BasicTimeStep_L2"))); - startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny"))); - startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi"))); - std::sort(startStepsTests.begin(), startStepsTests.end()); + std::vector<unsigned int> startStepsTests; + startStepsTests.push_back(StringUtil::toInt(input->getValue("BasicTimeStep_L2"))); + startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny"))); + startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi"))); + std::sort(startStepsTests.begin(), startStepsTests.end()); - return startStepsTests.at(0); + return startStepsTests.at(0); } int ConfigFileReader::calcNumberOfSimulations(std::shared_ptr<input::Input> input) { - int counter = 0; + int counter = 0; - int tgvCounterU0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUx"); - tgvCounterU0 *= StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")).size(); - counter += tgvCounterU0; + int tgvCounterU0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUx"); + tgvCounterU0 *= int(StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")).size()); + counter += tgvCounterU0; - int tgvCounterV0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUz");; - tgvCounterV0 *= StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")).size(); - counter += tgvCounterV0; + int tgvCounterV0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUz"); + ; + tgvCounterV0 *= int(StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")).size()); + counter += tgvCounterV0; - int swCounter = calcNumberOfSimulationGroup(input, "ShearWave");; - swCounter *= StringUtil::toDoubleVector(input->getValue("u0_SW")).size(); - counter += swCounter; + int swCounter = calcNumberOfSimulationGroup(input, "ShearWave"); + ; + swCounter *= int(StringUtil::toDoubleVector(input->getValue("u0_SW")).size()); + counter += swCounter; - counter *= StringUtil::toDoubleVector(input->getValue("Viscosity")).size(); - counter *= configData->kernelsToTest.size(); + counter *= int(StringUtil::toDoubleVector(input->getValue("Viscosity")).size()); + counter *= int(configData->kernelsToTest.size()); - return counter; + return counter; } int ConfigFileReader::calcNumberOfSimulationGroup(std::shared_ptr<input::Input> input, std::string simName) { - int counter = 0; - int number = 32; - std::vector<std::string> valueNames; - for (int i = 1; i <= 5; i++) { - std::string aValueName = simName; - aValueName += std::to_string(number); - valueNames.push_back(aValueName); - number *= 2; - } - for (int i = 0; i < valueNames.size(); i++) { - if (StringUtil::toBool(input->getValue(valueNames.at(i)))) - counter++; - } - return counter; + int counter = 0; + int number = 32; + std::vector<std::string> valueNames; + for (int i = 1; i <= 5; i++) { + std::string aValueName = simName; + aValueName += std::to_string(number); + valueNames.push_back(aValueName); + number *= 2; + } + for (int i = 0; i < valueNames.size(); i++) { + if (StringUtil::toBool(input->getValue(valueNames.at(i)))) + counter++; + } + return counter; } \ No newline at end of file diff --git a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h index 50794d4adc9b201aef2cfd3965e605f928c2fca0..64ae87ca0e4e62057049cfe824296b06843b160b 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h +++ b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h @@ -15,40 +15,50 @@ class KernelMapper; class ConfigFileReader { public: - static std::shared_ptr<ConfigFileReader> getNewInstance(const std::string aFilePath); - std::shared_ptr<ConfigDataStruct> getConfigData(); - void readConfigFile(); - + static std::shared_ptr<ConfigFileReader> getNewInstance(const std::string aFilePath); + std::shared_ptr<ConfigDataStruct> getConfigData(); + void readConfigFile(); + private: - ConfigFileReader() {}; - ConfigFileReader(const std::string aFilePath); - - std::ifstream openConfigFile(const std::string aFilePath); - bool checkConfigFile(std::shared_ptr<input::Input> input); - std::vector<KernelType> readKernelList(std::shared_ptr<input::Input> input); - - int calcNumberOfSimulations(std::shared_ptr<input::Input> input); - int calcNumberOfSimulationGroup(std::shared_ptr<input::Input> input, std::string simName); - unsigned int calcStartStepForToVectorWriter(std::shared_ptr<input::Input> input); - - std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct> > makeTaylorGreenVortexUxParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); - std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > makeTaylorGreenVortexUzParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); - std::vector<std::shared_ptr<ShearWaveParameterStruct> > makeShearWaveParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); - - std::shared_ptr<NyTestParameterStruct> makeNyTestParameter(std::shared_ptr<input::Input> input); - std::shared_ptr<PhiTestParameterStruct> makePhiTestParameter(std::shared_ptr<input::Input> input); - std::shared_ptr<L2NormTestParameterStruct> makeL2NormTestParameter(std::shared_ptr<input::Input> input); - std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input); - - std::shared_ptr<BasicSimulationParameterStruct> makeBasicSimulationParameter(std::shared_ptr<input::Input> input); - std::vector<std::shared_ptr<GridInformationStruct> > makeGridInformation(std::shared_ptr<input::Input> input, std::string simName); - - std::shared_ptr<VectorWriterInformationStruct> makeVectorWriterInformationStruct(std::shared_ptr<input::Input> input); - std::shared_ptr<LogFileParameterStruct> makeLogFilePara(std::shared_ptr<input::Input> input); - - - const std::string myFilePath; - std::shared_ptr<ConfigDataStruct> configData; - std::shared_ptr<KernelMapper> myKernelMapper; + ConfigFileReader(){}; + ConfigFileReader(const std::string aFilePath); + + std::ifstream openConfigFile(const std::string aFilePath); + bool checkConfigFile(std::shared_ptr<input::Input> input); + std::vector<KernelType> readKernelList(std::shared_ptr<input::Input> input); + + int calcNumberOfSimulations(std::shared_ptr<input::Input> input); + int calcNumberOfSimulationGroup(std::shared_ptr<input::Input> input, std::string simName); + unsigned int calcStartStepForToVectorWriter(std::shared_ptr<input::Input> input); + + std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct>> + makeTaylorGreenVortexUxParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); + std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct>> + makeTaylorGreenVortexUzParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); + std::vector<std::shared_ptr<ShearWaveParameterStruct>> + makeShearWaveParameter(std::shared_ptr<input::Input> input, + std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); + + std::shared_ptr<NyTestParameterStruct> makeNyTestParameter(std::shared_ptr<input::Input> input); + std::shared_ptr<PhiTestParameterStruct> makePhiTestParameter(std::shared_ptr<input::Input> input); + std::shared_ptr<L2NormTestParameterStruct> makeL2NormTestParameter(std::shared_ptr<input::Input> input); + std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> + makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input); + + std::shared_ptr<BasicSimulationParameterStruct> makeBasicSimulationParameter(std::shared_ptr<input::Input> input); + std::vector<std::shared_ptr<GridInformationStruct>> makeGridInformation(std::shared_ptr<input::Input> input, + std::string simName); + + std::shared_ptr<VectorWriterInformationStruct> + makeVectorWriterInformationStruct(std::shared_ptr<input::Input> input); + std::shared_ptr<LogFileParameterStruct> makeLogFilePara(std::shared_ptr<input::Input> input); + + std::string pathNumericalTests; + + const std::string myFilePath; + std::shared_ptr<ConfigDataStruct> configData; + std::shared_ptr<KernelMapper> myKernelMapper; }; #endif \ No newline at end of file diff --git a/apps/gpu/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp b/apps/gpu/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp index f04e0c4d0bc04a4f3ed8d48016020a0b618c51d0..d4def3edb7cb3bf1d7f27d461316660aaec03b0d 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp @@ -18,7 +18,8 @@ std::string BasicSimulationInfo::getOutput() return oss.str(); } -BasicSimulationInfo::BasicSimulationInfo(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, KernelType kernel):numberOfTimeSteps(numberOfTimeSteps), viscosity(viscosity), basicTimeStepLength(basicTimeStepLength), kernelName(kernelName) +BasicSimulationInfo::BasicSimulationInfo(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, KernelType kernel) + : numberOfTimeSteps(numberOfTimeSteps), viscosity(viscosity), basicTimeStepLength(basicTimeStepLength) { std::shared_ptr<KernelMapper> myKernelMapper = KernelMapper::getInstance(); kernelName = myKernelMapper->getString(kernel); diff --git a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueue.h b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueue.h index 2486dd2ecb7e97f351ea5b8cfd6333a7841d74b0..bb1bf9579504b888f6f8d5297d9096b742c70a1c 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueue.h +++ b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueue.h @@ -5,5 +5,6 @@ class TestQueue { public: virtual void makeFinalOutput() = 0; + virtual int getNumberOfFailedTests() const noexcept = 0; }; #endif \ No newline at end of file diff --git a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp index 49b26f898b123589eac8b02a8c688c57f5e08fec..5434c335c14ab6ed4f5a647089912417618db199 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp @@ -12,6 +12,8 @@ void TestQueueImp::makeFinalOutput() colorOutput->makeFinalTestOutputFoot(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest, numberOfErrorTest, numberOfNotExecutedTest); } +int TestQueueImp::getNumberOfFailedTests() const noexcept { return numberOfFailedTest; } + std::shared_ptr<TestQueueImp> TestQueueImp::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput) { return std::shared_ptr<TestQueueImp>(new TestQueueImp(colorOutput)); diff --git a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h index df5d12bea24224c941f571bfc64033e4f12593fe..27505efc7b3a58bb155f40813d87a7aab78157bc 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h +++ b/apps/gpu/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h @@ -14,6 +14,8 @@ class TestQueueImp : public TestQueue public: void makeFinalOutput(); + int getNumberOfFailedTests() const noexcept override; + static std::shared_ptr<TestQueueImp> getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput); void addTest(std::shared_ptr<Test> test); diff --git a/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt b/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt index c1592b7e04373da66d053d86dd2d054516a94f29..085fde0c134fc6005ca82dacf2296479953756d7 100644 --- a/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt +++ b/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt @@ -1,7 +1,7 @@ ################################################## # GPU Mapping # ################################################## -Devices="1" +Devices="0" ################################################## # Basic Simulation Parameter # @@ -86,8 +86,8 @@ NormalizeWith=amplitude TaylorGreenVortexUx32=true TaylorGreenVortexUx64=true TaylorGreenVortexUx128=true -TaylorGreenVortexUx256=true -TaylorGreenVortexUx512=true +TaylorGreenVortexUx256=false +TaylorGreenVortexUx512=false TaylorGreenVortexUz32=false TaylorGreenVortexUz64=false @@ -95,11 +95,11 @@ TaylorGreenVortexUz128=false TaylorGreenVortexUz256=false TaylorGreenVortexUz512=false -ShearWave32=true -ShearWave64=true -ShearWave128=true -ShearWave256=true -ShearWave512=true +ShearWave32=false +ShearWave64=false +ShearWave128=false +ShearWave256=false +ShearWave512=false ################################################## # Grid Information # diff --git a/apps/gpu/tests/NumericalTests/main.cpp b/apps/gpu/tests/NumericalTests/main.cpp index 0ba7ab31e33823ce240c7ae8ea324d3ef1aa4a79..703e8961497f3f1c93cb460fb9937f391e4ea0e9 100644 --- a/apps/gpu/tests/NumericalTests/main.cpp +++ b/apps/gpu/tests/NumericalTests/main.cpp @@ -101,7 +101,7 @@ static void validateTestSuite() } -static void startNumericalTests(const std::string &configFile) +static bool startNumericalTests(const std::string &configFile) { std::shared_ptr<ConfigFileReader> configReader = ConfigFileReader::getNewInstance(configFile); configReader->readConfigFile(); @@ -120,6 +120,8 @@ static void startNumericalTests(const std::string &configFile) testQueue->makeFinalOutput(); logFileQueue->writeLogFiles(); + + return testQueue->getNumberOfFailedTests() > 0; } int main(int argc, char **argv) @@ -128,12 +130,14 @@ int main(int argc, char **argv) //validateTestSuite(); + bool tests_passed{false}; + if (argc > 1) - startNumericalTests(argv[1]); + tests_passed = startNumericalTests(argv[1]); else std::cout << "Configuration file must be set!: lbmgm <config file>" << std::endl << std::flush; MPI_Finalize(); - return 0; + return tests_passed; } diff --git a/gpu.cmake b/gpu.cmake index d1d5415081aa131868c0bc2ee047e8a140eb9a78..29fe0d826a11d169f2c17510dde26c2581ce6ad5 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -7,24 +7,16 @@ #SET(CUDA_CUT_INCLUDE_DIR "/cluster/cuda/9.0/include;/cluster/cuda/9.0/samples/common/inc" CACHE PATH "CUDA_CUT_INCLUDE_DIR") #SET(CUDA_SAMPLE_INCLUDE_DIR "/cluster/cuda/9.0/samples/common/inc" CACHE PATH "CUDA_CUT_INCLUDE_DIR") -############################################################# -### OPTIONS ### -############################################################# -option(VF.BUILD_VF_GPU "Build VirtualFluids GPU" ON ) -option(VF.BUILD_VF_GKS "Build VirtualFluids GKS" OFF ) -option(VF.BUILD_VF_TRAFFIC "Build VirtualFluids Traffic" OFF) -option(VF.BUILD_JSONCPP "Builds json cpp " OFF) -option(VF.BUILD_NUMERIC_TESTS "Build numeric tests" OFF) ############################################################# -if(VF.BUILD_NUMERIC_TESTS) +if(BUILD_NUMERIC_TESTS) set(CMAKE_CXX_STANDARD 17) endif() ############################################################# -IF( VF.BUILD_VF_GKS ) +IF( BUILD_VF_GKS ) # only use this with device of CC larger than 6.0 set(CMAKE_CUDA_FLAGS "-Xptxas=\"-v\"" CACHE STRING "" FORCE) set(CMAKE_CUDA_ARCHITECTURES 60) @@ -51,7 +43,7 @@ add_subdirectory(src/gpu/GridGenerator) ### Virtual Fluids GPU ### ############################################################# -IF (VF.BUILD_VF_GPU) +IF (BUILD_VF_GPU) add_subdirectory(src/gpu/VirtualFluids_GPU) #add_subdirectory(targets/apps/LBM/lbmTest) @@ -73,7 +65,7 @@ ENDIF() ############################################################# -IF (VF.BUILD_VF_GKS) +IF (BUILD_VF_GKS) add_subdirectory(src/gpu/GksMeshAdapter) add_subdirectory(src/gpu/GksVtkAdapter) @@ -123,7 +115,7 @@ ENDIF() ############################################################# ### JSONCPP ### ############################################################# -IF (NOT VF.BUILD_JSONCPP) +IF (NOT BUILD_JSONCPP) MESSAGE( STATUS "Build Input Project without JsonCpp." ) ELSE() add_subdirectory(3rdParty/jsoncpp) @@ -134,7 +126,13 @@ ENDIF() ### Numeric Tests ### ############################################################# -if(VF.BUILD_NUMERIC_TESTS) +if(BUILD_NUMERIC_TESTS) + + # PATH_NUMERICAL_TESTS can be passed to cmake e.g. cmake .. -DPATH_NUMERICAL_TESTS=/data/ + if(PATH_NUMERICAL_TESTS) + LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") + endif() + add_subdirectory(3rdParty/fftw/fftw-3.3.7) add_subdirectory(3rdParty/googletest) add_subdirectory(apps/gpu/tests/NumericalTests) @@ -145,7 +143,7 @@ endif() ### Annas Traffic Sim ### ############################################################# -if(VF.BUILD_VF_TRAFFIC) +if(BUILD_VF_TRAFFIC) add_subdirectory(src/gpu/Traffic) add_subdirectory(apps/gpu/LBM/TrafficTest) endif() \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 74968f0365b83494fc124352d24e4b4637e66c51..7f31fa97101d3002aa47096831206cf9768a85b5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,12 +1,9 @@ # must be unique in a given SonarQube instance sonar.projectKey=vf:project:develop -# --- optional properties --- - -# defaults to project key sonar.projectName=VirtualFluids_dev -# defaults to 'not provided' -#sonar.projectVersion=1.0 + +sonar.projectVersion=0.1 sonar.language=cxx @@ -36,4 +33,4 @@ sonar.cxx.gcc.reportPath=build/gcc_warnings.txt sonar.cxx.funccomplexity.threshold=10 -sonar.cxx.funcsize.threshold=20 \ No newline at end of file +sonar.cxx.funcsize.threshold=20