diff --git a/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.cpp b/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b905afef7591e7d942dc995b2d9c071403595b25 --- /dev/null +++ b/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.cpp @@ -0,0 +1,47 @@ +#include "KernelFactory.h" + +#include "Kernel/Advection/Compressible/CumulantOne/CumulantOneCompSP27.h" +#include "Kernel/Advection/Compressible/CumulantAA2016/CumulantAA2016CompSP27.h" +#include "Kernel/Advection/Compressible/CumulantAll4/CumulantAll4CompSP27.h" +#include "Kernel/Advection/Compressible/CumulantF3/CumulantF3CompSP27.h" +#include "Kernel/Advection/Compressible/CumulantF32018/CumulantF32018CompSP27.h" + +std::shared_ptr<KernelFactory> KernelFactory::getNewInstance(std::shared_ptr<Parameter> para) +{ + return std::shared_ptr<KernelFactory>(new KernelFactory(para)); +} + +std::vector<std::shared_ptr<Kernel>> KernelFactory::makeKernels(int maxLevel, std::string kernelName) +{ + kernels.resize(0); + for (int i = 0; i <= maxLevel; i++) + { + kernels.push_back(makeKernel(kernelName, i)); + } + return kernels; +} + +void KernelFactory::setKernelAtLevel(std::vector<std::shared_ptr<Kernel>> kernels, int i, std::string kernelName) +{ + kernels.at(i) = makeKernel(kernelName, i); +} + +std::shared_ptr<Kernel> KernelFactory::makeKernel(std::string kernelName, int level) +{ + if (kernelName == "CumulantOneCompSP27") + return CumulantOneCompSP27::getNewInstance(para, level); + if (kernelName == "CumulantAA2016CompSP27") + return CumulantAA2016CompSP27::getNewInstance(para, level); + if (kernelName == "CumulantAll4CompSP27") + return CumulantAll4CompSP27::getNewInstance(para, level); + if (kernelName == "CumulantF3CompSP27") + return CumulantF3CompSP27::getNewInstance(para, level); + if (kernelName == "CumulantF32018CompSP27") + return CumulantF32018CompSP27::getNewInstance(para, level); +} + +KernelFactory::KernelFactory(std::shared_ptr<Parameter> para) +{ + this->para = para; + kernels.resize(0); +} \ No newline at end of file diff --git a/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.h b/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..9bb4b81debce65626767b4a2e51579e6b1277e74 --- /dev/null +++ b/src/VirtualFluids_GPU/Kernel/KernelFactory/KernelFactory.h @@ -0,0 +1,28 @@ +#ifndef KERNEL_FACTORY_H +#define KERNEL_FACTORY_H + +#include <memory> +#include <vector> +#include <iostream> + +class Kernel; +class Parameter; + +enum kernelName { CumulantOneCompSP27, CumulantAA2016CompSP27, CumulantAll4CompSP27, CumulantF3CompSP27, CumulantF32018CompSP27 }; + +class KernelFactory +{ +public: + static std::shared_ptr< KernelFactory> getNewInstance(std::shared_ptr<Parameter> para); + std::vector< std::shared_ptr< Kernel>> makeKernels(int maxLevel, std::string kernelName); + void setKernelAtLevel(std::vector< std::shared_ptr<Kernel>> kernels, int i, std::string kernelName); + +private: + std::shared_ptr< Kernel> makeKernel(std::string kernelName, int level); + KernelFactory(std::shared_ptr<Parameter> para); + KernelFactory(); + + std::vector< std::shared_ptr< Kernel>> kernels; + std::shared_ptr< Parameter> para; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/package.include b/src/VirtualFluids_GPU/Kernel/KernelFactory/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/package.include rename to src/VirtualFluids_GPU/Kernel/KernelFactory/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/BasicSimulation.h b/targets/tests/NumericalTestPostProcessing/Simulation/BasicSimulation.h new file mode 100644 index 0000000000000000000000000000000000000000..1319c1c2f3a3416bf7bbe4f989c7c07e983b525b --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/BasicSimulation.h @@ -0,0 +1,6 @@ +#ifndef BASIC_SIMULATION_H +#define BASIC_SIMULATION_H + +enum BasicSimulation { ShearWave, TaylorGreenVortexUx, TaylorGreenVortexUz }; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileData.h b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..83678dc864e2d3b75daa0fbe12e43a7ee4c230f1 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileData.h @@ -0,0 +1,13 @@ +#ifndef SHEAR_WAVE_LOG_FILE_DATA_H +#define SHEAR_WAVE_LOG_FILE_DATA_H + +#include <vector> + +class ShearWaveLogFileData +{ +public: + virtual std::vector<int> getL0() = 0; + virtual std::vector<double> getUx() = 0; + virtual std::vector<double> getUz() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c46108a6c104622094c5d47ee231bc9070eb85fe --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.cpp @@ -0,0 +1,44 @@ +#include "ShearWaveLogFileDataImp.h" + +std::shared_ptr<ShearWaveLogFileDataImp> ShearWaveLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<ShearWaveLogFileDataImp>(new ShearWaveLogFileDataImp()); +} + +std::vector<int> ShearWaveLogFileDataImp::getL0() +{ + return l0; +} + +std::vector<double> ShearWaveLogFileDataImp::getUx() +{ + return ux; +} + +std::vector<double> ShearWaveLogFileDataImp::getUz() +{ + return uz; +} + +void ShearWaveLogFileDataImp::setL0(std::vector<int> l0) +{ + this->l0 = l0; +} + +void ShearWaveLogFileDataImp::setUx(std::vector<double> ux) +{ + this->ux = ux; +} + +void ShearWaveLogFileDataImp::setUz(std::vector<double> uz) +{ + this->uz = uz; +} + +ShearWaveLogFileDataImp::ShearWaveLogFileDataImp() +{ +} + +ShearWaveLogFileDataImp::~ShearWaveLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..a8f3a22dcbc8f4282e3a3590d30d860bae050ce1 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.h @@ -0,0 +1,30 @@ +#ifndef SHEAR_WAVE_LOG_FILE_DATA_IMP_H +#define SHEAR_WAVE_LOG_FILE_DATA_IMP_H + +#include "ShearWaveLogFileData.h" + +#include <memory> + +class ShearWaveLogFileDataImp : public ShearWaveLogFileData +{ +public: + static std::shared_ptr<ShearWaveLogFileDataImp> getNewInstance(); + + std::vector<int> getL0(); + std::vector<double> getUx(); + std::vector<double> getUz(); + + void setL0(std::vector<int> l0); + void setUx(std::vector<double> ux); + void setUz(std::vector<double> amp); + + ~ShearWaveLogFileDataImp(); + +private: + ShearWaveLogFileDataImp(); + + std::vector<int> l0; + std::vector<double> ux; + std::vector<double> uz; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/package.include b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/package.include rename to targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileData/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe8160793f9d42668f27f47f7abfe9d245bf8461 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.cpp @@ -0,0 +1,31 @@ +#include "ShearWaveLogFileDataAssistantStrategy.h" + +#include "Utilities/LogFileData/LogFileData.h" +#include "Simulation/ShearWave/LogFileData/ShearWaveLogFileData.h" + +std::shared_ptr<LogFileDataAssistantStrategy> ShearWaveLogFileDataAssistantStrategy::getNewInstance() +{ + return std::shared_ptr<LogFileDataAssistantStrategy>(new ShearWaveLogFileDataAssistantStrategy()); +} + +std::string ShearWaveLogFileDataAssistantStrategy::getSimulationName() +{ + return simName; +} + +bool ShearWaveLogFileDataAssistantStrategy::checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (!equalDouble(logFileData1->getShearWaveLogFileData()->getUx().at(0), logFileData2->getShearWaveLogFileData()->getUx().at(0))) + return false; + if (!equalDouble(logFileData1->getShearWaveLogFileData()->getUz().at(0), logFileData2->getShearWaveLogFileData()->getUz().at(0))) + return false; + if (logFileData1->getShearWaveLogFileData()->getL0().at(0) != logFileData2->getShearWaveLogFileData()->getL0().at(0)) + return false; + + return true; +} + +ShearWaveLogFileDataAssistantStrategy::ShearWaveLogFileDataAssistantStrategy() +{ + this->simName = "ShearWave"; +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.h b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..3936964a217c507a90d4b4549150495c9ce5eb1e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.h @@ -0,0 +1,19 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_SHEARWAVE_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_SHEARWAVE_H + +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h" + +class ShearWaveLogFileDataAssistantStrategy : public LogFileDataAssistantStrategyImp +{ +public: + static std::shared_ptr<LogFileDataAssistantStrategy> getNewInstance(); + + std::string getSimulationName(); + bool checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + +private: + ShearWaveLogFileDataAssistantStrategy(); + + std::string simName; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/package.include b/targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/package.include rename to targets/tests/NumericalTestPostProcessing/Simulation/ShearWave/LogFileDataAssistantStrategy/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileData.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..6ca76576cbff511fef2b2cf61b844f7830a0cc4f --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileData.h @@ -0,0 +1,13 @@ +#ifndef TGV_UX_LOG_FILE_DATA_H +#define TGV_UX_LOG_FILE_DATA_H + +#include <vector> + +class TaylorGreenVortexUxLogFileData +{ +public: + virtual std::vector<int> getL0() = 0; + virtual std::vector<double> getUx() = 0; + virtual std::vector<double> getAmplitude() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..36b5ff48f3db2a17d179a7d9553eb0ea47b1caf4 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.cpp @@ -0,0 +1,44 @@ +#include "TaylorGreenVortexUxLogFileDataImp.h" + +std::shared_ptr<TaylorGreenVortexUxLogFileDataImp> TaylorGreenVortexUxLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<TaylorGreenVortexUxLogFileDataImp>(new TaylorGreenVortexUxLogFileDataImp()); +} + +std::vector<int> TaylorGreenVortexUxLogFileDataImp::getL0() +{ + return l0; +} + +std::vector<double> TaylorGreenVortexUxLogFileDataImp::getUx() +{ + return ux; +} + +std::vector<double> TaylorGreenVortexUxLogFileDataImp::getAmplitude() +{ + return amp; +} + +void TaylorGreenVortexUxLogFileDataImp::setL0(std::vector<int> l0) +{ + this->l0 = l0; +} + +void TaylorGreenVortexUxLogFileDataImp::setUx(std::vector<double> ux) +{ + this->ux = ux; +} + +void TaylorGreenVortexUxLogFileDataImp::setAmplitude(std::vector<double> amp) +{ + this->amp = amp; +} + +TaylorGreenVortexUxLogFileDataImp::TaylorGreenVortexUxLogFileDataImp() +{ +} + +TaylorGreenVortexUxLogFileDataImp::~TaylorGreenVortexUxLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..0f41b0a0e0d2a7ba8f9dda0337eb13bd593740e2 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.h @@ -0,0 +1,30 @@ +#ifndef TGV_UX_LOG_FILE_DATA_IMP_H +#define TGV_UX_LOG_FILE_DATA_IMP_H + +#include "TaylorGreenVortexUxLogFileData.h" + +#include <memory> + +class TaylorGreenVortexUxLogFileDataImp : public TaylorGreenVortexUxLogFileData +{ +public: + static std::shared_ptr<TaylorGreenVortexUxLogFileDataImp> getNewInstance(); + + std::vector<int> getL0(); + std::vector<double> getUx(); + std::vector<double> getAmplitude(); + + void setL0(std::vector<int> l0); + void setUx(std::vector<double> ux); + void setAmplitude(std::vector<double> amp); + + ~TaylorGreenVortexUxLogFileDataImp(); + +private: + TaylorGreenVortexUxLogFileDataImp(); + + std::vector<int> l0; + std::vector<double> ux; + std::vector<double> amp; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/package.include b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/package.include rename to targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileData/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..102bc41ae91ff96cc885e5a54886a4ca74a7a18e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.cpp @@ -0,0 +1,31 @@ +#include "TaylorGreenVortexUxLogFileDataAssistantStrategy.h" + +#include "Utilities/LogFileData/LogFileData.h" +#include "Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileData.h" + +std::shared_ptr<LogFileDataAssistantStrategy> TaylorGreenVortexUxLogFileDataAssistantStrategy::getNewInstance() +{ + return std::shared_ptr<LogFileDataAssistantStrategy>(new TaylorGreenVortexUxLogFileDataAssistantStrategy()); +} + +std::string TaylorGreenVortexUxLogFileDataAssistantStrategy::getSimulationName() +{ + return simName; +} + +bool TaylorGreenVortexUxLogFileDataAssistantStrategy::checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (!equalDouble(logFileData1->getTaylorGreenVortexUxLogFileData()->getUx().at(0), logFileData2->getTaylorGreenVortexUxLogFileData()->getUx().at(0))) + return false; + if (!equalDouble(logFileData1->getTaylorGreenVortexUxLogFileData()->getAmplitude().at(0), logFileData2->getTaylorGreenVortexUxLogFileData()->getAmplitude().at(0))) + return false; + if (logFileData1->getTaylorGreenVortexUxLogFileData()->getL0().at(0) != logFileData2->getTaylorGreenVortexUxLogFileData()->getL0().at(0)) + return false; + + return true; +} + +TaylorGreenVortexUxLogFileDataAssistantStrategy::TaylorGreenVortexUxLogFileDataAssistantStrategy() +{ + this->simName = "TaylorGreenVortexUx"; +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..3f754cad0ed6c4db4ed8f562fd6b045e988f54d9 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.h @@ -0,0 +1,19 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_TGVUX_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_TGVUX_H + +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h" + +class TaylorGreenVortexUxLogFileDataAssistantStrategy : public LogFileDataAssistantStrategyImp +{ +public: + static std::shared_ptr<LogFileDataAssistantStrategy> getNewInstance(); + + std::string getSimulationName(); + bool checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + +private: + TaylorGreenVortexUxLogFileDataAssistantStrategy(); + + std::string simName; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/package.include b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/package.include similarity index 100% rename from targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/package.include rename to targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileData.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..91b593da77b2b5cccb279a4bf6c9a8f12e6b6315 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileData.h @@ -0,0 +1,13 @@ +#ifndef TGV_UZ_LOG_FILE_DATA_H +#define TGV_UZ_LOG_FILE_DATA_H + +#include <vector> + +class TaylorGreenVortexUzLogFileData +{ +public: + virtual std::vector<int> getL0() = 0; + virtual std::vector<double> getUz() = 0; + virtual std::vector<double> getAmplitude() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79ebda156183b18b560a1bb652ecfce022c6b4d8 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.cpp @@ -0,0 +1,44 @@ +#include "TaylorGreenVortexUzLogFileDataImp.h" + +std::shared_ptr<TaylorGreenVortexUzLogFileDataImp> TaylorGreenVortexUzLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<TaylorGreenVortexUzLogFileDataImp>(new TaylorGreenVortexUzLogFileDataImp()); +} + +std::vector<int> TaylorGreenVortexUzLogFileDataImp::getL0() +{ + return l0; +} + +std::vector<double> TaylorGreenVortexUzLogFileDataImp::getUz() +{ + return ux; +} + +std::vector<double> TaylorGreenVortexUzLogFileDataImp::getAmplitude() +{ + return amp; +} + +void TaylorGreenVortexUzLogFileDataImp::setL0(std::vector<int> l0) +{ + this->l0 = l0; +} + +void TaylorGreenVortexUzLogFileDataImp::setUz(std::vector<double> ux) +{ + this->ux = ux; +} + +void TaylorGreenVortexUzLogFileDataImp::setAmplitude(std::vector<double> amp) +{ + this->amp = amp; +} + +TaylorGreenVortexUzLogFileDataImp::TaylorGreenVortexUzLogFileDataImp() +{ +} + +TaylorGreenVortexUzLogFileDataImp::~TaylorGreenVortexUzLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..90eea344794e8dcad179de6923a6dc07156ef8bb --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.h @@ -0,0 +1,30 @@ +#ifndef TGV_UZ_LOG_FILE_DATA_IMP_H +#define TGV_UZ_LOG_FILE_DATA_IMP_H + +#include "TaylorGreenVortexUzLogFileData.h" + +#include <memory> + +class TaylorGreenVortexUzLogFileDataImp : public TaylorGreenVortexUzLogFileData +{ +public: + static std::shared_ptr<TaylorGreenVortexUzLogFileDataImp> getNewInstance(); + + std::vector<int> getL0(); + std::vector<double> getUz(); + std::vector<double> getAmplitude(); + + void setL0(std::vector<int> l0); + void setUz(std::vector<double> ux); + void setAmplitude(std::vector<double> amp); + + ~TaylorGreenVortexUzLogFileDataImp(); + +private: + TaylorGreenVortexUzLogFileDataImp(); + + std::vector<int> l0; + std::vector<double> ux; + std::vector<double> amp; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/package.include b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/package.include similarity index 100% rename from targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/package.include rename to targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileData/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21c5fd6ff874b96abbe9594eaf2346a053447b99 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.cpp @@ -0,0 +1,31 @@ +#include "TaylorGreenVortexUzLogFileDataAssistantStrategy.h" + +#include "Utilities/LogFileData/LogFileData.h" +#include "Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileData.h" + +std::shared_ptr<LogFileDataAssistantStrategy> TaylorGreenVortexUzLogFileDataAssistantStrategy::getNewInstance() +{ + return std::shared_ptr<LogFileDataAssistantStrategy>(new TaylorGreenVortexUzLogFileDataAssistantStrategy()); +} + +std::string TaylorGreenVortexUzLogFileDataAssistantStrategy::getSimulationName() +{ + return simName; +} + +bool TaylorGreenVortexUzLogFileDataAssistantStrategy::checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (!equalDouble(logFileData1->getTaylorGreenVortexUzLogFileData()->getUz().at(0), logFileData2->getTaylorGreenVortexUzLogFileData()->getUz().at(0))) + return false; + if (!equalDouble(logFileData1->getTaylorGreenVortexUzLogFileData()->getAmplitude().at(0), logFileData2->getTaylorGreenVortexUzLogFileData()->getAmplitude().at(0))) + return false; + if (logFileData1->getTaylorGreenVortexUzLogFileData()->getL0().at(0) != logFileData2->getTaylorGreenVortexUzLogFileData()->getL0().at(0)) + return false; + + return true; +} + +TaylorGreenVortexUzLogFileDataAssistantStrategy::TaylorGreenVortexUzLogFileDataAssistantStrategy() +{ + this->simName = "TaylorGreenVortexUz"; +} diff --git a/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.h b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..75eca42f869d2e7bf6f9d486093350bec5729b31 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.h @@ -0,0 +1,19 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_TGVUZ_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_TGVUZ_H + +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h" + +class TaylorGreenVortexUzLogFileDataAssistantStrategy : public LogFileDataAssistantStrategyImp +{ +public: + static std::shared_ptr<LogFileDataAssistantStrategy> getNewInstance(); + + std::string getSimulationName(); + bool checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + +private: + TaylorGreenVortexUzLogFileDataAssistantStrategy(); + + std::string simName; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.cpp b/targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.cpp rename to targets/tests/NumericalTestPostProcessing/Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.h b/targets/tests/NumericalTestPostProcessing/Simulation/package.include similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaLinker/MathematicaLinker.h rename to targets/tests/NumericalTestPostProcessing/Simulation/package.include diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileData.h b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..d3c004f40ef7260981d24d2a36facfdb8bcf6db5 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileData.h @@ -0,0 +1,19 @@ +#ifndef L2_NORM_LOG_FILE_DATA_H +#define L2_NORM_LOG_FILE_DATA_H + +#include <string> +#include <vector> + +class L2NormLogFileData +{ +public: + virtual std::vector<double> getBasicGridLengths() = 0; + virtual std::string getDataToCalc() = 0; + virtual std::string getNormalizeData() = 0; + virtual int getBasicTimeStep() = 0; + virtual int getDivergentTimeStep() = 0; + virtual std::vector<double> getL2NormForBasicTimeStep() = 0; + virtual std::vector<double> getL2NormForDivergentTimeStep() = 0; + virtual std::vector<double> getL2NormDiff() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d2cb2a964d010a8eefc5f787807db386e007049 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.cpp @@ -0,0 +1,94 @@ +#include "L2NormLogFileDataImp.h" + +std::shared_ptr<L2NormLogFileDataImp> L2NormLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<L2NormLogFileDataImp>(new L2NormLogFileDataImp()); +} + +std::vector<double> L2NormLogFileDataImp::getBasicGridLengths() +{ + return basicGridLengths; +} + +std::string L2NormLogFileDataImp::getDataToCalc() +{ + return dataToCalc; +} + +std::string L2NormLogFileDataImp::getNormalizeData() +{ + return normalizeData; +} + +int L2NormLogFileDataImp::getBasicTimeStep() +{ + return basicTimeStep; +} + +int L2NormLogFileDataImp::getDivergentTimeStep() +{ + return divergentTimeStep; +} + +std::vector<double> L2NormLogFileDataImp::getL2NormForBasicTimeStep() +{ + return l2NormForBasicTimeStep; +} + +std::vector<double> L2NormLogFileDataImp::getL2NormForDivergentTimeStep() +{ + return l2NormForDivergentTimeStep; +} + +std::vector<double> L2NormLogFileDataImp::getL2NormDiff() +{ + return l2NormDiff; +} + +void L2NormLogFileDataImp::setBasicGridLengths(std::vector<double> basicGridLengths) +{ + this->basicGridLengths = basicGridLengths; +} + +void L2NormLogFileDataImp::setDataToCalc(std::string dataToCalc) +{ + this->dataToCalc = dataToCalc; +} + +void L2NormLogFileDataImp::setNormalizeData(std::string normalizeData) +{ + this->normalizeData = normalizeData; +} + +void L2NormLogFileDataImp::setBasicTimeStep(int basicTimeStep) +{ + this->basicTimeStep = basicTimeStep; +} + +void L2NormLogFileDataImp::setDivergentTimeStep(int divergentTimeStep) +{ + this->divergentTimeStep = divergentTimeStep; +} + +void L2NormLogFileDataImp::setL2NormForBasicTimeStep(std::vector<double> l2NormForBasicTimeStep) +{ + this->l2NormForBasicTimeStep = l2NormForBasicTimeStep; +} + +void L2NormLogFileDataImp::setL2NormForDivergentTimeStep(std::vector<double> l2NormForDivergentTimeStep) +{ + this->l2NormForDivergentTimeStep = l2NormForDivergentTimeStep; +} + +void L2NormLogFileDataImp::setL2NormDiff(std::vector<double> l2NormDiff) +{ + this->l2NormDiff = l2NormDiff; +} + +L2NormLogFileDataImp::L2NormLogFileDataImp() +{ +} + +L2NormLogFileDataImp::~L2NormLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..e99d83b81c48002081b8d37f9082d1d7a7783e6c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/L2NormLogFileDataImp.h @@ -0,0 +1,45 @@ +#ifndef L2_NORM_LOG_FILE_DATA_IMP_H +#define L2_NORM_LOG_FILE_DATA_IMP_H + +#include "L2NormLogFileData.h" + +#include <memory> + +class L2NormLogFileDataImp : public L2NormLogFileData +{ +public: + static std::shared_ptr<L2NormLogFileDataImp> getNewInstance(); + + std::vector<double> getBasicGridLengths(); + std::string getDataToCalc(); + std::string getNormalizeData(); + int getBasicTimeStep(); + int getDivergentTimeStep(); + std::vector<double> getL2NormForBasicTimeStep(); + std::vector<double> getL2NormForDivergentTimeStep(); + std::vector<double> getL2NormDiff(); + + void setBasicGridLengths(std::vector<double> basicGridLengths); + void setDataToCalc(std::string dataToCalc); + void setNormalizeData(std::string normalizeData); + void setBasicTimeStep(int basicTimeStep); + void setDivergentTimeStep(int divergentTimeStep); + void setL2NormForBasicTimeStep(std::vector<double> l2NormForBasicTimeStep); + void setL2NormForDivergentTimeStep(std::vector<double> l2NormForDivergentTimeStep); + void setL2NormDiff(std::vector<double> l2NormDiff); + + ~L2NormLogFileDataImp(); + +private: + L2NormLogFileDataImp(); + + std::vector<double> basicGridLengths; + std::string dataToCalc; + std::string normalizeData; + int basicTimeStep; + int divergentTimeStep; + std::vector<double> l2NormForBasicTimeStep; + std::vector<double> l2NormForDivergentTimeStep; + std::vector<double> l2NormDiff; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/package.include b/targets/tests/NumericalTestPostProcessing/Tests/L2Norm/LogFileData/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileData.h b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..69c08f0a145c6c6a1c7183722ae8c66eb379b449 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileData.h @@ -0,0 +1,19 @@ +#ifndef L2NORM_BETWEEN_KERNELS_LOG_FILE_DATA_H +#define L2NORM_BETWEEN_KERNELS_LOG_FILE_DATA_H + +#include <string> +#include <vector> + +class L2NormBetweenKernelsLogFileData +{ +public: + virtual std::vector<double> getBasicGridLengths() = 0; + virtual std::string getBasicKernel() = 0; + virtual std::string getDataToCalculate() = 0; + virtual int getTimeStep() = 0; + virtual std::vector<double> getL2NormForBasicKernel() = 0; + virtual std::vector<double> getL2NormForDivergentKernel() = 0; + virtual std::vector<double> getL2NormBetweenKernels() = 0; + virtual std::string getNormalizeData() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..958da95676a35e45f200bd6d8ed80b99fe4e2927 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.cpp @@ -0,0 +1,94 @@ +#include "L2NormBetweenKernelsLogFileDataImp.h" + +std::shared_ptr<L2NormBetweenKernelsLogFileDataImp> L2NormBetweenKernelsLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<L2NormBetweenKernelsLogFileDataImp>(new L2NormBetweenKernelsLogFileDataImp()); +} + +std::vector<double> L2NormBetweenKernelsLogFileDataImp::getBasicGridLengths() +{ + return basicGridLengths; +} + +std::string L2NormBetweenKernelsLogFileDataImp::getBasicKernel() +{ + return basicKernel; +} + +std::string L2NormBetweenKernelsLogFileDataImp::getDataToCalculate() +{ + return dataToCalc; +} + +int L2NormBetweenKernelsLogFileDataImp::getTimeStep() +{ + return timeStep; +} + +std::vector<double> L2NormBetweenKernelsLogFileDataImp::getL2NormForBasicKernel() +{ + return l2NormForBasicKernel; +} + +std::vector<double> L2NormBetweenKernelsLogFileDataImp::getL2NormForDivergentKernel() +{ + return l2NormForDivergentKernel; +} + +std::vector<double> L2NormBetweenKernelsLogFileDataImp::getL2NormBetweenKernels() +{ + return l2NormBetweenKernels; +} + +std::string L2NormBetweenKernelsLogFileDataImp::getNormalizeData() +{ + return normalizeData; +} + +void L2NormBetweenKernelsLogFileDataImp::setBasicGridLengths(std::vector<double> basicGridLengths) +{ + this->basicGridLengths = basicGridLengths; +} + +void L2NormBetweenKernelsLogFileDataImp::setBasicKernel(std::string basicKernel) +{ + this->basicKernel = basicKernel; +} + +void L2NormBetweenKernelsLogFileDataImp::setDataToCalculate(std::string dataToCalc) +{ + this->dataToCalc = dataToCalc; +} + +void L2NormBetweenKernelsLogFileDataImp::setTimeStep(int timeStep) +{ + this->timeStep = timeStep; +} + +void L2NormBetweenKernelsLogFileDataImp::setL2NormForBasicKernel(std::vector<double> l2Norm) +{ + this->l2NormForBasicKernel = l2Norm; +} + +void L2NormBetweenKernelsLogFileDataImp::setL2NormForDivergentKernel(std::vector<double> l2Norm) +{ + this->l2NormForDivergentKernel = l2Norm; +} + +void L2NormBetweenKernelsLogFileDataImp::setL2NormBetweenKernels(std::vector<double> l2Norm) +{ + this->l2NormBetweenKernels = l2Norm; +} + +void L2NormBetweenKernelsLogFileDataImp::setNormalizeData(std::string normalizeData) +{ + this->normalizeData = normalizeData; +} + +L2NormBetweenKernelsLogFileDataImp::L2NormBetweenKernelsLogFileDataImp() +{ +} + +L2NormBetweenKernelsLogFileDataImp::~L2NormBetweenKernelsLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..b5ec2c9d21a464a236369ee732428625e54378be --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.h @@ -0,0 +1,45 @@ +#ifndef L2NORM_BETWEEN_KERNELS_LOG_FILE_DATA_IMP_H +#define L2NORM_BETWEEN_KERNELS_LOG_FILE_DATA_IMP_H + +#include "L2NormBetweenKernelsLogFileData.h" + +#include <memory> + +class L2NormBetweenKernelsLogFileDataImp : public L2NormBetweenKernelsLogFileData +{ +public: + static std::shared_ptr<L2NormBetweenKernelsLogFileDataImp> getNewInstance(); + + std::vector<double> getBasicGridLengths(); + std::string getBasicKernel(); + std::string getDataToCalculate(); + int getTimeStep(); + std::vector<double> getL2NormForBasicKernel(); + std::vector<double> getL2NormForDivergentKernel(); + std::vector<double> getL2NormBetweenKernels(); + std::string getNormalizeData(); + + void setBasicGridLengths(std::vector<double> basicGridLengths); + void setBasicKernel(std::string basicKernel); + void setDataToCalculate(std::string dataToCalc); + void setTimeStep(int timeStep); + void setL2NormForBasicKernel(std::vector<double> l2Norm); + void setL2NormForDivergentKernel(std::vector<double> l2Norm); + void setL2NormBetweenKernels(std::vector<double> l2Norm); + void setNormalizeData(std::string normalizeData); + + ~L2NormBetweenKernelsLogFileDataImp(); + +private: + L2NormBetweenKernelsLogFileDataImp(); + + std::vector<double> basicGridLengths; + std::string basicKernel; + std::string dataToCalc; + int timeStep; + std::vector<double> l2NormForBasicKernel; + std::vector<double> l2NormForDivergentKernel; + std::vector<double> l2NormBetweenKernels; + std::string normalizeData; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/package.include b/targets/tests/NumericalTestPostProcessing/Tests/L2NormBetweenKernels/LogFileData/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileData.h b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..c4367ef591f5a02a6ec410e4dbaec48ea76f368e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileData.h @@ -0,0 +1,19 @@ +#ifndef NY_LOG_FILE_DATA_H +#define NY_LOG_FILE_DATA_H + +#include <memory> +#include <string> +#include <vector> + +class NyLogFileData +{ +public: + virtual std::vector<double> getBasicGridLengths() = 0; + virtual int getStartTimeStepCalculation() = 0; + virtual int getEndTimeStepCalculation() = 0; + virtual std::string getDataToCalc() = 0; + virtual std::vector<double> getNy() = 0; + virtual std::vector<double> getNyDiff() = 0; + virtual std::vector<std::vector<double> > getOrderOfAccuracy() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b63ddfc7464ddd6601c9ec4b1db3eead7a7ad1a --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.cpp @@ -0,0 +1,80 @@ +#include "NyLogFileDataImp.h" + +std::shared_ptr<NyLogFileDataImp> NyLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<NyLogFileDataImp>(new NyLogFileDataImp()); +} + +std::vector<double> NyLogFileDataImp::getBasicGridLengths() +{ + return basicGridLengths; +} + +int NyLogFileDataImp::getStartTimeStepCalculation() +{ + return startTimeStepCalculation; +} + +int NyLogFileDataImp::getEndTimeStepCalculation() +{ + return endTimeStepCalculation; +} + +std::string NyLogFileDataImp::getDataToCalc() +{ + return dataToCalc; +} + +std::vector<double> NyLogFileDataImp::getNy() +{ + return ny; +} + +std::vector<double> NyLogFileDataImp::getNyDiff() +{ + return nyDiff; +} + +std::vector<std::vector<double>> NyLogFileDataImp::getOrderOfAccuracy() +{ + return orderOfAccuracy; +} + +void NyLogFileDataImp::setBasicGridLengths(std::vector<double> basicGridLengths) +{ + this->basicGridLengths = basicGridLengths; +} + +void NyLogFileDataImp::setStartTimeStepCalculation(int startTimeStepCalculation) +{ + this->startTimeStepCalculation = startTimeStepCalculation; +} + +void NyLogFileDataImp::setEndTimeStepCalculation(int endTimeStepCalculation) +{ + this->endTimeStepCalculation = endTimeStepCalculation; +} + +void NyLogFileDataImp::setDataToCalcPhiAndNu(std::string dataToCalc) +{ + this->dataToCalc = dataToCalc; +} + +void NyLogFileDataImp::setNy(std::vector<double> ny) +{ + this->ny = ny; +} + +void NyLogFileDataImp::setNyDiff(std::vector<double> nyDiff) +{ + this->nyDiff = nyDiff; +} + +void NyLogFileDataImp::setOrderOfAccuracy(std::vector<std::vector<double>> orderOfAccuracy) +{ + this->orderOfAccuracy = orderOfAccuracy; +} + +NyLogFileDataImp::NyLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..789077718bfdc9f707f4154dbb78a9177f9734f4 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/NyLogFileDataImp.h @@ -0,0 +1,42 @@ +#ifndef NY_LOG_FILE_DATA_IMP_H +#define NY_LOG_FILE_DATA_IMP_H + +#include "NyLogFileData.h" + +#include <memory> + +class NyLogFileDataImp : public NyLogFileData +{ +public: + static std::shared_ptr<NyLogFileDataImp> getNewInstance(); + + std::vector<double> getBasicGridLengths(); + int getStartTimeStepCalculation(); + int getEndTimeStepCalculation(); + std::string getDataToCalc(); + std::vector<double> getNy(); + std::vector<double> getNyDiff(); + std::vector<std::vector<double> > getOrderOfAccuracy(); + + void setBasicGridLengths(std::vector<double> basicGridLengths); + void setStartTimeStepCalculation(int startTimeStepCalculation); + void setEndTimeStepCalculation(int endTimeStepCalculation); + void setDataToCalcPhiAndNu(std::string dataToCalcPhiAndNu); + void setNy(std::vector<double> ny); + void setNyDiff(std::vector<double> nyDiff); + void setOrderOfAccuracy(std::vector<std::vector<double> > orderOfAccuracy); + + +private: + NyLogFileDataImp(); + + std::vector<double> basicGridLengths; + int startTimeStepCalculation; + int endTimeStepCalculation; + std::string dataToCalc; + std::vector<double> ny; + std::vector<double> nyDiff; + std::vector<std::vector<double> > orderOfAccuracy; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/package.include b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/LogFileData/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.cpp b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2827ce438069abee1580372d2563cf051bc22717 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.cpp @@ -0,0 +1,123 @@ +#include "NyMathematicaAssistant.h" + +#include "Tests/NyTest/LogFileData/NyLogFileData.h" + +#include "Utilities/DataPoint/DataPoint.h" +#include "Utilities/LogFileData/LogFileData.h" +#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h" +#include "Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h" + +std::shared_ptr<NyMathematicaAssistant> NyMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory) +{ + return std::shared_ptr<NyMathematicaAssistant>(new NyMathematicaAssistant(functionFactory)); +} + +void NyMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile) +{ + std::shared_ptr<SortedDataNy> mySortedData = sortLogFileData(logFileData); + + makeNyDiffMathematicaOutput(aMathmaticaFile, mySortedData); +} + +NyMathematicaAssistant::NyMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : functionFactory(functionFactory) +{ +} + +bool NyMathematicaAssistant::checkTestParameter(std::shared_ptr<NyLogFileData> logFileData1, std::shared_ptr<NyLogFileData> logFileData2) +{ + if (logFileData1->getStartTimeStepCalculation() != logFileData2->getStartTimeStepCalculation()) + return false; + if (logFileData1->getEndTimeStepCalculation() != logFileData2->getEndTimeStepCalculation()) + return false; + if (logFileData1->getDataToCalc() != logFileData2->getDataToCalc()) + return false; + + return true; +} + +std::shared_ptr<SortedDataNy> NyMathematicaAssistant::sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData) +{ + std::vector<std::vector<std::shared_ptr<NyLogFileData> > > testLogFileData; + std::vector<std::vector<std::string> > basicListNames; + for (int i = 0; i < logFileData->getLogFileData(0)->getNyLogFileData().size(); i++) { + std::vector<std::shared_ptr<NyLogFileData> > aTestLogFileDataGroup; + aTestLogFileDataGroup.push_back(logFileData->getLogFileData(0)->getNyLogFileData().at(i)); + std::vector<std::string> aListNameGroup; + aListNameGroup.push_back(logFileData->getLogFileData(0)->getSimulationSigniture()); + basicListNames.push_back(aListNameGroup); + } + for (int i = 0; i < logFileData->getGroupSize(); i++) { + for (int j = 0; j < logFileData->getLogFileData(i)->getNyLogFileData().size(); j++) { + std::string dataToCalc = logFileData->getLogFileData(i)->getNyLogFileData().at(j)->getDataToCalc(); + bool added = false; + for (int k = 0; k < testLogFileData.size(); k++) { + if (checkTestParameter(logFileData->getLogFileData(i)->getNyLogFileData().at(j), testLogFileData.at(k).at(0))) { + testLogFileData.at(k).push_back(logFileData->getLogFileData(i)->getNyLogFileData().at(j)); + basicListNames.at(k).push_back(logFileData->getLogFileData(i)->getSimulationSigniture()); + added = true; + } + } + if (!added) { + std::vector<std::shared_ptr<NyLogFileData> > aTestLogFileDataGroup; + aTestLogFileDataGroup.push_back(logFileData->getLogFileData(i)->getNyLogFileData().at(j)); + testLogFileData.push_back(aTestLogFileDataGroup); + std::vector<std::string> aListNameGroup; + aListNameGroup.push_back(logFileData->getLogFileData(i)->getSimulationSigniture()); + basicListNames.push_back(aListNameGroup); + } + } + } + std::shared_ptr<SortedDataNy> mySortedData = std::shared_ptr<SortedDataNy>(new SortedDataNy); + mySortedData->basicListNames = basicListNames; + mySortedData->testLogFileData = testLogFileData; + + return mySortedData; +} + +void NyMathematicaAssistant::addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes) +{ + std::vector<std::vector<std::shared_ptr<DataPoint> > > dataPointGroup; + + for (int i = 0; i < xAxesData.size(); i++) { + std::vector<std::shared_ptr<DataPoint> > dataPoints; + for (int j = 0; j < xAxesData.at(i).size(); j++) + dataPoints.push_back(DataPoint::getNewInstance(xAxesData.at(i).at(j), yAxesData.at(i).at(j))); + dataPointGroup.push_back(dataPoints); + } + std::vector<std::shared_ptr<MathematicaPointList> > pointList; + for (int i = 0; i < dataPointGroup.size(); i++) { + std::shared_ptr<MathematicaPointList> aPointList = functionFactory->makeMathematicaPointList(aMathmaticaFile, listNames.at(i), dataPointGroup.at(i)); + pointList.push_back(aPointList); + } + std::shared_ptr<MathematicaListPlot> listLogLogPlot = functionFactory->makeMathematicaListPlot(aMathmaticaFile, pointList, "ListLogLogPlot", labelXAxes, labelYAxes); +} + +std::vector<std::string> NyMathematicaAssistant::finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName) +{ + std::vector<std::string> finalListNames; + + for (int i = 0; i < basicListNames.size(); i++) + finalListNames.push_back(testName + basicListNames.at(i) + dataToCalc); + + return finalListNames; +} + +void NyMathematicaAssistant::makeNyDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData) +{ + for (int i = 0; i < sortedData->testLogFileData.size(); i++) { + std::vector<std::vector<double> > gridLengths; + std::vector<std::vector<double> > nyDiff; + std::vector<std::string> aBasicListNamesList; + for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) { + gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths()); + nyDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getNyDiff()); + aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j)); + } + std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), "NyDiff"); + addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, nyDiff, "L[dx]", "Err Ny"); + } +} + +NyMathematicaAssistant::NyMathematicaAssistant() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.h b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.h new file mode 100644 index 0000000000000000000000000000000000000000..575d9884c0cac55f00542c5cc583a60198b0e5b1 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.h @@ -0,0 +1,34 @@ +#ifndef NY_MATHEMATICA_ASSISTANT_H +#define NY_MATHEMATICA_ASSISTANT_H + +#include "Utilities/MathematicaAssistant/MathematicaAssistantImp.h" + +class MathematicaFunctionFactory; +class NyLogFileData; + +struct SortedDataNy { + std::vector<std::vector<std::shared_ptr<NyLogFileData> > > testLogFileData; + std::vector<std::vector<std::string> > basicListNames; +}; + +class NyMathematicaAssistant : public MathematicaAssistantImp +{ +public: + static std::shared_ptr<NyMathematicaAssistant> getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory); + + void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile); + + +private: + NyMathematicaAssistant(); + NyMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory); + + bool checkTestParameter(std::shared_ptr<NyLogFileData> logFileData1, std::shared_ptr<NyLogFileData> logFileData2); + std::shared_ptr<SortedDataNy> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData); + void addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes); + std::vector<std::string> finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName); + void makeNyDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData); + + std::shared_ptr<MathematicaFunctionFactory> functionFactory; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/package.include b/targets/tests/NumericalTestPostProcessing/Tests/NyTest/MathematicaAssistant/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileData.h b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileData.h new file mode 100644 index 0000000000000000000000000000000000000000..63d169be7d1e0d73fe5db5b913eaec6094b7c593 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileData.h @@ -0,0 +1,18 @@ +#ifndef PHI_LOG_FILE_DATA_H +#define PHI_LOG_FILE_DATA_H + +#include <memory> +#include <string> +#include <vector> + +class PhiLogFileData +{ +public: + virtual std::vector<double> getBasicGridLengths() = 0; + virtual int getStartTimeStepCalculation() = 0; + virtual int getEndTimeStepCalculation() = 0; + virtual std::string getDataToCalc() = 0; + virtual std::vector<double> getPhiDiff() = 0; + virtual std::vector<std::vector<double> > getOrderOfAccuracy() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..63011851ebc2841c90221a3ff42b25b0b4ba6d13 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.cpp @@ -0,0 +1,70 @@ +#include "PhiLogFileDataImp.h" + +std::shared_ptr<PhiLogFileDataImp> PhiLogFileDataImp::getNewInstance() +{ + return std::shared_ptr<PhiLogFileDataImp>(new PhiLogFileDataImp()); +} + +std::vector<double> PhiLogFileDataImp::getBasicGridLengths() +{ + return basicGridLengths; +} + +int PhiLogFileDataImp::getStartTimeStepCalculation() +{ + return startTimeStepCalculation; +} + +int PhiLogFileDataImp::getEndTimeStepCalculation() +{ + return endTimeStepCalculation; +} + +std::string PhiLogFileDataImp::getDataToCalc() +{ + return dataToCalc; +} + +std::vector<double> PhiLogFileDataImp::getPhiDiff() +{ + return phiDiff; +} + +std::vector<std::vector<double>> PhiLogFileDataImp::getOrderOfAccuracy() +{ + return orderOfAccuracy; +} + +void PhiLogFileDataImp::setBasicGridLengths(std::vector<double> basicGridLengths) +{ + this->basicGridLengths = basicGridLengths; +} + +void PhiLogFileDataImp::setStartTimeStepCalculation(int startTimeStepCalculation) +{ + this->startTimeStepCalculation = startTimeStepCalculation; +} + +void PhiLogFileDataImp::setEndTimeStepCalculation(int endTimeStepCalculation) +{ + this->endTimeStepCalculation = endTimeStepCalculation; +} + +void PhiLogFileDataImp::setDataToCalc(std::string dataToCalc) +{ + this->dataToCalc = dataToCalc; +} + +void PhiLogFileDataImp::setPhiDiff(std::vector<double> phiDiff) +{ + this->phiDiff = phiDiff; +} + +void PhiLogFileDataImp::setOrderOfAccuracy(std::vector<std::vector<double>> orderOfAccuracy) +{ + this->orderOfAccuracy = orderOfAccuracy; +} + +PhiLogFileDataImp::PhiLogFileDataImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.h new file mode 100644 index 0000000000000000000000000000000000000000..c8c9960be29ef5d239c912edb23b709715f9889c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/PhiLogFileDataImp.h @@ -0,0 +1,37 @@ +#ifndef PHI_LOG_FILE_DATA_IMP_H +#define PHI_LOG_FILE_DATA_IMP_H + +#include "PhiLogFileData.h" + +#include <memory> + +class PhiLogFileDataImp : public PhiLogFileData +{ +public: + static std::shared_ptr<PhiLogFileDataImp> getNewInstance(); + + std::vector<double> getBasicGridLengths(); + int getStartTimeStepCalculation(); + int getEndTimeStepCalculation(); + std::string getDataToCalc(); + std::vector<double> getPhiDiff(); + std::vector<std::vector<double> > getOrderOfAccuracy(); + + void setBasicGridLengths(std::vector<double> basicGridLengths); + void setStartTimeStepCalculation(int startTimeStepCalculation); + void setEndTimeStepCalculation(int endTimeStepCalculation); + void setDataToCalc(std::string dataToCalcPhiAndNu); + void setPhiDiff(std::vector<double> phiDiff); + void setOrderOfAccuracy(std::vector<std::vector<double> > orderOfAccuracy); + +private: + PhiLogFileDataImp(); + + std::vector<double> basicGridLengths; + int startTimeStepCalculation; + int endTimeStepCalculation; + std::string dataToCalc; + std::vector<double> phiDiff; + std::vector<std::vector<double> > orderOfAccuracy; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/package.include b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/LogFileData/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.cpp b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d94434b8066a8e9651f505629bc81c90dae7b919 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.cpp @@ -0,0 +1,135 @@ +#include "PhiMathematicaAssistant.h" + +#include "Tests/PhiTest/LogFileData/PhiLogFileData.h" + +#include "Utilities/DataPoint/DataPoint.h" +#include "Utilities/LogFileData/LogFileData.h" +#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h" +#include "Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h" + +std::shared_ptr<PhiMathematicaAssistant> PhiMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory) +{ + return std::shared_ptr<PhiMathematicaAssistant>(new PhiMathematicaAssistant(functionFactory)); +} + +void PhiMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile) +{ + std::shared_ptr<SortedDataPhi> mySortedData = sortLogFileData(logFileData); + + makePhiDiffMathematicaOutput(aMathmaticaFile, mySortedData); +} + +PhiMathematicaAssistant::PhiMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : functionFactory(functionFactory) +{ +} + +bool PhiMathematicaAssistant::checkTestParameter(std::shared_ptr<PhiLogFileData> logFileData1, std::shared_ptr<PhiLogFileData> logFileData2) +{ + if (logFileData1->getStartTimeStepCalculation() != logFileData2->getStartTimeStepCalculation()) + return false; + if (logFileData1->getEndTimeStepCalculation() != logFileData2->getEndTimeStepCalculation()) + return false; + if (logFileData1->getDataToCalc() != logFileData2->getDataToCalc()) + return false; + + return true; +} + +std::shared_ptr<SortedDataPhi> PhiMathematicaAssistant::sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData) +{ + std::vector<std::vector<std::shared_ptr<PhiLogFileData> > > testLogFileData; + std::vector<std::vector<std::string> > basicListNames; + for (int i = 0; i < logFileData->getLogFileData(0)->getPhiLogFileData().size(); i++) { + std::vector<std::shared_ptr<PhiLogFileData> > aTestLogFileDataGroup; + aTestLogFileDataGroup.push_back(logFileData->getLogFileData(0)->getPhiLogFileData().at(i)); + std::vector<std::string> aListNameGroup; + aListNameGroup.push_back(logFileData->getLogFileData(0)->getSimulationSigniture()); + basicListNames.push_back(aListNameGroup); + } + for (int i = 0; i < logFileData->getGroupSize(); i++) { + for (int j = 0; j < logFileData->getLogFileData(i)->getPhiLogFileData().size(); j++) { + std::string dataToCalc = logFileData->getLogFileData(i)->getPhiLogFileData().at(j)->getDataToCalc(); + bool added = false; + for (int k = 0; k < testLogFileData.size(); k++) { + if (checkTestParameter(logFileData->getLogFileData(i)->getPhiLogFileData().at(j), testLogFileData.at(k).at(0))) { + testLogFileData.at(k).push_back(logFileData->getLogFileData(i)->getPhiLogFileData().at(j)); + basicListNames.at(k).push_back(logFileData->getLogFileData(i)->getSimulationSigniture()); + added = true; + } + } + if (!added) { + std::vector<std::shared_ptr<PhiLogFileData> > aTestLogFileDataGroup; + aTestLogFileDataGroup.push_back(logFileData->getLogFileData(i)->getPhiLogFileData().at(j)); + testLogFileData.push_back(aTestLogFileDataGroup); + std::vector<std::string> aListNameGroup; + aListNameGroup.push_back(logFileData->getLogFileData(i)->getSimulationSigniture()); + basicListNames.push_back(aListNameGroup); + } + } + } + std::shared_ptr<SortedDataPhi> mySortedData = std::shared_ptr<SortedDataPhi>(new SortedDataPhi); + mySortedData->basicListNames = basicListNames; + mySortedData->testLogFileData = testLogFileData; + + return mySortedData; +} + +void PhiMathematicaAssistant::addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes) +{ + std::vector<std::vector<std::shared_ptr<DataPoint> > > dataPointGroup; + + for (int i = 0; i < xAxesData.size(); i++) { + std::vector<std::shared_ptr<DataPoint> > dataPoints; + for (int j = 0; j < xAxesData.at(i).size(); j++) + dataPoints.push_back(DataPoint::getNewInstance(xAxesData.at(i).at(j), yAxesData.at(i).at(j))); + dataPointGroup.push_back(dataPoints); + } + std::vector<std::shared_ptr<MathematicaPointList> > pointList; + for (int i = 0; i < dataPointGroup.size(); i++) { + std::shared_ptr<MathematicaPointList> aPointList = functionFactory->makeMathematicaPointList(aMathmaticaFile, listNames.at(i), dataPointGroup.at(i)); + pointList.push_back(aPointList); + } + std::shared_ptr<MathematicaListPlot> listLogLogPlot = functionFactory->makeMathematicaListPlot(aMathmaticaFile, pointList, "ListLogLogPlot", labelXAxes, labelYAxes); +} + +void PhiMathematicaAssistant::addListOfListsToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::string listNames, std::vector<std::vector<double>> listOfLists) +{ + functionFactory->makeMathematicaListOfLists(aMathmaticaFile, listNames, listOfLists); +} + +std::vector<std::string> PhiMathematicaAssistant::finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName) +{ + std::vector<std::string> finalListNames; + + for (int i = 0; i < basicListNames.size(); i++) + finalListNames.push_back(testName + basicListNames.at(i) + dataToCalc); + + return finalListNames; +} + +void PhiMathematicaAssistant::makePhiDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData) +{ + for (int i = 0; i < sortedData->testLogFileData.size(); i++) { + std::vector<std::vector<double> > gridLengths; + std::vector<std::vector<double> > phiDiff; + std::vector<std::string> aBasicListNamesList; + for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) { + gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths()); + phiDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getPhiDiff()); + aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j)); + } + std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), "PhiDiff"); + addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, phiDiff, "L[dx]", "Err Phi"); + } +} + +void PhiMathematicaAssistant::makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData) +{ + for (int i = 0; i < sortedData->testLogFileData.size(); i++) { + + } +} + +PhiMathematicaAssistant::PhiMathematicaAssistant() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.h b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.h new file mode 100644 index 0000000000000000000000000000000000000000..a8696261d006c5e3eeec18626d949a89d96dd54d --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.h @@ -0,0 +1,36 @@ +#ifndef PHI_MATHEMATICA_ASSISTANT_H +#define PHI_MATHEMATICA_ASSISTANT_H + +#include "Utilities/MathematicaAssistant/MathematicaAssistantImp.h" + +class MathematicaFunctionFactory; +class PhiLogFileData; + +struct SortedDataPhi { + std::vector<std::vector<std::shared_ptr<PhiLogFileData> > > testLogFileData; + std::vector<std::vector<std::string> > basicListNames; +}; + +class PhiMathematicaAssistant : public MathematicaAssistantImp +{ +public: + static std::shared_ptr<PhiMathematicaAssistant> getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory); + + void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile); + + +private: + PhiMathematicaAssistant(); + PhiMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory); + + bool checkTestParameter(std::shared_ptr<PhiLogFileData> logFileData1, std::shared_ptr<PhiLogFileData> logFileData2); + std::shared_ptr<SortedDataPhi> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData); + void addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes); + void addListOfListsToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::string listNames, std::vector<std::vector<double> > listOfLists); + std::vector<std::string> finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName); + void makePhiDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData); + void makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData); + + std::shared_ptr<MathematicaFunctionFactory> functionFactory; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/package.include b/targets/tests/NumericalTestPostProcessing/Tests/PhiTest/MathematicaAssistant/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/AlmostEquals.h b/targets/tests/NumericalTestPostProcessing/Utilities/AlmostEquals.h new file mode 100644 index 0000000000000000000000000000000000000000..72922c8a0b5660645ae36e6745da210ae5505c27 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/AlmostEquals.h @@ -0,0 +1,286 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file declares functions and macros used internally by +// Google Test. They are subject to change without notice. + +#pragma once + +#include <limits> + +// This template class serves as a compile-time function from size to +// type. It maps a size in bytes to a primitive type with that +// size. e.g. +// +// TypeWithSize<4>::UInt +// +// is typedef-ed to be unsigned int (unsigned integer made up of 4 +// bytes). +// +// Such functionality should belong to STL, but I cannot find it +// there. +// +// Google Test uses this class in the implementation of floating-point +// comparison. +// +// For now it only handles UInt (unsigned int) as that's all Google Test +// needs. Other types can be easily added in the future if need +// arises. +template <size_t size> +class TypeWithSize { +public: + // This prevents the user from using TypeWithSize<N> with incorrect + // values of N. + typedef void UInt; +}; + +// The specialization for size 4. +template <> +class TypeWithSize<4> { +public: + // unsigned int has size 4 in both gcc and MSVC. + // + // As base/basictypes.h doesn't compile on Windows, we cannot use + // uint32, uint64, and etc here. + typedef int Int; + typedef unsigned int UInt; +}; + +// The specialization for size 8. +template <> +class TypeWithSize<8> { +public: +#if _MSC_VER + typedef __int64 Int; + typedef unsigned __int64 UInt; +#else + typedef long long Int; // NOLINT + typedef unsigned long long UInt; // NOLINT +#endif // _MSC_VER +}; + +// This template class represents an IEEE floating-point number +// (either single-precision or double-precision, depending on the +// template parameters). +// +// The purpose of this class is to do more sophisticated number +// comparison. (Due to round-off error, etc, it's very unlikely that +// two floating-points will be equal exactly. Hence a naive +// comparison by the == operation often doesn't work.) +// +// Format of IEEE floating-point: +// +// The most-significant bit being the leftmost, an IEEE +// floating-point looks like +// +// sign_bit exponent_bits fraction_bits +// +// Here, sign_bit is a single bit that designates the sign of the +// number. +// +// For float, there are 8 exponent bits and 23 fraction bits. +// +// For double, there are 11 exponent bits and 52 fraction bits. +// +// More details can be found at +// http://en.wikipedia.org/wiki/IEEE_floating-point_standard. +// +// Template parameter: +// +// RawType: the raw floating-point type (either float or double) +template <typename RawType> +class FloatingPoint { +public: + // Defines the unsigned integer type that has the same size as the + // floating point number. + typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits; + + // Constants. + + // # of bits in a number. + static const size_t kBitCount = 8 * sizeof(RawType); + + // # of fraction bits in a number. + static const size_t kFractionBitCount = + std::numeric_limits<RawType>::digits - 1; + + // # of exponent bits in a number. + static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount; + + // The mask for the sign bit. + static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1); + + // The mask for the fraction bits. + static const Bits kFractionBitMask = + ~static_cast<Bits>(0) >> (kExponentBitCount + 1); + + // The mask for the exponent bits. + static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask); + + // How many ULP's (Units in the Last Place) we want to tolerate when + // comparing two numbers. The larger the value, the more error we + // allow. A 0 value means that two numbers must be exactly the same + // to be considered equal. + // + // The maximum error of a single floating-point operation is 0.5 + // units in the last place. On Intel CPU's, all floating-point + // calculations are done with 80-bit precision, while double has 64 + // bits. Therefore, 4 should be enough for ordinary use. + // + // See the following article for more details on ULP: + // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ + static const size_t kMaxUlps = 4; + + // Constructs a FloatingPoint from a raw floating-point number. + // + // On an Intel CPU, passing a non-normalized NAN (Not a Number) + // around may change its bits, although the new value is guaranteed + // to be also a NAN. Therefore, don't expect this constructor to + // preserve the bits in x when x is a NAN. + explicit FloatingPoint(const RawType& x) { u_.value_ = x; } + + // Static methods + + // Reinterprets a bit pattern as a floating-point number. + // + // This function is needed to test the AlmostEquals() method. + static RawType ReinterpretBits(const Bits bits) { + FloatingPoint fp(0); + fp.u_.bits_ = bits; + return fp.u_.value_; + } + + // Returns the floating-point number that represent positive infinity. + static RawType Infinity() { + return ReinterpretBits(kExponentBitMask); + } + + // Returns the maximum representable finite floating-point number. + static RawType Max(); + + // Non-static methods + + // Returns the bits that represents this number. + const Bits &bits() const { return u_.bits_; } + + // Returns the exponent bits of this number. + Bits exponent_bits() const { return kExponentBitMask & u_.bits_; } + + // Returns the fraction bits of this number. + Bits fraction_bits() const { return kFractionBitMask & u_.bits_; } + + // Returns the sign bit of this number. + Bits sign_bit() const { return kSignBitMask & u_.bits_; } + + // Returns true iff this is NAN (not a number). + bool is_nan() const { + // It's a NAN if the exponent bits are all ones and the fraction + // bits are not entirely zeros. + return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0); + } + + // Returns true iff this number is at most kMaxUlps ULP's away from + // rhs. In particular, this function: + // + // - returns false if either number is (or both are) NAN. + // - treats really large numbers as almost equal to infinity. + // - thinks +0.0 and -0.0 are 0 DLP's apart. + bool AlmostEquals(const FloatingPoint& rhs) const { + // The IEEE standard says that any comparison operation involving + // a NAN must return false. + if (is_nan() || rhs.is_nan()) return false; + + return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) + <= kMaxUlps; + } + +private: + // The data type used to store the actual floating-point number. + union FloatingPointUnion { + RawType value_; // The raw floating-point number. + Bits bits_; // The bits that represent the number. + }; + + // Converts an integer from the sign-and-magnitude representation to + // the biased representation. More precisely, let N be 2 to the + // power of (kBitCount - 1), an integer x is represented by the + // unsigned number x + N. + // + // For instance, + // + // -N + 1 (the most negative number representable using + // sign-and-magnitude) is represented by 1; + // 0 is represented by N; and + // N - 1 (the biggest number representable using + // sign-and-magnitude) is represented by 2N - 1. + // + // Read http://en.wikipedia.org/wiki/Signed_number_representations + // for more details on signed number representations. + static Bits SignAndMagnitudeToBiased(const Bits &sam) { + if (kSignBitMask & sam) { + // sam represents a negative number. + return ~sam + 1; + } + else { + // sam represents a positive number. + return kSignBitMask | sam; + } + } + + // Given two numbers in the sign-and-magnitude representation, + // returns the distance between them as an unsigned number. + static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1, + const Bits &sam2) { + const Bits biased1 = SignAndMagnitudeToBiased(sam1); + const Bits biased2 = SignAndMagnitudeToBiased(sam2); + return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1); + } + + FloatingPointUnion u_; +}; + +// We cannot use std::numeric_limits<T>::max() as it clashes with the max() +// macro defined by <windows.h>. +template <> +inline float FloatingPoint<float>::Max() { return FLT_MAX; } +template <> +inline double FloatingPoint<double>::Max() { return DBL_MAX; } + +template <typename T> +bool AlmostEquals(T first, T second) +{ + FloatingPoint<T> firstAsFloatingPoint(first); + FloatingPoint<T> secondAsFloatingPoint(second); + + return firstAsFloatingPoint.AlmostEquals(secondAsFloatingPoint); +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp index ce5418c890ffdb3cb2a9728f41e35b9439647520..5ff5036175a99dd0c68834b5458c43abf213675d 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp +++ b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.cpp @@ -21,8 +21,4 @@ double DataPoint::getY() DataPoint::DataPoint(double x, double y) : x(x), y(y) { -} - -DataPoint::~DataPoint() -{ -} +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h index 1bbb2d94a283a7a5570308410094c74cf990b531..41e94ff6c7b4beeb8afe48f2cecd217dfcd65efc 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h +++ b/targets/tests/NumericalTestPostProcessing/Utilities/DataPoint/DataPoint.h @@ -6,14 +6,13 @@ class DataPoint { public: - std::shared_ptr<DataPoint> getNewInstance(double x, double y); + static 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; diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h index 85e6abdc22aec2ad402d5f881cdaa8abd15f4228..448c76d44102c55b5dff148e3919bf911ac2873f 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileData.h @@ -1,14 +1,52 @@ #ifndef LOGFILE_DATA_H #define LOGFILE_DATA_H +#include <memory> #include <string> +#include <vector> + +class L2NormLogFileData; +class L2NormBetweenKernelsLogFileData; +class NyLogFileData; +class PhiLogFileData; +class ShearWaveLogFileData; +class TaylorGreenVortexUxLogFileData; +class TaylorGreenVortexUzLogFileData; class LogFileData { public: + virtual std::vector<int> getAnalyticalVTKWritingTime() = 0; + virtual std::vector<double> getBasicGridLengths() = 0; virtual int getBasisTimeStepLength() = 0; + virtual std::string getDate() = 0; + virtual std::vector<std::string> getGpuDevices() = 0; virtual std::string getKernel() = 0; + virtual bool getL2NormTestRun() = 0; + virtual bool getL2NormTestBetweenKernelRun() = 0; virtual int getNumberOfTimeSteps() = 0; + virtual bool getNyTestRun() = 0; + virtual bool getPhiTestRun() = 0; + virtual std::vector<double> getResultCheckTime() = 0; + virtual std::string getSimName() = 0; + virtual std::vector<int> getSimTime() = 0; + + virtual std::vector<double> getTestTime() = 0; + virtual std::string getTime() = 0; virtual double getViscosity() = 0; + virtual bool getVTKFileWriting() = 0; + + virtual std::string getFilePath() = 0; + virtual std::string getSimulationSigniture() = 0; + + virtual std::vector<std::shared_ptr<L2NormLogFileData> > getL2NormLogFileData() = 0; + virtual std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > getL2NormBetweenKernelsLogFileData() = 0; + virtual std::vector<std::shared_ptr<NyLogFileData> > getNyLogFileData() = 0; + virtual std::vector<std::shared_ptr<PhiLogFileData> > getPhiLogFileData() = 0; + + virtual std::shared_ptr<TaylorGreenVortexUxLogFileData> getTaylorGreenVortexUxLogFileData() = 0; + virtual std::shared_ptr<TaylorGreenVortexUzLogFileData> getTaylorGreenVortexUzLogFileData() = 0; + virtual std::shared_ptr<ShearWaveLogFileData> getShearWaveLogFileData() = 0; + }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..c2688bc1b6b47d97e27ca6c23d9e591b95ae004b --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h @@ -0,0 +1,14 @@ +#ifndef LOG_FILE_DATA_GROUP_H +#define LOG_FILE_DATA_GROUP_H + +#include <memory> + +class LogFileData; + +class LogFileDataGroup +{ +public: + virtual std::shared_ptr<LogFileData> getLogFileData(int number) = 0; + virtual int getGroupSize() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e6eea97cf576b32d27fd25c82b06bfa8481e154 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.cpp @@ -0,0 +1,26 @@ +#include "LogFileDataGroupImp.h" + +std::shared_ptr<LogFileDataGroupImp> LogFileDataGroupImp::getNewInstance() +{ + return std::shared_ptr<LogFileDataGroupImp>(new LogFileDataGroupImp()); +} + +std::shared_ptr<LogFileData> LogFileDataGroupImp::getLogFileData(int number) +{ + return data.at(number); +} + +int LogFileDataGroupImp::getGroupSize() +{ + return data.size(); +} + +void LogFileDataGroupImp::addLogFileData(std::shared_ptr<LogFileData> logFileData) +{ + data.push_back(logFileData); +} + +LogFileDataGroupImp::LogFileDataGroupImp() +{ + data.resize(0); +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.h new file mode 100644 index 0000000000000000000000000000000000000000..9ac76e21946b037698f8ae2a13c1c6cc76f866af --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.h @@ -0,0 +1,22 @@ +#ifndef LOG_FILE_DATA_GROUP_IMP_H +#define LOG_FILE_DATA_GROUP_IMP_H + +#include "LogFileDataGroup.h" + +#include <vector> + +class LogFileDataGroupImp : public LogFileDataGroup +{ +public: + static std::shared_ptr<LogFileDataGroupImp> getNewInstance(); + + std::shared_ptr<LogFileData> getLogFileData(int number); + int getGroupSize(); + void addLogFileData(std::shared_ptr<LogFileData> logFileData); + +private: + LogFileDataGroupImp(); + + std::vector<std::shared_ptr<LogFileData>> data; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataGroup/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp index d329cabd618cc1e3afbc18e34f822f6047c4cad0..5e00598ee634e5b9da503608a6080693da38c857 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.cpp @@ -10,41 +10,275 @@ void LogFileDataImp::setBasisTimeStepLength(int basisTimeStepLength) this->basisTimeStepLength = basisTimeStepLength; } +void LogFileDataImp::setAnalyticalVTKWritingTime(std::vector<int> analyticalVTKWritingTime) +{ + this->analyticalVTKWritingTime = analyticalVTKWritingTime; +} + +void LogFileDataImp::setBasicGridLengths(std::vector<double> basicGridLenghts) +{ + this->basicGridLenghts = basicGridLenghts; +} + +void LogFileDataImp::setDate(std::string date) +{ + this->date = date; +} + +void LogFileDataImp::setGpuDevices(std::vector<std::string> gpuDevices) +{ + this->gpuDevices = gpuDevices; +} + +void LogFileDataImp::setSimName(std::string simName) +{ + this->simName = simName; +} + +void LogFileDataImp::setSimTime(std::vector<int> simTime) +{ + this->simTime = simTime; +} + +void LogFileDataImp::setTestTime(std::vector<double> testTime) +{ + this->testTime = testTime; +} + +void LogFileDataImp::setTime(std::string time) +{ + this->time = time; +} + void LogFileDataImp::setKernel(std::string kernelName) { this->kernelName = kernelName; } +void LogFileDataImp::setL2NormTestRun(bool l2NormTestRun) +{ + this->l2NormTestRun = l2NormTestRun; +} + +void LogFileDataImp::setL2NormTestBetweenKernelRun(bool l2NormTestBetweenKernelRun) +{ + this->l2NormTestBetweenKernelRun = l2NormTestBetweenKernelRun; +} + void LogFileDataImp::setNumberOfTimeSteps(int numberOfTimeSteps) { this->numberOfTimeSteps = numberOfTimeSteps; } +void LogFileDataImp::setPhiTestRun(bool phiTestRun) +{ + this->phiTestRun = phiTestRun; +} + +void LogFileDataImp::setNyTestRun(bool nyTestRun) +{ + this->nyTestRun = nyTestRun; +} + +void LogFileDataImp::setResultCheckTime(std::vector<double> resultsCheckTime) +{ + this->resultsCheckTime = resultsCheckTime; +} + void LogFileDataImp::setViscosity(double viscosity) { this->viscosity = viscosity; } +void LogFileDataImp::setVTKFileWriting(bool vtkFileWriting) +{ + this->vtkFileWriting = vtkFileWriting; +} + +void LogFileDataImp::setFilePath(std::string filePath) +{ + this->filePath = filePath; +} + +void LogFileDataImp::setSimulationSigniture(std::string simulationSigniture) +{ + this->simulationSigniture = simulationSigniture; +} + +void LogFileDataImp::setL2NormLogFileData(std::vector<std::shared_ptr<L2NormLogFileData>> data) +{ + this->l2NormLogFileData = data; +} + +void LogFileDataImp::setL2NormBetweenKernelsLogFileData(std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData>> data) +{ + this->l2NormBetweenKernelsDataLogFileData = data; +} + +void LogFileDataImp::setNyLogFileData(std::vector<std::shared_ptr<NyLogFileData>> data) +{ + this->nyLogFileData = data; +} + +void LogFileDataImp::setPhiLogFileData(std::vector<std::shared_ptr<PhiLogFileData>> data) +{ + this->phiLogFileData = data; +} + +void LogFileDataImp::setTaylorGreenVortexUxLogFileData(std::shared_ptr<TaylorGreenVortexUxLogFileData> data) +{ + this->tgvUxLogFileData = data; +} + +void LogFileDataImp::setTaylorGreenVortexUzLogFileData(std::shared_ptr<TaylorGreenVortexUzLogFileData> data) +{ + this->tgvUzLogFileData = data; +} + +void LogFileDataImp::setShearWaveLogFileData(std::shared_ptr<ShearWaveLogFileData> data) +{ + this->shearWaveLogFileData = data; +} + +LogFileDataImp::~LogFileDataImp() +{ +} + int LogFileDataImp::getBasisTimeStepLength() { return basisTimeStepLength; } +std::vector<int> LogFileDataImp::getAnalyticalVTKWritingTime() +{ + return analyticalVTKWritingTime; +} + +std::vector<double> LogFileDataImp::getBasicGridLengths() +{ + return basicGridLenghts; +} + +std::string LogFileDataImp::getDate() +{ + return date; +} + +std::vector<std::string> LogFileDataImp::getGpuDevices() +{ + return gpuDevices; +} + std::string LogFileDataImp::getKernel() { return kernelName; } +bool LogFileDataImp::getL2NormTestRun() +{ + return l2NormTestRun; +} + +bool LogFileDataImp::getL2NormTestBetweenKernelRun() +{ + return l2NormTestBetweenKernelRun; +} + int LogFileDataImp::getNumberOfTimeSteps() { return numberOfTimeSteps; } +bool LogFileDataImp::getNyTestRun() +{ + return nyTestRun; +} + +bool LogFileDataImp::getPhiTestRun() +{ + return phiTestRun; +} + +std::vector<double> LogFileDataImp::getResultCheckTime() +{ + return resultsCheckTime; +} + +std::string LogFileDataImp::getSimName() +{ + return simName; +} + +std::vector<int> LogFileDataImp::getSimTime() +{ + return simTime; +} + +std::vector<double> LogFileDataImp::getTestTime() +{ + return testTime; +} + +std::string LogFileDataImp::getTime() +{ + return time; +} + double LogFileDataImp::getViscosity() { return viscosity; } +bool LogFileDataImp::getVTKFileWriting() +{ + return vtkFileWriting; +} + +std::string LogFileDataImp::getFilePath() +{ + return filePath; +} + +std::string LogFileDataImp::getSimulationSigniture() +{ + return simulationSigniture; +} + +std::vector<std::shared_ptr<L2NormLogFileData>> LogFileDataImp::getL2NormLogFileData() +{ + return l2NormLogFileData; +} + +std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData>> LogFileDataImp::getL2NormBetweenKernelsLogFileData() +{ + return l2NormBetweenKernelsDataLogFileData; +} + +std::vector<std::shared_ptr<PhiLogFileData>> LogFileDataImp::getPhiLogFileData() +{ + return phiLogFileData; +} + +std::vector<std::shared_ptr<NyLogFileData>> LogFileDataImp::getNyLogFileData() +{ + return nyLogFileData; +} + +std::shared_ptr<TaylorGreenVortexUxLogFileData> LogFileDataImp::getTaylorGreenVortexUxLogFileData() +{ + return tgvUxLogFileData; +} + +std::shared_ptr<TaylorGreenVortexUzLogFileData> LogFileDataImp::getTaylorGreenVortexUzLogFileData() +{ + return tgvUzLogFileData; +} + +std::shared_ptr<ShearWaveLogFileData> LogFileDataImp::getShearWaveLogFileData() +{ + return shearWaveLogFileData; +} + LogFileDataImp::LogFileDataImp() { } diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h index 8db5e352abaa475bdbbc2833f6f002216c4b7a09..a105e55bdef71dc4c04f76f6dcbd809d946bbb9d 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileData/LogFileDataImp.h @@ -10,22 +10,99 @@ class LogFileDataImp : public LogFileData public: static std::shared_ptr<LogFileDataImp> getNewInstance(); + std::vector<int> getAnalyticalVTKWritingTime(); + std::vector<double> getBasicGridLengths(); int getBasisTimeStepLength(); + std::string getDate(); + std::vector<std::string> getGpuDevices(); std::string getKernel(); + bool getL2NormTestRun(); + bool getL2NormTestBetweenKernelRun(); int getNumberOfTimeSteps(); + bool getNyTestRun(); + bool getPhiTestRun(); + std::vector<double> getResultCheckTime(); + std::string getSimName(); + std::vector<int> getSimTime(); + std::vector<double> getTestTime(); + std::string getTime(); double getViscosity(); + bool getVTKFileWriting(); + std::string getFilePath(); + std::string getSimulationSigniture(); + + std::vector<std::shared_ptr<L2NormLogFileData> > getL2NormLogFileData(); + std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > getL2NormBetweenKernelsLogFileData(); + std::vector<std::shared_ptr<PhiLogFileData> > getPhiLogFileData(); + std::vector<std::shared_ptr<NyLogFileData> > getNyLogFileData(); + std::shared_ptr<TaylorGreenVortexUxLogFileData> getTaylorGreenVortexUxLogFileData(); + std::shared_ptr<TaylorGreenVortexUzLogFileData> getTaylorGreenVortexUzLogFileData(); + std::shared_ptr<ShearWaveLogFileData> getShearWaveLogFileData(); + + void setAnalyticalVTKWritingTime(std::vector<int> analyticalVTKWritingTime); + void setBasicGridLengths(std::vector<double> basicGridLenghts); void setBasisTimeStepLength(int basisTimeStepLength); + void setDate(std::string date); + void setGpuDevices(std::vector<std::string> gpuDevices); void setKernel(std::string kernelName); + void setL2NormTestRun(bool l2NormTestRun); + void setL2NormTestBetweenKernelRun(bool l2NormTestBetweenKernelRun); void setNumberOfTimeSteps(int numberOfTimeSteps); + void setPhiTestRun(bool phiTestRun); + void setNyTestRun(bool nyTestRun); + void setResultCheckTime(std::vector<double> resultsCheckTime); + void setSimName(std::string simName); + void setSimTime(std::vector<int> simTime); + void setTestTime(std::vector<double> testTime); + void setTime(std::string time); void setViscosity(double viscosity); + void setVTKFileWriting(bool vtkFileWriting); + void setFilePath(std::string filePath); + void setSimulationSigniture(std::string simulationSigniture); + + void setL2NormLogFileData(std::vector<std::shared_ptr<L2NormLogFileData> > data); + void setL2NormBetweenKernelsLogFileData(std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > data); + void setNyLogFileData(std::vector<std::shared_ptr<NyLogFileData> > data); + void setPhiLogFileData(std::vector<std::shared_ptr<PhiLogFileData> > data); + + void setTaylorGreenVortexUxLogFileData(std::shared_ptr<TaylorGreenVortexUxLogFileData> data); + void setTaylorGreenVortexUzLogFileData(std::shared_ptr<TaylorGreenVortexUzLogFileData> data); + void setShearWaveLogFileData(std::shared_ptr<ShearWaveLogFileData> data); + + ~LogFileDataImp(); private: LogFileDataImp(); + std::vector<int> analyticalVTKWritingTime; + std::vector<double> basicGridLenghts; int basisTimeStepLength; + std::string date; + std::vector<std::string> gpuDevices; std::string kernelName; + bool l2NormTestRun; + bool l2NormTestBetweenKernelRun; int numberOfTimeSteps; + bool phiTestRun; + bool nyTestRun; + std::vector<double> resultsCheckTime; + std::string simName; + std::vector<int> simTime; + std::vector<double> testTime; + std::string time; double viscosity; + bool vtkFileWriting; + std::string filePath; + std::string simulationSigniture; + + std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > l2NormBetweenKernelsDataLogFileData; + std::vector<std::shared_ptr<PhiLogFileData> > phiLogFileData; + std::vector<std::shared_ptr<NyLogFileData> > nyLogFileData; + std::vector<std::shared_ptr<L2NormLogFileData> > l2NormLogFileData; + + std::shared_ptr<ShearWaveLogFileData> shearWaveLogFileData; + std::shared_ptr<TaylorGreenVortexUxLogFileData> tgvUxLogFileData; + std::shared_ptr<TaylorGreenVortexUzLogFileData> tgvUzLogFileData; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistant.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistant.h new file mode 100644 index 0000000000000000000000000000000000000000..035eaf74aeb16c2037b9c7aec35f28597ba9f333 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistant.h @@ -0,0 +1,18 @@ +#ifndef LOGFILE_DATA_ASSISTANT_H +#define LOGFILE_DATA_ASSISTANT_H + +#include "Simulation/BasicSimulation.h" + +#include <memory> +#include <vector> + +class LogFileData; +class LogFileDataGroup; + +class LogFileDataAssistant +{ +public: + virtual std::vector<std::shared_ptr<LogFileDataGroup> > findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation) = 0; + virtual std::vector<std::shared_ptr<LogFileDataGroup> > findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation) = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..69c743f6b9ec9de69ce20f55faaf3674e6287004 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.cpp @@ -0,0 +1,167 @@ +#include "LogFileDataAssistantImp.h" + +#include "Utilities/AlmostEquals.h" +#include "Utilities/LogFileData/LogFileData.h" +#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroupImp.h" +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategy.h" +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.h" + +std::vector<std::vector<std::shared_ptr<LogFileData>>> LogFileDataAssistantImp::sortLogFileDataAfterKernels(std::vector<std::shared_ptr<LogFileData>> logFileData) +{ + std::vector<std::string> kernelNames; + for (int i = 0; i < logFileData.size(); i++) { + if (i == 0) + kernelNames.push_back(logFileData.at(i)->getKernel()); + else + { + bool newKernel = true; + for (int j = 0; j < kernelNames.size(); j++) { + if (kernelNames.at(i) == logFileData.at(i)->getKernel()) + newKernel = false; + } + if (newKernel) + kernelNames.push_back(logFileData.at(i)->getKernel()); + } + } + + std::vector<std::vector<std::shared_ptr<LogFileData> > > logFileDataAfterKernels; + logFileDataAfterKernels.resize(kernelNames.size()); + for (int i = 0; i < kernelNames.size(); i++) { + for (int j = 0; j < logFileData.size(); j++) { + if (kernelNames.at(i) == logFileData.at(j)->getKernel()) + logFileDataAfterKernels.at(i).push_back(logFileData.at(j)); + } + } + return logFileDataAfterKernels; +} + +bool LogFileDataAssistantImp::checkEqualSimulationData(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (logFileData1->getNumberOfTimeSteps() != logFileData2->getNumberOfTimeSteps()) + return false; + if (logFileData1->getBasisTimeStepLength() != logFileData2->getBasisTimeStepLength()) + return false; + + return true; +} + +bool LogFileDataAssistantImp::checkEqualViscosity(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (!equalDouble(logFileData1->getViscosity(), logFileData2->getViscosity())) + return false; + + return true; +} + +bool LogFileDataAssistantImp::checkEqualKernel(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) +{ + if (logFileData1->getKernel() != logFileData2->getKernel()) + return false; + + return true; +} + +std::vector<std::shared_ptr<LogFileDataGroup>> LogFileDataAssistantImp::castToLogFileDataGroup(std::vector<std::shared_ptr<LogFileDataGroupImp>> data) +{ + std::vector<std::shared_ptr<LogFileDataGroup>> casted; + + for (int i = 0; i < data.size(); i++) + casted.push_back(data.at(i)); + return casted; +} + +bool LogFileDataAssistantImp::equalDouble(double num1, double num2) +{ + const FloatingPoint<double> lhs(num1), rhs(num2); + + if (lhs.AlmostEquals(rhs)) + return true; + return false; +} + +std::vector<std::shared_ptr<LogFileData>> LogFileDataAssistantImp::getSimulationGroupLogFileData(std::string simName, std::vector<std::shared_ptr<LogFileData>> allLogFileData) +{ + std::vector<std::shared_ptr<LogFileData>> simGroupLogFileData; + + for (int i = 0; i < allLogFileData.size(); i++) { + if (allLogFileData.at(i)->getSimName() == simName) + simGroupLogFileData.push_back(allLogFileData.at(i)); + } + + return simGroupLogFileData; +} + +std::shared_ptr<LogFileDataAssistant> LogFileDataAssistantImp::getNewInstance() +{ + return std::shared_ptr<LogFileDataAssistant>(new LogFileDataAssistantImp()); +} + +std::vector<std::shared_ptr<LogFileDataGroup>> LogFileDataAssistantImp::findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData>> allLogFileData, BasicSimulation simulation) +{ + std::shared_ptr<LogFileDataAssistantStrategy> strategy = assistentStrategyFactory->makeLogFileDataAssistantStrategy(simulation); + + std::vector<std::shared_ptr<LogFileData>> myLogFileData = getSimulationGroupLogFileData(strategy->getSimulationName(), allLogFileData); + + std::vector<std::shared_ptr<LogFileDataGroupImp> > kernelGroups; + kernelGroups.push_back(LogFileDataGroupImp::getNewInstance()); + kernelGroups.at(0)->addLogFileData(myLogFileData.at(0)); + + for (int i = 1; i < myLogFileData.size(); i++) { + bool added = false; + for (int j = 0; j < kernelGroups.size(); j++) { + if (checkEqualSimulationData(myLogFileData.at(i), kernelGroups.at(j)->getLogFileData(0))) { + if (checkEqualViscosity(myLogFileData.at(i), kernelGroups.at(j)->getLogFileData(0))) { + if (strategy->checkSimulationParamerer(myLogFileData.at(i), kernelGroups.at(j)->getLogFileData(0))) { + kernelGroups.at(j)->addLogFileData(myLogFileData.at(i)); + added = true; + } + } + } + } + if (!added) { + std::shared_ptr<LogFileDataGroupImp> newGroup = LogFileDataGroupImp::getNewInstance(); + newGroup->addLogFileData(myLogFileData.at(i)); + kernelGroups.push_back(newGroup); + } + } + + return castToLogFileDataGroup(kernelGroups); +} + +std::vector<std::shared_ptr<LogFileDataGroup> > LogFileDataAssistantImp::findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData>> allLogFileData, BasicSimulation simulation) +{ + + std::shared_ptr<LogFileDataAssistantStrategy> strategy = assistentStrategyFactory->makeLogFileDataAssistantStrategy(simulation); + + std::vector<std::shared_ptr<LogFileData>> myLogFileData = getSimulationGroupLogFileData(strategy->getSimulationName(), allLogFileData); + + std::vector<std::shared_ptr<LogFileDataGroupImp> > viscosityGroups; + viscosityGroups.push_back(LogFileDataGroupImp::getNewInstance()); + viscosityGroups.at(0)->addLogFileData(myLogFileData.at(0)); + + for (int i = 1; i < myLogFileData.size(); i++) { + bool added = false; + for (int j = 0; j < viscosityGroups.size(); j++) { + if (checkEqualSimulationData(myLogFileData.at(i), viscosityGroups.at(j)->getLogFileData(0))) { + if (checkEqualKernel(myLogFileData.at(i), viscosityGroups.at(j)->getLogFileData(0))) { + if (strategy->checkSimulationParamerer(myLogFileData.at(i), viscosityGroups.at(j)->getLogFileData(0))) { + viscosityGroups.at(j)->addLogFileData(myLogFileData.at(i)); + added = true; + } + } + } + } + if (!added) { + std::shared_ptr<LogFileDataGroupImp> newGroup = LogFileDataGroupImp::getNewInstance(); + newGroup->addLogFileData(myLogFileData.at(i)); + viscosityGroups.push_back(newGroup); + } + } + + return castToLogFileDataGroup(viscosityGroups); +} + +LogFileDataAssistantImp::LogFileDataAssistantImp() +{ + assistentStrategyFactory = LogFileDataAssistantStrategyFactoryImp::getNewInstance(); +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.h new file mode 100644 index 0000000000000000000000000000000000000000..f54e357d9d8becd8bb521252f509a5066895a89e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantImp.h @@ -0,0 +1,34 @@ +#ifndef LOGFILE_DATA_ASSISTANT_IMP_H +#define LOGFILE_DATA_ASSISTANT_IMP_H + +#include "LogFileDataAssistant.h" + +class LogFileDataAssistantStrategyFactory; +class LogFileDataGroupImp; + +class LogFileDataAssistantImp : public LogFileDataAssistant +{ +public: + static std::shared_ptr<LogFileDataAssistant> getNewInstance(); + + std::vector<std::shared_ptr<LogFileDataGroup> > findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation); + std::vector<std::shared_ptr<LogFileDataGroup> > findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation); + + +protected: + LogFileDataAssistantImp(); + + std::vector<std::shared_ptr<LogFileData> > getSimulationGroupLogFileData(std::string simName, std::vector<std::shared_ptr<LogFileData> > allLogFileData); + std::vector<std::vector<std::shared_ptr<LogFileData> > > sortLogFileDataAfterKernels(std::vector<std::shared_ptr<LogFileData> > logFileData); + + bool checkEqualSimulationData(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + bool checkEqualViscosity(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + bool checkEqualKernel(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2); + + std::vector<std::shared_ptr<LogFileDataGroup>> castToLogFileDataGroup(std::vector<std::shared_ptr<LogFileDataGroupImp>> data); + + bool equalDouble(double num1, double num2); + + std::shared_ptr<LogFileDataAssistantStrategyFactory> assistentStrategyFactory; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategy.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..5c1b93dcf9dc38bd7a07263e857e0daba21c7545 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategy.h @@ -0,0 +1,15 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_H + +#include<memory> +#include <string> + +class LogFileData; + +class LogFileDataAssistantStrategy +{ +public: + virtual std::string getSimulationName() = 0; + virtual bool checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactory.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..51f3f43fb23bcd6af40d548c174fbbc2db6735eb --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactory.h @@ -0,0 +1,15 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_FACTORY_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_FACTORY_H + +#include "Simulation/BasicSimulation.h" + +#include <memory> + +class LogFileDataAssistantStrategy; + +class LogFileDataAssistantStrategyFactory +{ +public: + virtual std::shared_ptr<LogFileDataAssistantStrategy> makeLogFileDataAssistantStrategy(BasicSimulation sim) = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e5e5346c856cc79129ed9c5d76d7a1a28b53dba --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.cpp @@ -0,0 +1,34 @@ +#include "LogFileDataAssistantStrategyFactoryImp.h" + +#include "Simulation/ShearWave/LogFileDataAssistantStrategy/ShearWaveLogFileDataAssistantStrategy.h" +#include "Simulation/TaylorGreenVortexUx/LogFileDataAssistantStrategy/TaylorGreenVortexUxLogFileDataAssistantStrategy.h" +#include "Simulation/TaylorGreenVortexUz/LogFileDataAssistantStrategy/TaylorGreenVortexUzLogFileDataAssistantStrategy.h" + +std::shared_ptr<LogFileDataAssistantStrategyFactory> LogFileDataAssistantStrategyFactoryImp::getNewInstance() +{ + return std::shared_ptr<LogFileDataAssistantStrategyFactory>(new LogFileDataAssistantStrategyFactoryImp()); +} + +std::shared_ptr<LogFileDataAssistantStrategy> LogFileDataAssistantStrategyFactoryImp::makeLogFileDataAssistantStrategy(BasicSimulation sim) +{ + std::shared_ptr<LogFileDataAssistantStrategy> assistentStrategy; + switch (sim) + { + case ShearWave: + assistentStrategy = ShearWaveLogFileDataAssistantStrategy::getNewInstance(); + break; + case TaylorGreenVortexUx: + assistentStrategy = TaylorGreenVortexUxLogFileDataAssistantStrategy::getNewInstance(); + break; + case TaylorGreenVortexUz: + assistentStrategy = TaylorGreenVortexUzLogFileDataAssistantStrategy::getNewInstance(); + break; + default: + break; + } + return assistentStrategy; +} + +LogFileDataAssistantStrategyFactoryImp::LogFileDataAssistantStrategyFactoryImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.h new file mode 100644 index 0000000000000000000000000000000000000000..90fb1974a31db2eece47270e60d154194a00c985 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/LogFileDataAssistantStrategyFactoryImp.h @@ -0,0 +1,16 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_FACTORY_IMP_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_FACTORY_IMP_H + +#include "LogFileDataAssistantStrategyFactory.h" + +class LogFileDataAssistantStrategyFactoryImp : public LogFileDataAssistantStrategyFactory +{ +public: + static std::shared_ptr<LogFileDataAssistantStrategyFactory> getNewInstance(); + + std::shared_ptr<LogFileDataAssistantStrategy> makeLogFileDataAssistantStrategy(BasicSimulation sim); + +private: + LogFileDataAssistantStrategyFactoryImp(); +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyFactory/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..696e1c9ea33c706dfaeed96df2152ad237b4740a --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.cpp @@ -0,0 +1,12 @@ +#include "LogFileDataAssistantStrategyImp.h" + +#include "Utilities/AlmostEquals.h" + +bool LogFileDataAssistantStrategyImp::equalDouble(double num1, double num2) +{ + const FloatingPoint<double> lhs(num1), rhs(num2); + + if (lhs.AlmostEquals(rhs)) + return true; + return false; +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h new file mode 100644 index 0000000000000000000000000000000000000000..8c0035a8864a1600e65004ddb8ccee710304238c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/LogFileDataAssistantStrategyImp.h @@ -0,0 +1,15 @@ +#ifndef LOG_FILE_DATA_ASSISTANT_STRATEGY_IMP_H +#define LOG_FILE_DATA_ASSISTANT_STRATEGY_IMP_H + +#include "LogFileDataAssistantStrategy.h" + +class LogFileDataAssistantStrategyImp : public LogFileDataAssistantStrategy +{ +public: + virtual std::string getSimulationName() = 0; + virtual bool checkSimulationParamerer(std::shared_ptr<LogFileData> logFileData1, std::shared_ptr<LogFileData> logFileData2) = 0; + +protected: + bool equalDouble(double num1, double num2); +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/LogFileDataAssistantStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileDataAssistant/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp index 0b2caee617109e2d0217c1dec0cab96b49162489..576cec549197fc757c2d483589e5f0fd4d1d15cb 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp @@ -1,12 +1,22 @@ #include "LogFileReader.h" -#include "Utilities\LogFileData\LogFileDataImp.h" +#include "Simulation/ShearWave/LogFileData/ShearWaveLogFileDataImp.h" +#include "Simulation/TaylorGreenVortexUx/LogFileData/TaylorGreenVortexUxLogFileDataImp.h" +#include "Simulation/TaylorGreenVortexUz/LogFileData/TaylorGreenVortexUzLogFileDataImp.h" + +#include "Tests/L2Norm/LogFileData/L2NormLogFileDataImp.h" +#include "Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileDataImp.h" +#include "Tests/NyTest/LogFileData/NyLogFileDataImp.h" +#include "Tests/PhiTest/LogFileData/PhiLogFileDataImp.h" + +#include "Utilities/LogFileData/LogFileDataImp.h" #include "utilities/input/Input.h" #include "utilities/StringUtil/StringUtil.h" #include <filesystem> #include <fstream> +#include <iostream> std::shared_ptr<LogFileReader> LogFileReader::getInstance() { @@ -22,29 +32,348 @@ std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string std::ifstream stream; stream.open(filePath.c_str(), std::ios::in); - if (stream.fail()) - throw "can not open config file!\n"; + if (stream.fail()) { + std::cout << "can not open log file!\n"; + exit(1); + } std::unique_ptr<input::Input> input = input::Input::makeInput(stream, "config"); - logFileData->setBasisTimeStepLength(StringUtil::toInt(input->getValue("BasisTimeStepLength"))); + logFileData->setFilePath(filePath); + logFileData->setDate(StringUtil::toString(input->getValue("Date"))); + logFileData->setTime(StringUtil::toString(input->getValue("Time"))); + logFileData->setGpuDevices(StringUtil::toStringVector(input->getValue("GPU_Devices"))); + logFileData->setKernel(StringUtil::toString(input->getValue("Kernel"))); logFileData->setNumberOfTimeSteps(StringUtil::toInt(input->getValue("NumberOfTimeSteps"))); logFileData->setViscosity(StringUtil::toDouble(input->getValue("Viscosity"))); + logFileData->setBasisTimeStepLength(StringUtil::toInt(input->getValue("BasisTimeStepLength"))); + + logFileData->setSimName(StringUtil::toString(input->getValue("SimulationName"))); + + + std::ostringstream simSigniture; + if (logFileData->getSimName() == "ShearWave") { + std::vector<double> shearWaveLx = StringUtil::toDoubleVector(input->getValue("Lx")); + logFileData->setBasicGridLengths(shearWaveLx); + std::vector<int> shearWaveL0; + std::vector<double> shearWaveUx; + std::vector<double> shearWaveUz; + for (int i = 0; i < shearWaveLx.size(); i++) { + std::ostringstream l0, ux, uz; + l0 << "l0_" << shearWaveLx.at(i); + ux << "ux_" << shearWaveLx.at(i); + uz << "uz_" << shearWaveLx.at(i); + shearWaveL0.push_back(StringUtil::toInt(input->getValue(l0.str()))); + shearWaveUx.push_back(StringUtil::toDouble(input->getValue(ux.str()))); + shearWaveUz.push_back(StringUtil::toDouble(input->getValue(uz.str()))); + } + std::shared_ptr<ShearWaveLogFileDataImp> swLogFileData = ShearWaveLogFileDataImp::getNewInstance(); + swLogFileData->setL0(shearWaveL0); + swLogFileData->setUx(shearWaveUx); + swLogFileData->setUz(shearWaveUz); + logFileData->setShearWaveLogFileData(swLogFileData); + simSigniture << logFileData->getKernel() << "ShearWaveViscosity" << logFileData->getViscosity() << "ux" << shearWaveUx.at(0) << "uz" << shearWaveUz.at(0); + } + if (logFileData->getSimName() == "TaylorGreenVortexUx") { + std::vector<double> tgvUxLx = StringUtil::toDoubleVector(input->getValue("Lx")); + logFileData->setBasicGridLengths(tgvUxLx); + std::vector<int> tgvUxL0; + std::vector<double> tgvUxUx; + std::vector<double> tgvUxAmp; + for (int i = 0; i < tgvUxLx.size(); i++) { + std::ostringstream l0, ux, amplitude; + l0 << "l0_" << tgvUxLx.at(i); + ux << "ux_" << tgvUxLx.at(i); + amplitude << "Amplitude_" << tgvUxLx.at(i); + tgvUxL0.push_back(StringUtil::toInt(input->getValue(l0.str()))); + tgvUxUx.push_back(StringUtil::toDouble(input->getValue(ux.str()))); + tgvUxAmp.push_back(StringUtil::toDouble(input->getValue(amplitude.str()))); + } + std::shared_ptr<TaylorGreenVortexUxLogFileDataImp> tgvUxLogFileData = TaylorGreenVortexUxLogFileDataImp::getNewInstance(); + tgvUxLogFileData->setL0(tgvUxL0); + tgvUxLogFileData->setUx(tgvUxUx); + tgvUxLogFileData->setAmplitude(tgvUxAmp); + logFileData->setTaylorGreenVortexUxLogFileData(tgvUxLogFileData); + simSigniture << logFileData->getKernel() << "TaylorGreenVortexUxViscosity" << logFileData->getViscosity() << "Ux" << tgvUxUx.at(0) << "Amp" << tgvUxAmp.at(0); + } + if (logFileData->getSimName() == "TaylorGreenVortexUz") { + std::vector<double> tgvUzLz = StringUtil::toDoubleVector(input->getValue("Lx")); + logFileData->setBasicGridLengths(tgvUzLz); + std::vector<int> tgvUzL0; + std::vector<double> tgvUzUz; + std::vector<double> tgvUzAmp; + for (int i = 0; i < tgvUzLz.size(); i++) { + std::ostringstream l0, uz, amplitude; + l0 << "l0_" << tgvUzLz.at(i); + uz << "uz_" << tgvUzLz.at(i); + amplitude << "Amplitude_" << tgvUzLz.at(i); + tgvUzL0.push_back(StringUtil::toInt(input->getValue(l0.str()))); + tgvUzUz.push_back(StringUtil::toDouble(input->getValue(uz.str()))); + tgvUzAmp.push_back(StringUtil::toDouble(input->getValue(amplitude.str()))); + } + std::shared_ptr<TaylorGreenVortexUzLogFileDataImp> tgvUzLogFileData = TaylorGreenVortexUzLogFileDataImp::getNewInstance(); + tgvUzLogFileData->setL0(tgvUzL0); + tgvUzLogFileData->setUz(tgvUzUz); + tgvUzLogFileData->setAmplitude(tgvUzAmp); + logFileData->setTaylorGreenVortexUzLogFileData(tgvUzLogFileData); + simSigniture << logFileData->getKernel() << "TaylorGreenVortexUzViscosity" << logFileData->getViscosity() << "Uz" << tgvUzUz.at(0) << "Amp" << tgvUzAmp.at(0); + } + std::string compatibleString = removeCharsFromString(simSigniture.str(), "."); + logFileData->setSimulationSigniture(compatibleString); + + std::vector<int> simTime; + std::vector<double> resultsCheckTime; + std::vector<double> testTime; + std::vector<int> analyticalVTKWritingTime; + for (int i = 0; i < logFileData->getBasicGridLengths().size(); i++) { + std::ostringstream simTimeOStringStream, resultsCheckTimeOStringStream, testTimeOStringStream, analyticalVTKWritingTimeOStringStream; + simTimeOStringStream << "SimulationTime_" << logFileData->getBasicGridLengths().at(i); + resultsCheckTimeOStringStream << "ResultsCheckTime_" << logFileData->getBasicGridLengths().at(i); + testTimeOStringStream << "TestTime_" << logFileData->getBasicGridLengths().at(i); + analyticalVTKWritingTimeOStringStream << "AnalyticalVTKFileWritingTime_" << logFileData->getBasicGridLengths().at(i); + std::string simTimeString = StringUtil::toString(input->getValue(simTimeOStringStream.str())); + std::string resultCheckTimeString = StringUtil::toString(input->getValue(resultsCheckTimeOStringStream.str())); + std::string testTimeString = StringUtil::toString(input->getValue(testTimeOStringStream.str())); + std::string analyticalVTKWritingTimeString = StringUtil::toString(input->getValue(analyticalVTKWritingTimeOStringStream.str())); + simTimeString.erase(simTimeString.end() - 3, simTimeString.end()); + resultCheckTimeString.erase(resultCheckTimeString.end() - 3, resultCheckTimeString.end()); + testTimeString.erase(testTimeString.end() - 3, testTimeString.end()); + analyticalVTKWritingTimeString.erase(analyticalVTKWritingTimeString.end() - 3, analyticalVTKWritingTimeString.end()); + simTime.push_back(StringUtil::toInt(simTimeString)); + resultsCheckTime.push_back(StringUtil::toDouble(resultCheckTimeString)); + testTime.push_back(StringUtil::toDouble(testTimeString)); + analyticalVTKWritingTimeString.push_back(StringUtil::toInt(analyticalVTKWritingTimeString)); + } - std::string test = StringUtil::toString(input->getValue("GPU_Device_1")); + logFileData->setVTKFileWriting(StringUtil::toBool(input->getValue("VTKFileWriting"))); + logFileData->setSimTime(simTime); + logFileData->setResultCheckTime(resultsCheckTime); + logFileData->setTestTime(testTime); + logFileData->setAnalyticalVTKWritingTime(analyticalVTKWritingTime); + + logFileData->setPhiTestRun(StringUtil::toBool(input->getValue("PhiTest"))); + logFileData->setNyTestRun(StringUtil::toBool(input->getValue("NyTest"))); + logFileData->setL2NormTestRun(StringUtil::toBool(input->getValue("L2NormTest"))); + logFileData->setL2NormTestBetweenKernelRun(StringUtil::toBool(input->getValue("L2NormTestBetweenKernel"))); + + if (logFileData->getPhiTestRun()) { + std::vector<std::string> dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_PhiTest")); + std::vector<std::shared_ptr<PhiLogFileData> > aPhiLogGroup; + for (int i = 0; i < dataToCalc.size(); i++) { + std::shared_ptr<PhiLogFileDataImp> phiLog = PhiLogFileDataImp::getNewInstance(); + phiLog->setBasicGridLengths(logFileData->getBasicGridLengths()); + phiLog->setDataToCalc(dataToCalc.at(i)); + phiLog->setStartTimeStepCalculation(StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiTest"))); + phiLog->setEndTimeStepCalculation(StringUtil::toInt(input->getValue("EndTimeStepCalculation_PhiTest"))); + + std::vector<double> phiDiff; + std::vector<std::vector<double> > orderOfAccuracy; + for (int j = 0; j < logFileData->getBasicGridLengths().size(); j++) { + std::ostringstream phiDiffString; + phiDiffString << "PhiDiff_" << logFileData->getBasicGridLengths().at(j) << "_" << dataToCalc.at(i); + phiDiff.push_back(StringUtil::toDouble(input->getValue(phiDiffString.str()))); + + std::vector<double> aOrderOfAccuracyGroup; + for (int k = j + 1; k < logFileData->getBasicGridLengths().size(); k++) { + std::ostringstream phiDiff; + phiDiff << "OrderOfAccuracy_PhiDiff_" << logFileData->getBasicGridLengths().at(j) << "_" << logFileData->getBasicGridLengths().at(k) << "_" << dataToCalc.at(i); + aOrderOfAccuracyGroup.push_back(StringUtil::toDouble(input->getValue(phiDiff.str()))); + } + if(aOrderOfAccuracyGroup.size() > 0) + orderOfAccuracy.push_back(aOrderOfAccuracyGroup); + } + if(phiDiff.size() > 0) + phiLog->setPhiDiff(phiDiff); + if(orderOfAccuracy.size() > 0) + phiLog->setOrderOfAccuracy(orderOfAccuracy); + if(phiDiff.size() > 0 || orderOfAccuracy.size() > 0) + aPhiLogGroup.push_back(phiLog); + } + if (aPhiLogGroup.size() > 0) + logFileData->setPhiLogFileData(aPhiLogGroup); + else + logFileData->setPhiTestRun(false); + } + + if (logFileData->getNyTestRun()) { + std::vector<std::string> failNy = StringUtil::toStringVector(input->getValue("FailTests_Ny_NyTest")); + std::vector<std::string> failOOA = StringUtil::toStringVector(input->getValue("FailTests_OOA_NyTest")); + + std::vector<std::string> dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_NyTest")); + std::vector<std::shared_ptr<NyLogFileData> > aNyLogGroup; + for (int i = 0; i < dataToCalc.size(); i++) { + std::shared_ptr<NyLogFileDataImp> nyLog = NyLogFileDataImp::getNewInstance(); + nyLog->setBasicGridLengths(logFileData->getBasicGridLengths()); + nyLog->setDataToCalcPhiAndNu(dataToCalc.at(i)); + nyLog->setStartTimeStepCalculation(StringUtil::toInt(input->getValue("StartTimeStepCalculation_NyTest"))); + nyLog->setEndTimeStepCalculation(StringUtil::toInt(input->getValue("EndTimeStepCalculation_NyTest"))); + + std::vector<double> ny, nyDiff; + std::vector<std::vector<double> > orderOfAccuracy; + for (int j = 0; j < logFileData->getBasicGridLengths().size(); j++) { + std::ostringstream nyBasicString, nyString, nyDiffString; + nyBasicString << logFileData->getBasicGridLengths().at(j) << "_" << dataToCalc.at(i); + bool failData = false; + for (int k = 0; k < failNy.size(); k++) { + if (nyBasicString.str() == failNy.at(k)) + failData = true; + } + if (!failData) { + nyString << "Ny_" << nyBasicString.str(); + ny.push_back(StringUtil::toDouble(input->getValue(nyString.str()))); + nyDiffString << "NyDiff_" << logFileData->getBasicGridLengths().at(j) << "_" << dataToCalc.at(i); + nyDiff.push_back(StringUtil::toDouble(input->getValue(nyDiffString.str()))); + } + + std::vector<double> aOrderOfAccuracyGroup; + for (int k = j + 1; k < logFileData->getBasicGridLengths().size(); k++) { + std::ostringstream nyDiff, nyDiffBasic; + nyDiffBasic << logFileData->getBasicGridLengths().at(j) << "_" << logFileData->getBasicGridLengths().at(k) << "_" << dataToCalc.at(i); + bool failData = false; + for (int k = 0; k < failOOA.size(); k++) { + if (nyDiffBasic.str() == failOOA.at(k)) + failData = true; + } + if (!failData) { + nyDiff << "OrderOfAccuracy_NyDiff_" << nyDiffBasic.str(); + aOrderOfAccuracyGroup.push_back(StringUtil::toDouble(input->getValue(nyDiff.str()))); + } + } + if(aOrderOfAccuracyGroup.size() > 0) + orderOfAccuracy.push_back(aOrderOfAccuracyGroup); + + } + if (ny.size() > 0) { + nyLog->setNy(ny); + nyLog->setNyDiff(nyDiff); + } + if (orderOfAccuracy.size() > 0) + nyLog->setOrderOfAccuracy(orderOfAccuracy); + if (ny.size() > 0 || orderOfAccuracy.size() > 0) + aNyLogGroup.push_back(nyLog); + } + if (aNyLogGroup.size() > 0) + logFileData->setNyLogFileData(aNyLogGroup); + else + logFileData->setNyTestRun(false); + } + + if (logFileData->getL2NormTestRun()) { + std::vector<std::shared_ptr<L2NormLogFileData> > l2NormGroup; + std::vector<std::string> dataToCalcL2Norm = StringUtil::toStringVector(input->getValue("DataToCalc_L2Norm")); + std::vector<std::string> normData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); + std::vector<std::string> failL2Norm = StringUtil::toStringVector(input->getValue("FailTests_L2Norm")); + for (int i = 0; i < dataToCalcL2Norm.size(); i++) { + for (int k = 0; k < normData.size(); k++) { + std::shared_ptr<L2NormLogFileDataImp> aL2Norm = L2NormLogFileDataImp::getNewInstance(); + aL2Norm->setDataToCalc(dataToCalcL2Norm.at(i)); + aL2Norm->setNormalizeData(normData.at(k)); + aL2Norm->setBasicGridLengths(logFileData->getBasicGridLengths()); + aL2Norm->setBasicTimeStep(StringUtil::toInt(input->getValue("BasicTimeStep_L2Norm"))); + aL2Norm->setDivergentTimeStep(StringUtil::toInt(input->getValue("DivergentTimeStep_L2Norm"))); + + std::vector<double> l2NormBasicTimeStep; + std::vector<double> l2NormDivergentTimeStep; + std::vector<double> l2NormDiff; + for (int j = 0; j < logFileData->getBasicGridLengths().size(); j++) { + std::ostringstream basicTimeStep, divergentTimeStep, diff; + std::ostringstream basicString; + basicString << "L" << logFileData->getBasicGridLengths().at(j) << "_" << dataToCalcL2Norm.at(i) << "_" << normData.at(k); + bool fail = false; + for (int l = 0; l < failL2Norm.size(); l++) + if (basicString.str() == failL2Norm.at(i)) + fail = true; + if (!fail) { + basicTimeStep << "L2Norm_BasicTimeStep_" << basicString.str(); + divergentTimeStep << "L2Norm_DivergentTimeStep_" << basicString.str(); + diff << "L2Norm_Diff_" << basicString.str(); + l2NormBasicTimeStep.push_back(StringUtil::toDouble(input->getValue(basicTimeStep.str()))); + l2NormDivergentTimeStep.push_back(StringUtil::toDouble(input->getValue(divergentTimeStep.str()))); + l2NormDiff.push_back(StringUtil::toDouble(input->getValue(diff.str()))); + } + } + if (l2NormBasicTimeStep.size() > 0) { + aL2Norm->setL2NormForBasicTimeStep(l2NormBasicTimeStep); + aL2Norm->setL2NormForDivergentTimeStep(l2NormDivergentTimeStep); + aL2Norm->setL2NormDiff(l2NormDiff); + l2NormGroup.push_back(aL2Norm); + } + } + } + if (l2NormGroup.size() > 0) + logFileData->setL2NormLogFileData(l2NormGroup); + else + logFileData->setL2NormTestRun(false); + } + + if (logFileData->getL2NormTestBetweenKernelRun()) { + std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > l2NormBetweenKernelsData; + std::vector<std::string> dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalculate_L2Norm_BK")); + std::vector<int> timeSteps = StringUtil::toIntVector(input->getValue("TimeSteps_L2Norm_BK")); + std::vector<std::string> normalizeData = StringUtil::toStringVector(input->getValue("NormalizeWith_L2Norm_BK")); + std::vector<std::string> failL2Norm = StringUtil::toStringVector(input->getValue("FailTests_L2Norm_BK")); + + std::vector<double> l2NormBasicKernel; + std::vector<double> l2NormDivergentKernel; + std::vector<double> l2NormBetweenKernels; + for (int i = 0; i < dataToCalc.size(); i++) { + for (int j = 0; j < timeSteps.size(); j++) { + for (int k = 0; k < normalizeData.size(); k++) { + std::shared_ptr<L2NormBetweenKernelsLogFileDataImp> aL2NormLogFileData = L2NormBetweenKernelsLogFileDataImp::getNewInstance(); + aL2NormLogFileData->setBasicKernel(StringUtil::toString(input->getValue("BasicKernel_L2Norm_BK"))); + aL2NormLogFileData->setDataToCalculate(dataToCalc.at(i)); + aL2NormLogFileData->setTimeStep(timeSteps.at(j)); + aL2NormLogFileData->setNormalizeData(normalizeData.at(k)); + aL2NormLogFileData->setBasicGridLengths(logFileData->getBasicGridLengths()); + + for (int l = 0; l < logFileData->getBasicGridLengths().size(); l++) { + std::ostringstream basicKernel, divergentKernel, diff; + std::ostringstream basicString; + basicString << "L" << logFileData->getBasicGridLengths().at(l) << "_" << dataToCalc.at(i) << "_TimeStep_" << timeSteps.at(j) << "_" << normalizeData.at(k); + bool fail = false; + for (int m = 0; m < failL2Norm.size(); m++) { + if (basicString.str() == failL2Norm.at(m)) + fail = true; + } + if (!fail) { + basicKernel << "L2Norm_BasicKernel_" << basicString.str(); + divergentKernel << "L2Norm_DivergentKernel_" << basicString.str(); + diff << "L2Norm_Between_Kernels_" << basicString.str(); + l2NormBasicKernel.push_back(StringUtil::toDouble(input->getValue(basicKernel.str()))); + l2NormDivergentKernel.push_back(StringUtil::toDouble(input->getValue(divergentKernel.str()))); + l2NormBetweenKernels.push_back(StringUtil::toDouble(input->getValue(diff.str()))); + } + } + if (l2NormBasicKernel.size() > 0) { + aL2NormLogFileData->setL2NormForBasicKernel(l2NormBasicKernel); + aL2NormLogFileData->setL2NormForDivergentKernel(l2NormDivergentKernel); + aL2NormLogFileData->setL2NormBetweenKernels(l2NormBetweenKernels); + l2NormBetweenKernelsData.push_back(aL2NormLogFileData); + } + } + } + } + if (l2NormBetweenKernelsData.size() > 0) + logFileData->setL2NormBetweenKernelsLogFileData(l2NormBetweenKernelsData); + else + logFileData->setL2NormTestBetweenKernelRun(false); + } return logFileData; } -std::vector<std::shared_ptr<LogFileData>> LogFileReader::readLogFilesInDirectoryToLogFileData(std::string directory) +std::vector<std::shared_ptr<LogFileData> > LogFileReader::readLogFilesInDirectoryToLogFileData(std::string directory) { - std::vector< std::shared_ptr< LogFileData> > logFileData; + std::vector<std::shared_ptr<LogFileData> > logFileData; - std::vector< std::string> filePaths = getAllFilesInDir(directory, ".txt"); - for (int i = 0; i < filePaths.size(); i++) + std::cout << "seaching for LogFiles in: " << directory << std::endl; + std::vector<std::string> filePaths = getAllFilesInDir(directory, ".txt"); + std::cout << filePaths.size() << " LogFiles found." << std::endl; + std::cout << "reading LogFiles.." << std::endl; + for (int i = 0; i < filePaths.size(); i++) { logFileData.push_back(readLogFileToLogFileData(filePaths.at(i))); - + } return logFileData; } @@ -65,4 +394,11 @@ std::vector<std::string> LogFileReader::getAllFilesInDir(const std::string &dirP } } return listOfFiles; +} + +std::string LogFileReader::removeCharsFromString(std::string str, char * charsToRemove) +{ + for (unsigned int i = 0; i < strlen(charsToRemove); ++i) + str.erase(remove(str.begin(), str.end(), charsToRemove[i]), str.end()); + return str; } \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h index 482cdb1fe2b009d6f052e271cc5a28feaa98e3d2..7a98148692b2d9450de6111137a6badcfdc13991 100644 --- a/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h +++ b/targets/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.h @@ -13,13 +13,15 @@ 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); + 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); + std::string removeCharsFromString(std::string str, char* charsToRemove); + }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistant.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistant.h new file mode 100644 index 0000000000000000000000000000000000000000..96d38560aad89df94286a58eebdc574440ccb31c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistant.h @@ -0,0 +1,15 @@ +#ifndef MATHEMATICA_ASSISTANT_H +#define MATHEMATICA_ASSISTANT_H + +#include <memory> +#include <vector> + +class LogFileDataGroup; +class MathematicaFile; + +class MathematicaAssistant +{ +public: + virtual void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile) = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3aa5bbf326d0f4955cd456d296c6fedc78dd0679 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.cpp @@ -0,0 +1,5 @@ +#include "MathematicaAssistantImp.h" + +MathematicaAssistantImp::MathematicaAssistantImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.h new file mode 100644 index 0000000000000000000000000000000000000000..b508f01ae9cd1c3b10891e21873146d33303b16f --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/MathematicaAssistantImp.h @@ -0,0 +1,14 @@ +#ifndef MATHEMATICA_ASSISTANT_IMP_H +#define MATHEMATICA_ASSISTANT_IMP_H + +#include "MathematicaAssistant.h" + +class MathematicaAssistantImp : public MathematicaAssistant +{ +public: + virtual void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile) = 0; + +protected: + MathematicaAssistantImp(); +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaAssistant/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5e155fb1935ab14c4c7aeee5f1ccf3c34bcada30 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.cpp @@ -0,0 +1,57 @@ +#include "MathematicaFile.h" + +#include "Utilities/MathematicaFunction/MathematicaFunktion.h" + +#include <ctime> +#include <experimental/filesystem> +#include <iomanip> +#include <sstream> + +std::shared_ptr<MathematicaFile> MathematicaFile::getNewInstance(std::string filePath) +{ + return std::shared_ptr<MathematicaFile>(new MathematicaFile(filePath)); +} + +void MathematicaFile::addMathematicaFunction(std::shared_ptr<MathematicaFunction> aMathFunc) +{ + if (!fileFinished) + myFile << aMathFunc->getFunction() << std::endl; +} + +void MathematicaFile::finishFile() +{ + if (!fileFinished) { + fileFinished = true; + myFile.close(); + + std::experimental::filesystem::rename(filePathTxtFile, filePathMathematicaFile); + std::system(filePathMathematicaFile.c_str()); + } +} + +MathematicaFile::MathematicaFile(std::string filePath) +{ + fileFinished = false; + + std::ostringstream basicFilePath, textFile, mathematicaFile; + basicFilePath << filePath << "/NumericalTestPostProcessing_" << calcDateAndTime(); + textFile << basicFilePath.str() << ".txt"; + mathematicaFile << basicFilePath.str() << ".nb"; + filePathTxtFile = textFile.str(); + filePathMathematicaFile = mathematicaFile.str(); + + myFile.open(filePathTxtFile); +} + +std::string MathematicaFile::calcDateAndTime() +{ + std::ostringstream oss; + time_t now = time(NULL); + struct tm nowLocal = *localtime(&now); + oss << std::setfill('0') << nowLocal.tm_year + 1900 << std::setw(2) << nowLocal.tm_mon + 1 << std::setw(2) << nowLocal.tm_mday << "_" << std::setw(2) << nowLocal.tm_hour << std::setw(2) << nowLocal.tm_min << std::setw(2) << nowLocal.tm_sec; + return oss.str(); +} + +MathematicaFile::MathematicaFile() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.h new file mode 100644 index 0000000000000000000000000000000000000000..9b3c59a5b608862a3496abefcce8f2dbc4930ae2 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/MathematicaFile.h @@ -0,0 +1,29 @@ +#ifndef MATHEMATICA_FILE_H +#define MATHEMATICA_FILE_H + +#include <fstream> +#include <memory> +#include <string> + +class MathematicaFunction; + +class MathematicaFile +{ +public: + static std::shared_ptr<MathematicaFile> getNewInstance(std::string filePath); + + void addMathematicaFunction(std::shared_ptr<MathematicaFunction> aMathFunc); + void finishFile(); + + +private: + MathematicaFile(); + MathematicaFile(std::string filePath); + + std::string calcDateAndTime(); + + std::string filePathTxtFile, filePathMathematicaFile; + bool fileFinished; + std::ofstream myFile; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFile/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlot.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlot.h new file mode 100644 index 0000000000000000000000000000000000000000..0e4077c12605da124d3666a273a792f7d1977469 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlot.h @@ -0,0 +1,12 @@ +#ifndef MATHEMATICA_LIST_PLOT_H +#define MATHEMATICA_LIST_PLOT_H + +#include "../MathematicaFunktionImp.h" + + +class MathematicaListPlot : public MathematicaFunctionImp +{ +public: + +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0e940e22751d7097affe2ad28b7e3faf1fb6e19e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.cpp @@ -0,0 +1,31 @@ +#include "MathematicaListPlotImp.h" + +#include "Utilities\MathematicaFunction\PointList\MathematicaPointList.h" + +std::shared_ptr<MathematicaListPlot> MathematicaListPlotImp::getNewInstance(std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes) +{ + return std::shared_ptr<MathematicaListPlotImp>(new MathematicaListPlotImp(pointList, plotType, xAxes, yAxes)); +} + +MathematicaListPlotImp::MathematicaListPlotImp(std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes) +{ + mathematicaFunction << plotType << "[{"; + for (int i = 0; i < pointList.size(); i++) { + if(i < pointList.size() - 1) + mathematicaFunction << pointList.at(i)->getListName() << ", "; + else + mathematicaFunction << pointList.at(i)->getListName() << "}"; + } + mathematicaFunction << ", PlotLegends -> {\""; + for (int i = 0; i < pointList.size(); i++) { + if (i < pointList.size() - 1) + mathematicaFunction << pointList.at(i)->getListName() << "\", \""; + else + mathematicaFunction << pointList.at(i)->getListName() << "\"}"; + } + mathematicaFunction << ", AxesLabel -> {" << xAxes << ", " << yAxes << "}, Joined -> True, PlotMarkers->Automatic, PlotStyle -> Dashed]"; +} + +MathematicaListPlotImp::MathematicaListPlotImp() +{ +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.h new file mode 100644 index 0000000000000000000000000000000000000000..816af8c2d1bed1cf8ad7bb67cf5e6edf79d19e73 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.h @@ -0,0 +1,20 @@ +#ifndef MATHEMATICA_PLOT_IMP_H +#define MATHEMATICA_PLOT_IMP_H + +#include "MathematicaListPlot.h" + +#include <memory> +#include <vector> + +class MathematicaPointList; + +class MathematicaListPlotImp : public MathematicaListPlot +{ +public: + static std::shared_ptr<MathematicaListPlot> getNewInstance(std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes); + +private: + MathematicaListPlotImp(); + MathematicaListPlotImp(std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes); +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/LinePlot/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfLists.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfLists.h new file mode 100644 index 0000000000000000000000000000000000000000..b3201a013aa43f4b5ce50bc2f54738ad70c4fe69 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfLists.h @@ -0,0 +1,11 @@ +#ifndef MATHEMATICA_LIST_OF_LISTS_H +#define MATHEMATICA_LIST_OF_LISTS_H + +#include "../MathematicaFunktionImp.h" + +class MathematicaListOfLists : public MathematicaFunctionImp +{ +public: + virtual std::string getListName() = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc236d6495fc82e9c87a5e10fe33684306dbecd0 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.cpp @@ -0,0 +1,36 @@ +#include "MathematicaListOfListsImp.h" + +#include <iomanip> + +std::shared_ptr<MathematicaListOfLists> MathematicaListOfListsImp::getNewInstance(std::string listName, std::vector<std::vector<double>> listOfLists) +{ + return std::shared_ptr<MathematicaListOfLists>(new MathematicaListOfListsImp(listName, listOfLists)); +} + +std::string MathematicaListOfListsImp::getListName() +{ + return listName; +} + +MathematicaListOfListsImp::MathematicaListOfListsImp(std::string listName, std::vector<std::vector<double>> listOfLists) : listName(listName), listOfLists(listOfLists) +{ + mathematicaFunction << std::fixed << std::setprecision(std::numeric_limits<double>::digits10 + 1); + mathematicaFunction << listName << "= {"; + + for (int i = 0; listOfLists.size(); i++) { + mathematicaFunction << "{"; + if (i > 0) + mathematicaFunction << ", "; + for (int j = 0; j < listOfLists.at(i).size(); j++){ + if (i > 0) + mathematicaFunction << ", "; + mathematicaFunction << listOfLists.at(i).at(j); + } + mathematicaFunction << "}"; + } + mathematicaFunction << "};"; +} + +MathematicaListOfListsImp::MathematicaListOfListsImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.h new file mode 100644 index 0000000000000000000000000000000000000000..ba19ba20dde6f9810f1003fb56964c9915cb425b --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.h @@ -0,0 +1,25 @@ +#ifndef MATHEMATICA_LIST_OF_LISTS_IMP_H +#define MATHEMATICA_LIST_OF_LISTS_IMÜ_H + +#include "MathematicaListOfLists.h" + +#include <memory> +#include <vector> + +class MathematicaListOfListsImp : public MathematicaListOfLists +{ +public: + + static std::shared_ptr<MathematicaListOfLists> getNewInstance(std::string listName, std::vector<std::vector<double> > listOfLists); + + std::string getListName(); + + +private: + MathematicaListOfListsImp(); + MathematicaListOfListsImp(std::string listName, std::vector<std::vector<double> > listOfLists); + + std::string listName; + std::vector<std::vector<double> > listOfLists; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/ListOfLists/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktion.h similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktion.h rename to targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktion.h diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktionImp.cpp similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.cpp rename to targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktionImp.cpp diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktionImp.h similarity index 100% rename from targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/MathematicaFunktionImp.h rename to targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/MathematicaFunktionImp.h diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointList.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointList.h new file mode 100644 index 0000000000000000000000000000000000000000..d084d19e782dfa61c0ae2fc94dcebffa7d32a3de --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointList.h @@ -0,0 +1,11 @@ +#ifndef MATHEMATICA_POINT_LIST_H +#define MATHEMATICA_POINT_LIST_H + +#include "../MathematicaFunktionImp.h" + +class MathematicaPointList : public MathematicaFunctionImp +{ +public: + virtual std::string getListName() = 0; +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6689d5f14ad94cad908584c2847cc02536df60a6 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.cpp @@ -0,0 +1,33 @@ +#include "MathematicaPointListImp.h" + +#include "Utilities/DataPoint/DataPoint.h" +#include "MathematicaPointList.h" + +#include <iomanip> + +std::shared_ptr<MathematicaPointList> MathematicaPointListImp::getNewInstance(std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData) +{ + return std::shared_ptr<MathematicaPointList>(new MathematicaPointListImp(listName, plotData)); +} + +std::string MathematicaPointListImp::getListName() +{ + return listName; +} + +MathematicaPointListImp::MathematicaPointListImp(std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData) : listName(listName) +{ + mathematicaFunction << std::fixed << std::setprecision(std::numeric_limits<double>::digits10 + 1); + mathematicaFunction <<listName <<"= {"; + for (int i = 0; i < plotData.size(); i++) { + if (i > 0) + mathematicaFunction <<", "; + mathematicaFunction <<"{" << plotData.at(i)->getX() <<", " << plotData.at(i)->getY() <<"}"; + } + + mathematicaFunction << "};"; +} + +MathematicaPointListImp::MathematicaPointListImp() +{ +} \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.h new file mode 100644 index 0000000000000000000000000000000000000000..ef1459c3691ece9f461e7a7c3ee215bcdb5e7770 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/MathematicaPointListImp.h @@ -0,0 +1,24 @@ +#ifndef MATHEMATICA_POINT_LIST_IMP_H +#define MATHEMATICA_POINT_LIST_IMP_H + +#include "MathematicaPointList.h" + +#include <memory> +#include <vector> + +class DataPoint; + +class MathematicaPointListImp : public MathematicaPointList +{ +public: + static std::shared_ptr<MathematicaPointList> getNewInstance(std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData); + + std::string getListName(); + +private: + MathematicaPointListImp(); + MathematicaPointListImp(std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData); + + std::string listName; +}; +#endif diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/PointList/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunction/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..15d4469482ba233acd766a05b4b9e2de60ba179e --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h @@ -0,0 +1,21 @@ +#ifndef MATHEMATICA_FUNCTION_FACTORY_H +#define MATHEMATICA_FUNCTION_FACTORY_H + +#include <memory> +#include <string> +#include <vector> + +class DataPoint; +class MathematicaFile; +class MathematicaListPlot; +class MathematicaListOfLists; +class MathematicaPointList; + +class MathematicaFunctionFactory +{ +public: + virtual std::shared_ptr<MathematicaPointList> makeMathematicaPointList(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData) = 0; + virtual std::shared_ptr<MathematicaListPlot> makeMathematicaListPlot(std::shared_ptr<MathematicaFile> file, std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes) = 0; + virtual std::shared_ptr<MathematicaListOfLists> makeMathematicaListOfLists(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::vector<double>> listOfLists) = 0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ba51c2d47766853718e76aacc0156ee5414ffc2 --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.cpp @@ -0,0 +1,37 @@ +#include "MathematicaFunctionFactoryImp.h" + +#include "Utilities/MathematicaFile/MathematicaFile.h" + +#include "Utilities/MathematicaFunction/LinePlot/MathematicaListPlotImp.h" +#include "Utilities/MathematicaFunction/PointList/MathematicaPointListImp.h" +#include "Utilities/MathematicaFunction/ListOfLists/MathematicaListOfListsImp.h" + +std::shared_ptr<MathematicaFunctionFactory> MathematicaFunctionFactoryImp::getNewInstance() +{ + return std::shared_ptr<MathematicaFunctionFactory>(new MathematicaFunctionFactoryImp()); +} + +std::shared_ptr<MathematicaPointList> MathematicaFunctionFactoryImp::makeMathematicaPointList(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::shared_ptr<DataPoint>> plotData) +{ + std::shared_ptr<MathematicaPointList> mathPointList = MathematicaPointListImp::getNewInstance(listName, plotData); + file->addMathematicaFunction(mathPointList); + return mathPointList; +} + +std::shared_ptr<MathematicaListPlot> MathematicaFunctionFactoryImp::makeMathematicaListPlot(std::shared_ptr<MathematicaFile> file, std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes) +{ + std::shared_ptr<MathematicaListPlot> listLinePlot = MathematicaListPlotImp::getNewInstance(pointList, plotType, xAxes, yAxes); + file->addMathematicaFunction(listLinePlot); + return listLinePlot; +} + +std::shared_ptr<MathematicaListOfLists> MathematicaFunctionFactoryImp::makeMathematicaListOfLists(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::vector<double>> listOfLists) +{ + std::shared_ptr<MathematicaListOfLists> listOfList = MathematicaListOfListsImp::getNewInstance(listName, listOfLists); + file->addMathematicaFunction(listOfList); + return listOfList; +} + +MathematicaFunctionFactoryImp::MathematicaFunctionFactoryImp() +{ +} diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.h b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.h new file mode 100644 index 0000000000000000000000000000000000000000..741d302d08333765ec57ab52a5cae86eb912851c --- /dev/null +++ b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.h @@ -0,0 +1,19 @@ +#ifndef MATHEMATICA_FUNCTION_FACTORY_IMP_H +#define MATHEMATICA_FUNCTION_FACTORY_IMP_H + +#include "MathematicaFunctionFactory.h" + +class MathematicaFunctionFactoryImp : public MathematicaFunctionFactory +{ +public: + static std::shared_ptr<MathematicaFunctionFactory> getNewInstance(); + + std::shared_ptr<MathematicaPointList> makeMathematicaPointList(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::shared_ptr<DataPoint> > plotData); + std::shared_ptr<MathematicaListPlot> makeMathematicaListPlot(std::shared_ptr<MathematicaFile> file, std::vector<std::shared_ptr<MathematicaPointList>> pointList, std::string plotType, std::string xAxes, std::string yAxes); + std::shared_ptr<MathematicaListOfLists> makeMathematicaListOfLists(std::shared_ptr<MathematicaFile> file, std::string listName, std::vector<std::vector<double>> listOfLists); + +private: + MathematicaFunctionFactoryImp(); + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/package.include b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunctionFactory/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp deleted file mode 100644 index 0df6c36e8c53fdcce7045cc7ef112ffc0c8f2649..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#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 deleted file mode 100644 index ff4002e2bcdbba3f115bd857a5812a98eff45c80..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/ListLinePlot/MathematicaListLinePlot.h +++ /dev/null @@ -1,21 +0,0 @@ -#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/PointList/MathematicaPointList.cpp b/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp deleted file mode 100644 index c9c9a3d4d7b12c5103bcb1c97cd6e3fbb4fe42a2..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#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 deleted file mode 100644 index 2c2a46a07ab532568ce89bbfe8399753697f5b11..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTestPostProcessing/Utilities/MathematicaFunktion/PointList/MathematicaPointList.h +++ /dev/null @@ -1,25 +0,0 @@ -#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/main.cpp b/targets/tests/NumericalTestPostProcessing/main.cpp index ac5d87fad88028eae115137148b9d6688d3576b7..3122355776a3c973ca6bc797376afc630a810011 100644 --- a/targets/tests/NumericalTestPostProcessing/main.cpp +++ b/targets/tests/NumericalTestPostProcessing/main.cpp @@ -1,162 +1,50 @@ -#include "Utilities\LogFileData\LogFileData.h" -#include "Utilities\LogFileReader\LogFileReader.h" +#include "Simulation/BasicSimulation.h" + +#include "Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.h" +#include "Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.h" + +#include "Utilities/LogFileData/LogFileData.h" +#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h" +#include "Utilities/LogFileReader/LogFileReader.h" +#include "Utilities/LogFileDataAssistant/LogFileDataAssistantImp.h" +#include "Utilities/MathematicaFile/MathematicaFile.h" +#include "Utilities/MathematicaFunctionFactory/MathematicaFunctionFactoryImp.h" -#include <mpi.h> #include <memory> -#include <gmock/gmock.h> +#include <cfloat> #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) { + BasicSimulation simulation = ShearWave; + //BasicSimulation simulation = TaylorGreenVortexUx; + //BasicSimulation simulation = TaylorGreenVortexUz; + std::shared_ptr<LogFileReader> logFileReader = LogFileReader::getInstance(); + //std::shared_ptr<LogFileData> logFileData = logFileReader->readLogFileToLogFileData("C:/Users/Timon/Documents/studienarbeitIRMB/logFiles/NumericalTestLogFiles/TaylorGreenVortexUx/viscosity_0.001/ux_ 0.016_Amplitude_ 0.005/CumulantAA2016CompSP27/logfile_20190211_153133_CumulantAA2016CompSP27_vis_0.001.txt"); + std::vector<std::shared_ptr<LogFileData> > logFileDataVector = logFileReader->readLogFilesInDirectoryToLogFileData("C:/Users/Timon/Desktop/logFiles"); - 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"); + std::shared_ptr<LogFileDataAssistant> assistent = LogFileDataAssistantImp::getNewInstance(); + std::vector<std::shared_ptr<LogFileDataGroup> > logFileDataSorted = assistent->findEqualSimulationsForDifferentKernels(logFileDataVector, simulation); + //std::vector<std::vector<std::shared_ptr<LogFileData> > > logFileDataSorted = assistent->findEqualKernelSimulationsForDifferentViscosities(logFileDataVector, simulation); - + std::shared_ptr<MathematicaFile> aMathmaticaFile = MathematicaFile::getNewInstance("C:/Users/Timon/Desktop"); + std::shared_ptr<MathematicaFunctionFactory> functionFactory = MathematicaFunctionFactoryImp::getNewInstance(); - //variante1(); - variante2(); + std::shared_ptr<PhiMathematicaAssistant> mathematicaAssistantPhi = PhiMathematicaAssistant::getNewInstance(functionFactory); + std::shared_ptr<NyMathematicaAssistant> mathematicaAssistantNy = NyMathematicaAssistant::getNewInstance(functionFactory); + for (int i = 0; i < logFileDataSorted.size(); i++) { + mathematicaAssistantPhi->makeMathematicaOutput(logFileDataSorted.at(i), aMathmaticaFile); + mathematicaAssistantNy->makeMathematicaOutput(logFileDataSorted.at(i), aMathmaticaFile); + } + + aMathmaticaFile->finishFile(); return 0; } diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.cpp deleted file mode 100644 index d2c14f6f60cf9ebd126ed5b9f05856f4817d4071..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "PhiAndNyLogFileInformation.h" - -#include "Tests/PhiAndNyTest/PhiAndNyTest.h" -#include "Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h" - -#include <iomanip> -#include <sstream> - - -std::shared_ptr<PhiAndNyInformation> PhiAndNyInformation::getNewInstance(std::shared_ptr<PhiAndNyTestParameterStruct> testPara) -{ - return std::shared_ptr<PhiAndNyInformation>(new PhiAndNyInformation(testPara)); -} - -std::string PhiAndNyInformation::getOutput() -{ - std::ostringstream headName; - headName << testGroups.at(0).at(0)->getSimulationName() <<" Phi And Ny Test"; - makeCenterHead(headName.str()); - - oss << "StartTimeStepCalculation=" << startTimeStepCalculation << std::endl; - oss << "EndTimeStepCalculation=" << endTimeStepCalculation << std::endl; - oss << "DataToCalc_PhiAndNyTest=\""; - for (int i = 0; i < testGroups.size(); i++) { - oss << testGroups.at(i).at(0)->getDataToCalculate(); - if (i < testGroups.size() - 1) - oss << " "; - else - oss << "\"" << std::endl; - } - oss << std::endl; - - for (int i = 0; i < testGroups.size(); i++) { - fillMyData(testGroups.at(i)); - for (int j = 0; j < ny.size(); j++) - oss << "Ny_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << ny.at(j) << std::endl; - oss << std::endl; - for (int j = 0; j < nyDiff.size(); j++) - oss << "NyDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << nyDiff.at(j) << std::endl; - oss << std::endl; - for (int j = 0; j < orderOfAccuracyNyDiff.size(); j++) - oss << "OrderOfAccuracy_NyDiff_" << lx.at(2*j) << "_" << lx.at(2*j+1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracyNyDiff.at(j) << std::endl; - oss << std::endl; - for (int j = 0; j < phiDiff.size(); j++) - oss << "PhiDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << phiDiff.at(j) << std::endl; - oss << std::endl; - for (int j = 0; j < orderOfAccuracyPhiDiff.size(); j++) - oss << "OrderOfAccuracy_PhiDiff_" << lx.at(2*j) << "_" << lx.at(2*j+1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracyPhiDiff.at(j) << std::endl; - oss << std::endl; - } - - return oss.str(); -} - -void PhiAndNyInformation::addTestGroup(std::vector<std::shared_ptr<PhiAndNyTest> > tests) -{ - testGroups.push_back(tests); -} - -void PhiAndNyInformation::fillMyData(std::vector<std::shared_ptr<PhiAndNyTest> > testGroup) -{ - lxForErase.resize(0); - lx.resize(0); - ny.resize(0); - nyDiff.resize(0); - phiDiff.resize(0); - orderOfAccuracyNyDiff.resize(0); - orderOfAccuracyPhiDiff.resize(0); - dataToCalc.resize(0); - for (int i = 0; i < testGroup.size(); i++) { - std::vector<int> myLx = testGroup.at(i)->getLx(); - std::vector<double> myNy = testGroup.at(i)->getNy(); - std::vector<double> myNyDiff = testGroup.at(i)->getNyDiff(); - std::vector<double> myPhiDiff = testGroup.at(i)->getPhiDiff(); - - lx.insert(lx.end(), myLx.begin(), myLx.end()); - lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end()); - ny.insert(ny.end(), myNy.begin(), myNy.end()); - nyDiff.insert(nyDiff.end(), myNyDiff.begin(), myNyDiff.end()); - phiDiff.insert(phiDiff.end(), myPhiDiff.begin(), myPhiDiff.end()); - orderOfAccuracyNyDiff.push_back(testGroup.at(i)->getOrderOfAccuracyNyDiff()); - orderOfAccuracyPhiDiff.push_back(testGroup.at(i)->getOrderOfAccuracyPhiDiff()); - dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); - dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); - } - - for (int i = 0; i < lxForErase.size(); i++) - for (int j = i + 1; j < lxForErase.size(); j++) - if (lxForErase.at(i) == lxForErase.at(j)) - lxForErase.at(j) = -1; - - for (int i = lxForErase.size() - 1; i >= 0; i--) { - if (lxForErase.at(i) == -1) { - ny.erase(ny.begin() + i); - nyDiff.erase(nyDiff.begin() + i); - phiDiff.erase(phiDiff.begin() + i); - lxForErase.erase(lxForErase.begin() + i); - } - } - - -} - -PhiAndNyInformation::PhiAndNyInformation(std::shared_ptr<PhiAndNyTestParameterStruct> testPara) -{ - startTimeStepCalculation = testPara->startTimeStepCalculation; - endTimeStepCalculation = testPara->endTimeStepCalculation; -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.h b/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.h deleted file mode 100644 index c5bf8f3ef6dbcfc0b8dc712281c9c7b1543d0ec9..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef PHIANDNY_LOGFILE_INFORMATION_H -#define PHIANDNY_LOGFILE_INFORMATION_H - -#include "Utilities/LogFileInformation/TestLogFileInformation/TestLogFileInformation.h" - -#include <memory> -#include <vector> - -class PhiAndNyTest; -struct PhiAndNyTestParameterStruct; - -class PhiAndNyInformation : public TestLogFileInformation -{ -public: - static std::shared_ptr<PhiAndNyInformation> getNewInstance(std::shared_ptr<PhiAndNyTestParameterStruct> testPara); - - std::string getOutput(); - void addTestGroup(std::vector<std::shared_ptr<PhiAndNyTest> > tests); - -private: - PhiAndNyInformation() {}; - PhiAndNyInformation(std::shared_ptr<PhiAndNyTestParameterStruct> testPara); - - void fillMyData(std::vector<std::shared_ptr<PhiAndNyTest> > testGroup); - - std::vector<std::vector<std::shared_ptr<PhiAndNyTest> > > testGroups; - unsigned int startTimeStepCalculation, endTimeStepCalculation; - std::vector<int> lx; - std::vector<int> lxForErase; - std::vector<double> phiDiff; - std::vector<double> ny, nyDiff; - std::vector<double> orderOfAccuracyPhiDiff; - std::vector<double> orderOfAccuracyNyDiff; - std::vector<std::string> dataToCalc; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.cpp deleted file mode 100644 index 55783982bb9cd7cac4665a026265c47a4a53078d..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "PostProcessingStrategyPhiAndNyTest.h" - -#include "Utilities/Results/AnalyticalResults/AnalyticalResult.h" -#include "Utilities/Calculator/FFTCalculator/FFTCalculator.h" -#include "Utilities/Results/SimulationResults/SimulationResults.h" - -#include "Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h" - -std::shared_ptr<PhiAndNyTestPostProcessingStrategy> PhiAndNyTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNyTestParameterStruct> testPara) -{ - return std::shared_ptr<PhiAndNyTestPostProcessingStrategy>(new PhiAndNyTestPostProcessingStrategy(simResult, analyticalResult, testPara)); -} - -PhiAndNyTestPostProcessingStrategy::PhiAndNyTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNyTestParameterStruct> testPara) - : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) -{ - dataToCalculatePhiAndNy = testPara->basicTestParameter->dataToCalc; - startTimeStepCalculationPhiNy = testPara->startTimeStepCalculation; - endTimeStepCalculationPhiNy = testPara->endTimeStepCalculation; - - isEvaluated = false; - fftCalculator = FFTCalculator::getNewInstance(simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); -} - -std::vector<std::vector<double> > PhiAndNyTestPostProcessingStrategy::reduceDataToTimeSteps(std::vector<std::vector<double> > data, unsigned int startTimeStep, unsigned int endTimeStep) -{ - std::vector<int> timeStepsToDelete; - - for (int i = simResult->getTimeSteps().size() - 1; i >= 0; i--) { - if (simResult->getTimeSteps().at(i) > endTimeStep) - timeStepsToDelete.push_back(i); - if (simResult->getTimeSteps().at(i) < startTimeStep) - timeStepsToDelete.push_back(i); - } - - for (int i = 0; i < timeStepsToDelete.size(); i++) - data.erase(data.begin() + timeStepsToDelete.at(i)); - - return data; -} - -void PhiAndNyTestPostProcessingStrategy::evaluate() -{ - if (!isEvaluated) { - analyticalResult->calc(simResult); - for (int i = 0; i < dataToCalculatePhiAndNy.size(); i++) { - if (dataToCalculatePhiAndNy.at(i) == "Vx") { - fftCalculator->calc(reduceDataToTimeSteps(simResult->getVx(), startTimeStepCalculationPhiNy, endTimeStepCalculationPhiNy), false); - nyVx = fftCalculator->getNy(); - phiDiffVx = fftCalculator->getPhiDiff(); - } - if (dataToCalculatePhiAndNy.at(i) == "Vz") { - fftCalculator->calc(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculationPhiNy, endTimeStepCalculationPhiNy), true); - nyVz = fftCalculator->getNy(); - phiDiffVz = fftCalculator->getPhiDiff(); - } - } - } -} - -double PhiAndNyTestPostProcessingStrategy::getNyVx() -{ - return nyVx; -} - -double PhiAndNyTestPostProcessingStrategy::getNyVy() -{ - return nyVy; -} - -double PhiAndNyTestPostProcessingStrategy::getNyVz() -{ - return nyVz; -} - -double PhiAndNyTestPostProcessingStrategy::getPhiDiffVx() -{ - return phiDiffVx; -} - -double PhiAndNyTestPostProcessingStrategy::getPhiDiffVy() -{ - return phiDiffVy; -} - -double PhiAndNyTestPostProcessingStrategy::getPhiDiffVz() -{ - return phiDiffVz; -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.h b/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.h deleted file mode 100644 index f5da08b082e80ac16e7b18773630f88e2906413f..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef PHIANDNY_TEST_POST_PROCESSING_STRATEGY_H -#define PHIANDNY_TEST_POST_PROCESSING_STRATEGY_H - -#include "Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h" - -#include <memory> - -class AnalyticalResults; -class FFTCalculator; -struct PhiAndNyTestParameterStruct; - -class PhiAndNyTestPostProcessingStrategy : public PostProcessingStrategyImp -{ -public: - static std::shared_ptr<PhiAndNyTestPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNyTestParameterStruct> testPara); - void evaluate(); - - double getNyVx(); - double getNyVy(); - double getNyVz(); - double getPhiDiffVx(); - double getPhiDiffVy(); - double getPhiDiffVz(); - -private: - PhiAndNyTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiAndNyTestParameterStruct> testPara); - - std::vector<std::vector<double> > reduceDataToTimeSteps(std::vector<std::vector<double> > data, unsigned int startTimeStep, unsigned int endTimeStep); - - std::shared_ptr<AnalyticalResults> analyticalResult; - std::vector<std::string> dataToCalculatePhiAndNy; - std::shared_ptr<FFTCalculator> fftCalculator; - unsigned int startTimeStepCalculationPhiNy; - unsigned int endTimeStepCalculationPhiNy; - double nyVx, nyVy, nyVz; - double phiDiffVx, phiDiffVy, phiDiffVz; - bool isEvaluated; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.cpp deleted file mode 100644 index 0461e270c1c3ccc43a43a5b430db7e6e3d54466f..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "L2NormCalculatorFactory.h" - -#include "Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h" -#include "Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h" - -std::shared_ptr<L2NormCalculatorFactory> L2NormCalculatorFactory::getInstance() -{ - static std::shared_ptr<L2NormCalculatorFactory> uniqueInstance; - if (!uniqueInstance) - uniqueInstance = std::shared_ptr<L2NormCalculatorFactory>(new L2NormCalculatorFactory()); - return uniqueInstance; -} - -std::shared_ptr<L2NormCalculator> L2NormCalculatorFactory::makeL2NormCalculator(std::string type) -{ - if(type == "amplitude") - return L2CalculatorNormalizeWithAmplitude::getInstance(); - if (type == "basicData") - return L2CalculatorNormalizeWithBasicData::getInstance(); -} - -L2NormCalculatorFactory::L2NormCalculatorFactory() -{ -}