From dde85f50ee3d8c999a6c018f5f103625ddec21aa Mon Sep 17 00:00:00 2001 From: Timon Habenicht <t.habenicht@tu-bs.de> Date: Thu, 31 Jan 2019 11:01:53 +0100 Subject: [PATCH] rebuilds Numerical Test Factory --- CMakeLists.txt | 1 + CMakeMacros/MathLink/Link.cmake | 2 +- .../3rdPartyLinking.cmake | 10 + .../CMakeLists.txt | 14 + .../CMakePackage.cmake | 7 + .../Utilities/DataPoint/DataPoint.cpp | 28 + .../Utilities/DataPoint/DataPoint.h | 21 + .../Utilities/DataPoint/package.include | 0 .../Utilities/LogFileData/LogFileData.h | 14 + .../Utilities/LogFileData/LogFileDataImp.cpp | 50 ++ .../Utilities/LogFileData/LogFileDataImp.h | 31 ++ .../Utilities/LogFileData/package.include | 0 .../Utilities/LogFileReader/LogFileReader.cpp | 68 +++ .../Utilities/LogFileReader/LogFileReader.h | 25 + .../Utilities/LogFileReader/package.include | 0 .../ListLinePlot/MathematicaListLinePlot.cpp | 22 + .../ListLinePlot/MathematicaListLinePlot.h | 21 + .../ListLinePlot/package.include | 0 .../MathematicaFunktion/MathematicaFunktion.h | 14 + .../MathematicaFunktionImp.cpp | 10 + .../MathematicaFunktionImp.h | 17 + .../PointList/MathematicaPointList.cpp | 34 ++ .../PointList/MathematicaPointList.h | 25 + .../PointList/package.include | 0 .../MathematicaFunktion/package.include | 0 .../MathematicaLinker/MathematicaLinker.cpp | 0 .../MathematicaLinker/MathematicaLinker.h | 0 .../MathematicaLinker/package.include | 0 .../NumericalTestPostProcessing/config.txt | 0 .../NumericalTestPostProcessing/main.cpp | 162 ++++++ .../package.include | 0 .../tests/NumericalTestPostProcessing/test.nb | 420 +++++++++++++++ .../ShearWaveAnalyticalResults.cpp | 15 +- .../ShearWaveAnalyticalResults.h | 6 +- .../ShearWaveLogFileInformation.cpp | 26 +- .../ShearWaveLogFileInformation.h | 16 +- .../ShearWave/ShearWaveParameterStruct.h | 19 + .../ShearWaveSimulationInfo.cpp | 13 +- .../SimulationInfo/ShearWaveSimulationInfo.h | 7 +- .../ShearWaveSimulationParameter.cpp | 37 +- .../ShearWaveSimulationParameter.h | 20 +- .../Simulations/ShearWave/package.include | 0 .../AnalyticalResultsTaylorGreenVortexUx.cpp | 15 +- .../AnalyticalResultsTaylorGreenVortexUx.h | 6 +- .../LogFileInformationTaylorGreenVortexUx.cpp | 29 +- .../LogFileInformationTaylorGreenVortexUx.h | 12 +- .../SimulationInfoTaylorGreenVortexUx.cpp | 14 +- .../SimulationInfoTaylorGreenVortexUx.h | 7 +- ...SimulationParameterTaylorGreenVortexUx.cpp | 23 +- .../SimulationParameterTaylorGreenVortexUx.h | 18 +- .../TaylorGreenVortexUxParameterStruct.h | 19 + .../TaylorGreenVortexUx/package.include | 0 .../AnalyticalResultsTaylorGreenVortexUz.cpp | 14 +- .../AnalyticalResultsTaylorGreenVortexUz.h | 6 +- .../LogFileInformationTaylorGreenVortexUz.cpp | 28 +- .../LogFileInformationTaylorGreenVortexUz.h | 12 +- .../SimulationInfoTaylorGreenVortexUz.cpp | 14 +- .../SimulationInfoTaylorGreenVortexUz.h | 7 +- ...SimulationParameterTaylorGreenVortexUz.cpp | 21 +- .../SimulationParameterTaylorGreenVortexUz.h | 18 +- .../TaylorGreenVortexUzParameterStruct.h | 20 + .../TaylorGreenVortexUz/package.include | 0 .../Tests/L2NormTest/L2NormTest.cpp | 13 +- .../Tests/L2NormTest/L2NormTest.h | 6 +- .../L2NormTest/L2NormTestParameterStruct.h | 17 + .../Tests/L2NormTest/L2NormTestStruct.h | 20 + .../L2NormLogFileInformation.cpp | 10 +- .../L2NormLogFileInformation.h | 5 +- .../PostProcessingStrategyL2NormTest.cpp | 34 +- .../PostProcessingStrategyL2NormTest.h | 5 +- .../L2NormTestBetweenKernels.cpp | 10 +- .../L2NormTestBetweenKernelsParameterStruct.h | 20 + .../L2NormTestBetweenKernelsStruct.h | 19 + ...L2NormLogFileInformationBetweenKernels.cpp | 12 +- .../L2NormLogFileInformationBetweenKernels.h | 5 +- ...ormBetweenKernelPostProcessingStrategy.cpp | 21 +- ...2NormBetweenKernelPostProcessingStrategy.h | 5 +- .../PhiAndNuLogFileInformation.cpp | 10 +- .../PhiAndNuLogFileInformation.h | 10 +- .../Tests/PhiAndNuTest/PhiAndNuTest.cpp | 12 +- .../Tests/PhiAndNuTest/PhiAndNuTest.h | 5 +- .../PhiAndNuTestParameterStruct.h | 16 + .../Tests/PhiAndNuTest/PhiAndNuTestStruct.h | 18 + .../PostProcessingStrategyPhiAndNuTest.cpp | 14 +- .../PostProcessingStrategyPhiAndNuTest.h | 5 +- .../FFTCalculator/FFTCalculator.cpp | 11 +- .../Calculator/FFTCalculator/FFTCalculator.h | 2 + .../L2NormCalculator/L2NormCalculator.cpp | 13 +- .../L2NormCalculator/L2NormCalculator.h | 6 +- .../Utilities/ConfigFileReader/ConfigData.h | 63 --- .../ConfigFileReader/ConfigFileReader.cpp | 420 +++++++++++---- .../ConfigFileReader/ConfigFileReader.h | 27 +- .../AnalyticalResults2DToVTKWriterImp.cpp | 38 +- .../AnalyticalResults2DToVTKWriterImp.h | 4 +- .../Utilities/DataWriter/ToVectorWriter.cpp | 29 +- .../Utilities/DataWriter/ToVectorWriter.h | 18 +- .../Y2dSliceToResults/Y2dSliceToResults.cpp | 8 +- .../Y2dSliceToResults/Y2dSliceToResults.h | 13 +- .../LogFileHead/LogFileHead.cpp | 10 +- .../LogFileHead/LogFileHead.h | 2 +- .../LogFileTimeInformation.cpp | 3 +- .../LogFileTimeInformation.h | 6 +- .../SimulationLogFileInformation.h | 4 +- .../LogFileWriter/LogFileWriterImp.cpp | 14 +- .../LogFileWriter/LogFileWriterImp.h | 9 +- .../NumericalTestFactoryImp.cpp | 481 +++++++++--------- .../NumericalTestFactoryImp.h | 73 ++- .../PostProcessingStrategy.h | 2 + .../PostProcessingStrategyImp.cpp | 8 + .../PostProcessingStrategyImp.h | 1 + .../SimulationResults/SimulationResults.cpp | 18 +- .../SimulationResults/SimulationResults.h | 6 +- .../Utilities/SimulationInfo/SimulationInfo.h | 1 - .../SimulationInfo/SimulationInfoImp.cpp | 8 +- .../SimulationInfo/SimulationInfoImp.h | 3 +- .../SimulationParameter/SimulationParameter.h | 20 +- .../SimulationParameterImp.cpp | 55 +- .../SimulationParameterImp.h | 21 +- .../Structs/BasicSimulationParameterStruct.h | 12 + .../Structs/BasicTestParameterStruct.h | 13 + .../Utilities/Structs/ConfigDataStruct.h | 52 ++ .../Utilities/Structs/GridInformationStruct.h | 14 + .../Structs/LogFileParameterStruct.h | 13 + .../Utilities/Structs/NumericalTestStruct.h | 17 + .../Utilities/Structs/SimulationDataStruct.h | 17 + .../Structs/TestSimulationDataStruct.h | 16 + .../Structs/VectorWriterInformationStruct.h | 13 + .../Utilities/Structs/package.include | 0 .../NumericalTests/Utilities/Test/TestImp.cpp | 3 +- .../Utilities/TestSimulation/TestSimulation.h | 15 +- .../TestSimulation/TestSimulationImp.cpp | 62 ++- .../TestSimulation/TestSimulationImp.h | 23 +- .../VirtualFluidSimulationFactoryImp.cpp | 3 +- targets/tests/NumericalTests/config.txt | 46 +- targets/tests/NumericalTests/main.cpp | 2 - 135 files changed, 2553 insertions(+), 895 deletions(-) create mode 100644 targets/tests/NumericalTestPostProcessing/3rdPartyLinking.cmake create mode 100644 targets/tests/NumericalTestPostProcessing/CMakeLists.txt create mode 100644 targets/tests/NumericalTestPostProcessing/CMakePackage.cmake create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.h create mode 100644 targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/config.txt create mode 100644 targets/tests/NumericalTestPostProcessing/main.cpp create mode 100644 targets/tests/NumericalTestPostProcessing/package.include create mode 100644 targets/tests/NumericalTestPostProcessing/test.nb create mode 100644 targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h create mode 100644 targets/tests/NumericalTests/Simulations/ShearWave/package.include create mode 100644 targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h create mode 100644 targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/package.include create mode 100644 targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h create mode 100644 targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/package.include create mode 100644 targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestParameterStruct.h create mode 100644 targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestStruct.h create mode 100644 targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h create mode 100644 targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsStruct.h create mode 100644 targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestParameterStruct.h create mode 100644 targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestStruct.h delete mode 100644 targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/BasicSimulationParameterStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/GridInformationStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/LogFileParameterStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/NumericalTestStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/SimulationDataStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/TestSimulationDataStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/VectorWriterInformationStruct.h create mode 100644 targets/tests/NumericalTests/Utilities/Structs/package.include diff --git a/CMakeLists.txt b/CMakeLists.txt index 71fd19c00..ad795dcc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,5 +179,6 @@ endif() if(HULC.BUILD_NUMERIC_TESTS) add_subdirectory(3rdParty/fftw/fftw-3.3.7) add_subdirectory(targets/tests/NumericalTests) + add_subdirectory(targets/tests/NumericalTestPostProcessing) endif() diff --git a/CMakeMacros/MathLink/Link.cmake b/CMakeMacros/MathLink/Link.cmake index f13c060d6..ca929fe98 100644 --- a/CMakeMacros/MathLink/Link.cmake +++ b/CMakeMacros/MathLink/Link.cmake @@ -2,6 +2,6 @@ macro(linkMathLink targetName) include_directories(${MATHLINK_ROOT}) - target_link_libraries(${targetName} wstp64i4m) + target_link_libraries(${targetName} ${MATHLINK_ROOT}\\wstp64i4.lib) endmacro(linkMathLink) \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/3rdPartyLinking.cmake b/targets/tests/NumericalTestPostProcessing/3rdPartyLinking.cmake new file mode 100644 index 000000000..a9a871f27 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/3rdPartyLinking.cmake @@ -0,0 +1,10 @@ +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/GMock/Link.cmake) +linkGMock(${targetName}) +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) +linkCuda(${targetName}) +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) +linkMPI(${targetName}) +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Boost/Link.cmake) +linkBoost(${targetName} "") +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MathLink/Link.cmake) +linkMathLink(${targetName}) \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/CMakeLists.txt b/targets/tests/NumericalTestPostProcessing/CMakeLists.txt new file mode 100644 index 000000000..1ff89574c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/CMakeLists.txt @@ -0,0 +1,14 @@ +setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) + +set(linkDirectories "") +set(libsToLink VirtualFluids_GPU cudart_static VirtualFluidsBasics) +set(includeDirectories ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/VirtualFluids_GPU ${CMAKE_SOURCE_DIR}/src/VirtualFluidsBasics) + +#glob files and save in MY_SRCS +include(CMakePackage.cmake) + +buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") +groupTarget(${targetName} ${testFolder}) + +#Specify the linking to 3rdParty libs +include(3rdPartyLinking.cmake) \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/CMakePackage.cmake b/targets/tests/NumericalTestPostProcessing/CMakePackage.cmake new file mode 100644 index 000000000..317ed1a80 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/CMakePackage.cmake @@ -0,0 +1,7 @@ +#FILE ENDINGS +resetFileEndingsToCollect() +addCAndCPPFileTypes() + +#GLOB SOURCE FILES IN MY_SRCS +unset(MY_SRCS) +includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp new file mode 100644 index 000000000..ce5418c89 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp @@ -0,0 +1,28 @@ +#include "DataPoint.h" + +DataPoint::DataPoint() +{ +} + +std::shared_ptr<DataPoint> DataPoint::getNewInstance(double x, double y) +{ + return std::shared_ptr<DataPoint>(new DataPoint(x, y)); +} + +double DataPoint::getX() +{ + return x; +} + +double DataPoint::getY() +{ + return y; +} + +DataPoint::DataPoint(double x, double y) : x(x), y(y) +{ +} + +DataPoint::~DataPoint() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h new file mode 100644 index 000000000..1bbb2d94a --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h @@ -0,0 +1,21 @@ +#ifndef DATA_POINT_H +#define DATA_POINT_H + +#include <memory> + +class DataPoint +{ +public: + std::shared_ptr<DataPoint> getNewInstance(double x, double y); + double getX(); + double getY(); + +private: + DataPoint(double x, double y); + DataPoint(); + ~DataPoint(); + + double x; + double y; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h new file mode 100644 index 000000000..85e6abdc2 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h @@ -0,0 +1,14 @@ +#ifndef LOGFILE_DATA_H +#define LOGFILE_DATA_H + +#include <string> + +class LogFileData +{ +public: + virtual int getBasisTimeStepLength() = 0; + virtual std::string getKernel() = 0; + virtual int getNumberOfTimeSteps() = 0; + virtual double getViscosity() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp new file mode 100644 index 000000000..d329cabd6 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp @@ -0,0 +1,50 @@ +#include "LogFileDataImp.h" + +std::shared_ptr<LogFileDataImp> LogFileDataImp::getNewInstance() +{ + return std::shared_ptr<LogFileDataImp>(new LogFileDataImp()); +} + +void LogFileDataImp::setBasisTimeStepLength(int basisTimeStepLength) +{ + this->basisTimeStepLength = basisTimeStepLength; +} + +void LogFileDataImp::setKernel(std::string kernelName) +{ + this->kernelName = kernelName; +} + +void LogFileDataImp::setNumberOfTimeSteps(int numberOfTimeSteps) +{ + this->numberOfTimeSteps = numberOfTimeSteps; +} + +void LogFileDataImp::setViscosity(double viscosity) +{ + this->viscosity = viscosity; +} + +int LogFileDataImp::getBasisTimeStepLength() +{ + return basisTimeStepLength; +} + +std::string LogFileDataImp::getKernel() +{ + return kernelName; +} + +int LogFileDataImp::getNumberOfTimeSteps() +{ + return numberOfTimeSteps; +} + +double LogFileDataImp::getViscosity() +{ + return viscosity; +} + +LogFileDataImp::LogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h new file mode 100644 index 000000000..8db5e352a --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h @@ -0,0 +1,31 @@ +#ifndef LOGFILE_DATA_IMP_H +#define LOGFILE_DATA_IMP_H + +#include "LogFileData.h" + +#include <memory> + +class LogFileDataImp : public LogFileData +{ +public: + static std::shared_ptr<LogFileDataImp> getNewInstance(); + + int getBasisTimeStepLength(); + std::string getKernel(); + int getNumberOfTimeSteps(); + double getViscosity(); + + void setBasisTimeStepLength(int basisTimeStepLength); + void setKernel(std::string kernelName); + void setNumberOfTimeSteps(int numberOfTimeSteps); + void setViscosity(double viscosity); + +private: + LogFileDataImp(); + + int basisTimeStepLength; + std::string kernelName; + int numberOfTimeSteps; + double viscosity; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp new file mode 100644 index 000000000..0b2caee61 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp @@ -0,0 +1,68 @@ +#include "LogFileReader.h" + +#include "Utilities\LogFileData\LogFileDataImp.h" + +#include "utilities/input/Input.h" +#include "utilities/StringUtil/StringUtil.h" + +#include <filesystem> +#include <fstream> + +std::shared_ptr<LogFileReader> LogFileReader::getInstance() +{ + static std::shared_ptr<LogFileReader> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<LogFileReader>(new LogFileReader()); + return uniqueInstance; +} + +std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string filePath) +{ + std::shared_ptr<LogFileDataImp> logFileData = LogFileDataImp::getNewInstance(); + + std::ifstream stream; + stream.open(filePath.c_str(), std::ios::in); + if (stream.fail()) + throw "can not open config file!\n"; + + std::unique_ptr<input::Input> input = input::Input::makeInput(stream, "config"); + + logFileData->setBasisTimeStepLength(StringUtil::toInt(input->getValue("BasisTimeStepLength"))); + logFileData->setKernel(StringUtil::toString(input->getValue("Kernel"))); + logFileData->setNumberOfTimeSteps(StringUtil::toInt(input->getValue("NumberOfTimeSteps"))); + logFileData->setViscosity(StringUtil::toDouble(input->getValue("Viscosity"))); + + std::string test = StringUtil::toString(input->getValue("GPU_Device_1")); + + return logFileData; +} + +std::vector<std::shared_ptr<LogFileData>> LogFileReader::readLogFilesInDirectoryToLogFileData(std::string directory) +{ + std::vector< std::shared_ptr< LogFileData> > logFileData; + + std::vector< std::string> filePaths = getAllFilesInDir(directory, ".txt"); + for (int i = 0; i < filePaths.size(); i++) + logFileData.push_back(readLogFileToLogFileData(filePaths.at(i))); + + return logFileData; +} + +LogFileReader::LogFileReader() +{ +} + +std::vector<std::string> LogFileReader::getAllFilesInDir(const std::string &dirPath, const std::string &fileExtension) +{ + std::vector<std::string> listOfFiles; + std::experimental::filesystem::path myPath = dirPath; + if (std::experimental::filesystem::exists(myPath) && std::experimental::filesystem::is_directory(myPath)) + { + for (auto& item : std::experimental::filesystem::recursive_directory_iterator(myPath)) + { + if (std::experimental::filesystem::is_regular_file(item.path()) && item.path().extension() == fileExtension) + listOfFiles.push_back(item.path().string()); + } + } + return listOfFiles; +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h new file mode 100644 index 000000000..482cdb1fe --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h @@ -0,0 +1,25 @@ +#ifndef LOGFILE_READER_H +#define LOGFILE_READER_H + +#include <memory> +#include <string> +#include <vector> + +class LogFileData; + +class LogFileReader +{ +public: + static std::shared_ptr<LogFileReader> getInstance(); + + std::shared_ptr<LogFileData> readLogFileToLogFileData(std::string filePath); + std::vector<std::shared_ptr< LogFileData>> readLogFilesInDirectoryToLogFileData(std::string directory); + + +private: + LogFileReader(); + + std::vector<std::string> getAllFilesInDir(const std::string &dirPath, const std::string &fileExtension); +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp new file mode 100644 index 000000000..0df6c36e8 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp @@ -0,0 +1,22 @@ +#include "MathematicaListLinePlot.h" + +std::shared_ptr<MathematicaListLinePlot> MathematicaListLinePlot::getNewInstance(std::vector< std::shared_ptr< DataPoint>> plotData) +{ + return std::shared_ptr<MathematicaListLinePlot>(new MathematicaListLinePlot(plotData)); +} + +MathematicaListLinePlot::MathematicaListLinePlot(std::vector< std::shared_ptr< DataPoint>> plotData) +{ + mathematicaFunction << "ListLinePlot["; + + + mathematicaFunction << "]"; +} + +MathematicaListLinePlot::MathematicaListLinePlot() +{ +} + +MathematicaListLinePlot::~MathematicaListLinePlot() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.h new file mode 100644 index 000000000..ff4002e2b --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.h @@ -0,0 +1,21 @@ +#ifndef MATHEMATICA_PLOT_H +#define MATHEMATICA_PLOT_H + +#include "../MathematicaFunktionImp.h" + +#include <memory> +#include <vector> + +class DataPoint; + +class MathematicaListLinePlot : public MathematicaFunctionImp +{ +public: + static std::shared_ptr< MathematicaListLinePlot> getNewInstance(std::vector< std::shared_ptr< DataPoint>> plotData); + +private: + MathematicaListLinePlot(); + MathematicaListLinePlot(std::vector< std::shared_ptr< DataPoint>> plotData); + ~MathematicaListLinePlot(); +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h new file mode 100644 index 000000000..000188627 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h @@ -0,0 +1,14 @@ +#ifndef MATHEMATICA_FUNCTION_H +#define MATHEMATICA_FUNCTION_H + +#include <string> + +class MathematicaFunction +{ +public: + virtual std::string getFunction() = 0; + +private: + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp new file mode 100644 index 000000000..c64d4467a --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp @@ -0,0 +1,10 @@ +#include "MathematicaFunktionImp.h" + +std::string MathematicaFunctionImp::getFunction() +{ + return mathematicaFunction.str(); +} + +MathematicaFunctionImp::MathematicaFunctionImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h new file mode 100644 index 000000000..4e78f8023 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h @@ -0,0 +1,17 @@ +#ifndef MATHEMATICA_FUNCTION_IMP_H +#define MATHEMATICA_FUNCTION_IMP_H + +#include "MathematicaFunktion.h" +#include <sstream> + +class MathematicaFunctionImp : public MathematicaFunction +{ +public: + std::string getFunction(); + +protected: + MathematicaFunctionImp(); + std::ostringstream mathematicaFunction; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp new file mode 100644 index 000000000..c9c9a3d4d --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp @@ -0,0 +1,34 @@ +#include "MathematicaPointList.h" + +#include "Utilities\DataPoint\DataPoint.h" +#include "MathematicaPointList.h" + +std::shared_ptr<MathematicaPointList> MathematicaPointList::getNewInstance(std::string listName, std::vector< std::shared_ptr< DataPoint>> plotData) +{ + return std::shared_ptr<MathematicaPointList>(new MathematicaPointList(listName, plotData)); +} + +std::string MathematicaPointList::getListName() +{ + return listName; +} + +MathematicaPointList::MathematicaPointList(std::string listName, std::vector< std::shared_ptr< DataPoint>> plotData) : listName(listName) +{ + mathematicaFunction << listName << "= {"; + for (int i = 0; i < plotData.size(); i++) { + if (i > 0) + mathematicaFunction << ", "; + mathematicaFunction << "{" << plotData.at(i)->getX() << ", " << plotData.at(i)->getY() << "}"; + } + + mathematicaFunction << "}"; +} + +MathematicaPointList::MathematicaPointList() +{ +} + +MathematicaPointList::~MathematicaPointList() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.h new file mode 100644 index 000000000..2c2a46a07 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.h @@ -0,0 +1,25 @@ +#ifndef MATHEMATICA_POINT_LIST_H +#define MATHEMATICA_POINT_LIST_H + +#include "../MathematicaFunktionImp.h" + +#include <memory> +#include <vector> + +class DataPoint; + +class MathematicaPointList : public MathematicaFunctionImp +{ +public: + static std::shared_ptr< MathematicaPointList> getNewInstance(std::string listName, std::vector< std::shared_ptr< DataPoint>> plotData); + + std::string getListName(); + +private: + MathematicaPointList(); + MathematicaPointList(std::string listName, std::vector< std::shared_ptr< DataPoint>> plotData); + ~MathematicaPointList(); + + std::string listName; +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.h new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/config.txt b/targets/tests/NumericalTestPostProcessing/config.txt new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/main.cpp b/targets/tests/NumericalTestPostProcessing/main.cpp new file mode 100644 index 000000000..ac5d87fad --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/main.cpp @@ -0,0 +1,162 @@ +#include "Utilities\LogFileData\LogFileData.h" +#include "Utilities\LogFileReader\LogFileReader.h" + +#include <mpi.h> +#include <memory> +#include <gmock/gmock.h> +#include <cstdio> +#include "wstp.h" + +#include <iostream> +#include <fstream> + +void waitForLinkActivity(WSLINK link) +{ + switch (WSWaitForLinkActivity(link)){ + case WSWAITERROR: + fprintf(stderr, "Something went wrong when waiting for link"); + break; + case WSWAITSUCCESS: + fprintf(stderr, "\nwait succes"); + } +} + +WSENV initWSTP() { + WSENV env = WSInitialize((WSEnvironmentParameter)0); + return env; +} + +WSLinkServer initMathematicaServer(WSENV env, int &error) { + unsigned short port = 8000; + WSLinkServer server = WSNewLinkServerWithPort(env, port, NULL, &error); + if (error != WSEOK) { + fprintf(stderr, "Something went wrong when starting up the server"); + } + + return server; +} + +WSLINK initMathematicaLink(WSLinkServer server, int &error){ + const char *interface = WSInterfaceFromLinkServer(server, &error); + unsigned short port = WSPortFromLinkServer(server, &error); + + std::ofstream myMathematicaFile("C:\\Users\\Timon\\Desktop\\myFile1.txt"); + myMathematicaFile << "link = LinkConnect[\"" << port << "\", LinkProtocol -> \"TCPIP\", LinkHost -> \"" << interface << "\", LinkOptions -> 4];" << std::endl; + myMathematicaFile << "If[LinkReadyQ[link], LinkRead[link]]"; + myMathematicaFile.close(); + + std::rename("C:\\Users\\Timon\\Desktop\\myFile1.txt", "C:\\Users\\Timon\\Desktop\\myFile1.nb"); + system("C:\\Users\\Timon\\Desktop\\myFile1.nb"); + + fprintf(stderr, "link = LinkConnect[\"%d\", LinkProtocol -> \"TCPIP\", LinkHost -> \"%s\", LinkOptions -> 4];\nIf[LinkReadyQ[link], LinkRead[link]]", port, interface); + + WSLINK link = WSWaitForNewLinkFromLinkServer(server, &error); + if (link == (WSLINK)0 || error != WSEOK) + std::cout << "unable to open link" << std::endl << std::flush; + else + std::cout << "\nConected to new link..."; + + WSActivate(link); + WSPutFunction(link, "Print", 1); + WSPutString(link, "Hello client program.\nRead instructions in programm output."); + WSEndPacket(link); + WSFlush(link); + + std::cout << std::endl << std::endl << "Copy to Mathematica to read Data:" << std::endl << std::endl; + std::cout << "Do[If[LinkReadyQ[link], Print[LinkRead[link]], LinkWrite[link, \"End\"]; Break[]], 20]" << std::endl; + + return link; +} + +void DeinitializeMathematica(WSENV env, WSLinkServer server, WSLINK link) { + WSClose(link); + WSShutdownLinkServer(server); + WSDeinitialize(env); +} + +void variante1() { + int error; + WSENV env = initWSTP(); + WSLinkServer server = initMathematicaServer(env, error); + WSLINK link = initMathematicaLink(server, error); + + WSPutFunction(link, "Plot", 3); + WSPutSymbol(link, "x"); + WSPutFunction(link, "List", 3); + WSPutSymbol(link, "x"); + WSPutInteger(link, 0); + WSPutInteger(link, 1); + WSPutFunction(link, "Rule", 2); + WSPutSymbol(link, "AxesLabel"); + WSPutFunction(link, "List", 2); + WSPutSymbol(link, "x"); + WSPutSymbol(link, "y"); + WSEndPacket(link); + WSFlush(link); + + WSPutFunction(link, "Plot", 2); + WSPutFunction(link, "Times", 2); + WSPutSymbol(link, "x"); + WSPutSymbol(link, "x"); + WSPutFunction(link, "List", 3); + WSPutSymbol(link, "x"); + WSPutInteger(link, 0); + WSPutInteger(link, 2); + WSEndPacket(link); + WSFlush(link); + + int number = 2; + + WSPutFunction(link, "Plot", number); + WSPutSymbol(link, "x"); + WSPutFunction(link, "List", 3); + WSPutSymbol(link, "x"); + WSPutInteger(link, 0); + WSPutInteger(link, 3); + WSEndPacket(link); + WSFlush(link); + + double list[20]; + + for (int i = 0; i < 20; i++) + list[i] = i + .9; + + WSPutFunction(link, "Set", 2); + WSPutSymbol(link, "list"); + if (!WSPutReal64List(link, (double *)list, 20)) + std::cout << "unable to put the list to link" << std::endl << std::flush; + + + std::cout << std::endl << "Waiting for Mathematica to read Data"; + waitForLinkActivity(link); + DeinitializeMathematica(env, server, link); + std::cout << "\nend" << std::endl; +} + +void variante2() { + std::ofstream myMathematicaFile("C:\\Users\\Timon\\Desktop\\myFile2.txt"); + + myMathematicaFile << "Plot[x^2, {x, 0, 1}, AxesLabel -> {x, y}]" << std::endl; + myMathematicaFile << "list = {0, 1, 2, 3}" << std::endl; + myMathematicaFile << "Plot[list, {x, 0, 1}]" << std::endl; + + myMathematicaFile.close(); + + std::rename("C:\\Users\\Timon\\Desktop\\myFile2.txt", "C:\\Users\\Timon\\Desktop\\myFile2.nb"); + system("C:\\Users\\Timon\\Desktop\\myFile2.nb"); +} + + +int main(int argc, char **argv) +{ + std::shared_ptr<LogFileReader> logFileReader = LogFileReader::getInstance(); + + std::shared_ptr<LogFileData> logFileData = logFileReader->readLogFileToLogFileData("C:\\Users\\Timon\\Documents\\studienarbeitIRMB\\logFiles\\NumericalTestLogFiles\\TaylorGreenVortexU0\\viscosity_0.0001\\u0_ 0.032_Amplitude_ 0.01\\CumulantAA2016CompSP27\\logfile_20181212_164220_CumulantAA2016CompSP27_vis_0.0001.txt"); + + + + //variante1(); + variante2(); + + return 0; +} diff --git a/targets/tests/NumericalTestPostProcessing/package.include b/targets/tests/NumericalTestPostProcessing/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTestPostProcessing/test.nb b/targets/tests/NumericalTestPostProcessing/test.nb new file mode 100644 index 000000000..fc82e9ff2 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/test.nb @@ -0,0 +1,420 @@ +(* Content-type: application/vnd.wolfram.mathematica *) + +(*** Wolfram Notebook File ***) +(* http://www.wolfram.com/nb *) + +(* CreatedBy='Mathematica 11.2' *) + +(*CacheID: 234*) +(* Internal cache information: +NotebookFileLineBreakTest +NotebookFileLineBreakTest +NotebookDataPosition[ 158, 7] +NotebookDataLength[ 16664, 412] +NotebookOptionsPosition[ 14809, 371] +NotebookOutlinePosition[ 15159, 386] +CellTagsIndexPosition[ 15116, 383] +WindowFrame->Normal*) + +(* Beginning of Notebook Content *) +Notebook[{ + +Cell[CellGroupData[{ +Cell[BoxData[{ + RowBox[{ + RowBox[{"link", "=", + RowBox[{"LinkConnect", "[", + RowBox[{"\"\<8000\>\"", ",", + RowBox[{"LinkProtocol", "\[Rule]", "\"\<TCPIP\>\""}], ",", + RowBox[{"LinkHost", "\[Rule]", "\"\<134.169.81.78\>\""}], ",", + RowBox[{"LinkOptions", "\[Rule]", "4"}]}], "]"}]}], ";"}], "\n", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"LinkReadyQ", "[", "link", "]"}], ",", + RowBox[{"LinkRead", "[", "link", "]"}]}], "]"}]}], "Input", + CellChangeTimes->{{3.7544100651726403`*^9, 3.7544100651766415`*^9}, { + 3.7544101916228*^9, 3.7544102237177057`*^9}, {3.754410667136778*^9, + 3.754410686000425*^9}, {3.7544107533780265`*^9, + 3.754410769840086*^9}},ExpressionUUID->"ee160571-4372-4403-9a66-\ +2959b7db420c"], + +Cell[BoxData["\<\"Hello client program.\"\>"], "Print", + CellChangeTimes->{3.754410087584163*^9, 3.7544102624032383`*^9, + 3.754410403840088*^9, 3.7544104647340903`*^9, 3.7544105497850494`*^9, + 3.7544106347848167`*^9, 3.7544107236507015`*^9, 3.754410808082506*^9, + 3.754410853754762*^9, 3.754411067213627*^9, 3.7544112870287895`*^9, + 3.754411580016981*^9},ExpressionUUID->"c148cfae-8ec5-4c46-9788-\ +4ca7ec25b966"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Do", "[", + RowBox[{ + RowBox[{"If", "[", + RowBox[{ + RowBox[{"LinkReadyQ", "[", "link", "]"}], ",", + RowBox[{"Print", "[", + RowBox[{"LinkRead", "[", "link", "]"}], "]"}], ",", + RowBox[{ + RowBox[{"LinkWrite", "[", + RowBox[{"link", ",", " ", "\"\<End\>\""}], "]"}], ";", + RowBox[{"Break", "[", "]"}]}]}], "]"}], ",", "20"}], "]"}]], "Input", + CellChangeTimes->{ + 3.754410258035161*^9, {3.754410327092177*^9, 3.7544103675071373`*^9}, { + 3.7544104285941854`*^9, 3.7544104297614727`*^9}, {3.7544104908325224`*^9, + 3.7544105131380205`*^9}, {3.754410586979211*^9, + 3.754410596607585*^9}},ExpressionUUID->"beb75de2-6f3c-466a-a629-\ +e1756c395557"], + +Cell[CellGroupData[{ + +Cell[BoxData[ + GraphicsBox[{{{}, {}, + TagBox[ + {RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[ + 1.], LineBox[CompressedData[" +1:eJxFxW0w03EcAPCNdZRrjMr9adxE5SlOUlKpuMhDneHk8nRCWk/InXR1WrdJ +nua6nZTnh5R2jGyuMnHsdDnPo1GzMUtj83RndnRZ9cL39+JzH0r8XWqiHg6H +C/7n/wGJypGu+fAz2xN8LFJkmLv39kcrS8paMV84cED8vhwLgyMStB3PsQR4 +yuWpTwGWDlftvZydizFgumHroWcYG74SWc1dWa2DjXT0KD8rLmwXsqTsyePB +GYOe3iVrH2FzHkmKx3fCbXKf/qFT3XA3rdwyUi2ENQdPGzfe/gLrbXBMLO36 +YA9dXFtoUz/cz3Af7HUYgq2LVBsNS8OwSiuTjruOwnUL7X3EQhFMJL9ZVijG +4Pwb/KQq22/w+lmOIjlLDKe7CXn7eiZgWZMwb4TyHf5NGyu1f/ADdjxnsJXU +LoH9aijXW8ylcAY51mYmSgY7qcONxMHTsJnxiqFwE03oLOUeKJuBb7q3T+4M +lMOci/FVn9fRGpWFyVzxLMwP9dNn+yrgLH9mJW8OTZkKmKhl/oRPHmewMbc5 +OMpqaAMvQmv6CuQp9F9wCSEmnWqrhM2k/Bo9IXrHI3qYZ+o8jGuI4cpNF+C0 +V9wC0250h2OOIemOCiYFpDk9IaphifOwKFOAbq7wtlXELMLRXA8SeQv9mFlN +l7xbghuV5FJi0DKcU86Mk15CJ1AX7ZpC0PsFgubgCHQu62pvfjw62ePl6q5M +tA1jj79BPXrrxMPd4rfoycXZ0XoOuiiiNfpCC1rnQL3HFKAlI6wKfRH6Q7b2 +mmgczfaKta+dQAe+PsI7L0V/uj/wlT6PLnY+xgpRo1PlZWGUZfThoFuyrjU0 +AT9WV6RFT/O9aHGbaAGt1sX1D/qFtZFGp0P/BaO4ekM= + "]]}, + Annotation[#, "Charting`Private`Tag$16094#1"]& ]}, {}, {}}, + AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], + Axes->{True, True}, + AxesLabel->{None, None}, + AxesOrigin->{0, 0}, + DisplayFunction->Identity, + Frame->{{False, False}, {False, False}}, + FrameLabel->{{None, None}, {None, None}}, + FrameTicks->{{Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}, {Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}}, + GridLines->{None, None}, + GridLinesStyle->Directive[ + GrayLevel[0.5, 0.4]], + ImagePadding->All, + Method->{ + "DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" -> + AbsolutePointSize[6], "ScalingFunctions" -> None, + "CoordinatesToolOptions" -> {"DisplayFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& ), "CopiedValueFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& )}}, + PlotRange->{{0, 1}, {0., 0.9999999795918367}}, + PlotRangeClipping->True, + PlotRangePadding->{{ + Scaled[0.02], + Scaled[0.02]}, { + Scaled[0.05], + Scaled[0.05]}}, + Ticks->{Automatic, Automatic}]], "Print", + CellChangeTimes->{3.7544105536750064`*^9, 3.754410639812049*^9, + 3.7544108588260098`*^9, 3.7544110704214177`*^9, 3.7544112949508677`*^9, + 3.754411583782909*^9},ExpressionUUID->"b71e333f-093e-4e75-a131-\ +86138e08ceee"], + +Cell[BoxData[ + GraphicsBox[{{{}, {}, + TagBox[ + {RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[ + 1.], LineBox[CompressedData[" +1:eJwVlfk7lAsDhm1Jqplo0UwcZSulSQvazPNaSrYWW5FEJKljqQ6lE42MUkQd +UUyWLCW7LNkZgwhlO6iMkiOJJDT29+v74b6ef+B+rnvdKXez0yJCQkKPf/P/ +NTo90Fzx9TRz3EywZVSEv1dMj+7RQ9NHkE6WWyfxiLk99iHnBc0C1epPD7sS +hcw+WSWWt4odvPJzDx10aWAaN3bkPKY5QSt7Vmc70cVUCpZLIuXPYvmZA57y +RZ+Zs0aOkQ4qbhC2fi2m7DLEHAxo4zlEeGJHZNXmlZZjzKNOgtL7tEtIGist +kiGmmDw9ekEVxwttlRaq9AmSqa6onTUufwV8Id5eSpEoOCL2KcoJV5HVlWoZ +yl8IiV7/J1YqvnD45nBymcsSFH1saayyuA4BfSztQOoyeBx2MrKNYCHDlqOw +yHI5urfc1AuhBcBVQ0mwiKAhPHZ1hfJxNjwaRKyMWLIwoj7fW8YJxGe/A+mS +E/LI/96gMSIfhMUxAU8WFCnivJ1dzk2H23BV4HKTypWh0DTCWJtwByIa23vY +/PW4my694YjKXXSIZS0Rd1HDPrnExK9nQiHDLZZLbmHAtyZqWaVFGGoDr63U +S1XHDk21EOuIewhbLyknarkdcSsPBd6mhcO97NhKUWIXrjZG8qyKwjHUnkYx +f7cbVuyPIorHH4CdSxfXY+3FkglPv2JOBCRr9UZEJoDLbeGXh+QfITvutKVw +kR7Mg7vzX1Y8Av+Vl1FKoT4Y+ioTAQ5RiGoLZ8aX70PfiwJPuYRoFEUIFFl8 +Axz5553rQZUYJFYf/SzkYgI1Y8UUem0MdCTfvt0QZQoJ0fNf+s/E4s9tlqVx +LQdxsnA+u9wiDvmrqgyJ1MNYqRrGOBYRD4kzOnQhS3OwJF6sD6IlYtr2YiIJ +a2w0uHcrxyMRM/tT13bK2qCF7f71fW0iDqzO1XGes4GSqFoqwysJzR47LyTU +2aJmLpHR1pKMyll2zWEDeywZi9CQD05BxY4RC6vTTsjb+lfEgc8p2OJ0v9B9 +1Al2HuYCz93PsW9hzA9Hv9PIHKYW8gaew+nZ9/YPcc4wG7i113VfGryt/rq2 +bNoFD7t99PLmM/DFYTXht8ANOrLWiXzLTFS/1n29L9MNgzZaCyTSM2GY0r7h +i407/hi64pi+OQsJJ6M2dx/3gPtZTWWhD1m4ten8weYqT0g7ZT5L2pmDqah3 +htoVl3DMOj7zx2guPDp71yudu4qR9xaST+h5OO6smrXy36sItJM4ba6Xh6FX +Vhr/6vyNF47u9PzwPMwudtbkrbkGips2+6pWPj4FWS236PJFtX+Xjfi1Atjm +gBOvzcK2NClxWYkiGBhPRm7ZzEYdo9q+Ub0IER9ubXzozoZ99uViX+siaHUG +73HJYSMkv8fj0/MieFJGOpm7AjFQkf4+2bQYtV6ywjXGNxHTbpi99Z8SCDTX +LNwb8Nt7kmVr8Ec5PP569rVG9y4enj1qp7a/HHdiFbtCw+5CqU3NXsqtHEG+ +7Tol/LtgpnQ4vi8th9bxbl/8HYrClIi8AkYFkmrLWgUnwjBsPlRi3FQB1VE/ +65nke7B8Fvn64lIuxmiBXYfswsE54W/ivI4L07mMvnN3wtEr/WfjMQ0uZPZc +TCt8+fsX13TfaJ/gQqym0XNw+QMEmQ23LEznYhftdWtcwwOUzuq+izapwsq8 +/nF7g0goH/k+UHWHh7vc+FTGqSjQ/Qx2n4nnoSG6Uof/KArL0uPuSBbw4Bpr +ZveqOQrTEuaMI708lCq/2miiG423FQUX+Tur0ckQlpJW4cBHnTU/+V81Krel +SkdOPkYTdcUKBlGLsuvuE9y+OHg37cLD8ToYdp/yvro0CRRG3n91EvX4h7bd +z4iRhMQQ9eAZ2XpwOaWi2w/99txkfZfdvnp0eAvfOHwvCZter7ioHFGP9uv6 +NqWrktFTO5Kco/UadH7BOTuVpzCoTKI0+jTgbbU5vexYCmRypfjCwm/w3dA+ +eWxRBvJ79Rre7G1BvU9sWlFdLriuj9dYD7WBduHZYn/bYkyoaFPT/+yAc9LN +tLXrKyEylbpsjfI7+PbzhL1tq6FJ2uebZ3zA4zVOjFe5dWgI2NFUs7EHihs0 +7ejHmyAf9m0q5ftHUMjMmT3fmvFN0MNvV+9Fg+C9nldGGxIHi+spdz+Dw6K7 +HO7vAEXu6UhfXx/8YqM/ihu+R/DZPOc4pX7Yrgn6uSSJj19Eap+L3xd4SCVJ +K+h8wqVtvNxVVQOw9xs9Z6D6GT0ZvDvN6wYxsjSNWH30P8y4tkWr+nyDL9cj +fDLyCzbpLJx3Lh6CksK9Qu2GrzB4su5Mtsx3vGnareZrMgRvuZMKn2xH4Nth +Witc+h1qQ5aLO0x/QHxHVe2Gxz+wnPpDgjf9A7P7rQ17xX5CrDw6U5EzippB +m5ByhzGc21Hctcj4J/xZ+qs0B8eRangqruzXT1xfc11G0ucXJr7Rl/VHjEF/ +sit4dEaAPHMD0XD9cew4/1QQmTYFvwPs2Nz+cYRezpDnms5gXbdRZwJ7Ape2 +M802js1it1ZAOG3bL7wsuLTTsX4etn+8mRJu/QUb/Tu0+wZCxER9SK8HSwBa +gm23nL4w8VDM7pKZ0iS8D38ZSNQUIZbz856I8CYRutMmPHejKLHgGstil+cU +at9bbvXZLUYIpdhl9kpPY3JY37+YuYC4EJUZIs2dhiiFuV5wUpwo3XRLQspt +BtQbQeZaNxYSUkYX1Pwps5hzq3BwfSRBfNj8tvVKySzShseNNzUtIrJioNRn +NweZ+lN9qyYkiROZmlJy83PQqCvjeMkuIa6z41kfns9jPLmnfNhxKZE+IBdN +MSFx+9yolBSHQtx6zLbnHyQx9UpB+148hXAyG1bOOEIiL+RNv9RTCiFbUpJl +epSEtGl03oocCnE79HhN8Knf5UiYIda+ohAumo9GJa+Q0MjooRwapxAKASsO +LEwmIaGtcXOxKZWY3/n30o5nJOZutLKizahE1/DnluRUEtrbhqc3HaMSYUdf +nNifTSKBd9/loCOVIDeaXWSXkBCpTN766AqV+NAcGiPaSkJ89U+f/clU4mWg +wLG1nURZ6/4T/FQqEb7npGpCJ4mqX6vKvLKphHESI1eXTyLjgurMsxIqUXS5 +sY71lcRqXRnH5a1UImKzRuiRIRJbdxrsyuykEp69HIt1IyQePPgZYsynEhtM +zvdUjJPQDSzOYX+lEmLCbYlhAhLBtC5/xREq8TFvj6v9NAnFFReaK8epRIlr +whb1ORILvAJj7KepRKT84gmSJLENqwZJkkr8D3lPrGg= + "]]}, + Annotation[#, "Charting`Private`Tag$16135#1"]& ]}, {}, {}}, + AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], + Axes->{True, True}, + AxesLabel->{None, None}, + AxesOrigin->{0, 0}, + DisplayFunction->Identity, + Frame->{{False, False}, {False, False}}, + FrameLabel->{{None, None}, {None, None}}, + FrameTicks->{{Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}, {Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}}, + GridLines->{None, None}, + GridLinesStyle->Directive[ + GrayLevel[0.5, 0.4]], + ImagePadding->All, + Method->{ + "DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" -> + AbsolutePointSize[6], "ScalingFunctions" -> None, + "CoordinatesToolOptions" -> {"DisplayFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& ), "CopiedValueFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& )}}, + PlotRange->{{0, 2}, {0., 3.9999998367346956`}}, + PlotRangeClipping->True, + PlotRangePadding->{{ + Scaled[0.02], + Scaled[0.02]}, { + Scaled[0.05], + Scaled[0.05]}}, + Ticks->{Automatic, Automatic}]], "Print", + CellChangeTimes->{3.7544105536750064`*^9, 3.754410639812049*^9, + 3.7544108588260098`*^9, 3.7544110704214177`*^9, 3.7544112949508677`*^9, + 3.7544115838339214`*^9},ExpressionUUID->"d3b58627-2dae-4442-b746-\ +6b8364628fac"], + +Cell[BoxData[ + GraphicsBox[{{{}, {}, + TagBox[ + {RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[ + 1.], LineBox[CompressedData[" +1:eJxFxWlMknEcAODXE+cyczNWXvN8M12jVZbUvJtOy7Sa4BUFCpIRkivPNI+w +MmAqtWXm9cGp07WlS6flQSm+zaQ1Wc4VmqQVWHlgXoRUH/z9Pzx73FgZ59im +GIZF//P/9VP82tgMQeD2Zan7vN/hZ4K2H/s1my7GGfBiZ5iIh/PhErLOKRkv +hEdHoubO4xI4oyHrTQxeB8tEohfR+FPYwjKTpEkfgCNvMYXPaSNwdy5b1fRe +AU8mXqFkZo/DdhFijix4At6lZHccS/oIe7jyWoWsadhfdXU0pGoGlm0WnVbW +fIG5AwTRXzIHV6c0O+y+9A0+ED+zusXWwFO6GEVw5Dy8PL33IDnuJ1zRlpdG +py/AuK1VdE7NItwlKGqT1C/BSi8p6WzVMuxZOu59oVoHU2Onj9TXrMAqgTBQ +LPoNd1ATbIYrV2EybWSyRbgGB6mxylfX1+FqMtcGz9mAS+ou3/FL34RrFY/k +EoEeLuBLF50z/8DzTO89CSwDfN+gNZ/ibMG9PyIWdiYa4Q9e/urjnljw9tz9 +KRRpE1pGS8oPcTGBD8drW+0b0bzS8IkAR1P4Lsdq00SK7nNmGrX2ZnDPVpmZ +jwSt6AzTiu3M4WFXjlxUhb7dHdc4Y20BJ7t/YiSJ0fouiqMvyRK+aaZ5+7AQ +TfakMr0wEpzNp61Y56KdjqYSeD560HDtSWgB2losPplXjK5rG3qguYeWfz/k +RzxG26fYZglfont8nKMa+9GMZR+XvkF0S3G4fGUIfaKhgJw6hmap5rtCp9Ck +po1yxmd0O490MU+NXtW7kzq+ossdEuluC2iKOs03YAmtbL1hjNehXaiVzRVr +6NdYfX77BppLtMcQevSOil6PWQP6GZ1YMxrRfwHMnDDX + "]]}, + Annotation[#, "Charting`Private`Tag$16176#1"]& ]}, {}, {}}, + AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], + Axes->{True, True}, + AxesLabel->{None, None}, + AxesOrigin->{0, 0}, + DisplayFunction->Identity, + Frame->{{False, False}, {False, False}}, + FrameLabel->{{None, None}, {None, None}}, + FrameTicks->{{Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}, {Automatic, + Charting`ScaledFrameTicks[{Identity, Identity}]}}, + GridLines->{None, None}, + GridLinesStyle->Directive[ + GrayLevel[0.5, 0.4]], + ImagePadding->All, + Method->{ + "DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" -> + AbsolutePointSize[6], "ScalingFunctions" -> None, + "CoordinatesToolOptions" -> {"DisplayFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& ), "CopiedValueFunction" -> ({ + (Identity[#]& )[ + Part[#, 1]], + (Identity[#]& )[ + Part[#, 2]]}& )}}, + PlotRange->{{0, 3}, {0., 2.99999993877551}}, + PlotRangeClipping->True, + PlotRangePadding->{{ + Scaled[0.02], + Scaled[0.02]}, { + Scaled[0.05], + Scaled[0.05]}}, + Ticks->{Automatic, Automatic}]], "Print", + CellChangeTimes->{3.7544105536750064`*^9, 3.754410639812049*^9, + 3.7544108588260098`*^9, 3.7544110704214177`*^9, 3.7544112949508677`*^9, + 3.754411583888935*^9},ExpressionUUID->"1d3b6a10-cb76-46c4-825e-\ +40814844d3d9"], + +Cell[BoxData[ + RowBox[{"{", + RowBox[{ + "0.9`", ",", "1.9`", ",", "2.9`", ",", "3.9`", ",", "4.9`", ",", "5.9`", + ",", "6.9`", ",", "7.9`", ",", "8.9`", ",", "9.9`", ",", "10.9`", ",", + "11.9`", ",", "12.9`", ",", "13.9`", ",", "14.9`", ",", "15.9`", ",", + "16.9`", ",", "17.9`", ",", "18.9`", ",", "19.9`"}], "}"}]], "Print", + CellChangeTimes->{3.7544105536750064`*^9, 3.754410639812049*^9, + 3.7544108588260098`*^9, 3.7544110704214177`*^9, 3.7544112949508677`*^9, + 3.754411583894935*^9},ExpressionUUID->"6491bda4-7862-40db-9665-\ +690be9ae6025"] +}, Open ]] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData["list"], "Input", + CellChangeTimes->{{3.754411586156494*^9, + 3.7544115884120493`*^9}},ExpressionUUID->"2c8f75aa-afe6-4794-9ff3-\ +1ff624c39ff6"], + +Cell[BoxData[ + RowBox[{"{", + RowBox[{ + "0.9`", ",", "1.9`", ",", "2.9`", ",", "3.9`", ",", "4.9`", ",", "5.9`", + ",", "6.9`", ",", "7.9`", ",", "8.9`", ",", "9.9`", ",", "10.9`", ",", + "11.9`", ",", "12.9`", ",", "13.9`", ",", "14.9`", ",", "15.9`", ",", + "16.9`", ",", "17.9`", ",", "18.9`", ",", "19.9`"}], "}"}]], "Output", + CellChangeTimes->{ + 3.754411589194243*^9},ExpressionUUID->"a159cdd9-bebd-4537-a479-\ +c4763f3d7a8b"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Plus", "[", + RowBox[{"1", ",", "3"}], "]"}]], "Input", + CellChangeTimes->{{3.754411162226041*^9, + 3.754411171388294*^9}},ExpressionUUID->"60360890-90f4-4e10-852b-\ +5259041a601e"], + +Cell[BoxData["4"], "Output", + CellChangeTimes->{ + 3.754411171870414*^9},ExpressionUUID->"980eb0c4-927e-4ff7-9317-\ +6b896379323c"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Set", "[", + RowBox[{"a", ",", "1"}], "]"}]], "Input", + CellChangeTimes->{{3.7544114653247213`*^9, + 3.754411473434722*^9}},ExpressionUUID->"d56d2649-e26c-48c8-bfc6-\ +109c73ac33f0"], + +Cell[BoxData["1"], "Output", + CellChangeTimes->{ + 3.754411474198907*^9},ExpressionUUID->"0b8212b7-96b9-4b94-8baf-\ +6c14f57bbde3"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData["a"], "Input", + CellChangeTimes->{{3.7544114752171607`*^9, + 3.7544114766655154`*^9}},ExpressionUUID->"a71be289-c4f1-4775-84af-\ +ed1f102af44a"], + +Cell[BoxData["1"], "Output", + CellChangeTimes->{ + 3.7544114771096244`*^9},ExpressionUUID->"0b3b4395-223b-425a-bf9b-\ +93464d5a6e5f"] +}, Open ]] +}, +WindowSize->{958, 1108}, +WindowMargins->{{-1927, Automatic}, {Automatic, 0}}, +FrontEndVersion->"11.2 for Microsoft Windows (64-bit) (September 10, 2017)", +StyleDefinitions->"Default.nb" +] +(* End of Notebook Content *) + +(* Internal cache information *) +(*CellTagsOutline +CellTagsIndex->{} +*) +(*CellTagsIndex +CellTagsIndex->{} +*) +(*NotebookFileOutline +Notebook[{ +Cell[CellGroupData[{ +Cell[580, 22, 741, 16, 48, "Input",ExpressionUUID->"ee160571-4372-4403-9a66-2959b7db420c"], +Cell[1324, 40, 420, 6, 22, "Print",ExpressionUUID->"c148cfae-8ec5-4c46-9788-4ca7ec25b966"] +}, Open ]], +Cell[CellGroupData[{ +Cell[1781, 51, 715, 17, 28, "Input",ExpressionUUID->"beb75de2-6f3c-466a-a629-e1756c395557"], +Cell[CellGroupData[{ +Cell[2521, 72, 2510, 59, 229, "Print",ExpressionUUID->"b71e333f-093e-4e75-a131-86138e08ceee"], +Cell[5034, 133, 4953, 99, 235, "Print",ExpressionUUID->"d3b58627-2dae-4442-b746-6b8364628fac"], +Cell[9990, 234, 2508, 59, 229, "Print",ExpressionUUID->"1d3b6a10-cb76-46c4-825e-40814844d3d9"], +Cell[12501, 295, 560, 10, 22, "Print",ExpressionUUID->"6491bda4-7862-40db-9665-690be9ae6025"] +}, Open ]] +}, Open ]], +Cell[CellGroupData[{ +Cell[13110, 311, 158, 3, 28, "Input",ExpressionUUID->"2c8f75aa-afe6-4794-9ff3-1ff624c39ff6"], +Cell[13271, 316, 440, 9, 32, "Output",ExpressionUUID->"a159cdd9-bebd-4537-a479-c4763f3d7a8b"] +}, Open ]], +Cell[CellGroupData[{ +Cell[13748, 330, 206, 5, 28, "Input",ExpressionUUID->"60360890-90f4-4e10-852b-5259041a601e"], +Cell[13957, 337, 130, 3, 32, "Output",ExpressionUUID->"980eb0c4-927e-4ff7-9317-6b896379323c"] +}, Open ]], +Cell[CellGroupData[{ +Cell[14124, 345, 207, 5, 28, "Input",ExpressionUUID->"d56d2649-e26c-48c8-bfc6-109c73ac33f0"], +Cell[14334, 352, 130, 3, 32, "Output",ExpressionUUID->"0b8212b7-96b9-4b94-8baf-6c14f57bbde3"] +}, Open ]], +Cell[CellGroupData[{ +Cell[14501, 360, 157, 3, 28, "Input",ExpressionUUID->"a71be289-c4f1-4775-84af-ed1f102af44a"], +Cell[14661, 365, 132, 3, 32, "Output",ExpressionUUID->"0b3b4395-223b-425a-bf9b-93464d5a6e5f"] +}, Open ]] +} +] +*) + diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp index b3f6bfdd3..dddc7aba6 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp @@ -1,11 +1,13 @@ #include "ShearWaveAnalyticalResults.h" +#include "Simulations\ShearWave\ShearWaveParameterStruct.h" + #define _USE_MATH_DEFINES #include <math.h> -std::shared_ptr<AnalyticalResults> ShearWaveAnalyticalResults::getNewInstance(double viscosity, double u0, double v0, double l0, double rho0) +std::shared_ptr<AnalyticalResults> ShearWaveAnalyticalResults::getNewInstance(double viscosity, std::shared_ptr< ShearWaveParameterStruct> simParaStruct) { - return std::shared_ptr<AnalyticalResults>(new ShearWaveAnalyticalResults(viscosity, u0, v0, l0, rho0)); + return std::shared_ptr<AnalyticalResults>(new ShearWaveAnalyticalResults(viscosity,simParaStruct)); } void ShearWaveAnalyticalResults::calc(std::shared_ptr<SimulationResults> simResults) @@ -24,7 +26,12 @@ void ShearWaveAnalyticalResults::calc(std::shared_ptr<SimulationResults> simResu calculated = true; } -ShearWaveAnalyticalResults::ShearWaveAnalyticalResults(double viscosity, double u0, double v0, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), u0(u0), v0(v0), l0(l0), rho0(rho0) +ShearWaveAnalyticalResults::ShearWaveAnalyticalResults(double viscosity, std::shared_ptr< ShearWaveParameterStruct> simParaStruct) + : AnalyticalResultsImp() { - + this->viscosity = viscosity; + this->u0 = simParaStruct->ux; + this->v0 = simParaStruct->uz; + this->l0 = simParaStruct->l0; + this->rho0 = simParaStruct->rho0; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h index 610c74a2a..89f1281a4 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h @@ -3,15 +3,17 @@ #include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" +struct ShearWaveParameterStruct; + class ShearWaveAnalyticalResults : public AnalyticalResultsImp { public: - static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double u0, double v0, double l0, double rho0); + static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, std::shared_ptr< ShearWaveParameterStruct> simParaStruct); void calc(std::shared_ptr< SimulationResults> simResults); private: ShearWaveAnalyticalResults() {}; - ShearWaveAnalyticalResults(double viscosity, double u0, double v0, double l0, double rho0); + ShearWaveAnalyticalResults(double viscosity, std::shared_ptr< ShearWaveParameterStruct> simParaStruct); double viscosity, rho0; double l0; diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp index 16c9a7a36..45aa561df 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp @@ -1,21 +1,22 @@ #include "ShearWaveLogFileInformation.h" -std::shared_ptr<ShearWaveInformation> ShearWaveInformation::getNewInstance(double u0, double v0, std::vector< bool> tests, std::vector< real> l, int l0) +#include "Simulations\ShearWave\ShearWaveParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + +std::shared_ptr<ShearWaveInformation> ShearWaveInformation::getNewInstance(std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct) { - return std::shared_ptr<ShearWaveInformation>(new ShearWaveInformation(u0, v0, tests, l, l0)); + return std::shared_ptr<ShearWaveInformation>(new ShearWaveInformation(simParaStruct, gridInfoStruct)); } std::string ShearWaveInformation::getOutput() { makeCenterHead("ShearWave Information"); - for (int i = 0; i < tests.size(); i++) { - if (tests.at(i)) { - oss << "Lx=" << l.at(i) << std::endl; + for (int i = 0; i < lx.size(); i++) { + oss << "Lx=" << lx.at(i) << std::endl; oss << "l0=" << l0 << std::endl; - oss << "u0=" << u0 / (l.at(i) / l0) << std::endl; - oss << "v0=" << v0 / (l.at(i) / l0) << std::endl; + oss << "ux=" << ux / (lx.at(i) / l0) << std::endl; + oss << "uz=" << uz / (lx.at(i) / l0) << std::endl; oss << std::endl; - } } return oss.str(); } @@ -30,11 +31,16 @@ std::string ShearWaveInformation::getFilePathExtensionOne() std::string ShearWaveInformation::getFilePathExtensionTwo() { std::ostringstream oss; - oss << "u0_" << u0 << "_v0_" << v0 << "\\"; + oss << "ux_" << ux << "_uz_" << uz << "\\"; return oss.str(); } -ShearWaveInformation::ShearWaveInformation(double u0, double v0, std::vector< bool> tests, std::vector< real> l, int l0) : u0(u0), v0(v0), tests(tests), l(l), l0(l0) +ShearWaveInformation::ShearWaveInformation(std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct) { + this->ux = simParaStruct->ux; + this->uz = simParaStruct->uz; + this->l0 = simParaStruct->l0; + for (int i = 0; i < gridInfoStruct.size(); i++) + lx.push_back(gridInfoStruct.at(i)->lx); } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h index d9488c4d4..f452f9e77 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h @@ -9,10 +9,13 @@ #include <memory> #include <vector> -class ShearWaveInformation : public LogFileInformationImp, public SimulationLogFileInformation +struct ShearWaveParameterStruct; +struct GridInformationStruct; + +class ShearWaveInformation : public SimulationLogFileInformation { public: - static std::shared_ptr<ShearWaveInformation> getNewInstance(double u0, double v0, std::vector< bool> tests, std::vector< real> l, int l0); + static std::shared_ptr<ShearWaveInformation> getNewInstance(std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); std::string getOutput(); std::string getFilePathExtensionOne(); @@ -20,12 +23,11 @@ public: private: ShearWaveInformation() {}; - ShearWaveInformation(double u0, double v0, std::vector< bool> tests, std::vector< real> l, int l0); + ShearWaveInformation(std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); - double u0; - double v0; - std::vector< bool> tests; - std::vector< real> l; + double ux; + double uz; + std::vector< real> lx; int l0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h b/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h new file mode 100644 index 000000000..f31a726a3 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h @@ -0,0 +1,19 @@ +#ifndef SHEAR_WAVE_PARAMETER_STRUCT_H +#define SHEAR_WAVE_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities\Structs\BasicSimulationParameterStruct.h" + +struct ShearWaveParameterStruct +{ + std::shared_ptr<BasicSimulationParameterStruct> basicSimulationParameter; + + double ux; + double uz; + int basicTimeStepLength; + double l0; + double rho0; + std::string vtkFilePath; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp index baf3bb26c..d5ecf4163 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp @@ -1,17 +1,20 @@ #include "ShearWaveSimulationInfo.h" +#include "Simulations\ShearWave\ShearWaveParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + #include <sstream> -std::shared_ptr<SimulationInfo> ShearWaveSimulationInfo::getNewInstance(double u0, double v0, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) +std::shared_ptr<SimulationInfo> ShearWaveSimulationInfo::getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations) { - return std::shared_ptr<SimulationInfo>(new ShearWaveSimulationInfo(u0, v0, l0, lx, viscosity, kernelName, numberOfSimulations)); + return std::shared_ptr<SimulationInfo>(new ShearWaveSimulationInfo(simID, kernelName,viscosity, simParaStruct, gridInfoStruct, numberOfSimulations)); } -ShearWaveSimulationInfo::ShearWaveSimulationInfo(double u0, double v0, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lx, viscosity, kernelName, numberOfSimulations) +ShearWaveSimulationInfo::ShearWaveSimulationInfo(int simID, std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations) + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "ShearWave") { std::ostringstream oss; - oss << " u0: " << u0 / (lx / l0) << " v0: " << v0 / (lx / l0); + oss << " ux: " << simParaStruct->ux / (gridInfoStruct->lx / simParaStruct->l0) << " uz: " << simParaStruct->uz / (gridInfoStruct->lx / simParaStruct->l0); this->simulationParameterString = oss.str(); - simulationName = "ShearWave"; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h index 3ddf46d38..0b6247e34 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h @@ -5,13 +5,16 @@ #include <memory> +struct ShearWaveParameterStruct; +struct GridInformationStruct; + class ShearWaveSimulationInfo : public SimulationInfoImp { public: - static std::shared_ptr< SimulationInfo> getNewInstance(double u0, double v0, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + static std::shared_ptr< SimulationInfo> getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations); private: ShearWaveSimulationInfo() {}; - ShearWaveSimulationInfo(double u0, double v0, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + ShearWaveSimulationInfo(int simID, std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations); }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp index 1682c4b61..bbc1c8298 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp @@ -1,34 +1,37 @@ #include "ShearWaveSimulationParameter.h" -#include "Simulation/ShearWave/InitialConditions/InitialConditionShearWave.h" -#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" +#include "Simulations/ShearWave/InitialConditions/InitialConditionShearWave.h" +#include "Simulations\ShearWave\ShearWaveParameterStruct.h" + +#include "Utilities\Structs\GridInformationStruct.h" #include <sstream> -std::shared_ptr<SimulationParameter> ShearWaveSimulationParameter::getNewInstance(std::string kernelName, real u0, real v0, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, - unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices) +std::shared_ptr<SimulationParameter> ShearWaveSimulationParameter::getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> parameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) { - return std::shared_ptr<SimulationParameter>(new ShearWaveSimulationParameter(kernelName, u0, v0, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, - writeFiles, startStepFileWriter, filePath, devices)); + return std::shared_ptr<SimulationParameter>(new ShearWaveSimulationParameter(kernelName, viscosity, parameterStruct, gridInfo)); } double ShearWaveSimulationParameter::getMaxVelocity() { - if(u0 > v0) - return u0 / (lx / l0); - return v0 / (lx / l0); + if(ux > uz) + return ux / (lx / l0); + return uz / (lx / l0); } -ShearWaveSimulationParameter::ShearWaveSimulationParameter(std::string kernelName, real u0, real v0, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -:SimulationParameterImp("ShearWave", viscosity, lx, lz, l0, lx, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), u0(u0), v0(v0), rho0(rho0) +ShearWaveSimulationParameter::ShearWaveSimulationParameter(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> parameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) +:SimulationParameterImp(kernelName, viscosity, parameterStruct->basicSimulationParameter, gridInfo) { + this->ux = parameterStruct->ux; + this->uz = parameterStruct->uz; + this->l0 = parameterStruct->l0; + this->timeStepLength = parameterStruct->basicTimeStepLength * (gridInfo->lx / l0)*(gridInfo->lx / l0); + this->rho0 = parameterStruct->rho0; + std::ostringstream oss; - oss << filePath << "\\ShearWave\\viscosity" << viscosity << "\\u0_" << u0 << "_v0_" << v0 << "\\" << kernelName << "\\grid" << lx; - generateFilePath(oss.str()); + oss << parameterStruct->vtkFilePath << "\\ShearWave\\viscosity" << viscosity << "\\ux_" << ux << "_uz_" << uz << "\\" << kernelName << "\\grid" << lx; + generateFileDirectionInMyStystem(oss.str()); this->filePath = oss.str(); - initialCondition = InitialConditionShearWave::getNewInstance(lx, lz, l0, u0, v0, rho0); - kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); + initialCondition = InitialConditionShearWave::getNewInstance(lx, lz, l0, ux, uz, rho0); } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h index 8f7d009e9..1fea281fb 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h @@ -3,32 +3,20 @@ #include "Utilities/SimulationParameter/SimulationParameterImp.h" -class PhiAndNuTest; +struct ShearWaveParameterStruct; class ShearWaveSimulationParameter : public SimulationParameterImp { public: - static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, real u0, real v0, real viscosity, real rho0, - real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> parameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); double getMaxVelocity(); protected: ShearWaveSimulationParameter() {}; - ShearWaveSimulationParameter(std::string kernelName, real u0, real v0, real viscosity, real rho0, - real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + ShearWaveSimulationParameter(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> parameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); private: - real u0, v0, rho0; + real ux, uz, rho0; }; #endif diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp index 26727d9d3..beffea2a5 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp @@ -1,11 +1,13 @@ #include "AnalyticalResultsTaylorGreenVortexUx.h" +#include "Simulations\TaylorGreenVortexUx\TaylorGreenVortexUxParameterStruct.h" + #define _USE_MATH_DEFINES #include <math.h> -std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUx::getNewInstance(double viscosity, double ux, double amplitude, double l0, double rho0) +std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUx::getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct) { - return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUx(viscosity, ux, amplitude, l0, rho0)); + return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUx(viscosity, simParaStruct)); } void AnalyticalResultsTaylorGreenUx::calc(std::shared_ptr< SimulationResults> simResults) @@ -24,7 +26,12 @@ void AnalyticalResultsTaylorGreenUx::calc(std::shared_ptr< SimulationResults> si calculated = true; } -AnalyticalResultsTaylorGreenUx::AnalyticalResultsTaylorGreenUx(double viscosity, double ux, double amplitude, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), ux(ux), amplitude(amplitude), l0(l0), rho0(rho0) +AnalyticalResultsTaylorGreenUx::AnalyticalResultsTaylorGreenUx(double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct) + : AnalyticalResultsImp() { - + this->viscosity = viscosity; + this->ux = simParaStruct->ux; + this->amplitude = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + this->rho0 = simParaStruct->rho0; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h index c59c84b66..2bcb55cf8 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h @@ -3,15 +3,17 @@ #include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" +struct TaylorGreenVortexUxParameterStruct; + class AnalyticalResultsTaylorGreenUx : public AnalyticalResultsImp { public: - static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double ux, double amplitude, double l0, double rho0); + static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct); void calc(std::shared_ptr< SimulationResults> simResults); private: AnalyticalResultsTaylorGreenUx() {}; - AnalyticalResultsTaylorGreenUx(double viscosity, double ux, double amplitude, double l0, double rho0); + AnalyticalResultsTaylorGreenUx(double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct); double viscosity, rho0; double l0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp index 3f75326bb..4b09fa3e0 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp @@ -1,21 +1,22 @@ #include "LogFileInformationTaylorGreenVortexUx.h" -std::shared_ptr<LogFileInformationTaylorGreenUx> LogFileInformationTaylorGreenUx::getNewInstance(double ux, double amplitude, std::vector< bool> tests, std::vector<double> l, int l0) +#include "Simulations\TaylorGreenVortexUx\TaylorGreenVortexUxParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + +std::shared_ptr<LogFileInformationTaylorGreenUx> LogFileInformationTaylorGreenUx::getNewInstance(std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct) { - return std::shared_ptr<LogFileInformationTaylorGreenUx>(new LogFileInformationTaylorGreenUx(ux, amplitude, tests, l, l0)); + return std::shared_ptr<LogFileInformationTaylorGreenUx>(new LogFileInformationTaylorGreenUx(simParaStruct, gridInfoStruct)); } std::string LogFileInformationTaylorGreenUx::getOutput() { makeCenterHead("TaylorGreenVortex U0 Information"); - for (int i = 0; i < tests.size(); i++) { - if (tests.at(i)) { - oss << "Lx=" << l.at(i) << std::endl; - oss << "ux=" << ux / (l.at(i) / l0) << std::endl; - oss << "Amplitude= " << amplitude / (l.at(i) / l0) << std::endl; - oss << "l0=" << l0 << std::endl; - oss << std::endl; - } + for (int i = 0; i < lx.size(); i++) { + oss << "Lx=" << lx.at(i) << std::endl; + oss << "ux=" << ux / (lx.at(i) / l0) << std::endl; + oss << "Amplitude= " << amplitude / (lx.at(i) / l0) << std::endl; + oss << "l0=" << l0 << std::endl; + oss << std::endl; } return oss.str(); @@ -35,6 +36,12 @@ std::string LogFileInformationTaylorGreenUx::getFilePathExtensionOne() return oss.str(); } -LogFileInformationTaylorGreenUx::LogFileInformationTaylorGreenUx(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0) : ux(ux), amplitude(amplitude), tests(tests), l(l), l0(l0) +LogFileInformationTaylorGreenUx::LogFileInformationTaylorGreenUx(std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct) { + this->ux = simParaStruct->ux; + this->amplitude = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + + for(int i = 0; i < gridInfoStruct.size(); i++) + lx.push_back(gridInfoStruct.at(i)->lx); } diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h index c4d1b63da..d242eb4fe 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h @@ -7,10 +7,13 @@ #include <memory> #include <vector> -class LogFileInformationTaylorGreenUx : public LogFileInformationImp, public SimulationLogFileInformation +struct TaylorGreenVortexUxParameterStruct; +struct GridInformationStruct; + +class LogFileInformationTaylorGreenUx : public SimulationLogFileInformation { public: - static std::shared_ptr<LogFileInformationTaylorGreenUx> getNewInstance(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + static std::shared_ptr<LogFileInformationTaylorGreenUx> getNewInstance(std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct); std::string getOutput(); std::string getFilePathExtensionOne(); @@ -18,12 +21,11 @@ public: private: LogFileInformationTaylorGreenUx() {}; - LogFileInformationTaylorGreenUx(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + LogFileInformationTaylorGreenUx(std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct); double ux; double amplitude; - std::vector< bool> tests; - std::vector< double> l; + std::vector< double> lx; int l0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp index 681e43ca7..8f86185e4 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp @@ -1,17 +1,19 @@ #include "SimulationInfoTaylorGreenVortexUx.h" +#include "Simulations\TaylorGreenVortexUx\TaylorGreenVortexUxParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + #include <sstream> -std::shared_ptr<SimulationInfo> SimulationInfoTaylorGreenUx::getNewInstance(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) +std::shared_ptr<SimulationInfo> SimulationInfoTaylorGreenUx::getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations) { - return std::shared_ptr<SimulationInfo>(new SimulationInfoTaylorGreenUx(ux, amplitude, l0, lx, viscosity, kernelName, numberOfSimulations)); + return std::shared_ptr<SimulationInfo>(new SimulationInfoTaylorGreenUx(simID, kernelName, viscosity, simParaStruct, gridInfoStruct, numberOfSimulations)); } -SimulationInfoTaylorGreenUx::SimulationInfoTaylorGreenUx(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lx, viscosity, kernelName, numberOfSimulations) +SimulationInfoTaylorGreenUx::SimulationInfoTaylorGreenUx(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations) + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "TaylorGreenVortex Ux") { std::ostringstream oss; - oss << " ux: " << ux / (lx / l0) << " Amplitude: " << amplitude / (lx / l0); + oss << " ux: " << simParaStruct->ux / (gridInfoStruct->lx / simParaStruct->l0) << " Amplitude: " << simParaStruct->amplitude / (gridInfoStruct->lx / simParaStruct->l0); this->simulationParameterString = oss.str(); - - simulationName = "TaylorGreenVortex Ux"; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h index 9b9eedc05..94dfb4f9c 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h @@ -5,14 +5,17 @@ #include <memory> +struct TaylorGreenVortexUxParameterStruct; +struct GridInformationStruct; + class SimulationInfoTaylorGreenUx : public SimulationInfoImp { public: - static std::shared_ptr< SimulationInfo> getNewInstance(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + static std::shared_ptr< SimulationInfo> getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations); private: SimulationInfoTaylorGreenUx() {}; - SimulationInfoTaylorGreenUx(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + SimulationInfoTaylorGreenUx(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations); }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp index c91aafa77..939883dde 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp @@ -1,13 +1,15 @@ #include "SimulationParameterTaylorGreenVortexUx.h" #include "Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h" -#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" +#include "Simulations\TaylorGreenVortexUx\TaylorGreenVortexUxParameterStruct.h" + +#include "Utilities\Structs\GridInformationStruct.h" #include <sstream> -std::shared_ptr<SimulationParameter> SimulationParameterTaylorGreenUx::getNewInstance(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +std::shared_ptr<SimulationParameter> SimulationParameterTaylorGreenUx::getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) { - return std::shared_ptr<SimulationParameter>(new SimulationParameterTaylorGreenUx(kernelName, ux, amplitude, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, filePath, devices)); + return std::shared_ptr<SimulationParameter>(new SimulationParameterTaylorGreenUx(kernelName, viscosity, tgvParameterStruct, gridInfo)); } double SimulationParameterTaylorGreenUx::getMaxVelocity() @@ -15,14 +17,19 @@ double SimulationParameterTaylorGreenUx::getMaxVelocity() return ux / (lx / l0); } -SimulationParameterTaylorGreenUx::SimulationParameterTaylorGreenUx(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -:SimulationParameterImp("TaylorGreenVortex Ux", viscosity, lx, lz, l0, lx, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), ux(ux), amplitude(amplitude), rho0(rho0) +SimulationParameterTaylorGreenUx::SimulationParameterTaylorGreenUx(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) +:SimulationParameterImp(kernelName, viscosity, tgvParameterStruct->basicSimulationParameter, gridInfo) { + this->ux = tgvParameterStruct->ux; + this->amplitude = tgvParameterStruct->amplitude; + this->l0 = tgvParameterStruct->l0; + this->timeStepLength = tgvParameterStruct->basicTimeStepLength * (gridInfo->lx / l0)*(gridInfo->lx / l0); + this->rho0 = tgvParameterStruct->rho0; + std::ostringstream oss; - oss << filePath << "\\TaylorGreenVortex Ux\\" << viscosity << "\\ux_" << ux << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lx; - generateFilePath(oss.str()); + oss << tgvParameterStruct->vtkFilePath << "\\TaylorGreenVortex Ux\\" << viscosity << "\\ux_" << ux << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lx; + generateFileDirectionInMyStystem(oss.str()); this->filePath = oss.str(); initialCondition = InitialConditionTaylorGreenUx::getNewInstance(lx, lz, l0, ux, amplitude, rho0); - kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); } diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h index aa9932268..31752e8fc 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h @@ -6,28 +6,16 @@ #include <string> #include <memory> -class PhiAndNuTest; +struct TaylorGreenVortexUxParameterStruct; class SimulationParameterTaylorGreenUx : public SimulationParameterImp { public: - static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, - real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); double getMaxVelocity(); protected: - SimulationParameterTaylorGreenUx(std::string kernelName, real ux, real amplitude, - real viscosity, real rho0, real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + SimulationParameterTaylorGreenUx(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); private: real ux, amplitude, rho0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h new file mode 100644 index 000000000..1244cdb15 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h @@ -0,0 +1,19 @@ +#ifndef TAYLOR_GREEN_VORTEX_UX_PARAMETER_STRUCT_H +#define TAYLOR_GREEN_VORTEX_UX_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities\Structs\BasicSimulationParameterStruct.h" + +struct TaylorGreenVortexUxParameterStruct +{ + std::shared_ptr<BasicSimulationParameterStruct> basicSimulationParameter; + + double ux; + double amplitude; + int basicTimeStepLength; + double l0; + double rho0; + std::string vtkFilePath; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp index 7d5a19b83..01b5e4c2b 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp @@ -1,11 +1,13 @@ #include "AnalyticalResultsTaylorGreenVortexUz.h" +#include "Simulations\TaylorGreenVortexUz\TaylorGreenVortexUzParameterStruct.h" + #define _USE_MATH_DEFINES #include <math.h> -std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUz::getNewInstance(double viscosity, double uz, double amplitude, double l0, double rho0) +std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUz::getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct) { - return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUz(viscosity, uz, amplitude, l0, rho0)); + return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUz(viscosity, simParaStruct)); } void AnalyticalResultsTaylorGreenUz::calc(std::shared_ptr< SimulationResults> simResults) @@ -24,7 +26,11 @@ void AnalyticalResultsTaylorGreenUz::calc(std::shared_ptr< SimulationResults> si calculated = true; } -AnalyticalResultsTaylorGreenUz::AnalyticalResultsTaylorGreenUz(double viscosity, double uz, double amplitude, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), uz(uz), amplitude(amplitude), l0(l0), rho0(rho0) +AnalyticalResultsTaylorGreenUz::AnalyticalResultsTaylorGreenUz(double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct) : AnalyticalResultsImp() { - + this->viscosity = viscosity; + this->uz = simParaStruct->uz; + this->amplitude = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + this->rho0 = simParaStruct->rho0; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h index 9b9548615..0cd44ee60 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h @@ -3,16 +3,18 @@ #include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" +struct TaylorGreenVortexUzParameterStruct; + class AnalyticalResultsTaylorGreenUz : public AnalyticalResultsImp { public: - static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double uz, double amplitude, double l0, double rho0); + static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct); void calc(std::shared_ptr< SimulationResults> simResults); private: AnalyticalResultsTaylorGreenUz() {}; - AnalyticalResultsTaylorGreenUz(double viscosity, double uz, double amplitude, double l0, double rho0); + AnalyticalResultsTaylorGreenUz(double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct); double viscosity, rho0; double l0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp index 64a4f26fd..48693c653 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp @@ -1,21 +1,21 @@ #include "LogFileInformationTaylorGreenVortexUz.h" -std::shared_ptr<LogFileInformationTaylorGreenUz> LogFileInformationTaylorGreenUz::getNewInstance(double uz, double amplitude, std::vector< bool> tests, std::vector<double> l, int l0) +#include "Simulations\TaylorGreenVortexUz\TaylorGreenVortexUzParameterStruct.h" + +std::shared_ptr<LogFileInformationTaylorGreenUz> LogFileInformationTaylorGreenUz::getNewInstance(std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct) { - return std::shared_ptr<LogFileInformationTaylorGreenUz>(new LogFileInformationTaylorGreenUz(uz, amplitude, tests, l, l0)); + return std::shared_ptr<LogFileInformationTaylorGreenUz>(new LogFileInformationTaylorGreenUz(simParaStruct, gridInfoStruct)); } std::string LogFileInformationTaylorGreenUz::getOutput() { makeCenterHead("TaylorGreenVortex V0 Information"); - for (int i = 0; i < tests.size(); i++) { - if (tests.at(i)) { - oss << "Lx=" << l.at(i) << std::endl; - oss << "l0=" << l0 << std::endl; - oss << "uz=" << uz / (l.at(i) / l0) << std::endl; - oss << "Amplitude=" << amplitude / (l.at(i) / l0) << std::endl; - oss << std::endl; - } + for (int i = 0; i < lz.size(); i++) { + oss << "Lz=" << lz.at(i) << std::endl; + oss << "l0=" << l0 << std::endl; + oss << "uz=" << uz / (lz.at(i) / l0) << std::endl; + oss << "Amplitude=" << amplitude / (lz.at(i) / l0) << std::endl; + oss << std::endl; } return oss.str(); @@ -35,6 +35,12 @@ std::string LogFileInformationTaylorGreenUz::getFilePathExtensionTwo() return oss.str(); } -LogFileInformationTaylorGreenUz::LogFileInformationTaylorGreenUz(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0) : uz(uz), amplitude(amplitude), tests(tests), l(l), l0(l0) +LogFileInformationTaylorGreenUz::LogFileInformationTaylorGreenUz(std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector< std::shared_ptr< GridInformationStruct> > gridInfoStruct) { + this->uz = simParaStruct->uz; + this->amplitude = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + + for (int i = 0; i < gridInfoStruct.size(); i++) + lz.push_back(gridInfoStruct.at(i)->lz); } diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h index 3fa697e1a..8992b20f6 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h @@ -7,10 +7,13 @@ #include <memory> #include <vector> -class LogFileInformationTaylorGreenUz : public LogFileInformationImp, public SimulationLogFileInformation +struct TaylorGreenVortexUzParameterStruct; +struct GridInformationStruct; + +class LogFileInformationTaylorGreenUz : public SimulationLogFileInformation { public: - static std::shared_ptr<LogFileInformationTaylorGreenUz> getNewInstance(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + static std::shared_ptr<LogFileInformationTaylorGreenUz> getNewInstance(std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); std::string getOutput(); std::string getFilePathExtensionOne(); @@ -18,12 +21,11 @@ public: private: LogFileInformationTaylorGreenUz() {}; - LogFileInformationTaylorGreenUz(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + LogFileInformationTaylorGreenUz(std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); double uz; double amplitude; - std::vector< bool> tests; - std::vector< double> l; + std::vector< double> lz; int l0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp index f4461b7c3..cc7858052 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp @@ -1,17 +1,19 @@ #include "SimulationInfoTaylorGreenVortexUz.h" +#include "Simulations\TaylorGreenVortexUz\TaylorGreenVortexUzParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + #include <sstream> -std::shared_ptr<SimulationInfoTaylorGreenUz> SimulationInfoTaylorGreenUz::getNewInstance(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations) +std::shared_ptr<SimulationInfoTaylorGreenUz> SimulationInfoTaylorGreenUz::getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations) { - return std::shared_ptr<SimulationInfoTaylorGreenUz>(new SimulationInfoTaylorGreenUz(uz, amplitude, l0, lz, viscosity, kernelName, numberOfSimulations)); + return std::shared_ptr<SimulationInfoTaylorGreenUz>(new SimulationInfoTaylorGreenUz(simID, kernelName, viscosity, simParaStruct, gridInfoStruct, numberOfSimulations)); } -SimulationInfoTaylorGreenUz::SimulationInfoTaylorGreenUz(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lz, viscosity, kernelName, numberOfSimulations) +SimulationInfoTaylorGreenUz::SimulationInfoTaylorGreenUz(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations) + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lz, numberOfSimulations, "TaylorGreenVortex Uz") { std::ostringstream oss; - oss << " uz: " << uz / (lz / l0) << " Amplitude: " << amplitude / (lz / l0); + oss << " uz: " << simParaStruct->uz / (gridInfoStruct->lz / simParaStruct->l0) << " Amplitude: " << simParaStruct->amplitude / (gridInfoStruct->lz / simParaStruct->l0); this->simulationParameterString = oss.str(); - - simulationName = "TaylorGreenVortex Uz"; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h index 3613d241a..44183d8b4 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h @@ -5,14 +5,17 @@ #include <memory> +struct TaylorGreenVortexUzParameterStruct; +struct GridInformationStruct; + class SimulationInfoTaylorGreenUz : public SimulationInfoImp { public: - static std::shared_ptr< SimulationInfoTaylorGreenUz> getNewInstance(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations); + static std::shared_ptr< SimulationInfoTaylorGreenUz> getNewInstance(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations); private: SimulationInfoTaylorGreenUz() {}; - SimulationInfoTaylorGreenUz(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations); + SimulationInfoTaylorGreenUz(int simID, std::string kernelName, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr< GridInformationStruct> gridInfoStruct, int numberOfSimulations); }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp index 4ea94437d..f3c99bb94 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp @@ -1,13 +1,13 @@ #include "SimulationParameterTaylorGreenVortexUz.h" #include "Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h" -#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" +#include "Simulations\TaylorGreenVortexUz\TaylorGreenVortexUzParameterStruct.h" #include <sstream> -std::shared_ptr<SimulationParameterTaylorGreenUz> SimulationParameterTaylorGreenUz::getNewInstance(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +std::shared_ptr<SimulationParameterTaylorGreenUz> SimulationParameterTaylorGreenUz::getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) { - return std::shared_ptr<SimulationParameterTaylorGreenUz>(new SimulationParameterTaylorGreenUz(kernelName, uz, amplitude, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, filePath, devices)); + return std::shared_ptr<SimulationParameterTaylorGreenUz>(new SimulationParameterTaylorGreenUz(kernelName, viscosity, tgvParameterStruct, gridInfo)); } double SimulationParameterTaylorGreenUz::getMaxVelocity() @@ -15,14 +15,19 @@ double SimulationParameterTaylorGreenUz::getMaxVelocity() return uz / (lz / l0); } -SimulationParameterTaylorGreenUz::SimulationParameterTaylorGreenUz(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -:SimulationParameterImp("TaylorGreenVortex Uz", viscosity, lx, lz, l0, lz, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), uz(uz), amplitude(amplitude), rho0(rho0) +SimulationParameterTaylorGreenUz::SimulationParameterTaylorGreenUz(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo) +:SimulationParameterImp(kernelName, viscosity, tgvParameterStruct->basicSimulationParameter, gridInfo) { + this->uz = tgvParameterStruct->uz; + this->amplitude = tgvParameterStruct->amplitude; + this->l0 = tgvParameterStruct->l0; + this->timeStepLength = tgvParameterStruct->basicTimeStepLength * (gridInfo->lz / l0)*(gridInfo->lz / l0); + this->rho0 = tgvParameterStruct->rho0; + std::ostringstream oss; - oss << filePath << "\\TaylorGreenVortex Uz\\viscosity_" << viscosity << "\\uz_" << uz << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lx; - generateFilePath(oss.str()); + oss << tgvParameterStruct->vtkFilePath << "\\TaylorGreenVortex Uz\\viscosity_" << viscosity << "\\uz_" << uz << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lx; + generateFileDirectionInMyStystem(oss.str()); this->filePath = oss.str(); initialCondition = InitialConditionTaylorGreenUz::getNewInstance(lx, lz, l0, uz, amplitude, rho0); - kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); } diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h index a73dcb1c8..9b2fd581b 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h @@ -6,27 +6,17 @@ #include <string> #include <memory> +struct TaylorGreenVortexUzParameterStruct; +struct GridInformationStruct; class SimulationParameterTaylorGreenUz : public SimulationParameterImp { public: - static std::shared_ptr<SimulationParameterTaylorGreenUz> getNewInstance(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, - real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + static std::shared_ptr<SimulationParameterTaylorGreenUz> getNewInstance(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); double getMaxVelocity(); protected: - SimulationParameterTaylorGreenUz(std::string kernelName, real uz, real amplitude, - real viscosity, real rho0, real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, std::string filePath, - std::vector<int> devices); + SimulationParameterTaylorGreenUz(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> tgvParameterStruct, std::shared_ptr<GridInformationStruct> gridInfo); private: real uz, amplitude, rho0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h new file mode 100644 index 000000000..b6144a1d6 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h @@ -0,0 +1,20 @@ +#ifndef TAYLOR_GREEN_VORTEX_UZ_PARAMETER_STRUCT_H +#define TAYLOR_GREEN_VORTEX_UZ_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities\Structs\BasicSimulationParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + +struct TaylorGreenVortexUzParameterStruct +{ + std::shared_ptr<BasicSimulationParameterStruct> basicSimulationParameter; + + double uz; + double amplitude; + int basicTimeStepLength; + double l0; + double rho0; + std::string vtkFilePath; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp index 7aefc0922..54bff0969 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp @@ -5,12 +5,13 @@ #include "Utilities\Results\SimulationResults\SimulationResults.h" #include "Tests\L2NormTest\PostProcessingStrategy\PostProcessingStrategyL2NormTest.h" +#include "Tests\L2NormTest\L2NormTestParameterStruct.h" #include <iomanip> -std::shared_ptr<L2NormTest> L2NormTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) +std::shared_ptr<L2NormTest> L2NormTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate) { - return std::shared_ptr<L2NormTest>(new L2NormTest(colorOutput, dataToCalculate, maxL2NormDiff, basicTimeStep, divergentTimeStep)); + return std::shared_ptr<L2NormTest>(new L2NormTest(colorOutput, testParameter, dataToCalculate)); } void L2NormTest::update() @@ -67,8 +68,10 @@ void L2NormTest::makeConsoleOutput() colorOutput->makeL2NormTestOutput(testPassed, simInfos.at(0), basicTimeStep, divergentTimeStep, dataToCalculate, resultBasicTimestep, resultDivergentTimeStep, diffL2Norm); } -L2NormTest::L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) - : TestImp(colorOutput), basicTimeStep(basicTimeStep), divergentTimeStep(divergentTimeStep), dataToCalculate(dataToCalculate), maxL2NormDiff(maxL2NormDiff) +L2NormTest::L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate) + : TestImp(colorOutput), dataToCalculate(dataToCalculate) { - + basicTimeStep = testParameter->basicTimeStep; + divergentTimeStep = testParameter->divergentTimeStep; + maxL2NormDiff = testParameter->maxDiff; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h index 219e607b2..5486b4de5 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h @@ -9,10 +9,12 @@ class L2NormCalculator; class AnalyticalResults; class L2NormPostProcessingStrategy; +struct L2NormTestParameterStruct; + class L2NormTest : public TestImp { public: - static std::shared_ptr<L2NormTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); + static std::shared_ptr<L2NormTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate); void update(); void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< L2NormPostProcessingStrategy> postProStrategy); @@ -22,7 +24,7 @@ public: void makeConsoleOutput(); private: - L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); + L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate); unsigned int basicTimeStep, divergentTimeStep; double resultBasicTimestep, resultDivergentTimeStep; diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestParameterStruct.h b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestParameterStruct.h new file mode 100644 index 000000000..31dd98843 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestParameterStruct.h @@ -0,0 +1,17 @@ +#ifndef L2_NORM_TEST_PARAMETER_STRUCT_H +#define L2_NORM_TEST_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities\Structs\BasicTestParameterStruct.h" + +struct L2NormTestParameterStruct +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter; + + double maxDiff; + unsigned int basicTimeStep; + unsigned int divergentTimeStep; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestStruct.h b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestStruct.h new file mode 100644 index 000000000..5f18a48e3 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTestStruct.h @@ -0,0 +1,20 @@ +#ifndef L2_NORM_TEST_STRUCT_H +#define L2_NORM_TEST_STRUCT_H + +#include <memory> +#include <vector> + +class L2NormTest; +class L2NormInformation; +class L2NormPostProcessingStrategy; + + +struct L2NormTestStruct +{ + std::shared_ptr<L2NormInformation> logFileInfo; + + std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProcessingStrategies; + std::vector<std::shared_ptr<L2NormTest> > tests; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp index 7e83bbc84..25a4419d3 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp @@ -1,13 +1,14 @@ #include "L2NormLogFileInformation.h" #include "Tests\L2NormTest\L2NormTest.h" +#include "Tests\L2NormTest\L2NormTestParameterStruct.h" #include <iomanip> #include <sstream> -std::shared_ptr<L2NormInformation> L2NormInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTest>> tests, unsigned int basicTimeStep, unsigned int divergentTimeStep) +std::shared_ptr<L2NormInformation> L2NormInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTest>> tests, std::shared_ptr<L2NormTestParameterStruct> testParameter) { - return std::shared_ptr<L2NormInformation>(new L2NormInformation(tests, basicTimeStep, divergentTimeStep)); + return std::shared_ptr<L2NormInformation>(new L2NormInformation(tests, testParameter)); } std::string L2NormInformation::getOutput() @@ -26,7 +27,8 @@ std::string L2NormInformation::getOutput() return oss.str(); } -L2NormInformation::L2NormInformation(std::vector<std::shared_ptr<L2NormTest>> tests, unsigned int basicTimeStep, unsigned int divergentTimeStep) : tests(tests), basicTimeStep(basicTimeStep), divergentTimeStep(divergentTimeStep) +L2NormInformation::L2NormInformation(std::vector<std::shared_ptr<L2NormTest>> tests, std::shared_ptr<L2NormTestParameterStruct> testParameter) : tests(tests) { - + basicTimeStep = testParameter->basicTimeStep; + divergentTimeStep = testParameter->divergentTimeStep; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h index 54ec63157..cf365298c 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h @@ -7,17 +7,18 @@ #include <vector> class L2NormTest; +struct L2NormTestParameterStruct; class L2NormInformation : public TestLogFileInformation { public: - static std::shared_ptr< L2NormInformation> getNewInstance(std::vector< std::shared_ptr< L2NormTest>> tests, unsigned int basicTimeStep, unsigned int divergentTimeStep); + static std::shared_ptr< L2NormInformation> getNewInstance(std::vector< std::shared_ptr< L2NormTest>> tests, std::shared_ptr<L2NormTestParameterStruct> testParameter); std::string getOutput(); private: L2NormInformation() {}; - L2NormInformation(std::vector< std::shared_ptr< L2NormTest>> tests, unsigned int basicTimeStep, unsigned int divergentTimeStep); + L2NormInformation(std::vector< std::shared_ptr< L2NormTest>> tests, std::shared_ptr<L2NormTestParameterStruct> testParameter); std::vector< std::shared_ptr< L2NormTest>> tests; diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp index f386f1ac9..377bde016 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp @@ -1,17 +1,23 @@ #include "PostProcessingStrategyL2NormTest.h" +#include "Tests\L2NormTest\L2NormTestParameterStruct.h" + #include "Utilities\Calculator\L2NormCalculator\L2NormCalculator.h" #include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" #include "Utilities\Results\SimulationResults\SimulationResults.h" -std::shared_ptr<L2NormPostProcessingStrategy> L2NormPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) +std::shared_ptr<L2NormPostProcessingStrategy> L2NormPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara) { - return std::shared_ptr<L2NormPostProcessingStrategy>(new L2NormPostProcessingStrategy(simResult, analyticalResult, dataToCalculateL2, basicTimeStepL2Norm, divergentTimeStepL2Norm)); + return std::shared_ptr<L2NormPostProcessingStrategy>(new L2NormPostProcessingStrategy(simResult, analyticalResult, testPara)); } -L2NormPostProcessingStrategy::L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) - : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculateL2(dataToCalculateL2), basicTimeStepL2Norm(basicTimeStepL2Norm), divergentTimeStepL2Norm(divergentTimeStepL2Norm) +L2NormPostProcessingStrategy::L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) { + dataToCalculateL2 = testPara->basicTestParameter->dataToCalc; + basicTimeStepL2Norm = testPara->basicTimeStep; + divergentTimeStepL2Norm = testPara->divergentTimeStep; + isEvaluated = false; l2Normcalculator = L2NormCalculator::getInstance(); } @@ -25,24 +31,24 @@ void L2NormPostProcessingStrategy::evaluate() for (int i = 0; i < dataToCalculateL2.size(); i++) { if (dataToCalculateL2.at(i) == "Vx") { - l2VxBasic = l2Normcalculator->calc(analyticalResult->getVx().at(bS), simResult->getVx().at(bS), simResult->getLevels().at(bS)); - l2VxDivergent = l2Normcalculator->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS)); + l2VxBasic = l2Normcalculator->calc(analyticalResult->getVx().at(bS), simResult->getVx().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + l2VxDivergent = l2Normcalculator->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); } if (dataToCalculateL2.at(i) == "Vy") { - l2VyBasic = l2Normcalculator->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS)); - l2VyDivergent = l2Normcalculator->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS)); + l2VyBasic = l2Normcalculator->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + l2VyDivergent = l2Normcalculator->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); } if (dataToCalculateL2.at(i) == "Vz") { - l2VzBasic = l2Normcalculator->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS)); - l2VzDivergent = l2Normcalculator->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS)); + l2VzBasic = l2Normcalculator->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + l2VzDivergent = l2Normcalculator->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); } if (dataToCalculateL2.at(i) == "Press") { - l2PressBasic = l2Normcalculator->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS)); - l2PressDivergent = l2Normcalculator->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS)); + l2PressBasic = l2Normcalculator->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + l2PressDivergent = l2Normcalculator->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); } if (dataToCalculateL2.at(i) == "Rho") { - l2RhoBasic = l2Normcalculator->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS)); - l2RhoDivergent = l2Normcalculator->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS)); + l2RhoBasic = l2Normcalculator->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + l2RhoDivergent = l2Normcalculator->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); } } isEvaluated = true; diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h index 84c249cc8..a29a72a4c 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h @@ -7,11 +7,12 @@ class AnalyticalResults; class L2NormCalculator; +struct L2NormTestParameterStruct; class L2NormPostProcessingStrategy : public PostProcessingStrategyImp { public: - static std::shared_ptr< L2NormPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); + static std::shared_ptr< L2NormPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara); void evaluate(); std::vector< double> getL2NormVx(); @@ -21,7 +22,7 @@ public: std::vector< double> getL2NormRho(); private: - L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); + L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara); bool isEvaluated; std::shared_ptr< L2NormCalculator> l2Normcalculator; diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp index 13fbff32b..3b1644be6 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp @@ -30,27 +30,27 @@ void L2NormTestBetweenKernels::evaluate() if (dataToCalculate == "Vx") { basicL2Result = basicPostProcessingStrategy->getL2NormVx(timeStep); divergentL2Result = divergentPostProcessingStrategy->getL2NormVx(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVx().at(tS), divergentSimResults->getVx().at(tS), basicSimResults->getLevels().at(tS)); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVx().at(tS), divergentSimResults->getVx().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); } if (dataToCalculate == "Vy") { basicL2Result = basicPostProcessingStrategy->getL2NormVy(timeStep); divergentL2Result = divergentPostProcessingStrategy->getL2NormVy(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(tS), divergentSimResults->getVy().at(tS), basicSimResults->getLevels().at(tS)); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(tS), divergentSimResults->getVy().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); } if (dataToCalculate == "Vz") { basicL2Result = basicPostProcessingStrategy->getL2NormVz(timeStep); divergentL2Result = divergentPostProcessingStrategy->getL2NormVz(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(tS), divergentSimResults->getVz().at(tS), basicSimResults->getLevels().at(tS)); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(tS), divergentSimResults->getVz().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); } if (dataToCalculate == "Press") { basicL2Result = basicPostProcessingStrategy->getL2NormPress(timeStep); divergentL2Result = divergentPostProcessingStrategy->getL2NormPress(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(tS), divergentSimResults->getPress().at(tS), basicSimResults->getLevels().at(tS)); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(tS), divergentSimResults->getPress().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); } if (dataToCalculate == "Rho") { basicL2Result = basicPostProcessingStrategy->getL2NormRho(timeStep); divergentL2Result = divergentPostProcessingStrategy->getL2NormRho(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(tS), divergentSimResults->getRho().at(tS), basicSimResults->getLevels().at(tS)); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(tS), divergentSimResults->getRho().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); } if (basicL2Result < divergentL2Result) diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h new file mode 100644 index 000000000..4adcbcb12 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h @@ -0,0 +1,20 @@ +#ifndef L2_NORM_TEST_BETWEEN_KERNELS_PARAMETER_STRUCT_H +#define L2_NORM_TEST_BETWEEN_KERNELS_PARAMETER_STRUCT_H + +#include <memory> +#include <string> +#include <vector> + +#include "Utilities\Structs\BasicTestParameterStruct.h" + +struct L2NormTestBetweenKernelsParameterStruct +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter; + + std::string basicKernel; + + std::vector<std::string> kernelsToTest; + std::vector< int> timeSteps; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsStruct.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsStruct.h new file mode 100644 index 000000000..f724c0b2c --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsStruct.h @@ -0,0 +1,19 @@ +#ifndef L2_NORM_TEST_BETWEEN_KERNELS_STRUCT_H +#define L2_NORM_TEST_BETWEEN_KERNELS_STRUCT_H + +#include <memory> +#include <string> +#include <vector> + +class L2NormTestBetweenKernels; +class L2NormBetweenKernelPostProcessingStrategy; +class L2NormBetweenKernelsInformation; + +struct L2NormTestBetweenKernelsStruct +{ + std::shared_ptr<L2NormBetweenKernelsInformation> logFileInfo; + + std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp index 0e78870c7..7b000804c 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp @@ -1,13 +1,14 @@ #include "L2NormLogFileInformationBetweenKernels.h" #include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernels.h" +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernelsParameterStruct.h" #include <iomanip> #include <sstream> -std::shared_ptr<L2NormBetweenKernelsInformation> L2NormBetweenKernelsInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc) +std::shared_ptr<L2NormBetweenKernelsInformation> L2NormBetweenKernelsInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) { - return std::shared_ptr<L2NormBetweenKernelsInformation>(new L2NormBetweenKernelsInformation(tests, basicKernel, timeSteps, dataToCalc)); + return std::shared_ptr<L2NormBetweenKernelsInformation>(new L2NormBetweenKernelsInformation(tests, testPara)); } std::string L2NormBetweenKernelsInformation::getOutput() @@ -34,9 +35,12 @@ std::string L2NormBetweenKernelsInformation::getOutput() return oss.str(); } -L2NormBetweenKernelsInformation::L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc) : tests(tests), basicKernel(basicKernel), timeSteps(timeSteps), dataToCalc(dataToCalc) +L2NormBetweenKernelsInformation::L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) + : tests(tests) { - + basicKernel = testPara->basicKernel; + timeSteps = testPara->timeSteps; + dataToCalc = testPara->basicTestParameter->dataToCalc; } void L2NormBetweenKernelsInformation::deleteLastCharInOss() diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h index 80dfa3450..140008899 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h @@ -7,17 +7,18 @@ #include <vector> class L2NormTestBetweenKernels; +struct L2NormTestBetweenKernelsParameterStruct; class L2NormBetweenKernelsInformation : public TestLogFileInformation { public: - static std::shared_ptr< L2NormBetweenKernelsInformation> getNewInstance(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc); + static std::shared_ptr< L2NormBetweenKernelsInformation> getNewInstance(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); std::string getOutput(); private: L2NormBetweenKernelsInformation() {}; - L2NormBetweenKernelsInformation(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc); + L2NormBetweenKernelsInformation(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); void deleteLastCharInOss(); diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp index 37b2edb58..aced6d158 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp @@ -4,9 +4,11 @@ #include "Utilities\Results\SimulationResults\SimulationResults.h" #include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" -std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> L2NormBetweenKernelPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate) +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernelsParameterStruct.h" + +std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> L2NormBetweenKernelPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) { - return std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy>(new L2NormBetweenKernelPostProcessingStrategy(simResult, analyticalResult, timeSteps, dataToCalculate)); + return std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy>(new L2NormBetweenKernelPostProcessingStrategy(simResult, analyticalResult, testPara)); } void L2NormBetweenKernelPostProcessingStrategy::evaluate() @@ -19,15 +21,15 @@ void L2NormBetweenKernelPostProcessingStrategy::evaluate() for (int i = 0; i < timeSteps.size(); i++) { int time = calcTimeStepInResults(timeSteps.at(i)); if (dataToCalculate.at(j) == "Vx") - l2Vx.push_back(l2Normcalculator->calc(analyticalResult->getVx().at(time), simResult->getVx().at(time), simResult->getLevels().at(time))); + l2Vx.push_back(l2Normcalculator->calc(analyticalResult->getVx().at(time), simResult->getVx().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); if (dataToCalculate.at(j) == "Vy") - l2Vy.push_back(l2Normcalculator->calc(analyticalResult->getVy().at(time), simResult->getVy().at(time), simResult->getLevels().at(time))); + l2Vy.push_back(l2Normcalculator->calc(analyticalResult->getVy().at(time), simResult->getVy().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); if (dataToCalculate.at(j) == "Vz") - l2Vz.push_back(l2Normcalculator->calc(analyticalResult->getVz().at(time), simResult->getVz().at(time), simResult->getLevels().at(time))); + l2Vz.push_back(l2Normcalculator->calc(analyticalResult->getVz().at(time), simResult->getVz().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); if (dataToCalculate.at(j) == "Press") - l2Press.push_back(l2Normcalculator->calc(analyticalResult->getPress().at(time), simResult->getPress().at(time), simResult->getLevels().at(time))); + l2Press.push_back(l2Normcalculator->calc(analyticalResult->getPress().at(time), simResult->getPress().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); if (dataToCalculate.at(j) == "Rho") - l2Rho.push_back(l2Normcalculator->calc(analyticalResult->getRho().at(time), simResult->getRho().at(time), simResult->getLevels().at(time))); + l2Rho.push_back(l2Normcalculator->calc(analyticalResult->getRho().at(time), simResult->getRho().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); } } isEvaluated = true; @@ -64,8 +66,11 @@ std::shared_ptr<SimulationResults> L2NormBetweenKernelPostProcessingStrategy::ge return simResult; } -L2NormBetweenKernelPostProcessingStrategy::L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate) : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), timeSteps(timeSteps), dataToCalculate(dataToCalculate) +L2NormBetweenKernelPostProcessingStrategy::L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) { + timeSteps = testPara->timeSteps; + dataToCalculate = testPara->basicTestParameter->dataToCalc; l2Normcalculator = L2NormCalculator::getInstance(); isEvaluated = false; } diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h index c8e96126a..84b4fb1ea 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h @@ -7,11 +7,12 @@ class AnalyticalResults; class L2NormCalculator; +struct L2NormTestBetweenKernelsParameterStruct; class L2NormBetweenKernelPostProcessingStrategy : public PostProcessingStrategyImp { public: - static std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate); + static std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); void evaluate(); double getL2NormVx(int timeStep); @@ -23,7 +24,7 @@ public: virtual std::shared_ptr< SimulationResults> getSimulationResult(); private: - L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate); + L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); int calcPosInTimeStep(int time); diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp index 4aa25fad1..a54e88d97 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp @@ -1,14 +1,15 @@ #include "PhiAndNuLogFileInformation.h" #include "Tests\PhiAndNuTest\PhiAndNuTest.h" +#include "Tests\PhiAndNuTest\PhiAndNuTestParameterStruct.h" #include <iomanip> #include <sstream> -std::shared_ptr<PhiAndNuInformation> PhiAndNuInformation::getNewInstance(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) +std::shared_ptr<PhiAndNuInformation> PhiAndNuInformation::getNewInstance(std::shared_ptr<PhiAndNuTestParameterStruct> testPara) { - return std::shared_ptr<PhiAndNuInformation>(new PhiAndNuInformation(startTimeStepCalculation, endTimeStepCalculation)); + return std::shared_ptr<PhiAndNuInformation>(new PhiAndNuInformation(testPara)); } std::string PhiAndNuInformation::getOutput() @@ -92,7 +93,8 @@ void PhiAndNuInformation::fillMyData(std::vector<std::shared_ptr<PhiAndNuTest>> } -PhiAndNuInformation::PhiAndNuInformation(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) : startTimeStepCalculation(startTimeStepCalculation), endTimeStepCalculation(endTimeStepCalculation) +PhiAndNuInformation::PhiAndNuInformation(std::shared_ptr<PhiAndNuTestParameterStruct> testPara) { - + startTimeStepCalculation = testPara->startTimeStepCalculation; + endTimeStepCalculation = testPara->endTimeStepCalculation; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h index fb5d6f9f7..3f17dcedd 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h @@ -7,24 +7,24 @@ #include <vector> class PhiAndNuTest; +struct PhiAndNuTestParameterStruct; class PhiAndNuInformation : public TestLogFileInformation { public: - static std::shared_ptr< PhiAndNuInformation> getNewInstance(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); + static std::shared_ptr< PhiAndNuInformation> getNewInstance(std::shared_ptr<PhiAndNuTestParameterStruct> testPara); std::string getOutput(); void addTestGroup(std::vector< std::shared_ptr< PhiAndNuTest>> tests); private: - void fillMyData(std::vector< std::shared_ptr< PhiAndNuTest>> testGroup); - PhiAndNuInformation() {}; - PhiAndNuInformation(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); + PhiAndNuInformation(std::shared_ptr<PhiAndNuTestParameterStruct> testPara); + + void fillMyData(std::vector< std::shared_ptr< PhiAndNuTest>> testGroup); std::vector< std::vector< std::shared_ptr< PhiAndNuTest>>> testGroups; unsigned int startTimeStepCalculation, endTimeStepCalculation; - std::vector<int> lx; std::vector<int> lxForErase; std::vector<double> phiDiff; diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp index 2f14dcea8..5130f1841 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp @@ -5,12 +5,13 @@ #include "Utilities\SimulationInfo\SimulationInfo.h" #include "Tests\PhiAndNuTest\PostProcessingStrategy\PostProcessingStrategyPhiAndNuTest.h" +#include "Tests\PhiAndNuTest\PhiAndNuTestParameterStruct.h" #include <iomanip> -std::shared_ptr<PhiAndNuTest> PhiAndNuTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation) +std::shared_ptr<PhiAndNuTest> PhiAndNuTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNuTestParameterStruct> testPara, std::string dataToCalculate) { - return std::shared_ptr<PhiAndNuTest>(new PhiAndNuTest(colorOutput, dataToCalculate, minOrderOfAccuracy, viscosity, startStepCalculation, endStepCalculation)); + return std::shared_ptr<PhiAndNuTest>(new PhiAndNuTest(colorOutput, viscosity, testPara, dataToCalculate)); } void PhiAndNuTest::evaluate() @@ -102,8 +103,13 @@ double PhiAndNuTest::getOrderOfAccuracyPhiDiff() return orderOfAccuracyPhiDiff; } -PhiAndNuTest::PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation) : TestImp(colorOutput), minOrderOfAccuracy(minOrderOfAccuracy), viscosity(viscosity), dataToCalculate(dataToCalculate), startStepCalculation(startStepCalculation), endStepCalculation(endStepCalculation) +PhiAndNuTest::PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNuTestParameterStruct> testPara, std::string dataToCalculate) + : TestImp(colorOutput), viscosity(viscosity), dataToCalculate(dataToCalculate) { + minOrderOfAccuracy = testPara->minOrderOfAccuracy; + startStepCalculation = testPara->startTimeStepCalculation; + endStepCalculation = testPara->endTimeStepCalculation; + lx.resize(0); phiDiff.resize(0); nuDiff.resize(0); diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h index b1146ba89..bd1bf9e19 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h @@ -9,11 +9,12 @@ class FFTCalculator; class PhiAndNuTestPostProcessingStrategy; +struct PhiAndNuTestParameterStruct; class PhiAndNuTest : public TestImp { public: - static std::shared_ptr<PhiAndNuTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation); + static std::shared_ptr<PhiAndNuTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNuTestParameterStruct> testPara, std::string dataToCalculate); void update(); void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PhiAndNuTestPostProcessingStrategy> postProStrategy); @@ -32,7 +33,7 @@ public: private: - PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation); + PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNuTestParameterStruct> testPara, std::string dataToCalculate); double calcOrderOfAccuracy(std::vector<double> data); bool checkTestPassed(double orderOfAccuracy); std::vector< double> calcNuDiff(std::vector< double> nu); diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestParameterStruct.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestParameterStruct.h new file mode 100644 index 000000000..4eb553755 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestParameterStruct.h @@ -0,0 +1,16 @@ +#ifndef PHI_AND_NU_TEST_PARAMETER_STRUCT_H +#define PHI_AND_NU_TEST_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities\Structs\BasicTestParameterStruct.h" + +struct PhiAndNuTestParameterStruct +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter; + + double minOrderOfAccuracy; + unsigned int startTimeStepCalculation; + unsigned int endTimeStepCalculation; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestStruct.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestStruct.h new file mode 100644 index 000000000..be37702bb --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTestStruct.h @@ -0,0 +1,18 @@ +#ifndef PHI_AND_NU_TEST_STRUCT_H +#define PHI_AND_NU_TEST_STRUCT_H + +#include <memory> +#include <vector> + +class PhiAndNuInformation; +class PhiAndNuTestPostProcessingStrategy; +class PhiAndNuTest; + +struct PhiAndNuTestStruct +{ + std::shared_ptr<PhiAndNuInformation> logFileInfo; + + std::vector<std::shared_ptr<PhiAndNuTestPostProcessingStrategy> > postProcessingStrategies; + std::vector<std::shared_ptr<PhiAndNuTest> > tests; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp index 2137a7c1c..9eb281120 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp @@ -4,14 +4,20 @@ #include "Utilities\Calculator\FFTCalculator\FFTCalculator.h" #include "Utilities\Results\SimulationResults\SimulationResults.h" -std::shared_ptr<PhiAndNuTestPostProcessingStrategy> PhiAndNuTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu) +#include "Tests\PhiAndNuTest\PhiAndNuTestParameterStruct.h" + +std::shared_ptr<PhiAndNuTestPostProcessingStrategy> PhiAndNuTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNuTestParameterStruct> testPara) { - return std::shared_ptr<PhiAndNuTestPostProcessingStrategy>(new PhiAndNuTestPostProcessingStrategy(simResult, analyticalResult, dataToCalculatePhiAndNu, startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu)); + return std::shared_ptr<PhiAndNuTestPostProcessingStrategy>(new PhiAndNuTestPostProcessingStrategy(simResult, analyticalResult, testPara)); } -PhiAndNuTestPostProcessingStrategy::PhiAndNuTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu) - : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculatePhiAndNu(dataToCalculatePhiAndNu), startTimeStepCalculationPhiNu(startTimeStepCalculationPhiNu), endTimeStepCalculationPhiNu(endTimeStepCalculationPhiNu) +PhiAndNuTestPostProcessingStrategy::PhiAndNuTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNuTestParameterStruct> testPara) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) { + dataToCalculatePhiAndNu = testPara->basicTestParameter->dataToCalc; + startTimeStepCalculationPhiNu = testPara->startTimeStepCalculation; + endTimeStepCalculationPhiNu = testPara->endTimeStepCalculation; + isEvaluated = false; fftCalculator = FFTCalculator::getNewInstance(simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); } diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h index 83eabaa24..9b63e2be9 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h @@ -7,11 +7,12 @@ class AnalyticalResults; class FFTCalculator; +struct PhiAndNuTestParameterStruct; class PhiAndNuTestPostProcessingStrategy : public PostProcessingStrategyImp { public: - static std::shared_ptr< PhiAndNuTestPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu , unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu); + static std::shared_ptr< PhiAndNuTestPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNuTestParameterStruct> testPara); void evaluate(); double getNuVx(); @@ -22,7 +23,7 @@ public: double getPhiDiffVz(); private: - PhiAndNuTestPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu); + PhiAndNuTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNuTestParameterStruct> testPara); std::vector<std::vector<double>> reduceDataToTimeSteps(std::vector<std::vector<double>> data, unsigned int startTimeStep, unsigned int endTimeStep); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp index b97dfd244..de0e79e07 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp @@ -33,6 +33,16 @@ void FFTCalculator::calc(std::vector<std::vector<double>> data, bool transposeDa phidiff = calcPhiDiff(); } +double FFTCalculator::calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData) +{ + init(); + this->transposeData = transposeData; + this->data.resize(0); + this->data.push_back(data); + std::vector<double> amplitude = calcAmplitudeForAllSteps(); + return amplitude.at(0); +} + void FFTCalculator::init() { fftResultsIm.clear(); @@ -209,7 +219,6 @@ std::vector<std::vector<double>> FFTCalculator::transpose(std::vector<std::vecto void FFTCalculator::initDataForFFT(fftw_complex * input, unsigned int step) { - for (int i = 0; i < data.at(step).size(); i++) { input[i][0] = data.at(step).at(i); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h index 4a427770e..a5339dd44 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h @@ -16,6 +16,8 @@ public: static std::shared_ptr<FFTCalculator> getNewInstance(int lx, int lz, int timeStepLength); void calc(std::vector<std::vector<double>> data, bool transposeData); + + double calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData); double getNu(); double getPhiDiff(); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp index ba530e23b..63fd59afc 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp @@ -1,8 +1,9 @@ #include "L2NormCalculator.h" +#include "Utilities\Calculator\FFTCalculator\FFTCalculator.h" + #define _USE_MATH_DEFINES #include <math.h> - #include <iostream> std::shared_ptr<L2NormCalculator> L2NormCalculator::getInstance() @@ -13,8 +14,10 @@ std::shared_ptr<L2NormCalculator> L2NormCalculator::getInstance() return uniqueInstance; } -double L2NormCalculator::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level) +double L2NormCalculator::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) { + fftCalc = FFTCalculator::getNewInstance(lx, lz, timeStepLength); + double amplitude = fftCalc->calcAmplitudeForTimeStep(basicData, false); double zaehler = 0.0; double nenner = 0.0; for (int i = 0; i < basicData.size(); i++) { @@ -22,12 +25,10 @@ double L2NormCalculator::calc(std::vector<double> basicData, std::vector<double> zaehler += ((divergentData.at(i) - basicData.at(i))*(divergentData.at(i) - basicData.at(i))) * flaeche; nenner += (basicData.at(i)*basicData.at(i)) * flaeche; } - if (nenner == 0.0) - return sqrt(zaehler); - return sqrt(zaehler / nenner); + return sqrt(zaehler / (amplitude * amplitude)); } L2NormCalculator::L2NormCalculator() { - + } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h index b4dd6f775..9bc20e446 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h @@ -4,14 +4,18 @@ #include <vector> #include <memory> +class FFTCalculator; + class L2NormCalculator { public: static std::shared_ptr< L2NormCalculator> getInstance(); - double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level); + double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength); private: L2NormCalculator(); + + std::shared_ptr< FFTCalculator> fftCalc; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h deleted file mode 100644 index cc08d5203..000000000 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CONFIGFILE_DATA_H -#define CONFIGFILE_DATA_H - -#include <vector> - -struct ConfigDataStruct -{ - std::vector< int> devices; - - std::vector< std::string> kernelsToTest; - - unsigned int numberOfTimeSteps; - std::vector<double> viscosity; - - std::vector<double> amplitudeTGVux, u0TGVux; - double l0TGVux; - std::vector<double> amplitudeTGVuz, v0TGVuz; - double l0TGVuz; - std::vector<int> basisTimeStepLengthTGVux, basisTimeStepLengthTGVuz; - - std::vector<double> u0SW, v0SW; - std::vector<int> basisTimeStepLengthSW; - double l0SW; - - unsigned int ySliceForCalculation; - - double minOrderOfAccuracy; - std::vector<std::string> dataToCalcPhiAndNuTest; - unsigned int startTimeStepCalculationPhiNu; - unsigned int endTimeStepCalculationPhiNu; - bool nuAndPhiTest; - - double maxL2NormDiff; - std::vector<std::string> dataToCalcL2Test; - unsigned int basicTimeStepL2Norm; - unsigned int divergentTimeStepL2Norm; - bool l2NormTest; - - bool l2NormBetweenKernelTest; - std::string basicKernelL2NormTest; - std::vector< int> timeStepsL2NormBetweenKernel; - std::vector< std::string> dataToCalcL2NormBetweenKernel; - - std::vector< bool> tgvUx, tgvUz; - std::vector< bool> sw; - - unsigned int numberOfGridLevels; - unsigned int maxLevel; - std::vector< std::string> grids; - - bool writeFiles; - std::string filePath; - unsigned int startStepFileWriter; - std::string logFilePath; - - double rho0; - std::vector< double> lx; - std::vector< double> lz; - - bool writeAnalyticalToVTK; - -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp index 307c6831b..cc36ad2d5 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp @@ -4,7 +4,6 @@ #include "utilities/StringUtil/StringUtil.h" #include <fstream> -#include <iostream> std::shared_ptr<ConfigFileReader> ConfigFileReader::getNewInstance(const std::string aFilePath) { @@ -12,106 +11,57 @@ std::shared_ptr<ConfigFileReader> ConfigFileReader::getNewInstance(const std::st } ConfigFileReader::ConfigFileReader(const std::string aFilePath) +{ + readConfigFile(aFilePath); +} + +void ConfigFileReader::readConfigFile(const std::string aFilePath) { configData = std::shared_ptr< ConfigDataStruct>(new ConfigDataStruct); + std::ifstream stream = openConfigFile(aFilePath); + + std::shared_ptr<input::Input> input = input::Input::makeInput(stream, "config"); + + if (!checkConfigFile(input)) + exit(1); - configData->lx.resize(5); - configData->lx.at(0) = 32.0; - configData->lx.at(1) = 64.0; - configData->lx.at(2) = 128.0; - configData->lx.at(3) = 256.0; - configData->lx.at(4) = 512.0; + configData->viscosity = StringUtil::toDoubleVector(input->getValue("Viscosity")); + configData->kernelsToTest = readKernelList(input); + configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteVTKFiles")); + configData->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation"));; + configData->logFilePath = input->getValue("PathLogFile"); + configData->numberOfSimulations = calcNumberOfSimulations(input); - configData->lz.resize(5); - configData->lz.at(0) = configData->lx.at(0) * 3.0 / 2.0; - configData->lz.at(1) = configData->lx.at(1) * 3.0 / 2.0; - configData->lz.at(2) = configData->lx.at(2) * 3.0 / 2.0; - configData->lz.at(3) = configData->lx.at(3) * 3.0 / 2.0; - configData->lz.at(4) = configData->lx.at(4) * 3.0 / 2.0; + std::shared_ptr< BasicSimulationParameterStruct> basicSimPara = makeBasicSimulationParameter(input); - configData->rho0 = 1.0; + configData->taylorGreenVortexUxParameter = makeTaylorGreenVortexUxParameter(input, basicSimPara); + configData->taylorGreenVortexUxGridInformation = makeGridInformation(input, "TaylorGreenVortexUx");; - readConfigFile(aFilePath); + configData->taylorGreenVortexUzParameter = makeTaylorGreenVortexUzParameter(input, basicSimPara); + configData->taylorGreenVortexUzGridInformation = makeGridInformation(input, "TaylorGreenVortexUz");; + + configData->shearWaveParameter = makeShearWaveParameter(input, basicSimPara); + configData->shearWaveGridInformation = makeGridInformation(input, "ShearWave");; + + configData->phiAndNuTestParameter = makePhiAndNuTestParameter(input); + configData->l2NormTestParameter = makeL2NormTestParameter(input); + configData->l2NormTestBetweenKernelsParameter = makeL2NormTestBetweenKernelsParameter(input); + + configData->vectorWriterInfo = makeVectorWriterInformationStruct(input); + + configData->logFilePara = makeLogFilePara(input); + + stream.close(); } -void ConfigFileReader::readConfigFile(const std::string aFilePath) +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::unique_ptr<input::Input> input = input::Input::makeInput(stream, "config"); - - configData->devices = StringUtil::toIntVector(input->getValue("Devices")); - configData->kernelsToTest = StringUtil::toStringVector(input->getValue("KernelsToTest")); - configData->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); - configData->viscosity = StringUtil::toDoubleVector(input->getValue("Viscosity")); - configData->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy")); - configData->dataToCalcPhiAndNuTest = StringUtil::toStringVector(input->getValue("DataToCalc_PhiAndNu")); - configData->startTimeStepCalculationPhiNu = StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiNu")); - configData->endTimeStepCalculationPhiNu = StringUtil::toInt(input->getValue("EndTimeStepCalculation_PhiNu")); - configData->nuAndPhiTest = StringUtil::toBool(input->getValue("PhiAndNuTest")); - configData->l2NormTest = StringUtil::toBool(input->getValue("L2NormTest")); - configData->maxL2NormDiff = StringUtil::toDouble(input->getValue("MaxL2NormDiff")); - configData->dataToCalcL2Test = StringUtil::toStringVector(input->getValue("DataToCalc_L2")); - configData->basicTimeStepL2Norm = StringUtil::toInt(input->getValue("BasicTimeStep_L2")); - configData->divergentTimeStepL2Norm = StringUtil::toInt(input->getValue("DivergentTimeStep_L2")); - configData->basisTimeStepLengthTGVux = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); - configData->amplitudeTGVux = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); - configData->u0TGVux = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); - configData->l0TGVux = StringUtil::toInt(input->getValue("l0_TGV_Ux")); - configData->basisTimeStepLengthTGVuz = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); - configData->amplitudeTGVuz = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); - configData->v0TGVuz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); - configData->l0TGVuz = StringUtil::toInt(input->getValue("l0_TGV_Uz")); - - configData->basisTimeStepLengthSW = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); - configData->v0SW = StringUtil::toDoubleVector(input->getValue("v0_SW")); - configData->u0SW = StringUtil::toDoubleVector(input->getValue("u0_SW")); - configData->l0SW = StringUtil::toInt(input->getValue("l0_SW")); - - configData->l2NormBetweenKernelTest = StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest")); - configData->basicKernelL2NormTest = StringUtil::toString(input->getValue("BasicKernel_L2NormBetweenKernels")); - configData->timeStepsL2NormBetweenKernel = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); - configData->dataToCalcL2NormBetweenKernel = StringUtil::toStringVector(input->getValue("DataToCalc_L2NormBetweenKernels")); - - configData->grids.resize(5); - configData->grids.at(0) = input->getValue("GridPath32"); - configData->grids.at(1) = input->getValue("GridPath64"); - configData->grids.at(2) = input->getValue("GridPath128"); - configData->grids.at(3) = input->getValue("GridPath256"); - configData->grids.at(4) = input->getValue("GridPath512"); - configData->numberOfGridLevels = StringUtil::toInt(input->getValue("NumberOfGridLevels")); - configData->maxLevel = configData->numberOfGridLevels - 1; - configData->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - configData->writeFiles = StringUtil::toBool(input->getValue("WriteVTKFiles")); - configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); - configData->filePath = input->getValue("PathForFileWriting"); - configData->startStepFileWriter = StringUtil::toInt(input->getValue("StartStepFileWriter")); - configData->logFilePath = input->getValue("PathLogFile"); - configData->tgvUx.resize(5); - configData->tgvUx.at(0) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx32")); - configData->tgvUx.at(1) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx64")); - configData->tgvUx.at(2) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx128")); - configData->tgvUx.at(3) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx256")); - configData->tgvUx.at(4) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx512")); - configData->tgvUz.resize(5); - configData->tgvUz.at(0) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz32")); - configData->tgvUz.at(1) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz64")); - configData->tgvUz.at(2) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz128")); - configData->tgvUz.at(3) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz256")); - configData->tgvUz.at(4) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz512")); - configData->sw.resize(5); - configData->sw.at(0) = StringUtil::toBool(input->getValue("ShearWave32")); - configData->sw.at(1) = StringUtil::toBool(input->getValue("ShearWave64")); - configData->sw.at(2) = StringUtil::toBool(input->getValue("ShearWave128")); - configData->sw.at(3) = StringUtil::toBool(input->getValue("ShearWave256")); - configData->sw.at(4) = StringUtil::toBool(input->getValue("ShearWave512")); - - stream.close(); - - checkConfigFileData(); + return stream; } std::shared_ptr<ConfigDataStruct> ConfigFileReader::getConfigData() @@ -119,20 +69,296 @@ std::shared_ptr<ConfigDataStruct> ConfigFileReader::getConfigData() return configData; } -void ConfigFileReader::checkConfigFileData() +bool ConfigFileReader::checkConfigFile(std::shared_ptr<input::Input> input) { - if (configData->u0TGVux.size() != configData->amplitudeTGVux.size() || configData->u0TGVux.size() != configData->basisTimeStepLengthTGVux.size()) { - std::cout << "Length u0_TGV_U0 is unequal to Lenght Amplitude_TGV_U0 or BasisTimeStepLength_TGV_U0!" << std::endl << std::flush; - exit(1); - } + 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")); - if (configData->v0TGVuz.size() != configData->amplitudeTGVuz.size() || configData->v0TGVuz.size() != configData->basisTimeStepLengthTGVuz.size()) { + 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; - exit(1); + 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> basicSimPara = std::shared_ptr<BasicSimulationParameterStruct>(new BasicSimulationParameterStruct); + + basicSimPara->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); + basicSimPara->devices = StringUtil::toIntVector(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<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")); + + 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; - if (configData->u0SW.size() != configData->v0SW.size() || configData->u0SW.size() != configData->basisTimeStepLengthSW.size()) { - std::cout << "Length u0_SW is unequal to Lenght v0_SW!" << std::endl << std::flush; - exit(1); + 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 = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + 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<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")); + + 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 = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + 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<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")); + + 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 = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + parameter.push_back(aParameter); + } + return parameter; +} + +std::shared_ptr<PhiAndNuTestParameterStruct> ConfigFileReader::makePhiAndNuTestParameter(std::shared_ptr<input::Input> input) +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_PhiAndNu")); + basicTestParameter->runTest= StringUtil::toBool(input->getValue("PhiAndNuTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<PhiAndNuTestParameterStruct> testParameter = std::shared_ptr<PhiAndNuTestParameterStruct>(new PhiAndNuTestParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_PhiNu")); + testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy")); + testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiNu")); + + return testParameter; +} + +std::shared_ptr<L2NormTestParameterStruct> ConfigFileReader::makeL2NormTestParameter(std::shared_ptr<input::Input> input) +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_L2")); + 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->maxDiff = StringUtil::toDouble(input->getValue("MaxL2NormDiff")); + + return testParameter; +} + +std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> ConfigFileReader::makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input) +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_L2NormBetweenKernels")); + 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 = StringUtil::toString(input->getValue("BasicKernel_L2NormBetweenKernels")); + testParameter->kernelsToTest = readKernelList(input); + testParameter->timeSteps = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); + + return testParameter; +} + +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(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> 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; +} + +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("WriteVTKFiles")); + + return logFilePara; +} + +std::vector<std::string> 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 = StringUtil::toString(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> kernels = kernelList; + + while (kernels.at(0) != beginnKernel) { + kernels.push_back(kernels.at(0)); + std::vector<std::string>::iterator it = kernels.begin(); + kernels.erase(it); + } + return kernels; + }else { + std::vector<std::string> kernelList = StringUtil::toStringVector(input->getValue("KernelsToTest")); + return kernelList; } +} + +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_PhiNu"))); + std::sort(startStepsTests.begin(), startStepsTests.end()); + + return startStepsTests.at(0); +} + +int ConfigFileReader::calcNumberOfSimulations(std::shared_ptr<input::Input> input) +{ + int counter = 0; + + int tgvCounterU0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUx"); + tgvCounterU0 *= 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 swCounter = calcNumberOfSimulationGroup(input, "ShearWave");; + swCounter *= StringUtil::toDoubleVector(input->getValue("u0_SW")).size(); + counter += swCounter; + + counter *= StringUtil::toDoubleVector(input->getValue("Viscosity")).size(); + counter *= configData->kernelsToTest.size(); + + 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; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h index 1e34cf481..c4fba3135 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h @@ -1,7 +1,8 @@ #ifndef CONFIG_FILE_READER_H #define CONFIG_FILE_READER_H -#include "ConfigData.h" +#include "Utilities\input\Input.h" +#include "Utilities\Structs\ConfigDataStruct.h" #include <memory> #include <string> @@ -16,7 +17,29 @@ private: ConfigFileReader() {}; ConfigFileReader(const std::string aFilePath); void readConfigFile(const std::string aFilePath); - void checkConfigFileData(); + + std::ifstream openConfigFile(const std::string aFilePath); + bool checkConfigFile(std::shared_ptr<input::Input> input); + std::vector<std::string> 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<PhiAndNuTestParameterStruct> makePhiAndNuTestParameter(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::shared_ptr< ConfigDataStruct> configData; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp index 8ce4067e9..ed8e98a18 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp +++ b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp @@ -18,31 +18,41 @@ #include <mpi.h> -std::shared_ptr<AnalyticalResults2DToVTKWriterImp> AnalyticalResults2DToVTKWriterImp::getInstance() +std::shared_ptr<AnalyticalResults2DToVTKWriterImp> AnalyticalResults2DToVTKWriterImp::getInstance(bool writeAnalyticalResults) { static std::shared_ptr<AnalyticalResults2DToVTKWriterImp> uniqueInstance; if (!uniqueInstance) - uniqueInstance = std::shared_ptr<AnalyticalResults2DToVTKWriterImp>(new AnalyticalResults2DToVTKWriterImp()); + uniqueInstance = std::shared_ptr<AnalyticalResults2DToVTKWriterImp>(new AnalyticalResults2DToVTKWriterImp(writeAnalyticalResults)); return uniqueInstance; } +AnalyticalResults2DToVTKWriterImp::AnalyticalResults2DToVTKWriterImp(bool writeAnalyticalResults) : writeAnalyticalResults(writeAnalyticalResults) +{ + +} + void AnalyticalResults2DToVTKWriterImp::writeAnalyticalResult(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult) { - std::cout << "Write Analytical Result To VTK-Files" << std::endl; - for (int level = para->getCoarse(); level <= para->getFine(); level++) { + if (writeAnalyticalResults) { + std::cout << "Write Analytical Result To VTK-Files" << std::endl; + for (int level = para->getCoarse(); level <= para->getFine(); level++) { #pragma omp parallel for - for (int timeStep = 0; timeStep < analyticalResult->getNumberOfTimeSteps(); timeStep++) { - const unsigned int numberOfParts = para->getParH(level)->size_Mat_SP / para->getlimitOfNodesForVTK() + 1; - std::vector<std::string> fname; - unsigned int time = analyticalResult->getTimeSteps().at(timeStep)*analyticalResult->getTimeStepLength(); - for (int j = 1; j <= numberOfParts; j++) - fname.push_back(para->getFName() + "AnalyticalResult\\Analytical_cells_bin_lev_" + StringUtil::toString<int>(level) + "_ID_" + StringUtil::toString<int>(para->getMyID()) + "_Part_" + StringUtil::toString<int>(j) + "_t_" + StringUtil::toString<int>(time) + ".vtk"); - std::cout << "\t Write TimeStep=" << timeStep << " t=" << time << "..."; - writeTimeStep(para, analyticalResult, level, fname, timeStep); - std::cout << "done." << std::endl; + for (int timeStep = 0; timeStep < analyticalResult->getNumberOfTimeSteps(); timeStep++) { + const unsigned int numberOfParts = para->getParH(level)->size_Mat_SP / para->getlimitOfNodesForVTK() + 1; + std::vector<std::string> fname; + unsigned int time = analyticalResult->getTimeSteps().at(timeStep)*analyticalResult->getTimeStepLength(); + for (int j = 1; j <= numberOfParts; j++) { + std::string filePath = para->getFName(); + filePath.resize(filePath.size() - 5); + fname.push_back(filePath + "AnalyticalResult\\Analytical_cells_bin_lev_" + StringUtil::toString<int>(level) + "_ID_" + StringUtil::toString<int>(para->getMyID()) + "_Part_" + StringUtil::toString<int>(j) + "_t_" + StringUtil::toString<int>(time) + ".vtk"); + } + std::cout << "\t Write TimeStep=" << timeStep << " t=" << time << "..."; + writeTimeStep(para, analyticalResult, level, fname, timeStep); + std::cout << "done." << std::endl; + } } + std::cout << std::endl; } - std::cout << std::endl; } diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h index b74e5bd27..440fa50f5 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h +++ b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h @@ -9,17 +9,19 @@ class AnalyticalResults2DToVTKWriterImp : public AnalyticalResults2DToVTKWriter { public: - static std::shared_ptr< AnalyticalResults2DToVTKWriterImp> getInstance(); + static std::shared_ptr< AnalyticalResults2DToVTKWriterImp> getInstance(bool writeAnalyticalResults); void writeAnalyticalResult(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult); private: AnalyticalResults2DToVTKWriterImp() {}; + AnalyticalResults2DToVTKWriterImp(bool writeAnalyticalResults); void writeTimeStep(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult, int level, std::vector<std::string> & fname, int timeStep); int CoordResults2DTo1D(int x, int z); std::shared_ptr<Parameter> para; int maxX, maxY, maxZ; + bool writeAnalyticalResults; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp index 0c1e474cd..9e77d8862 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp +++ b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp @@ -2,35 +2,38 @@ #include "VirtualFluids_GPU/Output/FileWriter.h" #include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU\Output\FileWriter.h" -ToVectorWriter::ToVectorWriter(unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter) +#include "Utilities\Structs\VectorWriterInformationStruct.h" + +ToVectorWriter::ToVectorWriter(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength) { - this->writeFiles = writeFiles; - this->fileWriter = fileWriter; - this->ySliceForCalculation = ySliceForCalculation; - this->startTimeY2dSliceToVector = startTimeY2dSliceToVector; - this->startTimeDataWriter = startTimeDataWriter; - this->endTime = endTime; + this->startTimeVectorWriter = vectorWriterInfo->startTimeVectorWriter; + this->writeVTKFiles = vectorWriterInfo->writeVTKFiles; + this->startTimeVTKWriter = vectorWriterInfo->startTimeVTKDataWriter; + + this->vtkFileWriter = std::shared_ptr<FileWriter> (new FileWriter()); + this->timeStepLength = timeStepLength; } void ToVectorWriter::writeInit(std::shared_ptr<Parameter> para) { - if (startTimeY2dSliceToVector == 0) + if (startTimeVectorWriter == 0) writeTimestep(para, 0); - if (writeFiles && startTimeDataWriter == 0) - fileWriter->writeTimestep(para, 0); + if (writeVTKFiles && startTimeVTKWriter == 0) + vtkFileWriter->writeTimestep(para, 0); } void ToVectorWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int t) { - if (startTimeY2dSliceToVector <= t && endTime >= t) + if (startTimeVectorWriter <= t) { for (int level = para->getCoarse(); level <= para->getFine(); level++) { writeTimestep(para, t, level); } } - if (writeFiles && startTimeDataWriter < t) - fileWriter->writeTimestep(para, t); + if (writeVTKFiles && startTimeVTKWriter < t) + vtkFileWriter->writeTimestep(para, t); } diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h index d4626ad52..8853cf69e 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h +++ b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h @@ -4,31 +4,23 @@ #include "VirtualFluids_GPU/Output/DataWriter.h" class Parameter; -class SimulationResults; class FileWriter; +struct VectorWriterInformationStruct; class ToVectorWriter : public DataWriter { public: - ToVectorWriter(unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter); - void writeInit(std::shared_ptr<Parameter> para); void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t); protected: + ToVectorWriter(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength); virtual void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level) = 0; void writeUnstrucuredGridLT(std::shared_ptr<Parameter> para, int level, std::vector<std::string >& fname) {}; - std::shared_ptr<FileWriter> fileWriter; - bool writeFiles; - - unsigned int ySliceForCalculation; - unsigned int counterTimeSteps; + std::shared_ptr<FileWriter> vtkFileWriter; + bool writeVTKFiles; unsigned int timeStepLength; - unsigned int startTimeY2dSliceToVector, startTimeDataWriter; - unsigned int endTime; - unsigned int maxX, maxY, maxZ; -private: - + unsigned int startTimeVectorWriter, startTimeVTKWriter; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp index fc5df8973..62db296c4 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp +++ b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp @@ -4,14 +4,16 @@ #include "Utilities/Results/SimulationResults/SimulationResults.h" -std::shared_ptr<Y2dSliceToResults> Y2dSliceToResults::getNewInstance(std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter) +std::shared_ptr<Y2dSliceToResults> Y2dSliceToResults::getNewInstance(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation) { - return std::shared_ptr<Y2dSliceToResults>(new Y2dSliceToResults(simResults, ySliceForCalculation, startTimeY2dSliceToVector, endTime, timeStepLength, writeFiles, fileWriter, startTimeDataWriter)); + return std::shared_ptr<Y2dSliceToResults>(new Y2dSliceToResults(vectorWriterInfo, timeStepLength, simResults, ySliceForCalculation)); } -Y2dSliceToResults::Y2dSliceToResults(std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter): ToVectorWriter(ySliceForCalculation, startTimeY2dSliceToVector, endTime, timeStepLength, writeFiles, fileWriter, startTimeDataWriter) +Y2dSliceToResults::Y2dSliceToResults(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation) + : ToVectorWriter(vectorWriterInfo, timeStepLength) { this->simResults = simResults; + this->ySliceForCalculation = ySliceForCalculation; } void Y2dSliceToResults::writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level) diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h index b85333421..bf18dab58 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h +++ b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h @@ -7,18 +7,23 @@ #include <memory> class Parameter; +class SimulationResults; +struct VectorWriterInformationStruct; class Y2dSliceToResults : public ToVectorWriter { public: - static std::shared_ptr< Y2dSliceToResults> getNewInstance(std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter); + static std::shared_ptr< Y2dSliceToResults> getNewInstance(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation); private: - Y2dSliceToResults(std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation, unsigned int startTimeY2dSliceToVector, unsigned int endTime, unsigned int timeStepLength, bool writeFiles, std::shared_ptr<FileWriter> fileWriter, unsigned int startTimeDataWriter); - void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level); + Y2dSliceToResults(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation); - std::shared_ptr<SimulationResults> simResults; + void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level); int CoordPara3DTo1D(int x, int y, int z); int CoordResults2DTo1D(int x, int z); + + std::shared_ptr<SimulationResults> simResults; + unsigned int ySliceForCalculation; + unsigned int maxX, maxY, maxZ; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.cpp b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.cpp index 5d9618fe2..a52b50cdf 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.cpp @@ -7,9 +7,9 @@ #include <helper_functions.h> #include <helper_cuda.h> -std::shared_ptr<LogFileInformation> LogFileHead::getNewInstance(std::vector<int> devices) +std::shared_ptr<LogFileHead> LogFileHead::getNewInstance(std::vector<int> devices) { - return std::shared_ptr<LogFileInformation>(new LogFileHead(devices)); + return std::shared_ptr<LogFileHead>(new LogFileHead(devices)); } std::string LogFileHead::getOutput() @@ -17,14 +17,14 @@ std::string LogFileHead::getOutput() calcDateAndTime(); makeCenterHead("LogFile Information"); - oss << "Date: " << std::setw(2) << std::setfill('0') << nowLocal.tm_mday << "." << std::setw(2) << nowLocal.tm_mon + 1 << "." << nowLocal.tm_year + 1900 << std::endl; - oss << "Time: " << std::setw(2) << std::setfill('0') << nowLocal.tm_hour << ":" << std::setw(2) << nowLocal.tm_min << ":" << std::setw(2) << nowLocal.tm_sec << std::endl; + oss << "Date=" << std::setw(2) << std::setfill('0') << nowLocal.tm_mday << "." << std::setw(2) << nowLocal.tm_mon + 1 << "." << nowLocal.tm_year + 1900 << std::endl; + oss << "Time=" << std::setw(2) << std::setfill('0') << nowLocal.tm_hour << ":" << std::setw(2) << nowLocal.tm_min << ":" << std::setw(2) << nowLocal.tm_sec << std::endl; oss << std::endl; for (int i = 0; i < devices.size(); i++) { cudaDeviceProp prop; cudaGetDeviceProperties(&prop, devices.at(i)); - oss << "GPU Device " << devices.at(i) << ": " << prop.name << std::endl; + oss << "GPU_Device" << devices.at(i) << "=" << prop.name << std::endl; } oss << std::endl; diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.h index 11aa45386..c574c0322 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileHead/LogFileHead.h @@ -9,7 +9,7 @@ class LogFileHead : public LogFileInformationImp { public: - static std::shared_ptr<LogFileInformation> getNewInstance(std::vector<int> devices); + static std::shared_ptr<LogFileHead> getNewInstance(std::vector<int> devices); std::string getOutput(); private: diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp index fd4331d3e..f6e1bec8c 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp @@ -12,7 +12,7 @@ std::shared_ptr<LogFileTimeInformation> LogFileTimeInformation::getNewInstance(s std::string LogFileTimeInformation::getOutput() { makeCenterHead("Simulation Time Information"); - oss << "FileWriting: " << std::boolalpha << fileWriting <<std::endl; + oss << "FileWriting= " << std::boolalpha << fileWriting <<std::endl; oss << std::endl; oss << std::left << std::setfill(' ') << std::setw(11) << "" << "TestName \t \t \t" << " L\t\t" << "Time for Test" << std::endl; oss << std::endl; @@ -24,4 +24,5 @@ std::string LogFileTimeInformation::getOutput() LogFileTimeInformation::LogFileTimeInformation(std::vector<std::shared_ptr<TestSimulation>> testSimulation, bool fileWriting) : testSimulation(testSimulation), fileWriting(fileWriting) { + } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.h index 0e4587b0e..9e216b0a7 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.h @@ -11,14 +11,14 @@ class TestSimulation; class LogFileTimeInformation : public LogFileInformationImp { public: - static std::shared_ptr<LogFileTimeInformation> getNewInstance(std::vector< std::shared_ptr< TestSimulation>> testSimulation, bool fileWriting); + static std::shared_ptr<LogFileTimeInformation> getNewInstance(std::vector<std::shared_ptr<TestSimulation> > testSimulation, bool fileWriting); std::string getOutput(); private: LogFileTimeInformation(); - LogFileTimeInformation(std::vector< std::shared_ptr< TestSimulation> > testSimulation, bool fileWriting); + LogFileTimeInformation(std::vector<std::shared_ptr<TestSimulation> > testSimulation, bool fileWriting); - std::vector< std::shared_ptr< TestSimulation>> testSimulation; + std::vector<std::shared_ptr< TestSimulation> > testSimulation; bool fileWriting; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h index b54e19812..12f0a94d7 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h @@ -1,11 +1,11 @@ #ifndef SIMULATION_LOGFILE_INFORMATION_H #define SIMULATION_LOGFILE_INFORMATION_H -#include "Utilities\LogFileInformation\LogFileInformation.h" +#include "Utilities\LogFileInformation\LogFileInformationImp.h" #include <string> -class SimulationLogFileInformation : public LogFileInformation +class SimulationLogFileInformation : public LogFileInformationImp { public: virtual std::string getFilePathExtensionOne() = 0; diff --git a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp index 2ab9209b9..ad09b6bac 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp @@ -11,20 +11,20 @@ #include <ctime> #include <experimental/filesystem> -LogFileWriterImp::LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength) : kernelName(kernelName), viscosity(viscosity) +LogFileWriterImp::LogFileWriterImp(std::shared_ptr<LogFileHead> logFileHead, std::shared_ptr<BasicSimulationInfo> basicSimInfo, std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity) : kernelName(kernelName), viscosity(viscosity) { - logFileInfo.push_back(LogFileHead::getNewInstance(devices)); - logFileInfo.push_back(BasicSimulationInfo::getNewInstance(numberOfTimeSteps, viscosity, basicTimeStepLength, kernelName)); + logFileInfo.push_back(logFileHead); + logFileInfo.push_back(basicSimInfo); this->simLogInfo = simLogInfo; - logFileInfo.push_back(this->simLogInfo); + logFileInfo.push_back(simLogInfo); logFileInfo.push_back(logFileTimeInfo); for (int i = 0; i < testLogFiles.size(); i++) logFileInfo.push_back(testLogFiles.at(i)); } -std::shared_ptr<LogFileWriterImp> LogFileWriterImp::getNewInstance(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength) +std::shared_ptr<LogFileWriterImp> LogFileWriterImp::getNewInstance(std::shared_ptr<LogFileHead> logFileHead, std::shared_ptr<BasicSimulationInfo> basicSimInfo, std::vector< std::shared_ptr< TestLogFileInformation> > testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity) { - return std::shared_ptr<LogFileWriterImp>(new LogFileWriterImp(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, devices, numberOfTimeSteps, startStepCalculation, basicTimeStepLength)); + return std::shared_ptr<LogFileWriterImp>(new LogFileWriterImp(logFileHead, basicSimInfo, testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity)); } void LogFileWriterImp::writeLogFile(std::string basicFilePath) @@ -32,6 +32,8 @@ void LogFileWriterImp::writeLogFile(std::string basicFilePath) logFilePath = buildFilePath(basicFilePath); logFile.open(logFilePath, std::ios::out); + bool open = logFile.is_open(); + for (int i = 0; i < logFileInfo.size(); i++) logFile << logFileInfo.at(i)->getOutput(); } diff --git a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h index 83db69b7d..ccc8d7d44 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h +++ b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h @@ -7,7 +7,9 @@ #include <vector> #include <memory> +class BasicSimulationInfo; class SimulationLogFileInformation; +class LogFileHead; class LogFileInformation; class LogFileTimeInformation; class TestLogFileInformation; @@ -15,16 +17,15 @@ class TestLogFileInformation; class LogFileWriterImp : public LogFileWriter { public: - static std::shared_ptr<LogFileWriterImp> getNewInstance(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, + static std::shared_ptr<LogFileWriterImp> getNewInstance(std::shared_ptr<LogFileHead> logFileHead, std::shared_ptr<BasicSimulationInfo> basicSimInfo, std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, - std::string kernelName, - double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength); + std::string kernelName, double viscosity); void writeLogFile(std::string basicFilePath); private: - LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength); + LogFileWriterImp(std::shared_ptr<LogFileHead> logFileHead, std::shared_ptr<BasicSimulationInfo> basicSimInfo, std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity); std::string calcDateAndTime(); std::string buildFilePath(std::string basicFilePath); diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp index 200660ead..271dfe603 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp @@ -1,5 +1,11 @@ #include "NumericalTestFactoryImp.h" +#include "Utilities\Structs\ConfigDataStruct.h" +#include "Utilities\Structs\LogFileParameterStruct.h" +#include "Utilities\Structs\NumericalTestStruct.h" +#include "Utilities\Structs\SimulationDataStruct.h" +#include "Utilities\Structs\TestSimulationDataStruct.h" + #include "Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h" #include "Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h" #include "Simulations\TaylorGreenVortexUx\SimulationInfo\SimulationInfoTaylorGreenVortexUx.h" @@ -18,18 +24,29 @@ #include "Tests/PhiAndNuTest/PhiAndNuTest.h" #include "Tests\PhiAndNuTest\LogFileInformation\PhiAndNuLogFileInformation.h" #include "Tests\PhiAndNuTest\PostProcessingStrategy\PostProcessingStrategyPhiAndNuTest.h" +#include "Tests\PhiAndNuTest\PhiAndNuTestStruct.h" + #include "Tests\L2NormTest\L2NormTest.h" #include "Tests\L2NormTest\LogFileInformation\L2NormLogFileInformation.h" #include "Tests\L2NormTest\PostProcessingStrategy\PostProcessingStrategyL2NormTest.h" +#include "Tests\L2NormTest\L2NormTestStruct.h" + #include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernels.h" #include "Tests\L2NormTestBetweenKernels\PostProcessingStrategy\L2NormBetweenKernelPostProcessingStrategy.h" #include "Tests\L2NormTestBetweenKernels\LogFileInformation\L2NormLogFileInformationBetweenKernels.h" +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernelsStruct.h" #include "Utilities\ColorConsoleOutput\ColorConsoleOutputImp.h" #include "Utilities\DataWriter\AnalyticalResults2DToVTKWriter\AnalyticalResults2DToVTKWriterImp.h" +#include "Utilities\DataWriter\Y2dSliceToResults\Y2dSliceToResults.h" + +#include "Utilities\LogFileInformation\LogFileHead\LogFileHead.h" +#include "Utilities\LogFileInformation\BasicSimulationInfo\BasicSimulationInfo.h" +#include "Utilities\LogFileInformation\LogFileInformationImp.h" #include "Utilities\LogFileInformation\LogFileTimeInformation\LogFileTimeInformation.h" #include "Utilities\LogFileWriter\LogFileWriterImp.h" #include "Utilities\LogFileQueue\LogFileQueueImp.h" + #include "Utilities\PostProcessingResults\PostProcessingResultsImp.h" #include "Utilities\Results\SimulationResults\SimulationResults.h" #include "Utilities\TestQueue\TestQueueImp.h" @@ -42,336 +59,330 @@ std::shared_ptr<NumericalTestFactoryImp> NumericalTestFactoryImp::getNewInstance return std::shared_ptr<NumericalTestFactoryImp>(new NumericalTestFactoryImp(configFileData)); } -NumericalTestFactoryImp::NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData) : cfd(configFileData) +NumericalTestFactoryImp::NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData) { colorOutput = ColorConsoleOutputImp::getInstance(); - testQueue = TestQueueImp::getNewInstance(colorOutput); - logFileWriterQueue = LogFileQueueImp::getNewInstance(cfd->logFilePath); - anaResultWriter = AnalyticalResults2DToVTKWriterImp::getInstance(); - init(); + myTestQueue = TestQueueImp::getNewInstance(colorOutput); + myLogFileWriterQueue = LogFileQueueImp::getNewInstance(configFileData->logFilePath); + anaResultWriter = AnalyticalResults2DToVTKWriterImp::getInstance(configFileData->writeAnalyticalToVTK); + l2NormTestsBetweenKernels.resize(0); + init(configFileData); } std::vector<std::shared_ptr<TestSimulation>> NumericalTestFactoryImp::getTestSimulations() { - return testSimulations; + return myTestSimulations; } std::shared_ptr<TestQueue> NumericalTestFactoryImp::getTestQueue() { - return testQueue; + return myTestQueue; } std::shared_ptr<LogFileQueue> NumericalTestFactoryImp::getLogFileQueue() { - return logFileWriterQueue; + return myLogFileWriterQueue; } -void NumericalTestFactoryImp::init() +void NumericalTestFactoryImp::init(std::shared_ptr<ConfigDataStruct> configFileData) { - calcNumberOfSimulations(); simID = 1; - if (cfd->l2NormBetweenKernelTest && cfd->kernelsToTest.size() > 1) - { - sortKernels(); - simPerKernel = numberOfSimulations / cfd->kernelsToTest.size(); - numberOfTestGroupsBetweenKernels = (cfd->kernelsToTest.size() - 1) * simPerKernel; - numberOfTestsForOneSimulation = cfd->dataToCalcL2NormBetweenKernel.size() * cfd->timeStepsL2NormBetweenKernel.size(); - numberOfTestsBetweenKernels = numberOfTestGroupsBetweenKernels * numberOfTestsForOneSimulation; - posBasicSimulationForL2Test = 0; - posDivergentSimulationForL2Test = 0; - for (int i = 0; i < numberOfTestGroupsBetweenKernels; i++) { - for (int j = 0; j < cfd->dataToCalcL2NormBetweenKernel.size(); j++) { - for (int k = 0; k < cfd->timeStepsL2NormBetweenKernel.size(); k++) { - l2KernelTests.push_back(L2NormTestBetweenKernels::getNewInstance(colorOutput, cfd->dataToCalcL2NormBetweenKernel.at(j), cfd->timeStepsL2NormBetweenKernel.at(k))); - } + numberOfSimulations = configFileData->numberOfSimulations; + + for (int i = 0; i < configFileData->kernelsToTest.size(); i++) { + for (int j = 0; j < configFileData->viscosity.size(); j++) { + for (int k = 0; k < configFileData->taylorGreenVortexUxParameter.size(); k++) { + std::shared_ptr<SimulationDataStruct> simDataStruct = makeTaylorGreenUxSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUxParameter.at(k), configFileData->taylorGreenVortexUxGridInformation); + + std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUxParameter.at(k)->basicTimeStepLength); + addNumericalTestStruct(numericalTestStruct); } - } - } - - for (int i = 0; i < cfd->kernelsToTest.size(); i++) { - for (int j = 0; j < cfd->viscosity.size(); j++) { - for (int k = 0; k < cfd->u0TGVux.size(); k++) - if (shouldSimulationGroupRun(cfd->tgvUx)) - makeTaylorGreenUxSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0TGVux.at(k), cfd->amplitudeTGVux.at(k), cfd->basisTimeStepLengthTGVux.at(k)); - for (int k = 0; k < cfd->v0TGVuz.size(); k++) - if (shouldSimulationGroupRun(cfd->tgvUz)) - makeTaylorGreenUzSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->v0TGVuz.at(k), cfd->amplitudeTGVuz.at(k), cfd->basisTimeStepLengthTGVuz.at(k)); + for (int k = 0; k < configFileData->taylorGreenVortexUzParameter.size(); k++) { + std::shared_ptr<SimulationDataStruct> simDataStruct = makeTaylorGreenUzSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUzParameter.at(k), configFileData->taylorGreenVortexUzGridInformation); + + std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUzParameter.at(k)->basicTimeStepLength); + addNumericalTestStruct(numericalTestStruct); + } - for (int k = 0; k < cfd->u0SW.size(); k++) - if (shouldSimulationGroupRun(cfd->sw)) - makeShearWaveSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0SW.at(k), cfd->v0SW.at(k), cfd->basisTimeStepLengthSW.at(k)); + for (int k = 0; k < configFileData->shearWaveParameter.size(); k++) { + std::shared_ptr<SimulationDataStruct> simDataStruct = makeShearWaveSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->shearWaveParameter.at(k), configFileData->shearWaveGridInformation); + + std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->shearWaveParameter.at(k)->basicTimeStepLength); + addNumericalTestStruct(numericalTestStruct); + } } } } -void NumericalTestFactoryImp::makeTaylorGreenUxSimulations(std::string kernelName, double viscosity, double ux, double amplitude, int basicTimeStepLength) +std::shared_ptr<NumericalTestStruct> NumericalTestFactoryImp::makeNumericalTestStruct(std::shared_ptr<ConfigDataStruct> configFileData, std::shared_ptr<SimulationDataStruct> simDataStruct, std::string kernel, double viscosity, int basicTimeStepLength) { - std::vector< std::shared_ptr< SimulationParameter>> simParaTGV; - std::vector< std::shared_ptr< SimulationInfo>> simInfoTGV; - std::vector< std::shared_ptr< AnalyticalResults>> analyResultTGV; - - for (int i = 0; i < cfd->tgvUx.size(); i++) { - if (cfd->tgvUx.at(i)) { - simParaTGV.push_back(SimulationParameterTaylorGreenUx::getNewInstance(kernelName, ux, amplitude, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0TGVux, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); - simInfoTGV.push_back(SimulationInfoTaylorGreenUx::getNewInstance(ux, amplitude, cfd->l0TGVux, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); - analyResultTGV.push_back(AnalyticalResultsTaylorGreenUx::getNewInstance(viscosity, ux, amplitude, cfd->l0TGVux, cfd->rho0)); - } - } - std::shared_ptr<LogFileInformationTaylorGreenUx> tgInfo = LogFileInformationTaylorGreenUx::getNewInstance(ux, amplitude, cfd->tgvUx, cfd->lx, cfd->l0TGVux); + std::shared_ptr<NumericalTestStruct> numTestStruct = std::shared_ptr<NumericalTestStruct>(new NumericalTestStruct); + + std::vector<std::shared_ptr<TestSimulationImp> > testSim = makeTestSimulations(simDataStruct->testSimData, configFileData->vectorWriterInfo, configFileData->ySliceForCalculation); + numTestStruct->testSimulations = testSim; - makePeriodicBoundaryConditionSimulationAndTests(simParaTGV, simInfoTGV, analyResultTGV, tgInfo, kernelName, cfd->tgvUx, viscosity, basicTimeStepLength); + std::vector< std::shared_ptr< TestLogFileInformation>> testLogFileInfo; + + std::shared_ptr<PhiAndNuTestStruct> phiAndNuTestStruct = makePhiAndNuTestsStructs(configFileData->phiAndNuTestParameter, testSim, viscosity); + for (int i = 0; i < phiAndNuTestStruct->tests.size(); i++) + numTestStruct->tests.push_back(phiAndNuTestStruct->tests.at(i)); + if(phiAndNuTestStruct->tests.size() > 0) + testLogFileInfo.push_back(phiAndNuTestStruct->logFileInfo); + + std::shared_ptr<L2NormTestStruct> l2NormTestSruct = makeL2NormTestsStructs(configFileData->l2NormTestParameter, testSim); + for (int i = 0; i < l2NormTestSruct->tests.size(); i++) + numTestStruct->tests.push_back(l2NormTestSruct->tests.at(i)); + if (l2NormTestSruct->tests.size() > 0) + testLogFileInfo.push_back(l2NormTestSruct->logFileInfo); + + + + std::shared_ptr<L2NormTestBetweenKernelsStruct> l2NormTestBetweenKernelStruct = makeL2NormTestsBetweenKernelsStructs(configFileData->l2NormTestBetweenKernelsParameter, testSim, kernel); + for (int i = 0; i < l2NormTestBetweenKernelStruct->tests.size(); i++) + numTestStruct->tests.push_back(l2NormTestBetweenKernelStruct->tests.at(i)); + if (l2NormTestBetweenKernelStruct->tests.size() > 0) + testLogFileInfo.push_back(l2NormTestBetweenKernelStruct->logFileInfo); + + std::shared_ptr<LogFileWriter> logFileWriter = makeLogFileWriter(testLogFileInfo, simDataStruct->logFileInformation, testSim, kernel, viscosity, basicTimeStepLength, configFileData->logFilePara); + numTestStruct->logFileWriter = logFileWriter; + + return numTestStruct; } -void NumericalTestFactoryImp::makeTaylorGreenUzSimulations(std::string kernelName, double viscosity, double uz, double amplitude, int basicTimeStepLength) +void NumericalTestFactoryImp::addNumericalTestStruct(std::shared_ptr<NumericalTestStruct> numericalTestStruct) { - std::vector< std::shared_ptr< SimulationParameter>> simParaTGV; - std::vector< std::shared_ptr< SimulationInfo>> simInfoTGV; - std::vector< std::shared_ptr< AnalyticalResults>> analyResultTGV; - - for (int i = 0; i < cfd->tgvUz.size(); i++) { - if (cfd->tgvUz.at(i)) { - simParaTGV.push_back(SimulationParameterTaylorGreenUz::getNewInstance(kernelName, uz, amplitude, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0TGVuz, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); - simInfoTGV.push_back(SimulationInfoTaylorGreenUz::getNewInstance(uz, amplitude, cfd->l0TGVuz, cfd->lz.at(i), viscosity, kernelName, numberOfSimulations)); - analyResultTGV.push_back(AnalyticalResultsTaylorGreenUz::getNewInstance(viscosity, uz, amplitude, cfd->l0TGVuz, cfd->rho0)); - } - } - std::shared_ptr< LogFileInformationTaylorGreenUz> tgInfo = LogFileInformationTaylorGreenUz::getNewInstance(uz, amplitude, cfd->tgvUz, cfd->lz, cfd->l0TGVuz); + for (int i = 0; i < numericalTestStruct->testSimulations.size(); i++) + myTestSimulations.push_back(numericalTestStruct->testSimulations.at(i)); + + for (int i = 0; i < numericalTestStruct->tests.size(); i++) + myTestQueue->addTest(numericalTestStruct->tests.at(i)); - makePeriodicBoundaryConditionSimulationAndTests(simParaTGV, simInfoTGV, analyResultTGV, tgInfo, kernelName, cfd->tgvUz, viscosity, basicTimeStepLength); + myLogFileWriterQueue->addLogFileWriter(numericalTestStruct->logFileWriter); } -void NumericalTestFactoryImp::makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0, int basicTimeStepLength) +std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeTaylorGreenUxSimulationData(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct) { - std::vector< std::shared_ptr< SimulationParameter>> simParaSW; - std::vector< std::shared_ptr< SimulationInfo>> simInfoSW; - std::vector< std::shared_ptr< AnalyticalResults>> analyResultSW; - - for (int i = 0; i < cfd->sw.size(); i++) - if (cfd->sw.at(i)) { - simParaSW.push_back(ShearWaveSimulationParameter::getNewInstance(kernelName, u0, v0, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0SW, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); - simInfoSW.push_back(ShearWaveSimulationInfo::getNewInstance(u0, v0, cfd->l0SW, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); - analyResultSW.push_back(ShearWaveAnalyticalResults::getNewInstance(viscosity, u0, v0, cfd->l0SW, cfd->rho0)); - } + std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct); - std::shared_ptr< ShearWaveInformation> swInfo = ShearWaveInformation::getNewInstance(u0, v0, cfd->sw, cfd->lx, cfd->l0SW); + for (int i = 0; i < gridInfoStruct.size(); i++) { + std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct> (new TestSimulationDataStruct); + aTestSimData->simParameter = SimulationParameterTaylorGreenUx::getNewInstance(kernelName, viscosity, simParaStruct, gridInfoStruct.at(i)); + aTestSimData->simInformation = SimulationInfoTaylorGreenUx::getNewInstance(simID, kernelName, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations); + simID++; + aTestSimData->analyticalResult = AnalyticalResultsTaylorGreenUx::getNewInstance(viscosity, simParaStruct); + simDataStruct->testSimData.push_back(aTestSimData); + } + simDataStruct->logFileInformation = LogFileInformationTaylorGreenUx::getNewInstance(simParaStruct, gridInfoStruct); - makePeriodicBoundaryConditionSimulationAndTests(simParaSW, simInfoSW, analyResultSW, swInfo, kernelName, cfd->sw, viscosity, basicTimeStepLength); + return simDataStruct; } -void NumericalTestFactoryImp::makePeriodicBoundaryConditionSimulationAndTests(std::vector<std::shared_ptr<SimulationParameter>> simPara, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector<std::shared_ptr<AnalyticalResults>> analyResult, std::shared_ptr<SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector<bool> simulationsRun, double viscosity, int basicTimeStepLength) +std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeTaylorGreenUzSimulationData(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct) { - std::vector< std::shared_ptr< SimulationResults>> simResults; - for (int i = 0; i < simPara.size(); i++) { - std::shared_ptr< SimulationResults> simResult = SimulationResults::getNewInstance(simPara.at(i)->getLx(), 1, simPara.at(i)->getLz(), simPara.at(i)->getTimeStepLength()); - simResults.push_back(simResult); + std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct); + + for (int i = 0; i < gridInfoStruct.size(); i++) { + std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct>(new TestSimulationDataStruct); + aTestSimData->simParameter = SimulationParameterTaylorGreenUz::getNewInstance(kernelName, viscosity, simParaStruct, gridInfoStruct.at(i)); + aTestSimData->simInformation = SimulationInfoTaylorGreenUz::getNewInstance(simID, kernelName, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations); + simID++; + aTestSimData->analyticalResult = AnalyticalResultsTaylorGreenUz::getNewInstance(viscosity, simParaStruct); + simDataStruct->testSimData.push_back(aTestSimData); } + simDataStruct->logFileInformation = LogFileInformationTaylorGreenUz::getNewInstance(simParaStruct, gridInfoStruct); - std::vector< std::shared_ptr< TestSimulation>> testSim = buildTestSimulation(simPara, simInfo, simResults, analyResult); + return simDataStruct; +} - std::vector< std::shared_ptr< TestLogFileInformation>> testLogFileInfo; +std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeShearWaveSimulationData(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct) +{ + std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct); - if (cfd->nuAndPhiTest && checkNuAndPhiTestCouldRun(simulationsRun)) { - std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy; - for(int i = 0; i < testSim.size();i++) - phiAndNuPostProStrategy.push_back(PhiAndNuTestPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->dataToCalcPhiAndNuTest, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu)); - std::shared_ptr< PhiAndNuInformation> phiNuLogFileInfo = PhiAndNuInformation::getNewInstance(cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); - for (int i = 0; i < cfd->dataToCalcPhiAndNuTest.size(); i++) { - std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests = makePhiAndNuTests(testSim, simInfo, phiAndNuPostProStrategy, viscosity, cfd->dataToCalcPhiAndNuTest.at(i)); - phiNuLogFileInfo->addTestGroup(phiAndNuTests); - } - testLogFileInfo.push_back(phiNuLogFileInfo); + for (int i = 0; i < gridInfoStruct.size(); i++) { + std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct>(new TestSimulationDataStruct); + aTestSimData->simParameter = ShearWaveSimulationParameter::getNewInstance(kernelName, viscosity, simParaStruct, gridInfoStruct.at(i)); + aTestSimData->simInformation = ShearWaveSimulationInfo::getNewInstance(simID, kernelName, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations); + simID++; + aTestSimData->analyticalResult = ShearWaveAnalyticalResults::getNewInstance(viscosity, simParaStruct); + simDataStruct->testSimData.push_back(aTestSimData); } + simDataStruct->logFileInformation = ShearWaveInformation::getNewInstance(simParaStruct, gridInfoStruct); - if (cfd->l2NormTest) { - std::vector< std::shared_ptr< L2NormTest>> l2NormTests = makeL2NormTests(testSim, simInfo, simResults, analyResult); - std::shared_ptr< L2NormInformation> l2NormLogFileInfo = L2NormInformation::getNewInstance(l2NormTests, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); - testLogFileInfo.push_back(l2NormLogFileInfo); - } + return simDataStruct; +} - if (cfd->l2NormBetweenKernelTest){ - std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests = makeL2NormTestsBetweenKernels(testSim, simInfo, simResults, analyResult); - if (tests.size() > 0){ - std::shared_ptr<L2NormBetweenKernelsInformation> l2NormBetweenKernelLogFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, cfd->basicKernelL2NormTest, cfd->timeStepsL2NormBetweenKernel, cfd->dataToCalcL2NormBetweenKernel); - testLogFileInfo.push_back(l2NormBetweenKernelLogFileInfo); - } +std::vector<std::shared_ptr<TestSimulationImp> > NumericalTestFactoryImp::makeTestSimulations(std::vector<std::shared_ptr<TestSimulationDataStruct> > testSimDataStruct, std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int ySliceForCalculation) +{ + std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations; + for (int i = 0; i < testSimDataStruct.size(); i++) { + std::shared_ptr< SimulationResults> simResult = SimulationResults::getNewInstance(testSimDataStruct.at(i)->simParameter); + std::shared_ptr<ToVectorWriter> toVectorWriter = Y2dSliceToResults::getNewInstance(vectorWriterInfo, testSimDataStruct.at(i)->simParameter->getTimeStepLength(), simResult, ySliceForCalculation); + testSimumlations.push_back(TestSimulationImp::getNewInsance(testSimDataStruct.at(i), simResult, toVectorWriter, anaResultWriter, colorOutput)); } - for (int i = 0; i < testSim.size(); i++) - testSimulations.push_back(testSim.at(i)); - - std::shared_ptr< LogFileTimeInformation> logFileTimeInfo = LogFileTimeInformation::getNewInstance(testSim, cfd->writeFiles); - - makeLogFileWriter(testLogFileInfo, logFileTimeInfo, simlogFileInfo, kernelName, viscosity, basicTimeStepLength); + return testSimumlations; } -std::vector<std::shared_ptr<TestSimulation>> NumericalTestFactoryImp::buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector< std::shared_ptr< AnalyticalResults>> analyResult) +std::shared_ptr<PhiAndNuTestStruct> NumericalTestFactoryImp::makePhiAndNuTestsStructs(std::shared_ptr<PhiAndNuTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity) { - std::vector< std::shared_ptr< TestSimulation>> testSim; - testSim.resize(0); + std::shared_ptr<PhiAndNuTestStruct> testStruct = std::shared_ptr<PhiAndNuTestStruct> (new PhiAndNuTestStruct); - for (int i = 0; i < simPara.size(); i++) { - testSim.push_back(TestSimulationImp::getNewInsance(simID, simPara.at(i), simInfo.at(i), colorOutput, simResults.at(i), analyResult.at(i), anaResultWriter, cfd->writeAnalyticalToVTK)); - simID++; + if (testParameter->basicTestParameter->runTest && testSimumlations.size() > 1) { + testStruct->logFileInfo = PhiAndNuInformation::getNewInstance(testParameter); + + for (int i = 0; i < testSimumlations.size(); i++) + testStruct->postProcessingStrategies.push_back(PhiAndNuTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter)); + + for (int i = 0; i < testParameter->basicTestParameter->dataToCalc.size(); i++) { + std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests = makePhiAndNuTests(testParameter, testSimumlations, testStruct->postProcessingStrategies, viscosity, testParameter->basicTestParameter->dataToCalc.at(i)); + testStruct->logFileInfo->addTestGroup(phiAndNuTests); + for (int j = 0; j < phiAndNuTests.size(); j++) + testStruct->tests.push_back(phiAndNuTests.at(j)); + } } - return testSim; + + return testStruct; } -std::vector<std::shared_ptr<PhiAndNuTest>> NumericalTestFactoryImp::makePhiAndNuTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate) +std::vector<std::shared_ptr<PhiAndNuTest>> NumericalTestFactoryImp::makePhiAndNuTests(std::shared_ptr<PhiAndNuTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> postProStrategy, double viscosity, std::string dataToCalculate) { std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests; - for (int i = 1; i < testSim.size(); i++) { for (int j = 0; j < i; j++) { - std::shared_ptr< PhiAndNuTest> test = PhiAndNuTest::getNewInstance(colorOutput, dataToCalculate, cfd->minOrderOfAccuracy, viscosity, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); - test->addSimulation(testSim.at(j), simInfo.at(j), phiAndNuPostProStrategy.at(j)); - test->addSimulation(testSim.at(i), simInfo.at(i), phiAndNuPostProStrategy.at(i)); + std::shared_ptr< PhiAndNuTest> test = PhiAndNuTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate); + test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), postProStrategy.at(j)); + test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(i)); - testSim.at(j)->registerSimulationObserver(test); - testSim.at(i)->registerSimulationObserver(test); + testSim.at(j)->registerSimulationObserver(test); + testSim.at(i)->registerSimulationObserver(test); - phiAndNuTests.push_back(test); - testQueue->addTest(test); + phiAndNuTests.push_back(test); } } return phiAndNuTests; } -std::vector<std::shared_ptr<L2NormTest>> NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult) +std::shared_ptr<L2NormTestStruct> NumericalTestFactoryImp::makeL2NormTestsStructs(std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations) +{ + std::shared_ptr<L2NormTestStruct> testStruct = std::shared_ptr<L2NormTestStruct> (new L2NormTestStruct); + + if (testParameter->basicTestParameter->runTest) { + for (int i = 0; i < testSimumlations.size(); i++) + testStruct->postProcessingStrategies.push_back(L2NormPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter)); + + testStruct->tests = makeL2NormTests(testSimumlations, testStruct->postProcessingStrategies, testParameter); + testStruct->logFileInfo = L2NormInformation::getNewInstance(testStruct->tests, testParameter); + } + return testStruct; +} + +std::vector<std::shared_ptr<L2NormTest>> NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector< std::shared_ptr< L2NormPostProcessingStrategy>> postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter) { std::vector<std::shared_ptr<L2NormTest>> l2Tests; for (int i = 0; i < testSim.size(); i++) { - std::shared_ptr< L2NormPostProcessingStrategy> l2NormPostProStrategy = L2NormPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->dataToCalcL2Test, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); - for (int j = 0; j < cfd->dataToCalcL2Test.size(); j++) { - std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, cfd->dataToCalcL2Test.at(j), cfd->maxL2NormDiff, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); - test->addSimulation(testSim.at(i), simInfo.at(i), l2NormPostProStrategy); + for (int j = 0; j < testParameter->basicTestParameter->dataToCalc.size(); j++) { + std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, testParameter, testParameter->basicTestParameter->dataToCalc.at(j)); + test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(i)); testSim.at(i)->registerSimulationObserver(test); l2Tests.push_back(test); - testQueue->addTest(test); } - } return l2Tests; } -std::vector<std::shared_ptr<L2NormTestBetweenKernels>> NumericalTestFactoryImp::makeL2NormTestsBetweenKernels(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector<std::shared_ptr<SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult) +std::shared_ptr<L2NormTestBetweenKernelsStruct> NumericalTestFactoryImp::makeL2NormTestsBetweenKernelsStructs(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::string kernelName) { - std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests; - for (int i = 0; i < testSim.size(); i++) - { - std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy = L2NormBetweenKernelPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->timeStepsL2NormBetweenKernel, cfd->dataToCalcL2NormBetweenKernel); - if (simID - 1 <= simPerKernel) - { - for (int j = 0; j < numberOfTestsForOneSimulation; j++) - { - for (int k = 0; k < cfd->kernelsToTest.size() - 1; k++) - { - l2KernelTests.at(posBasicSimulationForL2Test + simPerKernel * k)->setBasicSimulation(testSim.at(i), simInfo.at(i), postProcessingStrategy); - testSim.at(i)->registerSimulationObserver(l2KernelTests.at(posBasicSimulationForL2Test + simPerKernel * k)); - } - posBasicSimulationForL2Test++; + std::shared_ptr<L2NormTestBetweenKernelsStruct> testStruct = std::shared_ptr<L2NormTestBetweenKernelsStruct>(new L2NormTestBetweenKernelsStruct); + + if (testPara->basicTestParameter->runTest) { + + std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies; + for (int i = 0; i < testSim.size(); i++) + postProcessingStrategies.push_back(L2NormBetweenKernelPostProcessingStrategy::getNewInstance(testSim.at(i)->getSimulationResults(), testSim.at(i)->getAnalyticalResults(), testPara)); + + if (kernelName == testPara->basicKernel) { + std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > tests = makeL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies); + + if (l2NormTestsBetweenKernels.size() == 0) { + l2NormTestsBetweenKernels = tests; } - } - else - { - for (int j = 0; j < numberOfTestsForOneSimulation; j++) - { - l2KernelTests.at(posDivergentSimulationForL2Test)->setDivergentKernelSimulation(testSim.at(i), simInfo.at(i), postProcessingStrategy); - tests.push_back(l2KernelTests.at(posDivergentSimulationForL2Test)); - testQueue->addTest(l2KernelTests.at(posDivergentSimulationForL2Test)); - testSim.at(i)->registerSimulationObserver(l2KernelTests.at(posDivergentSimulationForL2Test)); - posDivergentSimulationForL2Test++; + else { + for (int i = 0; i < tests.size(); i++) + for (int j = 0; j < tests.at(i).size(); j++) + l2NormTestsBetweenKernels.at(i).push_back(tests.at(i).at(j)); } + + }else{ + std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests = linkL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies); + testStruct->tests = tests; + testStruct->logFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, testPara); } } - return tests; + return testStruct; } -void NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation>> testLogFiles, std::shared_ptr<LogFileTimeInformation> logFileTimeInfo, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, int basicTimeStepLength) -{ - std::shared_ptr< LogFileWriterImp> logFileWriter = LogFileWriterImp::getNewInstance(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, cfd->devices, cfd->numberOfTimeSteps, calcStartStepForToVectorWriter(), basicTimeStepLength); - logFileWriterQueue->addLogFileWriter(logFileWriter); -} -void NumericalTestFactoryImp::sortKernels() +std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > NumericalTestFactoryImp::makeL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies) { - bool basicKernelInKernelList = false; - for (int i = 0; i < cfd->kernelsToTest.size(); i++) { - if (cfd->kernelsToTest.at(i) == cfd->basicKernelL2NormTest) - basicKernelInKernelList = true; - } - if (!basicKernelInKernelList) - cfd->kernelsToTest.push_back(cfd->basicKernelL2NormTest); - - std::vector< std::string> kernels = cfd->kernelsToTest; - - while (kernels.at(0)!= cfd->basicKernelL2NormTest){ - kernels.push_back(kernels.at(0)); - std::vector< std::string>::iterator it = kernels.begin(); - kernels.erase(it); + std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > testsForAllKernels; + + std::vector<std::shared_ptr<L2NormTestBetweenKernels> > testForOneKernel; + + for (int l = 0; l < testPara->kernelsToTest.size() - 1; l++) { + for (int k = 0; k < testSim.size(); k++) { + for(int j = 0; j < testPara->basicTestParameter->dataToCalc.size(); j++){ + for (int i = 0; i < testPara->timeSteps.size(); i++) { + std::shared_ptr<L2NormTestBetweenKernels> aTest = L2NormTestBetweenKernels::getNewInstance(colorOutput, testPara->basicTestParameter->dataToCalc.at(j), testPara->timeSteps.at(i)); + aTest->setBasicSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); + testSim.at(k)->registerSimulationObserver(aTest); + testForOneKernel.push_back(aTest); + } + } + } + testsForAllKernels.push_back(testForOneKernel); + testForOneKernel.resize(0); } - cfd->kernelsToTest = kernels; + + return testsForAllKernels; } -bool NumericalTestFactoryImp::shouldSimulationGroupRun(std::vector<bool> test) +std::vector<std::shared_ptr<L2NormTestBetweenKernels>> NumericalTestFactoryImp::linkL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector< std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies) { - for (int i = 0; i < test.size(); i++) { - if (test.at(i)) - return true; + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests; + + if (testSim.size() > 0) + if (l2NormTestsBetweenKernels.at(0).size() == 0) + l2NormTestsBetweenKernels.erase(l2NormTestsBetweenKernels.begin()); + + for (int k = 0; k < testSim.size(); k++) { + for (int j = 0; j < testPara->basicTestParameter->dataToCalc.size(); j++) { + for (int i = 0; i < testPara->timeSteps.size(); i++) { + std::shared_ptr<L2NormTestBetweenKernels> aTest = l2NormTestsBetweenKernels.at(0).at(0); + l2NormTestsBetweenKernels.at(0).erase(l2NormTestsBetweenKernels.at(0).begin()); + aTest->setDivergentKernelSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); + testSim.at(k)->registerSimulationObserver(aTest); + tests.push_back(aTest); + } + } } - return false; + return tests; } -unsigned int NumericalTestFactoryImp::calcStartStepForToVectorWriter() -{ - std::vector< unsigned int> startStepsTests; - startStepsTests.push_back(cfd->basicTimeStepL2Norm); - startStepsTests.push_back(cfd->startTimeStepCalculationPhiNu); - std::sort(startStepsTests.begin(), startStepsTests.end()); - return startStepsTests.at(0); -} - -bool NumericalTestFactoryImp::checkNuAndPhiTestCouldRun(std::vector<bool> test) +std::shared_ptr<LogFileWriter> NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation>> testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara) { - int numberOfTestInGroup = 0; - for (int i = 0; i < test.size(); i++) { - if (test.at(i)) - numberOfTestInGroup++; - } - return numberOfTestInGroup > 1; -} + std::shared_ptr<LogFileHead> logFileHead = LogFileHead::getNewInstance(logFilePara->devices); + std::shared_ptr<BasicSimulationInfo> basicSimInfo = BasicSimulationInfo::getNewInstance(logFilePara->numberOfTimeSteps, viscosity, basicTimeStepLength, kernelName); -void NumericalTestFactoryImp::calcNumberOfSimulations() -{ - int counter = 0; - - int tgvCounterU0 = 0; - for (int i = 0; i < cfd->tgvUx.size(); i++) - if (cfd->tgvUx.at(i)) - tgvCounterU0++; - tgvCounterU0 *= cfd->u0TGVux.size(); - counter += tgvCounterU0; - - int tgvCounterV0 = 0; - for (int i = 0; i < cfd->tgvUz.size(); i++) - if (cfd->tgvUz.at(i)) - tgvCounterV0++; - tgvCounterV0 *= cfd->v0TGVuz.size(); - counter += tgvCounterV0; - - - int swCounter = 0; - for (int i = 0; i < cfd->sw.size(); i++) - if (cfd->sw.at(i)) - swCounter++; - swCounter *= cfd->u0SW.size(); - counter += swCounter; - - counter *= cfd->viscosity.size(); - counter *= cfd->kernelsToTest.size(); - - numberOfSimulations = counter; + std::vector<std::shared_ptr<TestSimulation> > testSimCast; + for (int i = 0; i < testSim.size(); i++) + testSimCast.push_back(testSim.at(i)); + std::shared_ptr<LogFileTimeInformation> logFileTimeInfo = LogFileTimeInformation::getNewInstance(testSimCast, logFilePara->writeAnalyticalToVTK); + + std::shared_ptr<LogFileWriterImp> logFileWriter = LogFileWriterImp::getNewInstance(logFileHead, basicSimInfo, testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity); + + return logFileWriter; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h index 9468d4fa9..40cb2ac28 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h @@ -2,15 +2,33 @@ #define NUMERICAL_TEST_FACTORY_IMP_H #include "NumericalTestFactory.h" -#include "Utilities\ConfigFileReader\ConfigData.h" -class AnalyticalResults; +struct ConfigDataStruct; +struct GridInformationStruct; +struct L2NormTestStruct; +struct L2NormTestParameterStruct; +struct L2NormTestBetweenKernelsParameterStruct; +struct L2NormTestBetweenKernelsStruct; +struct LogFileParameterStruct; +struct NumericalTestStruct; +struct PhiAndNuTestStruct; +struct PhiAndNuTestParameterStruct; +struct ShearWaveParameterStruct; +struct SimulationDataStruct; +struct TaylorGreenVortexUxParameterStruct; +struct TaylorGreenVortexUzParameterStruct; +struct TestSimulationDataStruct; +struct VectorWriterInformationStruct; + class AnalyticalResults2DToVTKWriter; class ColorConsoleOutput; class L2NormTest; +class L2NormPostProcessingStrategy; +class L2NormBetweenKernelPostProcessingStrategy; class L2NormTestBetweenKernels; class LogFileTimeInformation; class LogFileQueueImp; +class LogFileWriter; class PhiAndNuTest; class PhiAndNuTestPostProcessingStrategy; class SimulationInfo; @@ -18,6 +36,8 @@ class SimulationLogFileInformation; class SimulationParameter; class SimulationResults; class TestQueueImp; +class TestSimulation; +class TestSimulationImp; class TestLogFileInformation; class NumericalTestFactoryImp : public NumericalTestFactory @@ -33,34 +53,41 @@ private: NumericalTestFactoryImp() {}; NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData); - void init(); - void makeTaylorGreenUxSimulations(std::string kernelName, double viscosity, double u0, double amplitude, int basicTimeStepLength); - void makeTaylorGreenUzSimulations(std::string kernelName, double viscosity, double u0, double amplitude, int basicTimeStepLength); - void makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0, int basicTimeStepLength); - void makePeriodicBoundaryConditionSimulationAndTests(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< AnalyticalResults>> analyResult, std::shared_ptr< SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector< bool> simulationsRun, double viscosity, int basicTimeStepLength); - std::vector< std::shared_ptr< TestSimulation>> buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector< std::shared_ptr< AnalyticalResults>> analyResult); - std::vector< std::shared_ptr< PhiAndNuTest>> makePhiAndNuTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); - std::vector< std::shared_ptr< L2NormTest>> makeL2NormTests(std::vector<std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult); - std::vector< std::shared_ptr< L2NormTestBetweenKernels>> makeL2NormTestsBetweenKernels(std::vector<std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult); - void makeLogFileWriter(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, int basicTimeStepLength); + void init(std::shared_ptr<ConfigDataStruct> configFileData); + + std::shared_ptr<NumericalTestStruct> makeNumericalTestStruct(std::shared_ptr<ConfigDataStruct> configFileData, std::shared_ptr<SimulationDataStruct> simDataStruct, std::string kernel, double viscosity, int basicTimeStepLength); + void addNumericalTestStruct(std::shared_ptr<NumericalTestStruct> numericalTestStruct); + + std::shared_ptr<SimulationDataStruct> makeTaylorGreenUxSimulationData(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); + std::shared_ptr<SimulationDataStruct> makeTaylorGreenUzSimulationData(std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); + std::shared_ptr<SimulationDataStruct> makeShearWaveSimulationData(std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct); + + std::vector<std::shared_ptr<TestSimulationImp> > makeTestSimulations(std::vector<std::shared_ptr<TestSimulationDataStruct> > testSimDataStruct, std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int ySliceForCalculation); + + std::shared_ptr<PhiAndNuTestStruct> makePhiAndNuTestsStructs(std::shared_ptr<PhiAndNuTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity); + std::shared_ptr<L2NormTestStruct> makeL2NormTestsStructs(std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations); + std::shared_ptr<L2NormTestBetweenKernelsStruct> makeL2NormTestsBetweenKernelsStructs(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::string kernelName); + std::vector<std::shared_ptr<PhiAndNuTest> > makePhiAndNuTests(std::shared_ptr<PhiAndNuTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); + std::vector<std::shared_ptr<L2NormTest> > makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector< std::shared_ptr< L2NormPostProcessingStrategy>> postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter); + std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > makeL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies); - void sortKernels(); - bool shouldSimulationGroupRun(std::vector<bool> test); - unsigned int calcStartStepForToVectorWriter(); - bool checkNuAndPhiTestCouldRun(std::vector<bool> test); - void calcNumberOfSimulations(); - - std::shared_ptr<ConfigDataStruct> cfd; - std::vector< std::shared_ptr< TestSimulation>> testSimulations; - std::shared_ptr< TestQueueImp> testQueue; - std::shared_ptr< LogFileQueueImp> logFileWriterQueue; + std::vector<std::shared_ptr<L2NormTestBetweenKernels> > linkL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector< std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies); + + std::shared_ptr< LogFileWriter> makeLogFileWriter(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara); + + std::vector< std::shared_ptr< TestSimulation>> myTestSimulations; + std::shared_ptr< TestQueueImp> myTestQueue; + std::shared_ptr< LogFileQueueImp> myLogFileWriterQueue; + + std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > l2NormTestsBetweenKernels; + + std::shared_ptr< ColorConsoleOutput> colorOutput; std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter; int simID; int numberOfSimulations; int simPerKernel, numberOfTestGroupsBetweenKernels, numberOfTestsForOneSimulation, numberOfTestsBetweenKernels; - std::vector< std::shared_ptr< L2NormTestBetweenKernels>> l2KernelTests; int posBasicSimulationForL2Test, posDivergentSimulationForL2Test; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h index 905e82820..8c9d2ba51 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h @@ -2,6 +2,7 @@ #define POST_PROCESSING_STRATEGY_H #include <vector> +#include <memory> class SimulationResults; @@ -9,6 +10,7 @@ class PostProcessingStrategy { public: virtual void evaluate() = 0; + virtual bool checkEqualSimulationResults(std::shared_ptr<SimulationResults> simResultsToCheck) = 0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp index f69f97b62..cc0f65f1b 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp @@ -2,6 +2,14 @@ #include "Utilities\Results\SimulationResults\SimulationResults.h" +bool PostProcessingStrategyImp::checkEqualSimulationResults(std::shared_ptr<SimulationResults> simResultsToCheck) +{ + if (simResultsToCheck.get() == simResult.get()) + return true; + + return false; +} + int PostProcessingStrategyImp::getNumberOfXNodes() { return simResult->getNumberOfXNodes(); diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h index 77b3e3b20..266055b5d 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h @@ -11,6 +11,7 @@ class PostProcessingStrategyImp : public PostProcessingStrategy { public: virtual void evaluate() = 0; + bool checkEqualSimulationResults(std::shared_ptr<SimulationResults> simResultsToCheck); int getNumberOfXNodes(); int getNumberOfYNodes(); diff --git a/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.cpp b/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.cpp index 6e7fafe23..71ace44b5 100644 --- a/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.cpp +++ b/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.cpp @@ -1,21 +1,23 @@ #include "SimulationResults.h" +#include "Utilities\SimulationParameter\SimulationParameter.h" + #define _USE_MATH_DEFINES #include <math.h> -SimulationResults::SimulationResults(unsigned int lx, unsigned int ly, unsigned int lz, unsigned int timeStepLength) +SimulationResults::SimulationResults(std::shared_ptr<SimulationParameter> simPara) { - this->xNodes = lx; - this->yNodes = ly; - this->zNodes = lz; - this->numberOfNodes = lx*ly*lz; - this->timeStepLength = timeStepLength; + this->xNodes = simPara->getLx(); + this->yNodes = 1; + this->zNodes = simPara->getLz(); + this->numberOfNodes = xNodes*yNodes*zNodes; + this->timeStepLength = simPara->getTimeStepLength(); this->numberOfTimeSteps = 0; } -std::shared_ptr<SimulationResults> SimulationResults::getNewInstance(unsigned int lx, unsigned int ly, unsigned int lz, unsigned int timeStepLength) +std::shared_ptr<SimulationResults> SimulationResults::getNewInstance(std::shared_ptr<SimulationParameter> simPara) { - return std::shared_ptr<SimulationResults>(new SimulationResults(lx, ly, lz, timeStepLength)); + return std::shared_ptr<SimulationResults>(new SimulationResults(simPara)); } void SimulationResults::addTimeStep(unsigned int timeStep, unsigned int time, std::vector<unsigned int> level, std::vector<double> x, std::vector<double> y, std::vector<double> z, std::vector<double> vx, std::vector<double> vy, std::vector<double> vz, std::vector<double> press, std::vector<double> rho) diff --git a/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.h b/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.h index 0b48cc89a..80bcadd3e 100644 --- a/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.h +++ b/targets/tests/NumericalTests/Utilities/Results/SimulationResults/SimulationResults.h @@ -4,14 +4,16 @@ #include "../ResultsImp.h" #include <memory> +class SimulationParameter; + class SimulationResults : public ResultsImp { public: - static std::shared_ptr<SimulationResults> getNewInstance(unsigned int lx, unsigned int ly, unsigned int lz, unsigned int timeStepLength); + static std::shared_ptr<SimulationResults> getNewInstance(std::shared_ptr<SimulationParameter> simPara); void addTimeStep(unsigned int timeStep, unsigned int time, std::vector<unsigned int> level, std::vector<double> x, std::vector<double> y, std::vector<double> z, std::vector<double> vx, std::vector<double> vy, std::vector<double> vz, std::vector<double> press, std::vector<double> rho); private: - SimulationResults(unsigned int lx, unsigned int ly, unsigned int lz, unsigned int timeStepLength); + SimulationResults(std::shared_ptr<SimulationParameter> simPara); }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h index 20dcb0808..2b04f75a1 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h @@ -13,7 +13,6 @@ public: virtual int getLx() = 0; virtual int getNumberOfSimulations() = 0; virtual int getSimulationID() = 0; - virtual void setSimulationID(int simID) = 0; private: diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp index bab0db903..e1e04c15f 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp @@ -35,11 +35,7 @@ int SimulationInfoImp::getSimulationID() return simID; } -void SimulationInfoImp::setSimulationID(int simID) -{ - this->simID = simID; -} - -SimulationInfoImp::SimulationInfoImp(int lx, double viscosity, std::string kernelName, int numberOfSimulations) : lx(lx), viscosity(viscosity), kernelName(kernelName), numberOfSimulations(numberOfSimulations) +SimulationInfoImp::SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName) + : simID(simID), lx(lx), viscosity(viscosity), kernelName(kernelName), numberOfSimulations(numberOfSimulations), simulationName(simulationName) { } diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h index 460afbe60..9a4d399d7 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h @@ -13,11 +13,10 @@ public: int getLx(); int getNumberOfSimulations(); int getSimulationID(); - void setSimulationID(int simID); protected: SimulationInfoImp() {}; - SimulationInfoImp(int lx, double viscosity, std::string kernelName, int numberOfSimulations); + SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName); double viscosity; std::string kernelName; diff --git a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameter.h b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameter.h index 8dd72a8a9..3946792c8 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameter.h +++ b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameter.h @@ -11,25 +11,21 @@ class KernelConfiguration; class SimulationParameter { public: + virtual std::shared_ptr< KernelConfiguration> getKernelConfiguration() = 0; virtual double getViscosity() = 0; - virtual double getMaxVelocity() = 0; + virtual std::string getGridPath() = 0; + virtual std::string getFilePath() = 0; virtual unsigned int getNumberOfGridLevels() = 0; virtual unsigned int getEndTime() = 0; virtual unsigned int getTimeStepLength() = 0; - virtual unsigned int getLx() = 0; - virtual unsigned int getLz() = 0; - virtual unsigned int getYSliceForCalculation() = 0; - virtual unsigned int getStartTimeCalculation() = 0; - virtual unsigned int getStartTimeDataWriter() = 0; - virtual bool getWriteFiles() = 0; - virtual std::string getGridPath() = 0; - virtual std::string getFilePath() = 0; virtual std::vector< int> getDevices() = 0; - virtual std::shared_ptr< InitialCondition> getInitialCondition() = 0; - virtual std::shared_ptr< KernelConfiguration> getKernelConfiguration() = 0; + virtual double getMaxVelocity() = 0; + -private: + virtual unsigned int getLx() = 0; + virtual unsigned int getLz() = 0; + virtual std::shared_ptr< InitialCondition> getInitialCondition() = 0; }; #endif diff --git a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp index a07cb857e..0f1ab8edb 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp +++ b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp @@ -1,27 +1,28 @@ #include "SimulationParameterImp.h" +#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" + +#include "Utilities\Structs\BasicSimulationParameterStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" + #include <experimental/filesystem> -SimulationParameterImp::SimulationParameterImp(std::string simName, real viscosity, real lx, real lz, real l0, real lForTimeStepLength, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, - std::vector<int> devices) - :simName(simName), viscosity(viscosity), lx(lx), l0(l0), lz(lz), - numberOfTimeSteps(numberOfTimeSteps), basisTimeStepLength(basisTimeStepLength), - startStepCalculation(startStepCalculation), ySliceForCalculation(ySliceForCalculation), - gridPath(gridPath), maxLevel(maxLevel), numberOfGridLevels(numberOfGridLevels), - writeFiles(writeFiles), startStepFileWriter(startStepFileWriter), devices(devices) +SimulationParameterImp::SimulationParameterImp(std::string kernelName, double viscosity, std::shared_ptr<BasicSimulationParameterStruct> basicSimPara, std::shared_ptr<GridInformationStruct> gridInfo) + : viscosity(viscosity) { - timeStepLength = basisTimeStepLength * (lForTimeStepLength / l0)*(lForTimeStepLength / l0); - startTimeCalculation = timeStepLength * startStepCalculation; - startTimeDataWriter = timeStepLength * startStepFileWriter; - endTime = timeStepLength * numberOfTimeSteps; + kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); + devices = basicSimPara->devices; + numberOfTimeSteps = basicSimPara->numberOfTimeSteps; + + gridPath = gridInfo->gridPath; + lx = gridInfo->lx; + lz = gridInfo->lz; + maxLevel = gridInfo->maxLevel; + numberOfGridLevels = gridInfo->numberOfGridLevels; } -void SimulationParameterImp::generateFilePath(std::string filePath) +void SimulationParameterImp::generateFileDirectionInMyStystem(std::string filePath) { std::experimental::filesystem::path dir(filePath); if (!(std::experimental::filesystem::exists(dir))) @@ -50,7 +51,7 @@ unsigned int SimulationParameterImp::getNumberOfGridLevels() unsigned int SimulationParameterImp::getEndTime() { - return endTime; + return timeStepLength * numberOfTimeSteps; } unsigned int SimulationParameterImp::getTimeStepLength() @@ -68,26 +69,6 @@ unsigned int SimulationParameterImp::getLz() return lz; } -unsigned int SimulationParameterImp::getYSliceForCalculation() -{ - return ySliceForCalculation; -} - -unsigned int SimulationParameterImp::getStartTimeCalculation() -{ - return startTimeCalculation; -} - -bool SimulationParameterImp::getWriteFiles() -{ - return writeFiles; -} - -unsigned int SimulationParameterImp::getStartTimeDataWriter() -{ - return startTimeDataWriter; -} - std::vector<int> SimulationParameterImp::getDevices() { return devices; diff --git a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h index b0cc2464e..21fbb78bd 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h +++ b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h @@ -5,6 +5,9 @@ #include "LBM\LB.h" +struct GridInformationStruct; +struct BasicSimulationParameterStruct; + class SimulationParameterImp : public SimulationParameter { public: @@ -16,39 +19,25 @@ public: unsigned int getTimeStepLength(); unsigned int getLx(); unsigned int getLz(); - unsigned int getYSliceForCalculation(); - unsigned int getStartTimeCalculation(); - bool getWriteFiles(); - unsigned int getStartTimeDataWriter(); std::vector< int> getDevices(); std::shared_ptr< InitialCondition> getInitialCondition(); std::shared_ptr< KernelConfiguration> getKernelConfiguration(); protected: SimulationParameterImp() {}; - SimulationParameterImp(std::string simName, real viscosity, real lx, real lz, real l0, - real lForTimeStepLength, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, - unsigned int startStepCalculation, unsigned int ySliceForCalculation, - std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, - bool writeFiles, unsigned int startStepFileWriter, - std::vector<int> devices); + SimulationParameterImp(std::string kernelName, double viscosity, std::shared_ptr<BasicSimulationParameterStruct> basicSimPara, std::shared_ptr<GridInformationStruct> gridInfo); - void generateFilePath(std::string filePath); + void generateFileDirectionInMyStystem(std::string filePath); real viscosity; real lx, l0, lz; unsigned int numberOfTimeSteps, basisTimeStepLength; - unsigned int startStepCalculation, startStepFileWriter, ySliceForCalculation; std::string gridPath; std::string filePath; - std::string simName; - bool writeFiles; std::vector<int> devices; unsigned int maxLevel, numberOfGridLevels; unsigned int timeStepLength; - unsigned int startTimeCalculation, startTimeDataWriter; - unsigned int endTime; std::shared_ptr< InitialCondition> initialCondition; std::shared_ptr< KernelConfiguration> kernelConfig; diff --git a/targets/tests/NumericalTests/Utilities/Structs/BasicSimulationParameterStruct.h b/targets/tests/NumericalTests/Utilities/Structs/BasicSimulationParameterStruct.h new file mode 100644 index 000000000..567947d61 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/BasicSimulationParameterStruct.h @@ -0,0 +1,12 @@ +#ifndef BASIC_SIMULATION_PARAMETER_STRUCT_H +#define BASIC_SIMULATION_PARAMETER_STRUCT_H + +#include <vector> + +struct BasicSimulationParameterStruct +{ + std::vector<int> devices; + unsigned int numberOfTimeSteps; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h b/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h new file mode 100644 index 000000000..d681c0724 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h @@ -0,0 +1,13 @@ +#ifndef BASIC_TEST_PARAMETER_STRUCT_H +#define BASIC_TEST_PARAMETER_STRUCT_H + +#include <string> +#include <vector> + +struct BasicTestParameterStruct +{ + unsigned int ySliceForCalculation; + bool runTest; + std::vector<std::string> dataToCalc; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h b/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h new file mode 100644 index 000000000..40defaf05 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h @@ -0,0 +1,52 @@ +#ifndef CONFIG_DATA_STRUCT_H +#define CONFIG_DATA_STRUCT_H + +#include <memory> +#include <string> +#include <vector> + +#include "Simulations\ShearWave\ShearWaveParameterStruct.h" +#include "Simulations\TaylorGreenVortexUx\TaylorGreenVortexUxParameterStruct.h" +#include "Simulations\TaylorGreenVortexUz\TaylorGreenVortexUzParameterStruct.h" +#include "Tests\L2NormTest\L2NormTestParameterStruct.h" +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernelsParameterStruct.h" +#include "Tests\PhiAndNuTest\PhiAndNuTestParameterStruct.h" +#include "Utilities\Structs\BasicSimulationParameterStruct.h" +#include "Utilities\Structs\VectorWriterInformationStruct.h" +#include "Utilities\Structs\GridInformationStruct.h" +#include "Utilities\Structs\LogFileParameterStruct.h" + +struct ConfigDataStruct +{ + std::vector<double> viscosity; + std::vector<std::string> kernelsToTest; + + std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct> > taylorGreenVortexUxParameter; + std::vector<std::shared_ptr<GridInformationStruct> > taylorGreenVortexUxGridInformation; + + std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > taylorGreenVortexUzParameter; + std::vector<std::shared_ptr<GridInformationStruct> > taylorGreenVortexUzGridInformation; + + std::vector<std::shared_ptr<ShearWaveParameterStruct> > shearWaveParameter; + std::vector<std::shared_ptr<GridInformationStruct> > shearWaveGridInformation; + + + + + bool writeAnalyticalToVTK; + unsigned int ySliceForCalculation; + + std::string logFilePath; + + int numberOfSimulations; + + std::shared_ptr<PhiAndNuTestParameterStruct> phiAndNuTestParameter; + std::shared_ptr<L2NormTestParameterStruct> l2NormTestParameter; + std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> l2NormTestBetweenKernelsParameter; + + std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo; + + std::shared_ptr<LogFileParameterStruct> logFilePara; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/GridInformationStruct.h b/targets/tests/NumericalTests/Utilities/Structs/GridInformationStruct.h new file mode 100644 index 000000000..1cf837ec2 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/GridInformationStruct.h @@ -0,0 +1,14 @@ +#ifndef GRID_INFORMATION_STRUCT_H +#define GRID_INFORMATION_STRUCT_H + +#include <string> + +struct GridInformationStruct +{ + unsigned int numberOfGridLevels; + unsigned int maxLevel; + std::string gridPath; + double lx; + double lz; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/LogFileParameterStruct.h b/targets/tests/NumericalTests/Utilities/Structs/LogFileParameterStruct.h new file mode 100644 index 000000000..9ed91eacc --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/LogFileParameterStruct.h @@ -0,0 +1,13 @@ +#ifndef LOG_FILE_PARAMETER_STRUCT_H +#define LOG_FILE_PARAMETER_STRUCT_H + +#include <vector> + +struct LogFileParameterStruct +{ + std::vector<int> devices; + int numberOfTimeSteps; + bool writeAnalyticalToVTK; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/NumericalTestStruct.h b/targets/tests/NumericalTests/Utilities/Structs/NumericalTestStruct.h new file mode 100644 index 000000000..75d432a5a --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/NumericalTestStruct.h @@ -0,0 +1,17 @@ +#ifndef NUMERICAL_TEST_STRUCT_H +#define NUMERICAL_TEST_STRUCT_H + +#include <memory> +#include <vector> + +class LogFileWriter; +class Test; +class TestSimulationImp; + +struct NumericalTestStruct +{ + std::vector<std::shared_ptr<TestSimulationImp> > testSimulations; + std::vector<std::shared_ptr<Test> > tests; + std::shared_ptr<LogFileWriter> logFileWriter; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/SimulationDataStruct.h b/targets/tests/NumericalTests/Utilities/Structs/SimulationDataStruct.h new file mode 100644 index 000000000..ed3e55ac7 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/SimulationDataStruct.h @@ -0,0 +1,17 @@ +#ifndef SIMULATION_DATA_STRUCT_H +#define SIMULATION_DATA_STRUCT_H + +#include "Utilities\Structs\TestSimulationDataStruct.h" + +#include <vector> +#include <memory> + +class LogFileInformationImp; + +struct SimulationDataStruct +{ + std::vector<std::shared_ptr<TestSimulationDataStruct> > testSimData; + + std::shared_ptr<SimulationLogFileInformation> logFileInformation; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/TestSimulationDataStruct.h b/targets/tests/NumericalTests/Utilities/Structs/TestSimulationDataStruct.h new file mode 100644 index 000000000..1744a0a7e --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/TestSimulationDataStruct.h @@ -0,0 +1,16 @@ +#ifndef TEST_SIMULATION_DATA_STRUCT_H +#define TEST_SIMULATION_DATA_STRUCT_H + +#include <memory> + +class SimulationParameter; +class SimulationInfo; +class AnalyticalResults; + +struct TestSimulationDataStruct +{ + std::shared_ptr< SimulationParameter> simParameter; + std::shared_ptr< SimulationInfo> simInformation; + std::shared_ptr< AnalyticalResults> analyticalResult; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/VectorWriterInformationStruct.h b/targets/tests/NumericalTests/Utilities/Structs/VectorWriterInformationStruct.h new file mode 100644 index 000000000..330e2ee5d --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Structs/VectorWriterInformationStruct.h @@ -0,0 +1,13 @@ +#ifndef FILE_WRITING_INFORMATION_STRUCT_H +#define FILE_WRITING_INFORMATION_STRUCT_H + +#include <string> + +struct VectorWriterInformationStruct +{ + unsigned int startTimeVectorWriter; + bool writeVTKFiles; + unsigned int startTimeVTKDataWriter; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/package.include b/targets/tests/NumericalTests/Utilities/Structs/package.include new file mode 100644 index 000000000..e69de29bb diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp index bc12f47f4..a85e26c5e 100644 --- a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp @@ -12,7 +12,8 @@ void TestImp::update() if (simulations.at(i)->getSimulationRun()) { simulationRun.at(i) = true; - postProStrategies.at(i)->evaluate(); + if (postProStrategies.at(i)->checkEqualSimulationResults(simulations.at(i)->getSimulationResults())) + postProStrategies.at(i)->evaluate(); } } } diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h index e4cb7d153..7901442f8 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h @@ -5,31 +5,34 @@ #include <memory> +class AnalyticalResults; class SimulationParameter; class SimulationResults; class SimulationObserver; class DataWriter; class Parameter; +class SimulationInfo; class TestSimulation { public: //beachte Interface Segregation + //TimeStopper + + virtual std::shared_ptr<SimulationParameter> getSimulationParameter() = 0; + virtual std::shared_ptr<DataWriter> getDataWriter() = 0; - virtual std::shared_ptr< SimulationParameter> getSimulationParameter() = 0; - virtual std::shared_ptr< DataWriter> getDataWriter() = 0; - - virtual std::shared_ptr< SimulationResults> getSimulationResults() = 0; virtual bool getSimulationRun() = 0; + virtual std::shared_ptr<SimulationResults> getSimulationResults() = 0; virtual std::string getRunTimeOutput() = 0; + + virtual void registerSimulationObserver(std::shared_ptr< SimulationObserver> simObserver) = 0; - virtual void makeSimulationHeadOutput() = 0; virtual void setSimulationStartTime() = 0; virtual void setSimulationEndTimeAndNotifyObserver() = 0; virtual void setParameter(std::shared_ptr<Parameter> para) = 0; -private: }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp index ad613adf6..ae381841c 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp @@ -1,23 +1,37 @@ #include "TestSimulationImp.h" -#include "VirtualFluids_GPU\Output\FileWriter.h" - +#include "Utilities\DataWriter\ToVectorWriter.h" #include "Utilities\SimulationParameter\SimulationParameter.h" #include "Utilities\SimulationInfo\SimulationInfo.h" #include "Utilities/Results/SimulationResults/SimulationResults.h" #include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" #include "Utilities\Test\SimulationObserver.h" -#include "Utilities\DataWriter\Y2dSliceToResults\Y2dSliceToResults.h" #include "Utilities\ColorConsoleOutput\ColorConsoleOutput.h" #include "Utilities\KernelConfiguration\KernelConfiguration.h" #include "Utilities\DataWriter\AnalyticalResults2DToVTKWriter\AnalyticalResults2DToVTKWriter.h" +#include "Utilities\Structs\TestSimulationDataStruct.h" + #include <sstream> #include <iomanip> -std::shared_ptr<TestSimulation> TestSimulationImp::getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults) +std::shared_ptr<TestSimulationImp> TestSimulationImp::getNewInsance(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResults, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput) +{ + return std::shared_ptr<TestSimulationImp>(new TestSimulationImp(testSimData, simResults, toVectorWriter, anaResultWriter, colorOutput)); +} + +TestSimulationImp::TestSimulationImp(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResults, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput) { - return std::shared_ptr< TestSimulation>(new TestSimulationImp(simID, simPara, simInfo, colorOutput, simResults, analyticalResult, anaResultWriter, writeAnalyticalResults)); + this->simPara = testSimData->simParameter; + this->simInfo = testSimData->simInformation; + this->analyticalResult = testSimData->analyticalResult; + this->simResults = simResults; + this->anaResultWriter = anaResultWriter; + this->toVectorWriter = toVectorWriter; + this->colorOutput = colorOutput; + + this->simObserver.resize(0); + this->simualtionRun = false; } std::shared_ptr<SimulationParameter> TestSimulationImp::getSimulationParameter() @@ -30,9 +44,19 @@ std::shared_ptr<SimulationResults> TestSimulationImp::getSimulationResults() return simResults; } +std::shared_ptr<AnalyticalResults> TestSimulationImp::getAnalyticalResults() +{ + return analyticalResult; +} + std::shared_ptr<DataWriter> TestSimulationImp::getDataWriter() { - return writeToVector; + return toVectorWriter; +} + +std::shared_ptr<SimulationInfo> TestSimulationImp::getSimulationInfo() +{ + return simInfo; } bool TestSimulationImp::getSimulationRun() @@ -84,11 +108,9 @@ void TestSimulationImp::setSimulationEndTimeAndNotifyObserver() notifyObserver(); setTestEndTime(); - if (writeAnalyticalResults) { - setAnalyticalResultWriteTimeStartTime(); - writeAnalyticalResultsToVTK(); - setAnalyticalResultWriteEndTime(); - } + setAnalyticalResultWriteTimeStartTime(); + writeAnalyticalResultsToVTK(); + setAnalyticalResultWriteEndTime(); } void TestSimulationImp::setTestStartTime() @@ -126,27 +148,11 @@ std::string TestSimulationImp::getRunTimeOutput() std::ostringstream oss; oss << std::left << std::setfill(' ') << std::setw(11) << "Simulation" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcSimTime() << " sec" << std::endl; oss << std::left << std::setfill(' ') << std::setw(11) << "Test" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcTestTime() << " sec" << std::endl; - if (writeAnalyticalResults) - oss << std::left << std::setfill(' ') << std::setw(11) << "FileWriting" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcAnalyticalResultWriteTime() << " sec" << std::endl; + oss << std::left << std::setfill(' ') << std::setw(11) << "FileWriting" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcAnalyticalResultWriteTime() << " sec" << std::endl; return oss.str(); } void TestSimulationImp::setParameter(std::shared_ptr<Parameter> para) { this->para = para; -} - -TestSimulationImp::TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults) : simID(simID), colorOutput(colorOutput), simResults(simResults), writeAnalyticalResults(writeAnalyticalResults) -{ - this->simPara = simPara; - this->simInfo = simInfo; - this->simInfo->setSimulationID(simID); - this->analyticalResult = analyticalResult; - this->anaResultWriter = anaResultWriter; - - - writeToVector = Y2dSliceToResults::getNewInstance(simResults, simPara->getYSliceForCalculation(), simPara->getStartTimeCalculation(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getWriteFiles(), std::shared_ptr<FileWriter>(new FileWriter()), simPara->getStartTimeDataWriter()); - - simObserver.resize(0); - simualtionRun = false; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h index bbba5b2ea..451bb9b79 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h @@ -12,17 +12,21 @@ class SimulationInfo; class AnalyticalResults; class AnalyticalResults2DToVTKWriter; +struct TestSimulationDataStruct; + class TestSimulationImp : public TestSimulation { public: - static std::shared_ptr< TestSimulation> getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults); + static std::shared_ptr< TestSimulationImp> getNewInsance(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResults, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput); std::shared_ptr< SimulationParameter> getSimulationParameter(); std::shared_ptr< DataWriter> getDataWriter(); + std::shared_ptr<SimulationInfo> getSimulationInfo(); void registerSimulationObserver(std::shared_ptr< SimulationObserver> simObserver); bool getSimulationRun(); std::shared_ptr< SimulationResults> getSimulationResults(); + std::shared_ptr<AnalyticalResults> getAnalyticalResults(); void makeSimulationHeadOutput(); void setSimulationStartTime(); @@ -31,7 +35,7 @@ public: void setParameter(std::shared_ptr<Parameter> para); private: - TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults); + TestSimulationImp(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResults, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput); void notifyObserver(); void setTestStartTime(); void setTestEndTime(); @@ -42,21 +46,18 @@ private: double calcAnalyticalResultWriteTime(); void writeAnalyticalResultsToVTK(); - std::shared_ptr< SimulationParameter> simPara; - std::shared_ptr< SimulationInfo> simInfo; - std::shared_ptr< SimulationResults> simResults; - std::shared_ptr< ToVectorWriter> writeToVector; - std::shared_ptr< ColorConsoleOutput> colorOutput; - std::vector< std::shared_ptr< SimulationObserver>> simObserver; + std::shared_ptr<SimulationParameter> simPara; + std::shared_ptr<SimulationInfo> simInfo; + std::shared_ptr<SimulationResults> simResults; + std::shared_ptr<ToVectorWriter> toVectorWriter; + std::shared_ptr<ColorConsoleOutput> colorOutput; std::shared_ptr<AnalyticalResults> analyticalResult; std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter; std::shared_ptr<Parameter> para; - bool writeAnalyticalResults; - + std::vector< std::shared_ptr< SimulationObserver>> simObserver; bool simualtionRun; time_t simulationStartTime, simulationEndTime; clock_t testStartTime, testEndTime; time_t analyticalResultWriteStartTime, analyticalResultWriteEndTime; - int simID; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp index 0fd9ac2fd..cc2fe29f7 100644 --- a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp +++ b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp @@ -26,10 +26,11 @@ std::vector<std::shared_ptr<VirtualFluidSimulation>> VirtualFluidSimulationFacto std::shared_ptr< Parameter> para = Parameter::make(); testSim.at(i)->setParameter(para); - vfSim->initParameter(para, simPara->getKernelConfiguration() ,simPara->getViscosity(), simPara->getGridPath(), simPara->getFilePath(), simPara->getNumberOfGridLevels(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getDevices(), simPara->getMaxVelocity()); + vfSim->initParameter(para, simPara->getKernelConfiguration(), simPara->getViscosity(), simPara->getGridPath(), simPara->getFilePath(), simPara->getNumberOfGridLevels(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getDevices(), simPara->getMaxVelocity()); vfSim->initInitialConditions(simPara->getInitialCondition()); vfSim->initGridProvider(); vfSim->setDataWriter(testSim.at(i)->getDataWriter()); + vfSim->setTestSimulation(testSim.at(i)); vfSimulations.push_back(vfSim); } diff --git a/targets/tests/NumericalTests/config.txt b/targets/tests/NumericalTests/config.txt index 05531f417..6433ae5f8 100644 --- a/targets/tests/NumericalTests/config.txt +++ b/targets/tests/NumericalTests/config.txt @@ -3,22 +3,18 @@ ################################################## Devices="1" -################################################## -# Kernels # -################################################## -KernelsToTest="CumulantAA2016CompSP27" - CumulantOneCompSP27 CumulantAll4CompSP27" - ################################################## # Basic Simulation Parameter # ################################################## -NumberOfTimeSteps=200 -Viscosity="0.0001" +KernelsToTest="CumulantOneCompSP27 CumulantAA2016CompSP27 CumulantAll4CompSP27" +NumberOfTimeSteps=20 +Viscosity="0.001" +Rho0=1.0 ################################################## # TaylorGreenVortex Parameter # ################################################## -BasisTimeStepLength_TGV_Ux="100" +BasisTimeStepLength_TGV_Ux="1000" ux_TGV_Ux="0.032" Amplitude_TGV_Ux="0.01" l0_TGV_Ux=32 @@ -31,9 +27,9 @@ l0_TGV_Uz=48 ################################################## # Shear Wave Parameter # ################################################## -BasisTimeStepLength_SW="1000 500 250" -u0_SW="0.032 0.064 0.128" -v0_SW="0.1 0.1 0.1" +BasisTimeStepLength_SW="1000" +u0_SW="0.032" +v0_SW="0.1" l0_SW=32 ################################################## @@ -44,9 +40,9 @@ ySliceForCalculation=0 ################################################## # PhiAndNu Test Parameter # ################################################## -PhiAndNuTest=false +PhiAndNuTest=true MinOrderOfAccuracy=1.95 -DataToCalc_PhiAndNu="Vx Vz" +DataToCalc_PhiAndNu="Vx" StartTimeStepCalculation_PhiNu=11 EndTimeStepCalculation_PhiNu=20 @@ -54,29 +50,29 @@ EndTimeStepCalculation_PhiNu=20 # L2-Norm Test Parameter # ################################################## L2NormTest=true -MaxL2NormDiff=0.05 -DataToCalc_L2="Vx Vz" +MaxL2NormDiff=2.5 +DataToCalc_L2="Vx" BasicTimeStep_L2=0 -DivergentTimeStep_L2=200 +DivergentTimeStep_L2=20 ################################################## # L2-Norm Test Between Kernels Parameter # ################################################## -L2NormBetweenKernelsTest=false +L2NormBetweenKernelsTest=true BasicKernel_L2NormBetweenKernels=CumulantOneCompSP27 -Timesteps_L2NormBetweenKernels="0 1 20" -DataToCalc_L2NormBetweenKernels="Vx Vy Vz" +Timesteps_L2NormBetweenKernels="0 20" +DataToCalc_L2NormBetweenKernels="Vx" ################################################## # Simulation To Perform # ################################################## TaylorGreenVortexUx32=true -TaylorGreenVortexUx64=false +TaylorGreenVortexUx64=true TaylorGreenVortexUx128=false TaylorGreenVortexUx256=false TaylorGreenVortexUx512=false -TaylorGreenVortexUz32=true +TaylorGreenVortexUz32=false TaylorGreenVortexUz64=false TaylorGreenVortexUz128=false TaylorGreenVortexUz256=false @@ -103,9 +99,9 @@ GridPath512="C:\Users\Timon\Documents\studienarbeitIRMB\grids\gridUni512x4x768" # File Writing Information # ################################################## WriteVTKFiles=true -WriteAnalyResultsToVTK=true - -PathForFileWriting="C:\Users\Timon\Documents\studienarbeitIRMB\Output" +PathForVTKFileWriting="C:\Users\Timon\Documents\studienarbeitIRMB\Output" StartStepFileWriter=0 +WriteAnalyResultsToVTK=false + PathLogFile="C:\Users\Timon\Documents\studienarbeitIRMB\logFiles" \ No newline at end of file diff --git a/targets/tests/NumericalTests/main.cpp b/targets/tests/NumericalTests/main.cpp index fe03da0b3..07503c5b0 100644 --- a/targets/tests/NumericalTests/main.cpp +++ b/targets/tests/NumericalTests/main.cpp @@ -1,8 +1,6 @@ #include <mpi.h> #include <gmock/gmock.h> -#include "wstp.h" - #include "Utilities/ConfigFileReader/ConfigFileReader.h" #include "Utilities\LogFileQueue\LogFileQueue.h" #include "Utilities\NumericalTestFactory\NumericalTestFactoryImp.h" -- GitLab