diff --git a/CMakeMacros/MathLink/Link.cmake b/CMakeMacros/MathLink/Link.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f13c060d69034dc1201f1c1254830028a1b5b1c1 --- /dev/null +++ b/CMakeMacros/MathLink/Link.cmake @@ -0,0 +1,7 @@ + +macro(linkMathLink targetName) + + include_directories(${MATHLINK_ROOT}) + target_link_libraries(${targetName} wstp64i4m) + +endmacro(linkMathLink) \ No newline at end of file diff --git a/targets/tests/NumericalTests/3rdPartyLinking.cmake b/targets/tests/NumericalTests/3rdPartyLinking.cmake index aeb913268f65525565f6c6a8838a20699dd301f9..1f956bbf2f4b0e77c5117056a776a8926d1e8020 100644 --- a/targets/tests/NumericalTests/3rdPartyLinking.cmake +++ b/targets/tests/NumericalTests/3rdPartyLinking.cmake @@ -7,4 +7,6 @@ linkMPI(${targetName}) include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/fftw/Link.cmake) linkFftw(${targetName}) include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Boost/Link.cmake) -linkBoost(${targetName} "") \ No newline at end of file +linkBoost(${targetName} "") +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MathLink/Link.cmake) +linkMathLink(${targetName}) \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp b/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp deleted file mode 100644 index 0ff2b2c0decc29eeacafdc52baddd3e6d4b1947a..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ShearWaveAnalyticalResults.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -std::shared_ptr<AnalyticalResults> ShearWaveAnalyticalResults::getNewInstance(double viscosity, double u0, double v0, double l0, double rho0) -{ - return std::shared_ptr<AnalyticalResults>(new ShearWaveAnalyticalResults(viscosity, u0, v0, l0, rho0)); -} - -void ShearWaveAnalyticalResults::calc(std::shared_ptr<SimulationResults> simResults) -{ - AnalyticalResults::init(simResults); - - for (int i = 0; i < numberOfTimeSteps; i++) { - for (int j = 0; j < numberOfNodes; j++) { - vx.at(i).at(j) = (l0*u0) / xNodes; - vy.at(i).at(j) = (double)0.0; - vz.at(i).at(j) = (l0*v0*cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) * sin(((double)2.0 * M_PI*(x.at(i).at(j) + (l0*timeStep.at(i)*u0) / xNodes)) / xNodes)) / (exp(timeStep.at(i)*viscosity*(((double)4.0 * M_PI*M_PI) / xNodes*xNodes + ((double)4.0 * M_PI*M_PI) / zNodes*zNodes))*xNodes); - press.at(i).at(j) = (double)0.0; - rho.at(i).at(j) = (l0*l0 * rho0*v0*sin(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) * ((double)-4.0 * exp(((double)4.0 * M_PI*M_PI * timeStep.at(i)*viscosity*(xNodes*xNodes + zNodes*zNodes)) / (xNodes*xNodes * zNodes*zNodes))*u0*zNodes*cos(((double)2.0 * M_PI*(l0*timeStep.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes)) + v0*xNodes*sin(((double)2.0 * M_PI*(l0*timeStep.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes))*sin(((double)2.0 * M_PI*(l0*timeStep.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes)) * sin((2 * M_PI*z.at(i).at(j)) / zNodes))) / ((double)2.0 * exp(((double)8.0 * M_PI*M_PI * timeStep.at(i)*viscosity*(xNodes*xNodes + zNodes*zNodes)) / (xNodes*xNodes * zNodes*zNodes))*xNodes*xNodes*xNodes); - } - } -} - -ShearWaveAnalyticalResults::ShearWaveAnalyticalResults(double viscosity, double u0, double v0, double l0, double rho0) : viscosity(viscosity), u0(u0), v0(v0), l0(l0), rho0(rho0) -{ - -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.cpp b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.cpp deleted file mode 100644 index 9f8e7066556d6954715bf4c523d253c48faba78c..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "TaylorGreenVortexAnalyticalResults.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -std::shared_ptr<AnalyticalResults> TaylorGreenAnalyticalResults::getNewInstance(double viscosity, double u0, double amplitude, double l0, double rho0) -{ - return std::shared_ptr<AnalyticalResults>(new TaylorGreenAnalyticalResults(viscosity, u0, amplitude, l0, rho0)); -} - -void TaylorGreenAnalyticalResults::calc(std::shared_ptr< SimulationResults> simResults) -{ - AnalyticalResults::init(simResults); - - for (int i = 0; i < numberOfTimeSteps; i++) { - for (int j = 0; j < numberOfNodes; j++) { - vx.at(i).at(j) = (l0*u0) / xNodes + (amplitude * exp(timeStep.at(i)*viscosity*(((double)-4.0 * M_PI*M_PI) / (xNodes*xNodes) - ((double)4.0 * M_PI *M_PI) / (zNodes*zNodes)))*l0*cos(((double)2.0 * M_PI * z.at(i).at(j)) / zNodes) * sin(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes)) / xNodes; - vy.at(i).at(j) = (double)0.0; - vz.at(i).at(j) = -((amplitude*exp(timeStep.at(i)*viscosity*(((double)-4.0 * M_PI*M_PI) / (xNodes*xNodes) - ((double)4.0 * M_PI*M_PI) / (zNodes*zNodes)))*l0*zNodes*cos(((double)2 * M_PI*x.at(i).at(j)) / xNodes) * sin((2 * M_PI*z.at(i).at(j)) / zNodes)) / (xNodes*xNodes)); - press.at(i).at(j) = (double)0.0; - rho.at(i).at(j) = (amplitude*l0*l0 * rho0*(amplitude * zNodes*zNodes * cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes)*cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) - (double)2.0 * exp(((double)4.0 * M_PI*M_PI * timeStep.at(i)*(xNodes*xNodes + zNodes*zNodes)*viscosity) / (xNodes*xNodes * zNodes*zNodes))*u0*(xNodes*xNodes - zNodes*zNodes)*cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) * sin(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes) - amplitude*xNodes*xNodes * sin(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes))) / ((double)2.0 * exp(((double)8.0 * M_PI*M_PI * timeStep.at(i)*(xNodes*xNodes + zNodes*zNodes)*viscosity) / (xNodes*xNodes * zNodes*zNodes))*xNodes*xNodes*xNodes*xNodes); - } - } -} - -TaylorGreenAnalyticalResults::TaylorGreenAnalyticalResults(double viscosity, double u0, double amplitude, double l0, double rho0) : viscosity(viscosity), u0(u0), amplitude(amplitude), l0(l0), rho0(rho0) -{ - -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.h b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.h deleted file mode 100644 index 8365673fc96e7799598157ac6c9ddcc40e505e78..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/TaylorGreenVortexAnalyticalResults.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef TAYLORGREENVORTEX_ANALYTICAL_RESULTS_H -#define TAYLORGREENVORTEX_ANALYTICAL_RESULTS_H - -#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" - -class TaylorGreenAnalyticalResults : public AnalyticalResults -{ -public: - static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double u0, double amplitude, double l0, double rho0); - void calc(std::shared_ptr< SimulationResults> simResults); - - -private: - TaylorGreenAnalyticalResults() {}; - TaylorGreenAnalyticalResults(double viscosity, double u0, double amplitude, double l0, double rho0); - - double viscosity, rho0; - double l0; - double u0, amplitude; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.cpp b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.cpp deleted file mode 100644 index f2ab209a8c9ed6f2ca3db885d9534842b4d674df..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "InitialconditionTaylorGreenVortex.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -InitialConditionTaylorGreen::InitialConditionTaylorGreen(real lx, real lz, real l0, real u0, real amplitude, real rho0) -{ - this->Amp = amplitude; - this->L0 = l0; - this->Lx = lx; - this->Lz = lz; - this->rho = rho0; - this->u0 = u0; -} - -std::shared_ptr<InitialConditionTaylorGreen> InitialConditionTaylorGreen::getNewInstance(real lx, real lz, real l0, real u0, real amplitude, real rho0) -{ - return std::shared_ptr<InitialConditionTaylorGreen>(new InitialConditionTaylorGreen(lx, lz, l0, u0, amplitude, rho0)); -} - -real InitialConditionTaylorGreen::getInitVX(int i, int level) -{ - real x = getXCoord(i, level); - real y = getYCoord(i, level); - real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) - { - real vx = (u0* L0 / Lx + (Amp * L0 * cos((real)2.0 * M_PI * z / Lz) * sin((real)2.0 * M_PI * x / Lx) / Lx)); - return vx; - } - else - return (real)0.0; - -} - -real InitialConditionTaylorGreen::getInitVY(int i, int level) -{ - return (real) 0.0; -} - -real InitialConditionTaylorGreen::getInitVZ(int i, int level) -{ - real x = getXCoord(i, level); - real y = getYCoord(i, level); - real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) - { - real vz = (-Amp * L0 * Lz * cos((real)2.0 * M_PI * x / Lx) * sin((real)2.0 * M_PI * z / Lz) / (Lx*Lx)); - return vz; - } - else - return (real) 0.0; -} - -real InitialConditionTaylorGreen::getInitROH(int i, int level) -{ - real x = getXCoord(i, level); - real y = getYCoord(i, level); - real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) - { - real press = (Amp*Amp * L0*L0 * rho * ((Lx*Lx * cos((real)4.0 * M_PI * x / Lx)) + (Lz*Lz * cos((real)4.0 * M_PI * z / Lz))) / ((real)4.0 * Lx*Lx*Lx*Lx)); - return press; - } - else - return (real) 0.0; -} - -real InitialConditionTaylorGreen::getInitPRESS(int i, int level) -{ - //nicht benötigt, da Druck aus Dichte berechnet wird - return (real) 0.0; -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.h b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.h deleted file mode 100644 index 19f0aa1792e67d93ee9a12d700a4e8ac135bd7bf..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef INITIAL_CONDITION_TAYLOR_GREEN_VORTEX_H -#define INITIAL_CONDITION_TAYLOR_GREEN_VORTEX_H - -#include "Utilities/InitialCondition/InitialConditionImp.h" - -#include <memory> - -class InitialConditionTaylorGreen :public InitialConditionImp -{ -public: - static std::shared_ptr< InitialConditionTaylorGreen> getNewInstance(real lx, real lz, real l0, real u0, real amplitude, real rho0); - - real getInitVX(int i, int level); - real getInitVY(int i, int level); - real getInitVZ(int i, int level); - real getInitROH(int i, int level); - real getInitPRESS(int i, int level); - -private: - InitialConditionTaylorGreen(real lx, real lz, real l0, real u0, real amplitude, real rho0); - InitialConditionTaylorGreen() {}; - - real Amp; - real rho; - real L0; - real Lx, Lz; - real u0; -}; - -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.cpp b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.cpp deleted file mode 100644 index c5704afae9963ac4e5116258ca4633a8ba975598..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "TaylorGreenLogFileInformation.h" - -std::shared_ptr<TaylorGreenInformation> TaylorGreenInformation::getNewInstance(double u0, double amplitude, std::vector< bool> tests, std::vector<double> l, int l0) -{ - return std::shared_ptr<TaylorGreenInformation>(new TaylorGreenInformation(u0, amplitude, tests, l, l0)); -} - -std::string TaylorGreenInformation::getOutput() -{ - makeCenterHead("TaylorGreenVortex Information"); - for (int i = 0; i < tests.size(); i++) { - if (tests.at(i)) { - oss << "Lx:" << l.at(i) << std::endl; - oss << "u0: " << u0 / (l.at(i) / l0) << std::endl; - oss << "Amplitude: " << amplitude / (l.at(i) / l0) << std::endl; - oss << std::endl; - } - } - - return oss.str(); -} - -std::string TaylorGreenInformation::getFilePathExtension() -{ - std::ostringstream oss; - oss <<"TaylorGreenVortex\\u0_ " << u0 << "_Amplitude_ " << amplitude; - return oss.str(); -} - -TaylorGreenInformation::TaylorGreenInformation(double u0, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0) : u0(u0), amplitude(amplitude), tests(tests), l(l), l0(l0) -{ -} diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.h b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.h deleted file mode 100644 index 953f1a5f0d851e2fe602fcdb737d3822c57d6f41..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef TAYLOR_GREEN_INFORMATION_H -#define TAYLOR_GREEN_INFORMATION_H - -#include "Utilities/LogFileInformation/LogFileInformationImp.h" -#include "Utilities\LogFileInformation\SimulationLogFileInformation\SimulationLogFileInformation.h" - -#include <memory> -#include <vector> - -class TaylorGreenInformation : public LogFileInformationImp, public SimulationLogFileInformation -{ -public: - static std::shared_ptr<TaylorGreenInformation> getNewInstance(double u0, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); - - std::string getOutput(); - std::string getFilePathExtension(); - -private: - TaylorGreenInformation() {}; - TaylorGreenInformation(double u0, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); - - double u0; - double amplitude; - std::vector< bool> tests; - std::vector< double> l; - int l0; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.cpp b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.cpp deleted file mode 100644 index a657bfcc9b5c41eb22cdfb1b37bf32be82c36f5e..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "TaylorGreenVortexSimulationInfo.h" - -#include <sstream> - -std::shared_ptr<SimulationInfo> TaylorGreenVortexSimulationInfo::getNewInstance(double u0, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) -{ - return std::shared_ptr<SimulationInfo>(new TaylorGreenVortexSimulationInfo(u0, amplitude, l0, lx, viscosity, kernelName, numberOfSimulations)); -} - -TaylorGreenVortexSimulationInfo::TaylorGreenVortexSimulationInfo(double u0, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lx, viscosity, kernelName, numberOfSimulations) -{ - std::ostringstream oss; - oss << " u0: " << u0 / (lx / l0) << " Amplitude: " << amplitude / (lx / l0); - this->simulationParameterString = oss.str(); - - simulationName = "TaylorGreenVortex"; -} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.h b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.h deleted file mode 100644 index bfc4953e41aa903308c2714adea73a471f96cd98..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/TaylorGreenVortexSimulationInfo.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TAYLORGREENVORTEX_SIMULATION_INFO_H -#define TAYLORGREENVORTEX_SIMULATION_INFO_H - -#include "Utilities\SimulationInfo\SimulationInfoImp.h" - -#include <memory> - -class TaylorGreenVortexSimulationInfo : public SimulationInfoImp -{ -public: - static std::shared_ptr< SimulationInfo> getNewInstance(double u0, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); - -private: - TaylorGreenVortexSimulationInfo() {}; - TaylorGreenVortexSimulationInfo(double u0, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); - -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.cpp b/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.cpp deleted file mode 100644 index b8897ae206045e59862086f0fc8e7f37a9b2fe71..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "TaylorGreenSimulationParameter.h" - -#include "Simulation/TaylorGreenVortex/InitialConditions/InitialConditionTaylorGreenVortex.h" -#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" - -#include <sstream> - -std::shared_ptr<SimulationParameter> TaylorGreenSimulationParameter::getNewInstance(std::string kernelName, real u0, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -{ - return std::shared_ptr<SimulationParameter>(new TaylorGreenSimulationParameter(kernelName, u0, amplitude, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, filePath, devices)); -} - -double TaylorGreenSimulationParameter::getMaxVelocity() -{ - return u0 / (lx / l0); -} - -TaylorGreenSimulationParameter::TaylorGreenSimulationParameter(std::string kernelName, real u0, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -:SimulationParameterImp("TaylorGreenVortex", viscosity, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), u0(u0), amplitude(amplitude), rho0(rho0) -{ - std::ostringstream oss; - oss << filePath << "\\" << kernelName << "\\TaylorGreenVortex\\" << viscosity << "\\u0_" << u0 << "_amplitude_" << amplitude << "\\grid" << lx; - generateFilePath(oss.str()); - this->filePath = oss.str(); - - initialCondition = InitialConditionTaylorGreen::getNewInstance(lx, lz, l0, u0, amplitude, rho0); - kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); -} diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b3f6bfdd3c58743c8a9866cc26dce8416d86d7c3 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp @@ -0,0 +1,30 @@ +#include "ShearWaveAnalyticalResults.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +std::shared_ptr<AnalyticalResults> ShearWaveAnalyticalResults::getNewInstance(double viscosity, double u0, double v0, double l0, double rho0) +{ + return std::shared_ptr<AnalyticalResults>(new ShearWaveAnalyticalResults(viscosity, u0, v0, l0, rho0)); +} + +void ShearWaveAnalyticalResults::calc(std::shared_ptr<SimulationResults> simResults) +{ + AnalyticalResultsImp::init(simResults); + + for (int i = 0; i < numberOfTimeSteps; i++) { + for (int j = 0; j < numberOfNodes; j++) { + vx.at(i).at(j) = (l0*u0) / xNodes; + vy.at(i).at(j) = (double)0.0; + vz.at(i).at(j) = (l0*v0*cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) * sin(((double)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*u0) / xNodes)) / xNodes)) / (exp(time.at(i)*viscosity*(((double)4.0 * M_PI*M_PI) / xNodes*xNodes + ((double)4.0 * M_PI*M_PI) / zNodes*zNodes))*xNodes); + press.at(i).at(j) = (double)0.0; + rho.at(i).at(j) = (l0*l0 * rho0*v0*sin(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes) * ((double)-4.0 * exp(((double)4.0 * M_PI*M_PI * time.at(i)*viscosity*(xNodes*xNodes + zNodes*zNodes)) / (xNodes*xNodes * zNodes*zNodes))*u0*zNodes*cos(((double)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes)) + v0*xNodes*sin(((double)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes))*sin(((double)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / (xNodes*xNodes)) * sin((2 * M_PI*z.at(i).at(j)) / zNodes))) / ((double)2.0 * exp(((double)8.0 * M_PI*M_PI * time.at(i)*viscosity*(xNodes*xNodes + zNodes*zNodes)) / (xNodes*xNodes * zNodes*zNodes))*xNodes*xNodes*xNodes); + } + } + calculated = true; +} + +ShearWaveAnalyticalResults::ShearWaveAnalyticalResults(double viscosity, double u0, double v0, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), u0(u0), v0(v0), l0(l0), rho0(rho0) +{ + +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h similarity index 78% rename from targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h rename to targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h index 3f40ba68700087b692efd5f278cdc556756e91e1..610c74a2aa8b4103c39a40ecbcac05ec639982b5 100644 --- a/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h @@ -1,15 +1,14 @@ #ifndef SHEARWAVE_ANALYTICAL_RESULTS_H #define SHEARWAVE_ANALYTICAL_RESULTS_H -#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" +#include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" -class ShearWaveAnalyticalResults : public AnalyticalResults +class ShearWaveAnalyticalResults : public AnalyticalResultsImp { public: static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double u0, double v0, double l0, double rho0); void calc(std::shared_ptr< SimulationResults> simResults); - private: ShearWaveAnalyticalResults() {}; ShearWaveAnalyticalResults(double viscosity, double u0, double v0, double l0, double rho0); diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/AnalyticalResults/package.include rename to targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/package.include diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/InitialConditionShearWave.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp similarity index 86% rename from targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/InitialConditionShearWave.cpp rename to targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp index c5aba1c083b9cd2620a0a22c01a85b21bd20148a..7adbca0f942e68dae5e9609c6b13fb0a6b90a242 100644 --- a/targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/InitialConditionShearWave.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp @@ -24,7 +24,7 @@ real InitialConditionShearWave::getInitVX(int i, int level) real x = getXCoord(i, level); real y = getYCoord(i, level); real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) { real vx = l0 * u0 / lx; return vx; @@ -44,7 +44,7 @@ real InitialConditionShearWave::getInitVZ(int i, int level) real x = getXCoord(i, level); real y = getYCoord(i, level); real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) { real vz = v0 * l0 / lx * cos((real)2.0 * M_PI * z /lz) * sin((real)2.0 * M_PI * x / lx); return vz; @@ -58,7 +58,7 @@ real InitialConditionShearWave::getInitROH(int i, int level) real x = getXCoord(i, level); real y = getYCoord(i, level); real z = getZCoord(i, level); - if ((i != 0) && (x != XCoordstopnode) && (y != YCoordstopnode) && (z != ZCoordstopnode)) + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) { real press = (l0*l0 * v0 * rho * sin(((real)2.0 * M_PI * z) / lz) * ((real)-4.0 * lz * u0 * cos((2 * M_PI * x) / lx) + lx * v0 * sin(((real)2.0 * M_PI * x) / lx)*sin(((real)2.0 * M_PI * x) / lx) * sin(((real)2.0 * M_PI * z) / lz))) / ((real)2.0 * lx*lx*lx); return press; diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/InitialConditionShearWave.h b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.h similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/InitialConditionShearWave.h rename to targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.h diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/InitialConditions/package.include rename to targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/package.include diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp similarity index 63% rename from targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp rename to targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp index 9e65a223cafc41cb3fdd869ac99b864078051b9c..16c9a7a36446c97d983fe35e6b9557933846e3fd 100644 --- a/targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.cpp @@ -10,19 +10,27 @@ std::string ShearWaveInformation::getOutput() makeCenterHead("ShearWave Information"); for (int i = 0; i < tests.size(); i++) { if (tests.at(i)) { - oss << "Lx:" << l.at(i) << std::endl; - oss << "u0: " << u0 / (l.at(i) / l0) << std::endl; - oss << "v0: " << v0 / (l.at(i) / l0) << std::endl; + oss << "Lx=" << l.at(i) << std::endl; + oss << "l0=" << l0 << std::endl; + oss << "u0=" << u0 / (l.at(i) / l0) << std::endl; + oss << "v0=" << v0 / (l.at(i) / l0) << std::endl; oss << std::endl; } } return oss.str(); } -std::string ShearWaveInformation::getFilePathExtension() +std::string ShearWaveInformation::getFilePathExtensionOne() { std::ostringstream oss; - oss << "ShearWave\\u0_" << u0 << "_v0_" << v0; + oss << "ShearWave\\"; + return oss.str(); +} + +std::string ShearWaveInformation::getFilePathExtensionTwo() +{ + std::ostringstream oss; + oss << "u0_" << u0 << "_v0_" << v0 << "\\"; return oss.str(); } diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h similarity index 90% rename from targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h rename to targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h index ae34fee7017b5b86c23967f225318ae910175a9f..d9488c4d4dad56fa351796411ff527d66b3aefd2 100644 --- a/targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h @@ -15,7 +15,8 @@ public: static std::shared_ptr<ShearWaveInformation> getNewInstance(double u0, double v0, std::vector< bool> tests, std::vector< real> l, int l0); std::string getOutput(); - std::string getFilePathExtension(); + std::string getFilePathExtensionOne(); + std::string getFilePathExtensionTwo(); private: ShearWaveInformation() {}; diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/LogFileInformation/package.include rename to targets/tests/NumericalTests/Simulations/ShearWave/LogFileInformation/package.include diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.h diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationInfo/package.include rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/package.include diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp similarity index 83% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp index 5517752ce92f57a60ab434f2703b4f73fcf64325..1682c4b61f1a17563fe1b326631ef0a60e427e08 100644 --- a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.cpp @@ -22,10 +22,10 @@ double ShearWaveSimulationParameter::getMaxVelocity() } ShearWaveSimulationParameter::ShearWaveSimulationParameter(std::string kernelName, real u0, real v0, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) -:SimulationParameterImp("ShearWave", viscosity, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), u0(u0), v0(v0), rho0(rho0) +:SimulationParameterImp("ShearWave", viscosity, lx, lz, l0, lx, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), u0(u0), v0(v0), rho0(rho0) { std::ostringstream oss; - oss << filePath << "\\" << kernelName << "\\ShearWave\\" << viscosity << "\\u0_" << u0 << "_v0_" << v0 << "\\grid" << lx; + oss << filePath << "\\ShearWave\\viscosity" << viscosity << "\\u0_" << u0 << "_v0_" << v0 << "\\" << kernelName << "\\grid" << lx; generateFilePath(oss.str()); this->filePath = oss.str(); diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h diff --git a/targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/package.include b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/ShearWave/SimulationParameter/package.include rename to targets/tests/NumericalTests/Simulations/ShearWave/SimulationParameter/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..26727d9d3ca579e790f71af8ffde10a5e860d696 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp @@ -0,0 +1,30 @@ +#include "AnalyticalResultsTaylorGreenVortexUx.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUx::getNewInstance(double viscosity, double ux, double amplitude, double l0, double rho0) +{ + return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUx(viscosity, ux, amplitude, l0, rho0)); +} + +void AnalyticalResultsTaylorGreenUx::calc(std::shared_ptr< SimulationResults> simResults) +{ + AnalyticalResultsImp::init(simResults); + + for (int i = 0; i < numberOfTimeSteps; i++) { + for (int j = 0; j < numberOfNodes; j++) { + vx.at(i).at(j) = (l0*ux) / xNodes + (amplitude*exp(time.at(i)*viscosity*((-(double)4.0 * pow(M_PI, (double)2.0)) / pow(xNodes, (double)2.0) - ((double)4.0 * pow(M_PI, (double)2.0)) / pow(zNodes, (double)2.0)))*l0*cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((double)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*ux) / xNodes)) / xNodes)) / xNodes; + vy.at(i).at(j) = (double)0.0; + vz.at(i).at(j) = -((amplitude*exp(time.at(i)*viscosity*((-(double)4.0 * pow(M_PI, (double)2.0)) / pow(xNodes, (double)2.0) - ((double)4.0 * pow(M_PI, (double)2.0)) / pow(zNodes, (double)2.0)))*l0*zNodes*cos(((double)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*ux) / xNodes)) / xNodes)*sin(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes)) / pow(xNodes, (double)2.0)); + press.at(i).at(j) = (double)0.0; + rho.at(i).at(j) = (amplitude*pow(l0, (double)2.0)*rho0*(amplitude*pow(zNodes, (double)2.0)*pow(cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes), (double)2.0) - (double)4.0 * exp(((double)4.0 * pow(M_PI, (double)2.0)*time.at(i)*viscosity*(pow(xNodes, (double)2.0) + pow(zNodes, (double)2.0))) / (pow(xNodes, (double)2.0)*pow(zNodes, (double)2.0)))*ux*(pow(xNodes, (double)2.0) - pow(zNodes, (double)2.0)) * cos(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((double)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (double)2.0)) - amplitude*pow(xNodes, (double)2.0)*pow(sin(((double)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (double)2.0)), (double)2.0))) / ((double)2.0*exp((8 * pow(M_PI, (double)2.0)*time.at(i)*viscosity*(pow(xNodes, (double)2.0) + pow(zNodes, (double)2.0))) / (pow(xNodes, (double)2.0)*pow(zNodes, (double)2.0)))*pow(xNodes, (double)4.0)); + } + } + calculated = true; +} + +AnalyticalResultsTaylorGreenUx::AnalyticalResultsTaylorGreenUx(double viscosity, double ux, double amplitude, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), ux(ux), amplitude(amplitude), l0(l0), rho0(rho0) +{ + +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h new file mode 100644 index 0000000000000000000000000000000000000000..c59c84b66e4df516deceb5ca4d004d5ccaafb880 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.h @@ -0,0 +1,20 @@ +#ifndef ANALYTICAL_RESULTS_TAYLORGREENVORTEX_U0_H +#define ANALYTICAL_RESULTS_TAYLORGREENVORTEX_U0_H + +#include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" + +class AnalyticalResultsTaylorGreenUx : public AnalyticalResultsImp +{ +public: + static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double ux, double amplitude, double l0, double rho0); + void calc(std::shared_ptr< SimulationResults> simResults); + +private: + AnalyticalResultsTaylorGreenUx() {}; + AnalyticalResultsTaylorGreenUx(double viscosity, double ux, double amplitude, double l0, double rho0); + + double viscosity, rho0; + double l0; + double ux, amplitude; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/AnalyticalResults/package.include rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f6c5f3cd87eaad28f4306f33058cd856571f88e9 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp @@ -0,0 +1,73 @@ +#include "InitialConditionTaylorGreenVortexUx.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +InitialConditionTaylorGreenUx::InitialConditionTaylorGreenUx(real lx, real lz, real l0, real ux, real amplitude, real rho0) +{ + this->Amp = amplitude; + this->L0 = l0; + this->Lx = lx; + this->Lz = lz; + this->rho = rho0; + this->ux = ux; +} + +std::shared_ptr<InitialConditionTaylorGreenUx> InitialConditionTaylorGreenUx::getNewInstance(real lx, real lz, real l0, real ux, real amplitude, real rho0) +{ + return std::shared_ptr<InitialConditionTaylorGreenUx>(new InitialConditionTaylorGreenUx(lx, lz, l0, ux, amplitude, rho0)); +} + +real InitialConditionTaylorGreenUx::getInitVX(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real vx = (ux* L0 / Lx + (Amp * L0 * cos((real)2.0 * M_PI * z / Lz) * sin((real)2.0 * M_PI * x / Lx) / Lx)); + return vx; + } + else + return (real)0.0; + +} + +real InitialConditionTaylorGreenUx::getInitVY(int i, int level) +{ + return (real) 0.0; +} + +real InitialConditionTaylorGreenUx::getInitVZ(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real vz = (-Amp * L0 * Lz * cos((real)2.0 * M_PI * x / Lx) * sin((real)2.0 * M_PI * z / Lz) / (Lx*Lx)); + return vz; + } + else + return (real) 0.0; +} + +real InitialConditionTaylorGreenUx::getInitROH(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real press = (Amp*Amp * L0*L0 * rho * ((Lx*Lx * cos((real)4.0 * M_PI * x / Lx)) + (Lz*Lz * cos((real)4.0 * M_PI * z / Lz))) / ((real)4.0 * Lx*Lx*Lx*Lx)); + return press; + } + else + return (real) 0.0; +} + +real InitialConditionTaylorGreenUx::getInitPRESS(int i, int level) +{ + //nicht benötigt, da Druck aus Dichte berechnet wird + return (real) 0.0; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h new file mode 100644 index 0000000000000000000000000000000000000000..7d20de12e83fb72377dfcee6f776501253d15150 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h @@ -0,0 +1,30 @@ +#ifndef INITIAL_CONDITION_TAYLORGREENVORTEX_UX_H +#define INITIAL_CONDITION_TAYLORGREENVORTEX_UX_H + +#include "Utilities/InitialCondition/InitialConditionImp.h" + +#include <memory> + +class InitialConditionTaylorGreenUx :public InitialConditionImp +{ +public: + static std::shared_ptr< InitialConditionTaylorGreenUx> getNewInstance(real lx, real lz, real l0, real ux, real amplitude, real rho0); + + real getInitVX(int i, int level); + real getInitVY(int i, int level); + real getInitVZ(int i, int level); + real getInitROH(int i, int level); + real getInitPRESS(int i, int level); + +private: + InitialConditionTaylorGreenUx(real lx, real lz, real l0, real ux, real amplitude, real rho0); + InitialConditionTaylorGreenUx() {}; + + real Amp; + real rho; + real L0; + real Lx, Lz; + real ux; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/InitialConditions/package.include rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3f75326bb1ba2c1ace1a1b37294c14a1d158e1e0 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.cpp @@ -0,0 +1,40 @@ +#include "LogFileInformationTaylorGreenVortexUx.h" + +std::shared_ptr<LogFileInformationTaylorGreenUx> LogFileInformationTaylorGreenUx::getNewInstance(double ux, double amplitude, std::vector< bool> tests, std::vector<double> l, int l0) +{ + return std::shared_ptr<LogFileInformationTaylorGreenUx>(new LogFileInformationTaylorGreenUx(ux, amplitude, tests, l, l0)); +} + +std::string LogFileInformationTaylorGreenUx::getOutput() +{ + makeCenterHead("TaylorGreenVortex U0 Information"); + for (int i = 0; i < tests.size(); i++) { + if (tests.at(i)) { + oss << "Lx=" << l.at(i) << std::endl; + oss << "ux=" << ux / (l.at(i) / l0) << std::endl; + oss << "Amplitude= " << amplitude / (l.at(i) / l0) << std::endl; + oss << "l0=" << l0 << std::endl; + oss << std::endl; + } + } + + return oss.str(); +} + +std::string LogFileInformationTaylorGreenUx::getFilePathExtensionTwo() +{ + std::ostringstream oss; + oss << "ux_ " << ux << "_Amplitude_ " << amplitude << "\\"; + return oss.str(); +} + +std::string LogFileInformationTaylorGreenUx::getFilePathExtensionOne() +{ + std::ostringstream oss; + oss <<"TaylorGreenVortexUx\\"; + return oss.str(); +} + +LogFileInformationTaylorGreenUx::LogFileInformationTaylorGreenUx(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0) : ux(ux), amplitude(amplitude), tests(tests), l(l), l0(l0) +{ +} diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h new file mode 100644 index 0000000000000000000000000000000000000000..c4d1b63da565129a6e3c7b5d84f8035d461d386a --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h @@ -0,0 +1,29 @@ +#ifndef LOGFILE_INFORMATION_TAYLOR_GREEN_UX_H +#define LOGFILE_INFORMATION_TAYLOR_GREEN_UX_H + +#include "Utilities/LogFileInformation/LogFileInformationImp.h" +#include "Utilities\LogFileInformation\SimulationLogFileInformation\SimulationLogFileInformation.h" + +#include <memory> +#include <vector> + +class LogFileInformationTaylorGreenUx : public LogFileInformationImp, public SimulationLogFileInformation +{ +public: + static std::shared_ptr<LogFileInformationTaylorGreenUx> getNewInstance(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + + std::string getOutput(); + std::string getFilePathExtensionOne(); + std::string getFilePathExtensionTwo(); + +private: + LogFileInformationTaylorGreenUx() {}; + LogFileInformationTaylorGreenUx(double ux, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + + double ux; + double amplitude; + std::vector< bool> tests; + std::vector< double> l; + int l0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/LogFileInformation/package.include rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/LogFileInformation/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..681e43ca733e9137d9ca1b7ede71bcd9d8d6293b --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp @@ -0,0 +1,17 @@ +#include "SimulationInfoTaylorGreenVortexUx.h" + +#include <sstream> + +std::shared_ptr<SimulationInfo> SimulationInfoTaylorGreenUx::getNewInstance(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) +{ + return std::shared_ptr<SimulationInfo>(new SimulationInfoTaylorGreenUx(ux, amplitude, l0, lx, viscosity, kernelName, numberOfSimulations)); +} + +SimulationInfoTaylorGreenUx::SimulationInfoTaylorGreenUx(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lx, viscosity, kernelName, numberOfSimulations) +{ + std::ostringstream oss; + oss << " ux: " << ux / (lx / l0) << " Amplitude: " << amplitude / (lx / l0); + this->simulationParameterString = oss.str(); + + simulationName = "TaylorGreenVortex Ux"; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h new file mode 100644 index 0000000000000000000000000000000000000000..9b9eedc059a17e7247be9ce2ab82e308473e508c --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.h @@ -0,0 +1,18 @@ +#ifndef SIMULATION_INFO_TAYLORGREENVORTEX_UX_H +#define SIMULATION_INFO_TAYLORGREENVORTEX_UX_H + +#include "Utilities\SimulationInfo\SimulationInfoImp.h" + +#include <memory> + +class SimulationInfoTaylorGreenUx : public SimulationInfoImp +{ +public: + static std::shared_ptr< SimulationInfo> getNewInstance(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + +private: + SimulationInfoTaylorGreenUx() {}; + SimulationInfoTaylorGreenUx(double ux, double amplitude, int l0, int lx, double viscosity, std::string kernelName, int numberOfSimulations); + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationInfo/package.include rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c91aafa77a6bf220dcf8d8560d2c1dfa2800eeed --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.cpp @@ -0,0 +1,28 @@ +#include "SimulationParameterTaylorGreenVortexUx.h" + +#include "Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h" +#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" + +#include <sstream> + +std::shared_ptr<SimulationParameter> SimulationParameterTaylorGreenUx::getNewInstance(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +{ + return std::shared_ptr<SimulationParameter>(new SimulationParameterTaylorGreenUx(kernelName, ux, amplitude, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, filePath, devices)); +} + +double SimulationParameterTaylorGreenUx::getMaxVelocity() +{ + return ux / (lx / l0); +} + +SimulationParameterTaylorGreenUx::SimulationParameterTaylorGreenUx(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +:SimulationParameterImp("TaylorGreenVortex Ux", viscosity, lx, lz, l0, lx, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), ux(ux), amplitude(amplitude), rho0(rho0) +{ + std::ostringstream oss; + oss << filePath << "\\TaylorGreenVortex Ux\\" << viscosity << "\\ux_" << ux << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lx; + generateFilePath(oss.str()); + this->filePath = oss.str(); + + initialCondition = InitialConditionTaylorGreenUx::getNewInstance(lx, lz, l0, ux, amplitude, rho0); + kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); +} diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h similarity index 76% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.h rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h index 8fbbe615639b2be296d85b8a9f6d5e50fdac65fc..aa9932268aa24ce6bade732cf59ea4abb9cc67ec 100644 --- a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h @@ -1,5 +1,5 @@ -#ifndef TGV_SIMULATION_PARAMETER_H -#define TGV_SIMULATION_PARAMETER_H +#ifndef SIMULATION_PARAMETER_TaylorGreen_Ux_H +#define SIMULATION_PARAMETER_TaylorGreen_Ux_H #include "Utilities/SimulationParameter/SimulationParameterImp.h" @@ -8,10 +8,10 @@ class PhiAndNuTest; -class TaylorGreenSimulationParameter : public SimulationParameterImp +class SimulationParameterTaylorGreenUx : public SimulationParameterImp { public: - static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, real u0, real amplitude, real viscosity, real rho0, + static std::shared_ptr<SimulationParameter> getNewInstance(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, @@ -21,7 +21,7 @@ public: double getMaxVelocity(); protected: - TaylorGreenSimulationParameter(std::string kernelName, real u0, real amplitude, + SimulationParameterTaylorGreenUx(std::string kernelName, real ux, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, @@ -30,6 +30,6 @@ protected: std::vector<int> devices); private: - real u0, amplitude, rho0; + real ux, amplitude, rho0; }; #endif diff --git a/targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/package.include similarity index 100% rename from targets/tests/NumericalTests/Simulation/TaylorGreenVortex/SimulationParameter/package.include rename to targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationParameter/package.include diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7d5a19b835e4dbb1909f04757091ba8cdd5e3be3 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp @@ -0,0 +1,30 @@ +#include "AnalyticalResultsTaylorGreenVortexUz.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +std::shared_ptr<AnalyticalResults> AnalyticalResultsTaylorGreenUz::getNewInstance(double viscosity, double uz, double amplitude, double l0, double rho0) +{ + return std::shared_ptr<AnalyticalResults>(new AnalyticalResultsTaylorGreenUz(viscosity, uz, amplitude, l0, rho0)); +} + +void AnalyticalResultsTaylorGreenUz::calc(std::shared_ptr< SimulationResults> simResults) +{ + AnalyticalResultsImp::init(simResults); + + for (int i = 0; i < numberOfTimeSteps; i++) { + for (int j = 0; j < numberOfNodes; j++) { + vx.at(i).at(j) = (amplitude*exp( time.at(i)*viscosity*((-(double)4.0 * pow(M_PI, (double)2.0)) / pow(xNodes, (double)2.0) - ((double)4.0 * pow(M_PI, (double)2.0)) / pow(zNodes, (double)2.0)))*l0*cos(((double)2.0 * M_PI*((l0*time.at(i)*uz) / xNodes + z.at(i).at(j))) / zNodes)*sin(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes)) / xNodes; + vy.at(i).at(j) = (double)0.0; + vz.at(i).at(j) = (l0*uz) / xNodes - (amplitude*exp( time.at(i)*viscosity*((-(double)4.0 * pow(M_PI, (double)2.0)) / pow(xNodes, (double)2.0) - ((double)4.0 * pow(M_PI, (double)2.0)) / pow(zNodes, (double)2.0)))*l0*zNodes*cos(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((double)2.0 * M_PI*((l0*time.at(i)*uz) / xNodes + z.at(i).at(j))) / zNodes)) / pow(xNodes, (double)2.0); + press.at(i).at(j) = (double)0.0; + rho.at(i).at(j) = (amplitude*pow(l0, (double)2.0)*rho0*(amplitude*pow(xNodes, (double)2.0)*zNodes*pow(cos(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes), (double)2.0) - (double)4.0 * exp( ((double)4.0 * pow(M_PI, (double)2.0)*time.at(i)*viscosity*(pow(xNodes, (double)2.0) + pow(zNodes, (double)2.0))) / (pow(xNodes, (double)2.0)*pow(zNodes, (double)2.0)))*uz*xNodes * (pow(xNodes, (double)2.0) - pow(zNodes, (double)2.0))*cos(((double)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((double)2.0 * M_PI*((l0*time.at(i)*uz) / xNodes + z.at(i).at(j))) / zNodes) - amplitude*pow(zNodes, 3)*pow(sin(((double)2.0 * M_PI*((l0*time.at(i)*uz) / xNodes + z.at(i).at(j))) / zNodes), (double)2.0))) / ((double)2.0 *exp( (8 * pow(M_PI, (double)2.0)*time.at(i)*viscosity*(pow(xNodes, (double)2.0) + pow(zNodes, (double)2.0))) / (pow(xNodes, (double)2.0)*pow(zNodes, (double)2.0)))*pow(xNodes, (double)4.0)*zNodes); + } + } + calculated = true; +} + +AnalyticalResultsTaylorGreenUz::AnalyticalResultsTaylorGreenUz(double viscosity, double uz, double amplitude, double l0, double rho0) : AnalyticalResultsImp(), viscosity(viscosity), uz(uz), amplitude(amplitude), l0(l0), rho0(rho0) +{ + +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h new file mode 100644 index 0000000000000000000000000000000000000000..9b9548615fd7bb7a19728af185d4bff3da0fce02 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.h @@ -0,0 +1,21 @@ +#ifndef ANALYTICAL_RESULTS_TAYLORGREENVORTEX_Uz_H +#define ANALYTICAL_RESULTS_TAYLORGREENVORTEX_Uz_H + +#include "Utilities\Results\AnalyticalResults\AnalyticalResultImp.h" + +class AnalyticalResultsTaylorGreenUz : public AnalyticalResultsImp +{ +public: + static std::shared_ptr< AnalyticalResults> getNewInstance(double viscosity, double uz, double amplitude, double l0, double rho0); + void calc(std::shared_ptr< SimulationResults> simResults); + + +private: + AnalyticalResultsTaylorGreenUz() {}; + AnalyticalResultsTaylorGreenUz(double viscosity, double uz, double amplitude, double l0, double rho0); + + double viscosity, rho0; + double l0; + double uz, amplitude; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ea369338ed566d1d64305b8a1719b3c1ce51371 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp @@ -0,0 +1,73 @@ +#include "InitialConditionTaylorGreenVortexUz.h" + +#define _USE_MATH_DEFINES +#include <math.h> + +InitialConditionTaylorGreenUz::InitialConditionTaylorGreenUz(real lx, real lz, real l0, real uz, real amplitude, real rho0) +{ + this->Amp = amplitude; + this->L0 = l0; + this->Lx = lx; + this->Lz = lz; + this->rho = rho0; + this->uz = uz; +} + +std::shared_ptr<InitialConditionTaylorGreenUz> InitialConditionTaylorGreenUz::getNewInstance(real lx, real lz, real l0, real uz, real amplitude, real rho0) +{ + return std::shared_ptr<InitialConditionTaylorGreenUz>(new InitialConditionTaylorGreenUz(lx, lz, l0, uz, amplitude, rho0)); +} + +real InitialConditionTaylorGreenUz::getInitVX(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real vx = (Amp * L0 * cos((real)2.0 * M_PI * z / Lz) * sin((real)2.0 * M_PI * x / Lx) / Lx); + return vx; + } + else + return (real)0.0; + +} + +real InitialConditionTaylorGreenUz::getInitVY(int i, int level) +{ + return (real) 0.0; +} + +real InitialConditionTaylorGreenUz::getInitVZ(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real vz = (uz* L0 / Lz) - (Amp * L0 * Lz * cos((real)2.0 * M_PI * x / Lx) * sin((real)2.0 * M_PI * z / Lz) / (Lx*Lx)); + return vz; + } + else + return (real) 0.0; +} + +real InitialConditionTaylorGreenUz::getInitROH(int i, int level) +{ + real x = getXCoord(i, level); + real y = getYCoord(i, level); + real z = getZCoord(i, level); + if ((i != 0) && (x != XCoordStopNode) && (y != YCoordStopNode) && (z != ZCoordStopNode)) + { + real press = (Amp*Amp * L0*L0 * rho * ((Lx*Lx * cos((real)4.0 * M_PI * x / Lx)) + (Lz*Lz * cos((real)4.0 * M_PI * z / Lz))) / ((real)4.0 * Lx*Lx*Lx*Lx)); + return press; + } + else + return (real) 0.0; +} + +real InitialConditionTaylorGreenUz::getInitPRESS(int i, int level) +{ + //nicht benötigt, da Druck aus Dichte berechnet wird + return (real) 0.0; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h new file mode 100644 index 0000000000000000000000000000000000000000..60d69e359cbc572c57b9d4c1d5835919544f3d19 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h @@ -0,0 +1,30 @@ +#ifndef INITIAL_CONDITION_TAYLORGREENVORTEX_UZ_H +#define INITIAL_CONDITION_TAYLORGREENVORTEX_UZ_H + +#include "Utilities/InitialCondition/InitialConditionImp.h" + +#include <memory> + +class InitialConditionTaylorGreenUz :public InitialConditionImp +{ +public: + static std::shared_ptr< InitialConditionTaylorGreenUz> getNewInstance(real lx, real lz, real l0, real uz, real amplitude, real rho0); + + real getInitVX(int i, int level); + real getInitVY(int i, int level); + real getInitVZ(int i, int level); + real getInitROH(int i, int level); + real getInitPRESS(int i, int level); + +private: + InitialConditionTaylorGreenUz(real lx, real lz, real l0, real u0, real amplitude, real rho0); + InitialConditionTaylorGreenUz() {}; + + real Amp; + real rho; + real L0; + real Lx, Lz; + real uz; +}; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64a4f26fd768f081aca6a3bf95a8754c3fbb4a99 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp @@ -0,0 +1,40 @@ +#include "LogFileInformationTaylorGreenVortexUz.h" + +std::shared_ptr<LogFileInformationTaylorGreenUz> LogFileInformationTaylorGreenUz::getNewInstance(double uz, double amplitude, std::vector< bool> tests, std::vector<double> l, int l0) +{ + return std::shared_ptr<LogFileInformationTaylorGreenUz>(new LogFileInformationTaylorGreenUz(uz, amplitude, tests, l, l0)); +} + +std::string LogFileInformationTaylorGreenUz::getOutput() +{ + makeCenterHead("TaylorGreenVortex V0 Information"); + for (int i = 0; i < tests.size(); i++) { + if (tests.at(i)) { + oss << "Lx=" << l.at(i) << std::endl; + oss << "l0=" << l0 << std::endl; + oss << "uz=" << uz / (l.at(i) / l0) << std::endl; + oss << "Amplitude=" << amplitude / (l.at(i) / l0) << std::endl; + oss << std::endl; + } + } + + return oss.str(); +} + +std::string LogFileInformationTaylorGreenUz::getFilePathExtensionOne() +{ + std::ostringstream oss; + oss << "TaylorGreenVortexUz\\"; + return oss.str(); +} + +std::string LogFileInformationTaylorGreenUz::getFilePathExtensionTwo() +{ + std::ostringstream oss; + oss << "uz_ " << uz << "_Amplitude_ " << amplitude << "\\"; + return oss.str(); +} + +LogFileInformationTaylorGreenUz::LogFileInformationTaylorGreenUz(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0) : uz(uz), amplitude(amplitude), tests(tests), l(l), l0(l0) +{ +} diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h new file mode 100644 index 0000000000000000000000000000000000000000..3fa697e1afe6b38ed70b629eaedca2cfa44804c9 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h @@ -0,0 +1,29 @@ +#ifndef LOGFILE_INFORMATION_TAYLOR_GREEN_UZ_H +#define LOGFILE_INFORMATION_TAYLOR_GREEN_UZ_H + +#include "Utilities/LogFileInformation/LogFileInformationImp.h" +#include "Utilities\LogFileInformation\SimulationLogFileInformation\SimulationLogFileInformation.h" + +#include <memory> +#include <vector> + +class LogFileInformationTaylorGreenUz : public LogFileInformationImp, public SimulationLogFileInformation +{ +public: + static std::shared_ptr<LogFileInformationTaylorGreenUz> getNewInstance(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + + std::string getOutput(); + std::string getFilePathExtensionOne(); + std::string getFilePathExtensionTwo(); + +private: + LogFileInformationTaylorGreenUz() {}; + LogFileInformationTaylorGreenUz(double uz, double amplitude, std::vector< bool> tests, std::vector< double> l, int l0); + + double uz; + double amplitude; + std::vector< bool> tests; + std::vector< double> l; + int l0; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f4461b7c3234cc26dcda175a12c396cf212e03f8 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp @@ -0,0 +1,17 @@ +#include "SimulationInfoTaylorGreenVortexUz.h" + +#include <sstream> + +std::shared_ptr<SimulationInfoTaylorGreenUz> SimulationInfoTaylorGreenUz::getNewInstance(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations) +{ + return std::shared_ptr<SimulationInfoTaylorGreenUz>(new SimulationInfoTaylorGreenUz(uz, amplitude, l0, lz, viscosity, kernelName, numberOfSimulations)); +} + +SimulationInfoTaylorGreenUz::SimulationInfoTaylorGreenUz(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations) : SimulationInfoImp(lz, viscosity, kernelName, numberOfSimulations) +{ + std::ostringstream oss; + oss << " uz: " << uz / (lz / l0) << " Amplitude: " << amplitude / (lz / l0); + this->simulationParameterString = oss.str(); + + simulationName = "TaylorGreenVortex Uz"; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h new file mode 100644 index 0000000000000000000000000000000000000000..3613d241aa3f53a38a38eb795f6017145622b74e --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.h @@ -0,0 +1,18 @@ +#ifndef SIMULATION_INFO_TAYLORGREENVORTEX_UZ_H +#define SIMULATION_INFO_TAYLORGREENVORTEX_UZ_H + +#include "Utilities\SimulationInfo\SimulationInfoImp.h" + +#include <memory> + +class SimulationInfoTaylorGreenUz : public SimulationInfoImp +{ +public: + static std::shared_ptr< SimulationInfoTaylorGreenUz> getNewInstance(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations); + +private: + SimulationInfoTaylorGreenUz() {}; + SimulationInfoTaylorGreenUz(double uz, double amplitude, int l0, int lz, double viscosity, std::string kernelName, int numberOfSimulations); + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd934834f8473ede299956429193377a24168ff3 --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.cpp @@ -0,0 +1,28 @@ +#include "SimulationParameterTaylorGreenVortexUz.h" + +#include "Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h" +#include "Utilities\KernelConfiguration\KernelConfigurationImp.h" + +#include <sstream> + +std::shared_ptr<SimulationParameterTaylorGreenUz> SimulationParameterTaylorGreenUz::getNewInstance(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +{ + return std::shared_ptr<SimulationParameterTaylorGreenUz>(new SimulationParameterTaylorGreenUz(kernelName, uz, amplitude, viscosity, rho0, lx, lz, l0, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, filePath, devices)); +} + +double SimulationParameterTaylorGreenUz::getMaxVelocity() +{ + return uz / (lz / l0); +} + +SimulationParameterTaylorGreenUz::SimulationParameterTaylorGreenUz(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, real lx, real lz, real l0, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, std::string filePath, std::vector<int> devices) +:SimulationParameterImp("TaylorGreenVortex Uz", viscosity, lx, lz, l0, lz, numberOfTimeSteps, basisTimeStepLength, startStepCalculation, ySliceForCalculation, gridPath, maxLevel, numberOfGridLevels, writeFiles, startStepFileWriter, devices), uz(uz), amplitude(amplitude), rho0(rho0) +{ + std::ostringstream oss; + oss << filePath << "\\TaylorGreenVortex Uz\\viscosity_" << viscosity << "\\uz_" << uz << "_amplitude_" << amplitude << "\\" << kernelName << "\\grid" << lz; + generateFilePath(oss.str()); + this->filePath = oss.str(); + + initialCondition = InitialConditionTaylorGreenUz::getNewInstance(lx, lz, l0, uz, amplitude, rho0); + kernelConfig = KernelConfigurationImp::getNewInstance(kernelName); +} diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h new file mode 100644 index 0000000000000000000000000000000000000000..a73dcb1c8813d60b20128bcc5cd3f845ddfbc9ed --- /dev/null +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h @@ -0,0 +1,34 @@ +#ifndef SIMULATION_PARAMETER_TAYLORGREENVORTEX_UZ_H +#define SIMULATION_PARAMETER_TAYLORGREENVORTEX_UZ_H + +#include "Utilities/SimulationParameter/SimulationParameterImp.h" + +#include <string> +#include <memory> + + +class SimulationParameterTaylorGreenUz : public SimulationParameterImp +{ +public: + static std::shared_ptr<SimulationParameterTaylorGreenUz> getNewInstance(std::string kernelName, real uz, real amplitude, real viscosity, real rho0, + real lx, real lz, real l0, + unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, + unsigned int startStepCalculation, unsigned int ySliceForCalculation, + std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, + bool writeFiles, unsigned int startStepFileWriter, std::string filePath, + std::vector<int> devices); + double getMaxVelocity(); + +protected: + SimulationParameterTaylorGreenUz(std::string kernelName, real uz, real amplitude, + real viscosity, real rho0, real lx, real lz, real l0, + unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, + unsigned int startStepCalculation, unsigned int ySliceForCalculation, + std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, + bool writeFiles, unsigned int startStepFileWriter, std::string filePath, + std::vector<int> devices); + +private: + real uz, amplitude, rho0; +}; +#endif diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/package.include b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationParameter/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp index 2dcefca654d6ce570e8792166707648e3485d183..7aefc09227777c0a9f5155e227c289778fdbca84 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp @@ -4,11 +4,13 @@ #include "Utilities\PostProcessingResults\PostProcessingResults.h" #include "Utilities\Results\SimulationResults\SimulationResults.h" +#include "Tests\L2NormTest\PostProcessingStrategy\PostProcessingStrategyL2NormTest.h" + #include <iomanip> -std::shared_ptr<L2NormTest> L2NormTest::getNewInstance(std::shared_ptr< PostProcessingResults> postProResults, std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) +std::shared_ptr<L2NormTest> L2NormTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) { - return std::shared_ptr<L2NormTest>(new L2NormTest(postProResults, colorOutput, dataToCalculate, maxL2NormDiff, basicTimeStep, divergentTimeStep)); + return std::shared_ptr<L2NormTest>(new L2NormTest(colorOutput, dataToCalculate, maxL2NormDiff, basicTimeStep, divergentTimeStep)); } void L2NormTest::update() @@ -16,9 +18,10 @@ void L2NormTest::update() TestImp::update(); } -void L2NormTest::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResults) +void L2NormTest::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr< L2NormPostProcessingStrategy> postProStrategy) { - TestImp::addSimulation(sim, simInfo, postProResults); + TestImp::addSimulation(sim, simInfo, postProStrategy); + l2NormPostProStrategies.push_back(postProStrategy); } void L2NormTest::evaluate() @@ -26,15 +29,15 @@ void L2NormTest::evaluate() std::vector<double> results; if (dataToCalculate == "Vx") - results = postProResults->getL2NormVx(); + results = l2NormPostProStrategies.at(0)->getL2NormVx(); if (dataToCalculate == "Vy") - results = postProResults->getL2NormVy(); + results = l2NormPostProStrategies.at(0)->getL2NormVy(); if (dataToCalculate == "Vz") - results = postProResults->getL2NormVz(); + results = l2NormPostProStrategies.at(0)->getL2NormVz(); if (dataToCalculate == "Press") - results = postProResults->getL2NormPress(); + results = l2NormPostProStrategies.at(0)->getL2NormPress(); if (dataToCalculate == "Rho") - results = postProResults->getL2NormRho(); + results = l2NormPostProStrategies.at(0)->getL2NormRho(); resultBasicTimestep = results.at(0); resultDivergentTimeStep = results.at(1); @@ -48,9 +51,9 @@ void L2NormTest::evaluate() std::string L2NormTest::getLogFileOutput() { std::ostringstream oss; - oss << "L2Norm_BasicTimeStep_L" << postProResults->getNumberOfXNodes() << "=" << resultBasicTimestep << std::endl; - oss << "L2Norm_DivergentTimeStep_L" << postProResults->getNumberOfXNodes() << "=" << resultDivergentTimeStep << std::endl; - oss << "L2Norm_Diff_L" << postProResults->getNumberOfXNodes() << "=" << diffL2Norm << std::endl << std::endl; + oss << "L2Norm_BasicTimeStep_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "=" << resultBasicTimestep << std::endl; + oss << "L2Norm_DivergentTimeStep_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "=" << resultDivergentTimeStep << std::endl; + oss << "L2Norm_Diff_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "=" << diffL2Norm << std::endl << std::endl; return oss.str(); } @@ -64,8 +67,8 @@ void L2NormTest::makeConsoleOutput() colorOutput->makeL2NormTestOutput(testPassed, simInfos.at(0), basicTimeStep, divergentTimeStep, dataToCalculate, resultBasicTimestep, resultDivergentTimeStep, diffL2Norm); } -L2NormTest::L2NormTest(std::shared_ptr< PostProcessingResults> postProResults, std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) - : TestImp(colorOutput), basicTimeStep(basicTimeStep), divergentTimeStep(divergentTimeStep), dataToCalculate(dataToCalculate), maxL2NormDiff(maxL2NormDiff), postProResults(postProResults) +L2NormTest::L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep) + : TestImp(colorOutput), basicTimeStep(basicTimeStep), divergentTimeStep(divergentTimeStep), dataToCalculate(dataToCalculate), maxL2NormDiff(maxL2NormDiff) { } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h index adb657bd23d00653eac2afc8d70540c8416ca181..219e607b228389f61d9e77a28bb35e075a095780 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h @@ -7,29 +7,30 @@ class L2NormCalculator; class AnalyticalResults; -class PostProcessingResults; +class L2NormPostProcessingStrategy; class L2NormTest : public TestImp { public: - static std::shared_ptr<L2NormTest> getNewInstance(std::shared_ptr< PostProcessingResults> postProResults, std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); + static std::shared_ptr<L2NormTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); void update(); - void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResults); + void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< L2NormPostProcessingStrategy> postProStrategy); void evaluate(); std::string getLogFileOutput(); std::vector< bool> getPassedTests(); void makeConsoleOutput(); private: - L2NormTest(std::shared_ptr< PostProcessingResults> postProResults, std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); + L2NormTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double maxL2NormDiff, unsigned int basicTimeStep, unsigned int divergentTimeStep); - std::shared_ptr< PostProcessingResults> postProResults; unsigned int basicTimeStep, divergentTimeStep; double resultBasicTimestep, resultDivergentTimeStep; std::string dataToCalculate; double diffL2Norm; double maxL2NormDiff; bool testPassed; + + std::vector<std::shared_ptr< L2NormPostProcessingStrategy>> l2NormPostProStrategies; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f386f1ac956d05d72e7cef4d08a168ce36d70b19 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp @@ -0,0 +1,90 @@ +#include "PostProcessingStrategyL2NormTest.h" + +#include "Utilities\Calculator\L2NormCalculator\L2NormCalculator.h" +#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" +#include "Utilities\Results\SimulationResults\SimulationResults.h" + +std::shared_ptr<L2NormPostProcessingStrategy> L2NormPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) +{ + return std::shared_ptr<L2NormPostProcessingStrategy>(new L2NormPostProcessingStrategy(simResult, analyticalResult, dataToCalculateL2, basicTimeStepL2Norm, divergentTimeStepL2Norm)); +} + +L2NormPostProcessingStrategy::L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculateL2(dataToCalculateL2), basicTimeStepL2Norm(basicTimeStepL2Norm), divergentTimeStepL2Norm(divergentTimeStepL2Norm) +{ + isEvaluated = false; + l2Normcalculator = L2NormCalculator::getInstance(); +} + +void L2NormPostProcessingStrategy::evaluate() +{ + if (!isEvaluated) { + analyticalResult->calc(simResult); + int bS = calcTimeStepInResults(basicTimeStepL2Norm); + int dS = calcTimeStepInResults(divergentTimeStepL2Norm); + + for (int i = 0; i < dataToCalculateL2.size(); i++) { + if (dataToCalculateL2.at(i) == "Vx") { + l2VxBasic = l2Normcalculator->calc(analyticalResult->getVx().at(bS), simResult->getVx().at(bS), simResult->getLevels().at(bS)); + l2VxDivergent = l2Normcalculator->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS)); + } + if (dataToCalculateL2.at(i) == "Vy") { + l2VyBasic = l2Normcalculator->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS)); + l2VyDivergent = l2Normcalculator->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS)); + } + if (dataToCalculateL2.at(i) == "Vz") { + l2VzBasic = l2Normcalculator->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS)); + l2VzDivergent = l2Normcalculator->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS)); + } + if (dataToCalculateL2.at(i) == "Press") { + l2PressBasic = l2Normcalculator->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS)); + l2PressDivergent = l2Normcalculator->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS)); + } + if (dataToCalculateL2.at(i) == "Rho") { + l2RhoBasic = l2Normcalculator->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS)); + l2RhoDivergent = l2Normcalculator->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS)); + } + } + isEvaluated = true; + } +} + +std::vector<double> L2NormPostProcessingStrategy::getL2NormVx() +{ + std::vector<double> v; + v.push_back(l2VxBasic); + v.push_back(l2VxDivergent); + return v; +} + +std::vector<double> L2NormPostProcessingStrategy::getL2NormVy() +{ + std::vector<double> v; + v.push_back(l2VyBasic); + v.push_back(l2VyDivergent); + return v; +} + +std::vector<double> L2NormPostProcessingStrategy::getL2NormVz() +{ + std::vector<double> v; + v.push_back(l2VzBasic); + v.push_back(l2VzDivergent); + return v; +} + +std::vector<double> L2NormPostProcessingStrategy::getL2NormPress() +{ + std::vector<double> v; + v.push_back(l2PressBasic); + v.push_back(l2PressDivergent); + return v; +} + +std::vector<double> L2NormPostProcessingStrategy::getL2NormRho() +{ + std::vector<double> v; + v.push_back(l2RhoBasic); + v.push_back(l2RhoDivergent); + return v; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h new file mode 100644 index 0000000000000000000000000000000000000000..84c249cc88a4c48286036ee0845066bb2a10f42b --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h @@ -0,0 +1,35 @@ +#ifndef L2NORM_POST_PROCESSING_STRATEGY_H +#define L2NORM_POST_PROCESSING_STRATEGY_H + +#include "Utilities\PostProcessingStrategy\PostProcessingStrategyImp.h" + +#include <memory> + +class AnalyticalResults; +class L2NormCalculator; + +class L2NormPostProcessingStrategy : public PostProcessingStrategyImp +{ +public: + static std::shared_ptr< L2NormPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); + void evaluate(); + + std::vector< double> getL2NormVx(); + std::vector< double> getL2NormVy(); + std::vector< double> getL2NormVz(); + std::vector< double> getL2NormPress(); + std::vector< double> getL2NormRho(); + +private: + L2NormPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculateL2, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); + bool isEvaluated; + + std::shared_ptr< L2NormCalculator> l2Normcalculator; + std::shared_ptr< AnalyticalResults> analyticalResult; + std::vector<std::string> dataToCalculateL2; + unsigned int basicTimeStepL2Norm; + unsigned int divergentTimeStepL2Norm; + double l2VxBasic, l2VyBasic, l2VzBasic, l2RhoBasic, l2PressBasic; + double l2VxDivergent, l2VyDivergent, l2VzDivergent, l2RhoDivergent, l2PressDivergent; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13fbff32b455fc23bcc6195db0cc06c8cc9c0f6c --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp @@ -0,0 +1,117 @@ +#include "L2NormTestBetweenKernels.h" + +#include "Utilities\Calculator\L2NormCalculator\L2NormCalculator.h" +#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" +#include "Utilities\PostProcessingResults\PostProcessingResults.h" +#include "Utilities\Results\SimulationResults\SimulationResults.h" +#include "Utilities\TestSimulation\TestSimulation.h" +#include "Utilities\SimulationInfo\SimulationInfo.h" +#include "Tests\L2NormTestBetweenKernels\PostProcessingStrategy\L2NormBetweenKernelPostProcessingStrategy.h" + +#include <iomanip> + +std::shared_ptr<L2NormTestBetweenKernels> L2NormTestBetweenKernels::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep) +{ + return std::shared_ptr<L2NormTestBetweenKernels>(new L2NormTestBetweenKernels(colorOutput, dataToCalculate, timeStep)); +} + +void L2NormTestBetweenKernels::update() +{ + TestImp::update(); +} + +void L2NormTestBetweenKernels::evaluate() +{ + basicPostProcessingStrategy->evaluate(); + divergentPostProcessingStrategy->evaluate(); + + int tS = calcTimeStepInResults(timeStep); + + if (dataToCalculate == "Vx") { + basicL2Result = basicPostProcessingStrategy->getL2NormVx(timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2NormVx(timeStep); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVx().at(tS), divergentSimResults->getVx().at(tS), basicSimResults->getLevels().at(tS)); + } + if (dataToCalculate == "Vy") { + basicL2Result = basicPostProcessingStrategy->getL2NormVy(timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2NormVy(timeStep); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(tS), divergentSimResults->getVy().at(tS), basicSimResults->getLevels().at(tS)); + } + if (dataToCalculate == "Vz") { + basicL2Result = basicPostProcessingStrategy->getL2NormVz(timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2NormVz(timeStep); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(tS), divergentSimResults->getVz().at(tS), basicSimResults->getLevels().at(tS)); + } + if (dataToCalculate == "Press") { + basicL2Result = basicPostProcessingStrategy->getL2NormPress(timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2NormPress(timeStep); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(tS), divergentSimResults->getPress().at(tS), basicSimResults->getLevels().at(tS)); + } + if (dataToCalculate == "Rho") { + basicL2Result = basicPostProcessingStrategy->getL2NormRho(timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2NormRho(timeStep); + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(tS), divergentSimResults->getRho().at(tS), basicSimResults->getLevels().at(tS)); + } + + if (basicL2Result < divergentL2Result) + testPassed = true; + + makeConsoleOutput(); +} + +std::string L2NormTestBetweenKernels::getLogFileOutput() +{ + std::ostringstream oss; + oss << "L2Norm_" << dataToCalculate << "_TimeStep_" << timeStep << "=" << divergentL2Result << std::endl; + oss << "L2Norm_BasicKernel_" << dataToCalculate << "_TimeStep_" << timeStep << "=" << basicL2Result << std::endl; + oss << "L2Norm_Between_Kernels_" << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "=" << resultL2ToBasicKernel << std::endl << std::endl; + + return oss.str(); +} + +double L2NormTestBetweenKernels::getBasicL2Result() +{ + return basicL2Result; +} + +std::vector<bool> L2NormTestBetweenKernels::getPassedTests() +{ + return std::vector<bool>(1, testPassed); +} + +void L2NormTestBetweenKernels::makeConsoleOutput() +{ + colorOutput->makeL2NormBetweenKernelsTestOutput(testPassed, basicSimInfo, divergentSimInfo, dataToCalculate, timeStep, basicL2Result, divergentL2Result, resultL2ToBasicKernel); +} + +void L2NormTestBetweenKernels::setBasicSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy) +{ + TestImp::addSimulation(sim, simInfo, postProcessingStrategy); + this->basicSim = sim; + this->basicSimInfo = simInfo; + this->basicPostProcessingStrategy = postProcessingStrategy; + this->basicSimResults = basicPostProcessingStrategy->getSimulationResult(); +} + +void L2NormTestBetweenKernels::setDivergentKernelSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy) +{ + TestImp::addSimulation(sim, simInfo, postProcessingStrategy); + this->divergentSim = sim; + this->divergentSimInfo = simInfo; + this->divergentPostProcessingStrategy = postProcessingStrategy; + this->divergentSimResults = divergentPostProcessingStrategy->getSimulationResult(); +} + +L2NormTestBetweenKernels::L2NormTestBetweenKernels(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep) + : TestImp(colorOutput), timeStep(timeStep), dataToCalculate(dataToCalculate) +{ + l2Normcalculator = L2NormCalculator::getInstance(); +} + +int L2NormTestBetweenKernels::calcTimeStepInResults(unsigned int timeStep) +{ + for (int i = 0; i < basicSimResults->getTimeSteps().size(); i++) { + if (timeStep == basicSimResults->getTimeSteps().at(i)) + return basicSimResults->getTimeSteps().at(i); + } +} diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h new file mode 100644 index 0000000000000000000000000000000000000000..4711f3bb4dac3e50f907c7ea927f2975d884b3a2 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h @@ -0,0 +1,52 @@ +#ifndef L2_NORM_TEST_BETWEEN_KERNELS_H +#define L2_NORM_TEST_BETWEEN_KERNELS_H + +#include "Utilities\Test\TestImp.h" + +#include <memory> + +class L2NormBetweenKernelPostProcessingStrategy; +class L2NormCalculator; +class AnalyticalResults; +class SimulationResults; + +class L2NormTestBetweenKernels : public TestImp +{ +public: + static std::shared_ptr<L2NormTestBetweenKernels> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep); + + void update(); + void evaluate(); + std::string getLogFileOutput(); + double getBasicL2Result(); + std::vector< bool> getPassedTests(); + void makeConsoleOutput(); + + void setBasicSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy); + void setDivergentKernelSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy); + +private: + L2NormTestBetweenKernels(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep); + int calcTimeStepInResults(unsigned int timeStep); + + unsigned int timeStep; + std::string dataToCalculate; + bool testPassed; + + std::shared_ptr< TestSimulation> basicSim; + std::shared_ptr< SimulationInfo> basicSimInfo; + std::shared_ptr< SimulationResults> basicSimResults; + std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> basicPostProcessingStrategy; + double basicL2Result; + + std::shared_ptr< TestSimulation> divergentSim; + std::shared_ptr< SimulationInfo> divergentSimInfo; + std::shared_ptr< SimulationResults> divergentSimResults; + std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> divergentPostProcessingStrategy; + double divergentL2Result; + + std::shared_ptr< L2NormCalculator> l2Normcalculator; + + double resultL2ToBasicKernel; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0e78870c7f972ada5fefb790da47e64dc5790f29 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp @@ -0,0 +1,48 @@ +#include "L2NormLogFileInformationBetweenKernels.h" + +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernels.h" + +#include <iomanip> +#include <sstream> + +std::shared_ptr<L2NormBetweenKernelsInformation> L2NormBetweenKernelsInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc) +{ + return std::shared_ptr<L2NormBetweenKernelsInformation>(new L2NormBetweenKernelsInformation(tests, basicKernel, timeSteps, dataToCalc)); +} + +std::string L2NormBetweenKernelsInformation::getOutput() +{ + std::ostringstream headName; + headName << tests.at(0)->getSimulationName() << "L2Norm Test Between Kernels"; + makeCenterHead(headName.str()); + + oss << "BasicKernel=" << basicKernel << std::endl; + oss << "DataToCalculate=\""; + for (int i = 0; i < dataToCalc.size(); i++) + oss << dataToCalc.at(i) << " "; + deleteLastCharInOss(); + oss << "\"" << std::endl; + oss << "TimeSteps=\""; + for (int i = 0; i < timeSteps.size(); i++) + oss << timeSteps.at(i) << " "; + deleteLastCharInOss(); + oss << "\""<< std::endl << std::endl; + + for (int i = 0; i < tests.size(); i++) + oss << tests.at(i)->getLogFileOutput(); + + return oss.str(); +} + +L2NormBetweenKernelsInformation::L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc) : tests(tests), basicKernel(basicKernel), timeSteps(timeSteps), dataToCalc(dataToCalc) +{ + +} + +void L2NormBetweenKernelsInformation::deleteLastCharInOss() +{ + std::string myString = oss.str().substr(0, oss.str().size() - 1); + oss.str(""); + oss.clear(); + oss << myString; +} diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h new file mode 100644 index 0000000000000000000000000000000000000000..80dfa3450b7fc4441fef8cd9a53680e2b3074582 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h @@ -0,0 +1,30 @@ +#ifndef L2NORM_BETWEEN_KERNELS_LOGFILE_INFORMATION_H +#define L2NORM_BETWEEN_KERNELS_LOGFILE_INFORMATION_H + +#include "Utilities\LogFileInformation\TestLogFileInformation\TestLogFileInformation.h" + +#include <memory> +#include <vector> + +class L2NormTestBetweenKernels; + +class L2NormBetweenKernelsInformation : public TestLogFileInformation +{ +public: + static std::shared_ptr< L2NormBetweenKernelsInformation> getNewInstance(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc); + + std::string getOutput(); + +private: + L2NormBetweenKernelsInformation() {}; + L2NormBetweenKernelsInformation(std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests, std::string basicKernel, std::vector<int> timeSteps, std::vector<std::string> dataToCalc); + + void deleteLastCharInOss(); + + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests; + + std::string basicKernel; + std::vector<int> timeSteps; + std::vector<std::string> dataToCalc; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/package.include b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..37b2edb5838c5eede22e37a88e9f08f5f74cedec --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp @@ -0,0 +1,78 @@ +#include "L2NormBetweenKernelPostProcessingStrategy.h" + +#include "Utilities\Calculator\L2NormCalculator\L2NormCalculator.h" +#include "Utilities\Results\SimulationResults\SimulationResults.h" +#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" + +std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> L2NormBetweenKernelPostProcessingStrategy::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate) +{ + return std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy>(new L2NormBetweenKernelPostProcessingStrategy(simResult, analyticalResult, timeSteps, dataToCalculate)); +} + +void L2NormBetweenKernelPostProcessingStrategy::evaluate() +{ + if (!isEvaluated) { + analyticalResult->calc(simResult); + + l2Norm.resize(timeSteps.size()); + for (int j = 0; j < dataToCalculate.size(); j++) { + for (int i = 0; i < timeSteps.size(); i++) { + int time = calcTimeStepInResults(timeSteps.at(i)); + if (dataToCalculate.at(j) == "Vx") + l2Vx.push_back(l2Normcalculator->calc(analyticalResult->getVx().at(time), simResult->getVx().at(time), simResult->getLevels().at(time))); + if (dataToCalculate.at(j) == "Vy") + l2Vy.push_back(l2Normcalculator->calc(analyticalResult->getVy().at(time), simResult->getVy().at(time), simResult->getLevels().at(time))); + if (dataToCalculate.at(j) == "Vz") + l2Vz.push_back(l2Normcalculator->calc(analyticalResult->getVz().at(time), simResult->getVz().at(time), simResult->getLevels().at(time))); + if (dataToCalculate.at(j) == "Press") + l2Press.push_back(l2Normcalculator->calc(analyticalResult->getPress().at(time), simResult->getPress().at(time), simResult->getLevels().at(time))); + if (dataToCalculate.at(j) == "Rho") + l2Rho.push_back(l2Normcalculator->calc(analyticalResult->getRho().at(time), simResult->getRho().at(time), simResult->getLevels().at(time))); + } + } + isEvaluated = true; + } +} + +double L2NormBetweenKernelPostProcessingStrategy::getL2NormVx(int timeStep) +{ + return l2Vx.at(calcPosInTimeStep(timeStep)); +} + +double L2NormBetweenKernelPostProcessingStrategy::getL2NormVy(int timeStep) +{ + return l2Vy.at(calcPosInTimeStep(timeStep)); +} + +double L2NormBetweenKernelPostProcessingStrategy::getL2NormVz(int timeStep) +{ + return l2Vz.at(calcPosInTimeStep(timeStep)); +} + +double L2NormBetweenKernelPostProcessingStrategy::getL2NormPress(int timeStep) +{ + return l2Press.at(calcPosInTimeStep(timeStep)); +} + +double L2NormBetweenKernelPostProcessingStrategy::getL2NormRho(int timeStep) +{ + return l2Rho.at(calcPosInTimeStep(timeStep)); +} + +std::shared_ptr<SimulationResults> L2NormBetweenKernelPostProcessingStrategy::getSimulationResult() +{ + return simResult; +} + +L2NormBetweenKernelPostProcessingStrategy::L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate) : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), timeSteps(timeSteps), dataToCalculate(dataToCalculate) +{ + l2Normcalculator = L2NormCalculator::getInstance(); + isEvaluated = false; +} + +int L2NormBetweenKernelPostProcessingStrategy::calcPosInTimeStep(int time) +{ + for (int i = 0; i < timeSteps.size(); i++) + if (timeSteps.at(i) == time) + return i; +} diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..c8e96126a0de002f2deb93a21639cd10f4e24c8e --- /dev/null +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h @@ -0,0 +1,43 @@ +#ifndef L2NORM_BETWEEN_KERNEL_POST_PROCESSING_STRATEGY_H +#define L2NORM_BETWEEN_KERNEL_POST_PROCESSING_STRATEGY_H + +#include "Utilities\PostProcessingStrategy\PostProcessingStrategyImp.h" + +#include <memory> + +class AnalyticalResults; +class L2NormCalculator; + +class L2NormBetweenKernelPostProcessingStrategy : public PostProcessingStrategyImp +{ +public: + static std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate); + void evaluate(); + + double getL2NormVx(int timeStep); + double getL2NormVy(int timeStep); + double getL2NormVz(int timeStep); + double getL2NormPress(int timeStep); + double getL2NormRho(int timeStep); + + virtual std::shared_ptr< SimulationResults> getSimulationResult(); + +private: + L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<int> timeSteps, std::vector< std::string> dataToCalculate); + + int calcPosInTimeStep(int time); + + std::vector<int> timeSteps; + std::vector<double> l2Norm; + std::vector< double> l2Vx; + std::vector< double> l2Vy; + std::vector< double> l2Vz; + std::vector< double> l2Press; + std::vector< double> l2Rho; + std::vector< std::string> dataToCalculate; + std::shared_ptr< AnalyticalResults> analyticalResult; + std::shared_ptr< L2NormCalculator> l2Normcalculator; + bool isEvaluated; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/package.include b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp index 19b56737ba4db054e0b4f5175ea9782ccbf9e5a2..4aa25fad1a15d8565c48dfe607c5c3d06393ebb7 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.cpp @@ -6,30 +6,93 @@ #include <sstream> -std::shared_ptr<PhiAndNuInformation> PhiAndNuInformation::getNewInstance(std::vector<std::shared_ptr<PhiAndNuTest>> tests, unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) +std::shared_ptr<PhiAndNuInformation> PhiAndNuInformation::getNewInstance(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) { - return std::shared_ptr<PhiAndNuInformation>(new PhiAndNuInformation(tests, startTimeStepCalculation, endTimeStepCalculation)); + return std::shared_ptr<PhiAndNuInformation>(new PhiAndNuInformation(startTimeStepCalculation, endTimeStepCalculation)); } std::string PhiAndNuInformation::getOutput() { std::ostringstream headName; - headName << tests.at(0)->getSimulationName() <<" Phi And Nu Test"; + headName << testGroups.at(0).at(0)->getSimulationName() <<" Phi And Nu Test"; makeCenterHead(headName.str()); oss << "StartTimeStepCalculation=" << startTimeStepCalculation << std::endl; oss << "EndTimeStepCalculation=" << endTimeStepCalculation << std::endl; oss << std::endl; - oss << std::setfill(' ') << std::left << std::setw(4) << "L" << std::setw(15) << "NuDiff" << std::setw(30) << "Order of Accuracy" << std::setw(15) << "PhiDiff" << "Order of Accuracy" << std::endl; - - for(int i = 0; i < tests.size(); i++) - oss << tests.at(i)->getLogFileOutput(); + for (int i = 0; i < testGroups.size(); i++) { + fillMyData(testGroups.at(i)); + for (int j = 0; j < nu.size(); j++) + oss << "Nu_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << nu.at(j) << std::endl; + oss << std::endl; + for (int j = 0; j < nuDiff.size(); j++) + oss << "NuDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << nuDiff.at(j) << std::endl; + oss << std::endl; + for (int j = 0; j < orderOfAccuracyNuDiff.size(); j++) + oss << "OrderOfAccuracy_NuDiff_" << lx.at(2*j) << "_" << lx.at(2*j+1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracyNuDiff.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(); } -PhiAndNuInformation::PhiAndNuInformation(std::vector<std::shared_ptr<PhiAndNuTest>> tests, unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) : startTimeStepCalculation(startTimeStepCalculation), endTimeStepCalculation(endTimeStepCalculation) +void PhiAndNuInformation::addTestGroup(std::vector<std::shared_ptr<PhiAndNuTest>> tests) +{ + testGroups.push_back(tests); +} + +void PhiAndNuInformation::fillMyData(std::vector<std::shared_ptr<PhiAndNuTest>> testGroup) { - this->tests = tests; + lxForErase.resize(0); + lx.resize(0); + nu.resize(0); + nuDiff.resize(0); + phiDiff.resize(0); + orderOfAccuracyNuDiff.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> myNu = testGroup.at(i)->getNu(); + std::vector<double> myNuDiff = testGroup.at(i)->getNuDiff(); + std::vector<double> myPhiDiff = testGroup.at(i)->getPhiDiff(); + + lx.insert(lx.end(), myLx.begin(), myLx.end()); + lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end()); + nu.insert(nu.end(), myNu.begin(), myNu.end()); + nuDiff.insert(nuDiff.end(), myNuDiff.begin(), myNuDiff.end()); + phiDiff.insert(phiDiff.end(), myPhiDiff.begin(), myPhiDiff.end()); + orderOfAccuracyNuDiff.push_back(testGroup.at(i)->getOrderOfAccuracyNuDiff()); + 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) { + nu.erase(nu.begin() + i); + nuDiff.erase(nuDiff.begin() + i); + phiDiff.erase(phiDiff.begin() + i); + lxForErase.erase(lxForErase.begin() + i); + } + } + + +} + +PhiAndNuInformation::PhiAndNuInformation(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation) : startTimeStepCalculation(startTimeStepCalculation), endTimeStepCalculation(endTimeStepCalculation) +{ + } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h index 453fe1d047a453442c3c358f8a464eb90924c42b..fb5d6f9f79b1a512325e540af850eb5af752a032 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/LogFileInformation/PhiAndNuLogFileInformation.h @@ -11,15 +11,26 @@ class PhiAndNuTest; class PhiAndNuInformation : public TestLogFileInformation { public: - static std::shared_ptr< PhiAndNuInformation> getNewInstance(std::vector< std::shared_ptr< PhiAndNuTest>> tests, unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); + static std::shared_ptr< PhiAndNuInformation> getNewInstance(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); std::string getOutput(); + void addTestGroup(std::vector< std::shared_ptr< PhiAndNuTest>> tests); private: + void fillMyData(std::vector< std::shared_ptr< PhiAndNuTest>> testGroup); + PhiAndNuInformation() {}; - PhiAndNuInformation(std::vector< std::shared_ptr< PhiAndNuTest>> tests, unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); + PhiAndNuInformation(unsigned int startTimeStepCalculation, unsigned int endTimeStepCalculation); - std::vector< std::shared_ptr< PhiAndNuTest>> tests; + std::vector< std::vector< std::shared_ptr< PhiAndNuTest>>> testGroups; unsigned int startTimeStepCalculation, endTimeStepCalculation; + + std::vector<int> lx; + std::vector<int> lxForErase; + std::vector<double> phiDiff; + std::vector<double> nu, nuDiff; + std::vector<double> orderOfAccuracyPhiDiff; + std::vector<double> orderOfAccuracyNuDiff; + std::vector<std::string> dataToCalc; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp index 6ba3f2657ab6b314a42082e262752a7fd56e149a..2f14dcea858abc4aa596b54f7e6f9685defa67d7 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.cpp @@ -1,10 +1,11 @@ #include "PhiAndNuTest.h" #include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" -#include "Utilities\PostProcessingResults\PostProcessingResults.h" #include "Utilities\TestSimulation\TestSimulation.h" #include "Utilities\SimulationInfo\SimulationInfo.h" +#include "Tests\PhiAndNuTest\PostProcessingStrategy\PostProcessingStrategyPhiAndNuTest.h" + #include <iomanip> std::shared_ptr<PhiAndNuTest> PhiAndNuTest::getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation) @@ -14,19 +15,19 @@ std::shared_ptr<PhiAndNuTest> PhiAndNuTest::getNewInstance(std::shared_ptr< Colo void PhiAndNuTest::evaluate() { - for (int i = 0; i < postProResults.size(); i++) { - lx.push_back(postProResults.at(i)->getNumberOfXNodes()); + for (int i = 0; i < phiAndNuPostProStrategies.size(); i++) { + lx.push_back(phiAndNuPostProStrategies.at(i)->getNumberOfXNodes()); if (dataToCalculate == "Vx") { - nu.push_back(postProResults.at(i)->getNuVx()); - phiDiff.push_back(postProResults.at(i)->getPhiDiffVx()); + nu.push_back(phiAndNuPostProStrategies.at(i)->getNuVx()); + phiDiff.push_back(phiAndNuPostProStrategies.at(i)->getPhiDiffVx()); } if (dataToCalculate == "Vy") { - nu.push_back(postProResults.at(i)->getNuVy()); - phiDiff.push_back(postProResults.at(i)->getPhiDiffVy()); + nu.push_back(phiAndNuPostProStrategies.at(i)->getNuVy()); + phiDiff.push_back(phiAndNuPostProStrategies.at(i)->getPhiDiffVy()); } if (dataToCalculate == "Vz") { - nu.push_back(postProResults.at(i)->getNuVz()); - phiDiff.push_back(postProResults.at(i)->getPhiDiffVz()); + nu.push_back(phiAndNuPostProStrategies.at(i)->getNuVz()); + phiDiff.push_back(phiAndNuPostProStrategies.at(i)->getPhiDiffVz()); } } nuDiff = calcNuDiff(nu); @@ -43,9 +44,10 @@ void PhiAndNuTest::update() TestImp::update(); } -void PhiAndNuTest::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResults) +void PhiAndNuTest::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PhiAndNuTestPostProcessingStrategy> postProStrategy) { - TestImp::addSimulation(sim, simInfo, postProResults); + TestImp::addSimulation(sim, simInfo, postProStrategy); + phiAndNuPostProStrategies.push_back(postProStrategy); } std::vector<bool> PhiAndNuTest::getPassedTests() @@ -59,24 +61,45 @@ std::vector<bool> PhiAndNuTest::getPassedTests() void PhiAndNuTest::makeConsoleOutput() { colorOutput->makeNuTestOutput(nuDiffTestPassed, simInfos.at(0), simInfos.at(1), startStepCalculation, endStepCalculation, dataToCalculate, nu.at(0), nu.at(1), nuDiff.at(0), nuDiff.at(1), orderOfAccuracyNuDiff); - colorOutput->makePhiTestOutput(nuDiffTestPassed, simInfos.at(0), simInfos.at(1), startStepCalculation, endStepCalculation, dataToCalculate, phiDiff.at(0), phiDiff.at(1), orderOfAccuracyPhiDiff); + colorOutput->makePhiTestOutput(phiDiffTestPassed, simInfos.at(0), simInfos.at(1), startStepCalculation, endStepCalculation, dataToCalculate, phiDiff.at(0), phiDiff.at(1), orderOfAccuracyPhiDiff); +} + +std::string PhiAndNuTest::getDataToCalculate() +{ + return dataToCalculate; +} + +std::vector<int> PhiAndNuTest::getLx() +{ + std::vector<int> lxINT; + for (int i = 0; i < lx.size(); i++) + lxINT.push_back((int)lx.at(i)); + return lxINT; +} + +std::vector<double> PhiAndNuTest::getNu() +{ + return nu; } -std::string PhiAndNuTest::getLogFileOutput() +std::vector<double> PhiAndNuTest::getNuDiff() { - std::ostringstream oss; + return nuDiff; +} - oss << "Nu_" << lx.at(0) << "=" << nu.at(0) << std::endl; - oss << "NuDiff_" << lx.at(0) << "=" << nuDiff.at(0) << std::endl; - oss << "Nu_" << lx.at(1) << "=" << nu.at(1) << std::endl; - oss << "NuDiff_" << lx.at(1) << "=" << nuDiff.at(1) << std::endl; - oss << "OrderOfAccuracy_NuDiff_" << lx.at(0) << lx.at(1) << "=" << orderOfAccuracyNuDiff << std::endl << std::endl; +std::vector<double> PhiAndNuTest::getPhiDiff() +{ + return phiDiff; +} - oss << "PhiDiff_" << lx.at(0) << "=" << phiDiff.at(0) << std::endl; - oss << "PhiDiff_" << lx.at(1) << "=" << phiDiff.at(1) << std::endl; - oss << "OrderOfAccuracy_NuDiff_" << lx.at(0) << lx.at(1) << "=" << orderOfAccuracyPhiDiff << std::endl << std::endl; +double PhiAndNuTest::getOrderOfAccuracyNuDiff() +{ + return orderOfAccuracyNuDiff; +} - return oss.str(); +double PhiAndNuTest::getOrderOfAccuracyPhiDiff() +{ + return orderOfAccuracyPhiDiff; } PhiAndNuTest::PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation) : TestImp(colorOutput), minOrderOfAccuracy(minOrderOfAccuracy), viscosity(viscosity), dataToCalculate(dataToCalculate), startStepCalculation(startStepCalculation), endStepCalculation(endStepCalculation) diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h index ee465debd05d40a628fe9d2ff2637963199a397d..b1146ba89c1b70c95ed495c09228fb2b5b548689 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PhiAndNuTest.h @@ -8,6 +8,7 @@ #include <iostream> class FFTCalculator; +class PhiAndNuTestPostProcessingStrategy; class PhiAndNuTest : public TestImp { @@ -15,12 +16,21 @@ public: static std::shared_ptr<PhiAndNuTest> getNewInstance(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation); void update(); - void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResults); + void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PhiAndNuTestPostProcessingStrategy> postProStrategy); void evaluate(); - std::string getLogFileOutput(); std::vector< bool> getPassedTests(); void makeConsoleOutput(); + std::string getDataToCalculate(); + std::vector<int> getLx(); + std::vector<double> getNu(); + std::vector<double> getNuDiff(); + std::vector<double> getPhiDiff(); + double getOrderOfAccuracyNuDiff(); + double getOrderOfAccuracyPhiDiff(); + + + private: PhiAndNuTest(std::shared_ptr< ColorConsoleOutput> colorOutput, std::string dataToCalculate, double minOrderOfAccuracy, double viscosity, unsigned int startStepCalculation, unsigned int endStepCalculation); double calcOrderOfAccuracy(std::vector<double> data); @@ -39,6 +49,7 @@ private: bool nuDiffTestPassed; std::string dataToCalculate; + std::vector<std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategies; }; #endif diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2137a7c1ca7f4a2018d273daeaeee6d08d4f40e2 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.cpp @@ -0,0 +1,83 @@ +#include "PostProcessingStrategyPhiAndNuTest.h" + +#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" +#include "Utilities\Calculator\FFTCalculator\FFTCalculator.h" +#include "Utilities\Results\SimulationResults\SimulationResults.h" + +std::shared_ptr<PhiAndNuTestPostProcessingStrategy> PhiAndNuTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu) +{ + return std::shared_ptr<PhiAndNuTestPostProcessingStrategy>(new PhiAndNuTestPostProcessingStrategy(simResult, analyticalResult, dataToCalculatePhiAndNu, startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu)); +} + +PhiAndNuTestPostProcessingStrategy::PhiAndNuTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculatePhiAndNu(dataToCalculatePhiAndNu), startTimeStepCalculationPhiNu(startTimeStepCalculationPhiNu), endTimeStepCalculationPhiNu(endTimeStepCalculationPhiNu) +{ + isEvaluated = false; + fftCalculator = FFTCalculator::getNewInstance(simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); +} + +std::vector<std::vector<double>> PhiAndNuTestPostProcessingStrategy::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 PhiAndNuTestPostProcessingStrategy::evaluate() +{ + if (!isEvaluated) { + analyticalResult->calc(simResult); + for (int i = 0; i < dataToCalculatePhiAndNu.size(); i++) { + if (dataToCalculatePhiAndNu.at(i) == "Vx") { + fftCalculator->calc(reduceDataToTimeSteps(simResult->getVx(), startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu), false); + nuVx = fftCalculator->getNu(); + phiDiffVx = fftCalculator->getPhiDiff(); + } + if (dataToCalculatePhiAndNu.at(i) == "Vz") { + fftCalculator->calc(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu), true); + nuVz = fftCalculator->getNu(); + phiDiffVz = fftCalculator->getPhiDiff(); + } + } + } +} + +double PhiAndNuTestPostProcessingStrategy::getNuVx() +{ + return nuVx; +} + +double PhiAndNuTestPostProcessingStrategy::getNuVy() +{ + return nuVy; +} + +double PhiAndNuTestPostProcessingStrategy::getNuVz() +{ + return nuVz; +} + +double PhiAndNuTestPostProcessingStrategy::getPhiDiffVx() +{ + return phiDiffVx; +} + +double PhiAndNuTestPostProcessingStrategy::getPhiDiffVy() +{ + return phiDiffVy; +} + +double PhiAndNuTestPostProcessingStrategy::getPhiDiffVz() +{ + return phiDiffVz; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h new file mode 100644 index 0000000000000000000000000000000000000000..83eabaa24d5329cc16dce72d401d74fdcbacaa44 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNuTest.h @@ -0,0 +1,38 @@ +#ifndef PHIANDNU_TEST_POST_PROCESSING_STRATEGY_H +#define PHIANDNU_TEST_POST_PROCESSING_STRATEGY_H + +#include "Utilities\PostProcessingStrategy\PostProcessingStrategyImp.h" + +#include <memory> + +class AnalyticalResults; +class FFTCalculator; + +class PhiAndNuTestPostProcessingStrategy : public PostProcessingStrategyImp +{ +public: + static std::shared_ptr< PhiAndNuTestPostProcessingStrategy> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu , unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu); + void evaluate(); + + double getNuVx(); + double getNuVy(); + double getNuVz(); + double getPhiDiffVx(); + double getPhiDiffVy(); + double getPhiDiffVz(); + +private: + PhiAndNuTestPostProcessingStrategy(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu); + + 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> dataToCalculatePhiAndNu; + std::shared_ptr< FFTCalculator> fftCalculator; + unsigned int startTimeStepCalculationPhiNu; + unsigned int endTimeStepCalculationPhiNu; + double nuVx, nuVy, nuVz; + double phiDiffVx, phiDiffVy, phiDiffVz; + bool isEvaluated; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Tests/PhiAndNuTest/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp index bae5ff01fc67df536797cedece47b471f592e4ee..b97dfd24467dfd4d711d736fe4eba6bbf781f8d2 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp @@ -19,9 +19,14 @@ FFTCalculator::FFTCalculator(int lx, int lz, int timeStepLength) this->timeStepLength = (double)timeStepLength; } -void FFTCalculator::calc(std::vector<std::vector<double>> data) +void FFTCalculator::calc(std::vector<std::vector<double>> data, bool transposeData) { - this->data = data; + this->transposeData = transposeData; + if (!transposeData) + this->data = data; + else + this->data = transpose(data); + init(); nu = calcNu(); @@ -109,7 +114,12 @@ std::vector<double> FFTCalculator::calcAmplitudeForAllSteps() calcFFT2D(step); fftCalculated = true; } - int pos = 2 + (lx - 1); + int pos; + if (!transposeData) + pos = 2 + (lx - 1); + else + pos = 2 + (lz - 1); + for (int step = 0; step < data.size(); step++) amplitude.push_back(4.0 / (lx * lz) * sqrt(fftResultsRe.at(step).at(pos) * fftResultsRe.at(step).at(pos) + fftResultsIm.at(step).at(pos) * fftResultsIm.at(step).at(pos))); @@ -124,7 +134,12 @@ std::vector<double> FFTCalculator::calcPhiForAllSteps() calcFFT2D(step); fftCalculated = true; } - int pos = 2 + (lx - 1); + int pos; + if (!transposeData) + pos = 2 + (lx - 1); + else + pos = 2 + (lz - 1); + for (int step = 0; step < data.size(); step++) phi.push_back(atan(fftResultsIm.at(step).at(pos) / fftResultsRe.at(step).at(pos))); return phi; @@ -137,7 +152,11 @@ void FFTCalculator::calcFFT2D(unsigned int timeStep) initDataForFFT(in, timeStep); - fftw_plan p = fftw_plan_dft_2d(lz, lx, in, out, FFTW_FORWARD, FFTW_ESTIMATE); + fftw_plan p; + if (!transposeData) + p = fftw_plan_dft_2d(lz, lx, in, out, FFTW_FORWARD, FFTW_ESTIMATE); + else + p = fftw_plan_dft_2d(lx, lz, in, out, FFTW_FORWARD, FFTW_ESTIMATE); fftw_execute(p); setFFTResults(out, timeStep); @@ -147,6 +166,47 @@ void FFTCalculator::calcFFT2D(unsigned int timeStep) fftw_free(out); } +std::vector<std::vector<double>> FFTCalculator::transpose(std::vector<std::vector<double>> dataToTranspose) +{ + std::vector< std::vector< std::vector< double>>> dataInLx; + dataInLx.resize(dataToTranspose.size()); + for (int i = 0; i < dataInLx.size(); i++) { + dataInLx.at(i).resize(lz); + for(int j = 0; j < dataInLx.at(i).size(); j++) + dataInLx.at(i).at(j).resize(lx); + } + for (int timeStep = 0; timeStep < dataInLx.size(); timeStep++) { + for (int posInLZ = 0; posInLZ < lz; posInLZ++) + for (int posInLX = 0; posInLX < lx; posInLX++) + dataInLx.at(timeStep).at(posInLZ).at(posInLX) = dataToTranspose.at(timeStep).at(posInLX + posInLZ*lx); + } + + std::vector< std::vector< std::vector< double>>> dataInLz; + dataInLz.resize(dataToTranspose.size()); + for (int i = 0; i < dataInLx.size(); i++) { + dataInLz.at(i).resize(lx); + for (int j = 0; j < dataInLz.at(i).size(); j++) + dataInLz.at(i).at(j).resize(lz); + } + + for (int timeStep = 0; timeStep < dataInLz.size(); timeStep++) { + for (int posInLX = 0; posInLX < lx; posInLX++) + for (int posInLZ = 0; posInLZ < lz; posInLZ++) + dataInLz.at(timeStep).at(posInLX).at(posInLZ) = dataInLx.at(timeStep).at(posInLZ).at(posInLX); + } + + std::vector< std::vector< double>> result; + result.resize(dataToTranspose.size()); + + for (int timeStep = 0; timeStep < dataInLz.size(); timeStep++) { + result.at(timeStep).resize(0); + for (int posInLX = 0; posInLX < lx; posInLX++) + for (int posInLZ = 0; posInLZ < lz; posInLZ++) + result.at(timeStep).push_back(dataInLz.at(timeStep).at(posInLX).at(posInLZ)); + } + return result; +} + void FFTCalculator::initDataForFFT(fftw_complex * input, unsigned int step) { diff --git a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h index ac584517fe61f7874455106f29a0576d9423ac81..4a427770ea3e003d381a594bef01b4f08a3f6f8d 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h @@ -15,7 +15,7 @@ class FFTCalculator public: static std::shared_ptr<FFTCalculator> getNewInstance(int lx, int lz, int timeStepLength); - void calc(std::vector<std::vector<double>> data); + void calc(std::vector<std::vector<double>> data, bool transposeData); double getNu(); double getPhiDiff(); @@ -31,6 +31,7 @@ private: std::vector<double> calcLogAmplitudeForAllSteps(); std::vector<double> calcAmplitudeForAllSteps(); void calcFFT2D(unsigned int step); + std::vector<std::vector<double>> transpose(std::vector<std::vector<double>>); void initDataForFFT(fftw_complex* input, unsigned int step); void setFFTResults(fftw_complex* result, unsigned int step); @@ -39,6 +40,7 @@ private: std::vector<std::vector<double>> fftResultsRe; bool fftCalculated; + bool transposeData; double lx, lz; double timeStepLength; double nu; diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp index 211971987befe13e5ce7977be487f653a440aa5b..ba530e23b43cd9e7689147ac5bab0fc38027c10c 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.cpp @@ -3,9 +3,14 @@ #define _USE_MATH_DEFINES #include <math.h> -std::shared_ptr<L2NormCalculator> L2NormCalculator::getNewInstance() +#include <iostream> + +std::shared_ptr<L2NormCalculator> L2NormCalculator::getInstance() { - return std::shared_ptr<L2NormCalculator>(new L2NormCalculator()); + static std::shared_ptr<L2NormCalculator> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<L2NormCalculator>(new L2NormCalculator()); + return uniqueInstance; } double L2NormCalculator::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level) diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h index f914ecba563e714a40d61fb9d718710b525ac9c7..b4dd6f775980243bea3ad061182f64b64aab6909 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h @@ -7,7 +7,7 @@ class L2NormCalculator { public: - static std::shared_ptr< L2NormCalculator> getNewInstance(); + static std::shared_ptr< L2NormCalculator> getInstance(); double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level); diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h index 84fe65a36df61f74a019a09689be719c07955def..9bad6f9c28901b916c0cbd87bdd6cf781c2f4772 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h @@ -12,6 +12,7 @@ public: virtual void makeNuTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo1, std::shared_ptr<SimulationInfo> simInfo2, unsigned int startTimeStep, unsigned int endTimeStep, std::string dataToCalc, double nu1, double nu2, double nuDiff1, double nuDiff2, double ooa) = 0; virtual void makePhiTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo1, std::shared_ptr<SimulationInfo> simInfo2, unsigned int startTimeStep, unsigned int endTimeStep, std::string dataToCalc, double phiDiff1, double phiDiff2, double ooa) = 0; virtual void makeL2NormTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc, double testWert1, double testWert2, double testWert3) = 0; + virtual void makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep, double l2NormBasicKernel, double l2NormDivergentKernel, double l2NormBetweenKernel) = 0; virtual void makeSimulationHeadOutput(std::shared_ptr< SimulationInfo> simInfo) = 0; virtual void makeFinalTestOutputHead(int numberOfPassedTests, int numberOfTests) = 0; virtual void makeFinalTestOutputFoot(int numberOfPassedTests, int numberOfTests) = 0; diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp index e9c0b4f08a12b746e557dfbb29083bb7a2e816fd..6a71ae5433c071c5acc647e9bc3bccf2031b0e7d 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp @@ -203,6 +203,64 @@ void ColorConsoleOutputImp::makeL2NormTestOutput(bool testPassed, std::shared_pt printTestEnd(testPassed); } +void ColorConsoleOutputImp::makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep, double l2NormBasicKernel, double l2NormDivergentKernel, double l2NormBetweenKernel) +{ + setColor(testPassed); + printTestStart(); + + printColor(""); + printColor("L2 Norm Between Kernels Test"); + printColor(""); + + std::ostringstream oss; + oss << "Basic Kernel: " << basicSimInfo->getKernelName(); + print(oss.str()); + oss.str(std::string()); + oss << "Divergent Kernel: " << divergentSimInfo->getKernelName(); + print(oss.str()); + oss.str(std::string()); + + oss << "Viscosity: " << basicSimInfo->getViscosity(); + print(oss.str()); + oss.str(std::string()); + + print(oss.str()); + oss << basicSimInfo->getSimulationName(); + print(oss.str()); + oss.str(std::string()); + + oss << "L: " << basicSimInfo->getLx() << basicSimInfo->getSimulationParameterString(); + print(oss.str()); + oss.str(std::string()); + + print(oss.str()); + oss << "DataToCalculate: " << dataToCalc; + print(oss.str()); + oss.str(std::string()); + oss << "TimeStep: " << timeStep; + print(oss.str()); + oss.str(std::string()); + + print(oss.str()); + oss << "L2Norm BasicKernel: " << l2NormBasicKernel; + print(oss.str()); + oss.str(std::string()); + + oss << "L2Norm DivergentKernel: " << l2NormDivergentKernel; + print(oss.str()); + oss.str(std::string()); + + oss << "L2NormDiff: " << l2NormBetweenKernel; + print(oss.str()); + oss.str(std::string()); + + printColor(""); + printColor("L2 Norm Between Kernels Test"); + printColor(""); + + printTestEnd(testPassed); +} + void ColorConsoleOutputImp::makeSimulationHeadOutput(std::shared_ptr< SimulationInfo> simInfo) { std::ostringstream ossLine0; diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h index dd3ca9638afef88113419a95a33f495456a9f591..aac39c51d463c2f355e41316438ad8b562508edd 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h @@ -36,6 +36,7 @@ public: void makeNuTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo1, std::shared_ptr<SimulationInfo> simInfo2, unsigned int startTimeStep, unsigned int endTimeStep, std::string dataToCalc, double nu1, double nu2, double nuDiff1, double nuDiff2, double ooa); void makePhiTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo1, std::shared_ptr<SimulationInfo> simInfo2, unsigned int startTimeStep, unsigned int endTimeStep, std::string dataToCalc, double phiDiff1, double phiDiff2, double ooa); void makeL2NormTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc, double testWert1, double testWert2, double testWert3); + void makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep, double l2NormBasicKernel, double l2NormDivergentKernel, double l2NormBetweenKernel); void makeSimulationHeadOutput(std::shared_ptr< SimulationInfo> simInfo); void makeFinalTestOutputHead(int numberOfPassedTests, int numberOfTests); void makeFinalTestOutputFoot(int numberOfPassedTests, int numberOfTests); diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h index 70915fffcc01efb4f84d27a225f8be29e4d4ae4e..cc08d5203c63d088af014531fda4291751363daf 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigData.h @@ -10,29 +10,38 @@ struct ConfigDataStruct std::vector< std::string> kernelsToTest; unsigned int numberOfTimeSteps; - unsigned int basisTimeStepLength; std::vector<double> viscosity; - std::vector<double> amplitudeTGV, u0TGV; + std::vector<double> amplitudeTGVux, u0TGVux; + double l0TGVux; + std::vector<double> amplitudeTGVuz, v0TGVuz; + double l0TGVuz; + std::vector<int> basisTimeStepLengthTGVux, basisTimeStepLengthTGVuz; + std::vector<double> u0SW, v0SW; - + std::vector<int> basisTimeStepLengthSW; + double l0SW; + unsigned int ySliceForCalculation; double minOrderOfAccuracy; std::vector<std::string> dataToCalcPhiAndNuTest; unsigned int startTimeStepCalculationPhiNu; unsigned int endTimeStepCalculationPhiNu; - bool nuAndPhiTestTGV; - bool nuAndPhiTestSW; + bool nuAndPhiTest; double maxL2NormDiff; std::vector<std::string> dataToCalcL2Test; unsigned int basicTimeStepL2Norm; unsigned int divergentTimeStepL2Norm; - bool l2NormTestTGV; - bool l2NormTestSW; + bool l2NormTest; - std::vector< bool> tgv; + bool l2NormBetweenKernelTest; + std::string basicKernelL2NormTest; + std::vector< int> timeStepsL2NormBetweenKernel; + std::vector< std::string> dataToCalcL2NormBetweenKernel; + + std::vector< bool> tgvUx, tgvUz; std::vector< bool> sw; unsigned int numberOfGridLevels; @@ -45,9 +54,10 @@ struct ConfigDataStruct std::string logFilePath; double rho0; - double l0; std::vector< double> lx; std::vector< double> lz; + bool writeAnalyticalToVTK; + }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp index d09cd4ec7b4855424de4b6c345e7b110d3005d3a..307c6831b1dc49c6ec4bfd61d8d4cb6daa60afac 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp @@ -29,7 +29,6 @@ ConfigFileReader::ConfigFileReader(const std::string aFilePath) configData->lz.at(3) = configData->lx.at(3) * 3.0 / 2.0; configData->lz.at(4) = configData->lx.at(4) * 3.0 / 2.0; - configData->l0 = 32.0; configData->rho0 = 1.0; readConfigFile(aFilePath); @@ -46,25 +45,37 @@ void ConfigFileReader::readConfigFile(const std::string aFilePath) configData->devices = StringUtil::toIntVector(input->getValue("Devices")); configData->kernelsToTest = StringUtil::toStringVector(input->getValue("KernelsToTest")); + configData->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); configData->viscosity = StringUtil::toDoubleVector(input->getValue("Viscosity")); configData->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy")); configData->dataToCalcPhiAndNuTest = StringUtil::toStringVector(input->getValue("DataToCalc_PhiAndNu")); configData->startTimeStepCalculationPhiNu = StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiNu")); configData->endTimeStepCalculationPhiNu = StringUtil::toInt(input->getValue("EndTimeStepCalculation_PhiNu")); + configData->nuAndPhiTest = StringUtil::toBool(input->getValue("PhiAndNuTest")); + configData->l2NormTest = StringUtil::toBool(input->getValue("L2NormTest")); configData->maxL2NormDiff = StringUtil::toDouble(input->getValue("MaxL2NormDiff")); configData->dataToCalcL2Test = StringUtil::toStringVector(input->getValue("DataToCalc_L2")); configData->basicTimeStepL2Norm = StringUtil::toInt(input->getValue("BasicTimeStep_L2")); configData->divergentTimeStepL2Norm = StringUtil::toInt(input->getValue("DivergentTimeStep_L2")); - configData->amplitudeTGV = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV")); - configData->u0TGV = StringUtil::toDoubleVector(input->getValue("u0_TGV")); - configData->nuAndPhiTestTGV = StringUtil::toBool(input->getValue("PhiAndNuTest_TGV")); - configData->l2NormTestTGV = StringUtil::toBool(input->getValue("L2NormTest_TGV")); + configData->basisTimeStepLengthTGVux = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Ux")); + configData->amplitudeTGVux = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Ux")); + configData->u0TGVux = StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")); + configData->l0TGVux = StringUtil::toInt(input->getValue("l0_TGV_Ux")); + configData->basisTimeStepLengthTGVuz = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_TGV_Uz")); + configData->amplitudeTGVuz = StringUtil::toDoubleVector(input->getValue("Amplitude_TGV_Uz")); + configData->v0TGVuz = StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")); + configData->l0TGVuz = StringUtil::toInt(input->getValue("l0_TGV_Uz")); + + configData->basisTimeStepLengthSW = StringUtil::toIntVector(input->getValue("BasisTimeStepLength_SW")); configData->v0SW = StringUtil::toDoubleVector(input->getValue("v0_SW")); configData->u0SW = StringUtil::toDoubleVector(input->getValue("u0_SW")); - configData->nuAndPhiTestSW = StringUtil::toBool(input->getValue("PhiAndNuTest_SW")); - configData->l2NormTestSW = StringUtil::toBool(input->getValue("L2NormTest_SW")); - configData->numberOfTimeSteps = StringUtil::toInt(input->getValue("NumberOfTimeSteps")); - configData->basisTimeStepLength = StringUtil::toInt(input->getValue("BasisTimeStepLength")); + configData->l0SW = StringUtil::toInt(input->getValue("l0_SW")); + + configData->l2NormBetweenKernelTest = StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest")); + configData->basicKernelL2NormTest = StringUtil::toString(input->getValue("BasicKernel_L2NormBetweenKernels")); + configData->timeStepsL2NormBetweenKernel = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); + configData->dataToCalcL2NormBetweenKernel = StringUtil::toStringVector(input->getValue("DataToCalc_L2NormBetweenKernels")); + configData->grids.resize(5); configData->grids.at(0) = input->getValue("GridPath32"); configData->grids.at(1) = input->getValue("GridPath64"); @@ -74,16 +85,23 @@ void ConfigFileReader::readConfigFile(const std::string aFilePath) configData->numberOfGridLevels = StringUtil::toInt(input->getValue("NumberOfGridLevels")); configData->maxLevel = configData->numberOfGridLevels - 1; configData->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - configData->writeFiles = StringUtil::toBool(input->getValue("WriteFiles")); + configData->writeFiles = StringUtil::toBool(input->getValue("WriteVTKFiles")); + configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue("WriteAnalyResultsToVTK")); configData->filePath = input->getValue("PathForFileWriting"); configData->startStepFileWriter = StringUtil::toInt(input->getValue("StartStepFileWriter")); - configData->logFilePath = input->getValue("PathLogFile");; - configData->tgv.resize(5); - configData->tgv.at(0) = StringUtil::toBool(input->getValue("TaylorGreenVortex32")); - configData->tgv.at(1) = StringUtil::toBool(input->getValue("TaylorGreenVortex64")); - configData->tgv.at(2) = StringUtil::toBool(input->getValue("TaylorGreenVortex128")); - configData->tgv.at(3) = StringUtil::toBool(input->getValue("TaylorGreenVortex256")); - configData->tgv.at(4) = StringUtil::toBool(input->getValue("TaylorGreenVortex512")); + configData->logFilePath = input->getValue("PathLogFile"); + configData->tgvUx.resize(5); + configData->tgvUx.at(0) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx32")); + configData->tgvUx.at(1) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx64")); + configData->tgvUx.at(2) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx128")); + configData->tgvUx.at(3) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx256")); + configData->tgvUx.at(4) = StringUtil::toBool(input->getValue("TaylorGreenVortexUx512")); + configData->tgvUz.resize(5); + configData->tgvUz.at(0) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz32")); + configData->tgvUz.at(1) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz64")); + configData->tgvUz.at(2) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz128")); + configData->tgvUz.at(3) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz256")); + configData->tgvUz.at(4) = StringUtil::toBool(input->getValue("TaylorGreenVortexUz512")); configData->sw.resize(5); configData->sw.at(0) = StringUtil::toBool(input->getValue("ShearWave32")); configData->sw.at(1) = StringUtil::toBool(input->getValue("ShearWave64")); @@ -103,12 +121,17 @@ std::shared_ptr<ConfigDataStruct> ConfigFileReader::getConfigData() void ConfigFileReader::checkConfigFileData() { - if (configData->u0TGV.size() != configData->amplitudeTGV.size()) { - std::cout << "Length u0_TGV is unequal to Lenght Amplitude_TGV!" << std::endl << std::flush; + if (configData->u0TGVux.size() != configData->amplitudeTGVux.size() || configData->u0TGVux.size() != configData->basisTimeStepLengthTGVux.size()) { + std::cout << "Length u0_TGV_U0 is unequal to Lenght Amplitude_TGV_U0 or BasisTimeStepLength_TGV_U0!" << std::endl << std::flush; + exit(1); + } + + if (configData->v0TGVuz.size() != configData->amplitudeTGVuz.size() || configData->v0TGVuz.size() != configData->basisTimeStepLengthTGVuz.size()) { + std::cout << "Length v0_TGV_V0 is unequal to Lenght Amplitude_TGV_V0 or BasisTimeStepLength_TGV_V0!" << std::endl << std::flush; exit(1); } - if (configData->u0SW.size() != configData->v0SW.size()) { + if (configData->u0SW.size() != configData->v0SW.size() || configData->u0SW.size() != configData->basisTimeStepLengthSW.size()) { std::cout << "Length u0_SW is unequal to Lenght v0_SW!" << std::endl << std::flush; exit(1); } diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriter.h b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriter.h new file mode 100644 index 0000000000000000000000000000000000000000..3af764aeeaa8b6f29831ead54b1f312d3be54e9f --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriter.h @@ -0,0 +1,17 @@ +#ifndef ANALYTICAL_RESULTS_2D_TO_VTK_WRITER_H +#define ANALYTICAL_RESULTS_2D_TO_VTK_WRITER_H + +#include <memory> +#include <string> + +class Parameter; +class AnalyticalResults; + +class AnalyticalResults2DToVTKWriter +{ +public: + + virtual void writeAnalyticalResult(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult) = 0; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ce4067e99098783bb7c7022fd2c6f81c09a9bc7 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp @@ -0,0 +1,163 @@ +#include "AnalyticalResults2DToVTKWriterImp.h" + +#include <stdio.h> +#include <fstream> +#include <sstream> +#include <cmath> + +#include <utilities/StringUtil/StringUtil.h> + +#include "Parameter/Parameter.h" + +#include "LBM/LB.h" +#include "LBM/D3Q27.h" + +#include <VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h> + +#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" +#include <mpi.h> + + +std::shared_ptr<AnalyticalResults2DToVTKWriterImp> AnalyticalResults2DToVTKWriterImp::getInstance() +{ + static std::shared_ptr<AnalyticalResults2DToVTKWriterImp> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<AnalyticalResults2DToVTKWriterImp>(new AnalyticalResults2DToVTKWriterImp()); + return uniqueInstance; +} + +void AnalyticalResults2DToVTKWriterImp::writeAnalyticalResult(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult) +{ + std::cout << "Write Analytical Result To VTK-Files" << std::endl; + for (int level = para->getCoarse(); level <= para->getFine(); level++) { +#pragma omp parallel for + for (int timeStep = 0; timeStep < analyticalResult->getNumberOfTimeSteps(); timeStep++) { + const unsigned int numberOfParts = para->getParH(level)->size_Mat_SP / para->getlimitOfNodesForVTK() + 1; + std::vector<std::string> fname; + unsigned int time = analyticalResult->getTimeSteps().at(timeStep)*analyticalResult->getTimeStepLength(); + for (int j = 1; j <= numberOfParts; j++) + fname.push_back(para->getFName() + "AnalyticalResult\\Analytical_cells_bin_lev_" + StringUtil::toString<int>(level) + "_ID_" + StringUtil::toString<int>(para->getMyID()) + "_Part_" + StringUtil::toString<int>(j) + "_t_" + StringUtil::toString<int>(time) + ".vtk"); + std::cout << "\t Write TimeStep=" << timeStep << " t=" << time << "..."; + writeTimeStep(para, analyticalResult, level, fname, timeStep); + std::cout << "done." << std::endl; + } + } + std::cout << std::endl; +} + + +void AnalyticalResults2DToVTKWriterImp::writeTimeStep(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult, int level, std::vector<std::string> & fname, int timeStep) +{ + std::vector< UbTupleFloat3 > nodes; + std::vector< UbTupleUInt8 > cells; + std::vector< std::string > nodedatanames; + nodedatanames.push_back("press"); + nodedatanames.push_back("rho"); + nodedatanames.push_back("vx1"); + nodedatanames.push_back("vx2"); + nodedatanames.push_back("vx3"); + nodedatanames.push_back("geo"); + unsigned int number1, number2, number3, number4, number5, number6, number7, number8; + uint dn1, dn2, dn3, dn4, dn5, dn6, dn7, dn8; + bool neighborsAreFluid; + unsigned int startpos = 0; + unsigned int endpos = 0; + unsigned int sizeOfNodes = 0; + std::vector< std::vector< double > > nodedata(nodedatanames.size()); + + maxX = para->getGridX().at(level); + maxY = para->getGridY().at(level); + maxZ = para->getGridZ().at(level); + + std::vector<double> press = analyticalResult->getPress()[timeStep]; + std::vector<double> rho = analyticalResult->getRho()[timeStep]; + std::vector<double> vx = analyticalResult->getVx()[timeStep]; + std::vector<double> vy = analyticalResult->getVy()[timeStep]; + std::vector<double> vz = analyticalResult->getVz()[timeStep]; + + for (unsigned int part = 0; part < fname.size(); part++){ + if (((part + 1)*para->getlimitOfNodesForVTK()) > para->getParH(level)->size_Mat_SP) + sizeOfNodes = para->getParH(level)->size_Mat_SP - (part * para->getlimitOfNodesForVTK()); + else + sizeOfNodes = para->getlimitOfNodesForVTK(); + + ////////////////////////////////////////////////////////////////////////// + startpos = part * para->getlimitOfNodesForVTK(); + endpos = startpos + sizeOfNodes; + ////////////////////////////////////////////////////////////////////////// + cells.clear(); + nodes.resize(sizeOfNodes); + nodedata[0].resize(sizeOfNodes); + nodedata[1].resize(sizeOfNodes); + nodedata[2].resize(sizeOfNodes); + nodedata[3].resize(sizeOfNodes); + nodedata[4].resize(sizeOfNodes); + nodedata[5].resize(sizeOfNodes); + ////////////////////////////////////////////////////////////////////////// + for (unsigned int pos = startpos; pos < endpos; pos++) + { + if (para->getParH(level)->geoSP[pos] == GEO_FLUID) + { + ////////////////////////////////////////////////////////////////////////// + double x1 = para->getParH(level)->coordX_SP[pos]; + double x2 = para->getParH(level)->coordY_SP[pos]; + double x3 = para->getParH(level)->coordZ_SP[pos]; + ////////////////////////////////////////////////////////////////////////// + number1 = pos; + dn1 = pos - startpos; + neighborsAreFluid = true; + ////////////////////////////////////////////////////////////////////////// + nodes[dn1] = (makeUbTuple((float)(x1), (float)(x2), (float)(x3))); + + int numberInResults = CoordResults2DTo1D(x1 - 1.0, x3 - 1.0); + nodedata[0][dn1] = press[numberInResults]; + nodedata[1][dn1] = rho[numberInResults]; + nodedata[2][dn1] = vx[numberInResults]; + nodedata[3][dn1] = vy[numberInResults]; + nodedata[4][dn1] = vz[numberInResults]; + nodedata[5][dn1] = (double)para->getParH(level)->geoSP[pos]; + ////////////////////////////////////////////////////////////////////////// + number2 = para->getParH(level)->neighborX_SP[number1]; + number3 = para->getParH(level)->neighborY_SP[number2]; + number4 = para->getParH(level)->neighborY_SP[number1]; + number5 = para->getParH(level)->neighborZ_SP[number1]; + number6 = para->getParH(level)->neighborZ_SP[number2]; + number7 = para->getParH(level)->neighborZ_SP[number3]; + number8 = para->getParH(level)->neighborZ_SP[number4]; + ////////////////////////////////////////////////////////////////////////// + if (para->getParH(level)->geoSP[number2] != GEO_FLUID || + para->getParH(level)->geoSP[number3] != GEO_FLUID || + para->getParH(level)->geoSP[number4] != GEO_FLUID || + para->getParH(level)->geoSP[number5] != GEO_FLUID || + para->getParH(level)->geoSP[number6] != GEO_FLUID || + para->getParH(level)->geoSP[number7] != GEO_FLUID || + para->getParH(level)->geoSP[number8] != GEO_FLUID) neighborsAreFluid = false; + ////////////////////////////////////////////////////////////////////////// + if (number2 > endpos || + number3 > endpos || + number4 > endpos || + number5 > endpos || + number6 > endpos || + number7 > endpos || + number8 > endpos) neighborsAreFluid = false; + ////////////////////////////////////////////////////////////////////////// + dn2 = number2 - startpos; + dn3 = number3 - startpos; + dn4 = number4 - startpos; + dn5 = number5 - startpos; + dn6 = number6 - startpos; + dn7 = number7 - startpos; + dn8 = number8 - startpos; + ////////////////////////////////////////////////////////////////////////// + if (neighborsAreFluid) + cells.push_back(makeUbTuple(dn1, dn2, dn3, dn4, dn5, dn6, dn7, dn8)); + } + } + WbWriterVtkXmlBinary::getInstance()->writeOctsWithNodeData(fname[part], nodes, cells, nodedatanames, nodedata); + } +} + +int AnalyticalResults2DToVTKWriterImp::CoordResults2DTo1D(int x, int z) +{ + return z * (maxX - 1) + x; +} diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h new file mode 100644 index 0000000000000000000000000000000000000000..b74e5bd27d43f851d573188d9239371299897706 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h @@ -0,0 +1,25 @@ +#ifndef ANALYTICAL_RESULTS_2D_TO_VTK_WRITER_IMP_H +#define ANALYTICAL_RESULTS_2D_TO_VTK_WRITER_IMP_H + +#include "AnalyticalResults2DToVTKWriter.h" + +#include <vector> + + +class AnalyticalResults2DToVTKWriterImp : public AnalyticalResults2DToVTKWriter +{ +public: + static std::shared_ptr< AnalyticalResults2DToVTKWriterImp> getInstance(); + + void writeAnalyticalResult(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult); + +private: + AnalyticalResults2DToVTKWriterImp() {}; + + void writeTimeStep(std::shared_ptr<Parameter> para, std::shared_ptr<AnalyticalResults> analyticalResult, int level, std::vector<std::string> & fname, int timeStep); + int CoordResults2DTo1D(int x, int z); + + std::shared_ptr<Parameter> para; + int maxX, maxY, maxZ; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/package.include b/targets/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.cpp b/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.cpp index d9fda5e3806ffbc1bb1b55dad09c0bd93888914a..c31f8cbea82441eb41d2e39e96e502504d5fa5dd 100644 --- a/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.cpp +++ b/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.cpp @@ -9,9 +9,9 @@ void InitialConditionImp::setParameter(std::shared_ptr<Parameter> para) void InitialConditionImp::init(const int level) { - XCoordstopnode = para->getGridX().at(level) - 1.0 + 0.5; - YCoordstopnode = para->getGridY().at(level) - 1.0 + 0.5; - ZCoordstopnode = para->getGridZ().at(level) - 1.0 + 0.5; + XCoordStopNode = para->getGridX().at(level) - 1.0 + 0.5; + YCoordStopNode = para->getGridY().at(level) - 1.0 + 0.5; + ZCoordStopNode = para->getGridZ().at(level) - 1.0 + 0.5; } real InitialConditionImp::getXCoord(int i, int level) diff --git a/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.h b/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.h index e499dfeef335181522b59780b612710dc83cba40..f82ad6a9f2f6a690917c2710e40950c7d607faae 100644 --- a/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.h +++ b/targets/tests/NumericalTests/Utilities/InitialCondition/InitialConditionImp.h @@ -3,8 +3,6 @@ #include "InitialCondition.h" -#include "VirtualFluids_GPU/LBM/LB.h" - #include <vector> #include <memory> @@ -28,7 +26,7 @@ protected: real getZCoord(int i, int level); std::shared_ptr<Parameter> para; - real XCoordstopnode, YCoordstopnode, ZCoordstopnode; + real XCoordStopNode, YCoordStopNode, ZCoordStopNode; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp index 514572fa45829ef1bc0fa2fa42af1958b3db050f..a16468a47b78d65f3f800816485b42c0e233edc5 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.cpp @@ -1,21 +1,22 @@ #include "BasicSimulationInfo.h" -std::shared_ptr<BasicSimulationInfo> BasicSimulationInfo::getNewInstance(int numberOfTimeSteps, int basisTimeStepLength, double viscosity) +std::shared_ptr<BasicSimulationInfo> BasicSimulationInfo::getNewInstance(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, std::string kernelName) { - return std::shared_ptr<BasicSimulationInfo>(new BasicSimulationInfo(numberOfTimeSteps, basisTimeStepLength, viscosity)); + return std::shared_ptr<BasicSimulationInfo>(new BasicSimulationInfo(numberOfTimeSteps, viscosity, basicTimeStepLength, kernelName)); } std::string BasicSimulationInfo::getOutput() { makeCenterHead("Basic Simulation Information"); - oss << "NumberOfTimeSteps: " << numberOfTimeSteps << std::endl; - oss << "BasisTimeStepLength: " << basisTimeStepLength << std::endl; - oss << "Viscosity: " << viscosity << std::endl; + oss << "Kernel=" << kernelName << std::endl; + oss << "NumberOfTimeSteps=" << numberOfTimeSteps << std::endl; + oss << "Viscosity=" << viscosity << std::endl; + oss << "BasisTimeStepLength=" << basicTimeStepLength << std::endl; oss << std::endl; return oss.str(); } -BasicSimulationInfo::BasicSimulationInfo(int numberOfTimeSteps, int basisTimeStepLength, double viscosity):numberOfTimeSteps(numberOfTimeSteps), basisTimeStepLength(basisTimeStepLength), viscosity(viscosity) +BasicSimulationInfo::BasicSimulationInfo(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, std::string kernelName):numberOfTimeSteps(numberOfTimeSteps), viscosity(viscosity), basicTimeStepLength(basicTimeStepLength), kernelName(kernelName) { } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.h index d2d881a29147941875a220cc97b3a900a9b928b0..7fa6c0c3bc0d894ebb9046174eba4d2142387c26 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicSimulationInfo/BasicSimulationInfo.h @@ -8,15 +8,16 @@ class BasicSimulationInfo : public LogFileInformationImp { public: - static std::shared_ptr<BasicSimulationInfo> getNewInstance(int numberOfTimeSteps, int basisTimeStepLength, double viscosity); + static std::shared_ptr<BasicSimulationInfo> getNewInstance(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, std::string kernelName); std::string getOutput(); private: BasicSimulationInfo() {}; - BasicSimulationInfo(int numberOfTimeSteps, int basisTimeStepLength, double viscosity); + BasicSimulationInfo(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, std::string kernelName); int numberOfTimeSteps; - int basisTimeStepLength; + int basicTimeStepLength; double viscosity; + std::string kernelName; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h index 2a20d66dcb10a122b04c790aabcfc9d455e0f010..b54e19812bb204411e0c53d9a8aa8dce8595941f 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/SimulationLogFileInformation/SimulationLogFileInformation.h @@ -8,7 +8,8 @@ class SimulationLogFileInformation : public LogFileInformation { public: - virtual std::string getFilePathExtension() = 0; + virtual std::string getFilePathExtensionOne() = 0; + virtual std::string getFilePathExtensionTwo() = 0; private: diff --git a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp index e8298ca38f0833e457ee5ac1a7100c126205cdd2..2ab9209b993f561ea7f66d06595b98a77634ac4e 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.cpp @@ -11,10 +11,10 @@ #include <ctime> #include <experimental/filesystem> -LogFileWriterImp::LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int basisTimeStepLength, int startStepCalculation) : kernelName(kernelName), viscosity(viscosity) +LogFileWriterImp::LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength) : kernelName(kernelName), viscosity(viscosity) { logFileInfo.push_back(LogFileHead::getNewInstance(devices)); - logFileInfo.push_back(BasicSimulationInfo::getNewInstance(numberOfTimeSteps, basisTimeStepLength, viscosity)); + logFileInfo.push_back(BasicSimulationInfo::getNewInstance(numberOfTimeSteps, viscosity, basicTimeStepLength, kernelName)); this->simLogInfo = simLogInfo; logFileInfo.push_back(this->simLogInfo); logFileInfo.push_back(logFileTimeInfo); @@ -22,19 +22,16 @@ LogFileWriterImp::LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInfo logFileInfo.push_back(testLogFiles.at(i)); } -std::shared_ptr<LogFileWriterImp> LogFileWriterImp::getNewInstance(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int basisTimeStepLength, int startStepCalculation) +std::shared_ptr<LogFileWriterImp> LogFileWriterImp::getNewInstance(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength) { - return std::shared_ptr<LogFileWriterImp>(new LogFileWriterImp(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, devices, numberOfTimeSteps, basisTimeStepLength, startStepCalculation)); + return std::shared_ptr<LogFileWriterImp>(new LogFileWriterImp(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, devices, numberOfTimeSteps, startStepCalculation, basicTimeStepLength)); } void LogFileWriterImp::writeLogFile(std::string basicFilePath) { logFilePath = buildFilePath(basicFilePath); - logFile.open(logFilePath, std::ios::out); - bool test = logFile.is_open(); - for (int i = 0; i < logFileInfo.size(); i++) logFile << logFileInfo.at(i)->getOutput(); } @@ -52,7 +49,7 @@ std::string LogFileWriterImp::calcDateAndTime() std::string LogFileWriterImp::buildFilePath(std::string basicFilePath) { std::ostringstream filePath; - filePath << basicFilePath << kernelName << "\\viscosity_" << viscosity << "\\" << simLogInfo->getFilePathExtension(); + filePath << basicFilePath << simLogInfo->getFilePathExtensionOne() << "viscosity_" << viscosity << "\\" << simLogInfo->getFilePathExtensionTwo() << kernelName; std::experimental::filesystem::path dir(filePath.str()); if (!(std::experimental::filesystem::exists(dir))) diff --git a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h index a2b46cbfded696ad7c37844892485d60b5b2a566..83db69b7d592592766b6171eb86cf0f192bf8cf7 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h +++ b/targets/tests/NumericalTests/Utilities/LogFileWriter/LogFileWriterImp.h @@ -19,12 +19,12 @@ public: std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, - double viscosity, std::vector<int> devices, int numberOfTimeSteps, int basisTimeStepLength, int startStepCalculation); + double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength); void writeLogFile(std::string basicFilePath); private: - LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int basisTimeStepLength, int startStepCalculation); + LogFileWriterImp(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, std::vector<int> devices, int numberOfTimeSteps, int startStepCalculation, int basicTimeStepLength); std::string calcDateAndTime(); std::string buildFilePath(std::string basicFilePath); diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp index 72546151a8ba62c8531e2a428722e360b311f3c6..200660eada703f7d448453d55c327a55935ff1ce 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp @@ -1,21 +1,32 @@ #include "NumericalTestFactoryImp.h" -#include "Simulation/TaylorGreenVortex/SimulationParameter/TaylorGreenSimulationParameter.h" -#include "Simulation/TaylorGreenVortex/LogFileInformation/TaylorGreenLogFileInformation.h" -#include "Simulation\TaylorGreenVortex\SimulationInfo\TaylorGreenVortexSimulationInfo.h" -#include "Simulation\TaylorGreenVortex\AnalyticalResults\TaylorGreenVortexAnalyticalResults.h" +#include "Simulations/TaylorGreenVortexUx/SimulationParameter/SimulationParameterTaylorGreenVortexUx.h" +#include "Simulations/TaylorGreenVortexUx/LogFileInformation/LogFileInformationTaylorGreenVortexUx.h" +#include "Simulations\TaylorGreenVortexUx\SimulationInfo\SimulationInfoTaylorGreenVortexUx.h" +#include "Simulations\TaylorGreenVortexUx\AnalyticalResults\AnalyticalResultsTaylorGreenVortexUx.h" -#include "Simulation/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h" -#include "Simulation/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h" -#include "Simulation\ShearWave\SimulationInfo\ShearWaveSimulationInfo.h" -#include "Simulation\ShearWave\AnalyticalResults\ShearWaveAnalyticalResults.h" +#include "Simulations/TaylorGreenVortexUz/SimulationParameter/SimulationParameterTaylorGreenVortexUz.h" +#include "Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenvortexUz.h" +#include "Simulations\TaylorGreenVortexUz\SimulationInfo\SimulationInfoTaylorGreenVortexUz.h" +#include "Simulations\TaylorGreenVortexUz\AnalyticalResults\AnalyticalResultsTaylorGreenVortexUz.h" + +#include "Simulations/ShearWave/SimulationParameter/ShearWaveSimulationParameter.h" +#include "Simulations/ShearWave/LogFileInformation/ShearWaveLogFileInformation.h" +#include "Simulations\ShearWave\SimulationInfo\ShearWaveSimulationInfo.h" +#include "Simulations\ShearWave\AnalyticalResults\ShearWaveAnalyticalResults.h" #include "Tests/PhiAndNuTest/PhiAndNuTest.h" #include "Tests\PhiAndNuTest\LogFileInformation\PhiAndNuLogFileInformation.h" +#include "Tests\PhiAndNuTest\PostProcessingStrategy\PostProcessingStrategyPhiAndNuTest.h" #include "Tests\L2NormTest\L2NormTest.h" #include "Tests\L2NormTest\LogFileInformation\L2NormLogFileInformation.h" +#include "Tests\L2NormTest\PostProcessingStrategy\PostProcessingStrategyL2NormTest.h" +#include "Tests\L2NormTestBetweenKernels\L2NormTestBetweenKernels.h" +#include "Tests\L2NormTestBetweenKernels\PostProcessingStrategy\L2NormBetweenKernelPostProcessingStrategy.h" +#include "Tests\L2NormTestBetweenKernels\LogFileInformation\L2NormLogFileInformationBetweenKernels.h" #include "Utilities\ColorConsoleOutput\ColorConsoleOutputImp.h" +#include "Utilities\DataWriter\AnalyticalResults2DToVTKWriter\AnalyticalResults2DToVTKWriterImp.h" #include "Utilities\LogFileInformation\LogFileTimeInformation\LogFileTimeInformation.h" #include "Utilities\LogFileWriter\LogFileWriterImp.h" #include "Utilities\LogFileQueue\LogFileQueueImp.h" @@ -36,6 +47,7 @@ NumericalTestFactoryImp::NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruc colorOutput = ColorConsoleOutputImp::getInstance(); testQueue = TestQueueImp::getNewInstance(colorOutput); logFileWriterQueue = LogFileQueueImp::getNewInstance(cfd->logFilePath); + anaResultWriter = AnalyticalResults2DToVTKWriterImp::getInstance(); init(); } @@ -58,40 +70,79 @@ void NumericalTestFactoryImp::init() { calcNumberOfSimulations(); simID = 1; - for (int i = 0; i < cfd->kernelsToTest.size(); i++) { - for (int j = 0; j < cfd->viscosity.size(); j++) { - for (int k = 0; k < cfd->u0TGV.size(); k++) { - if (shouldSimulationGroupRun(cfd->tgv)) { - makeTaylorGreenSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0TGV.at(k), cfd->amplitudeTGV.at(k)); + if (cfd->l2NormBetweenKernelTest && cfd->kernelsToTest.size() > 1) + { + sortKernels(); + simPerKernel = numberOfSimulations / cfd->kernelsToTest.size(); + numberOfTestGroupsBetweenKernels = (cfd->kernelsToTest.size() - 1) * simPerKernel; + numberOfTestsForOneSimulation = cfd->dataToCalcL2NormBetweenKernel.size() * cfd->timeStepsL2NormBetweenKernel.size(); + numberOfTestsBetweenKernels = numberOfTestGroupsBetweenKernels * numberOfTestsForOneSimulation; + posBasicSimulationForL2Test = 0; + posDivergentSimulationForL2Test = 0; + for (int i = 0; i < numberOfTestGroupsBetweenKernels; i++) { + for (int j = 0; j < cfd->dataToCalcL2NormBetweenKernel.size(); j++) { + for (int k = 0; k < cfd->timeStepsL2NormBetweenKernel.size(); k++) { + l2KernelTests.push_back(L2NormTestBetweenKernels::getNewInstance(colorOutput, cfd->dataToCalcL2NormBetweenKernel.at(j), cfd->timeStepsL2NormBetweenKernel.at(k))); } } - for (int k = 0; k < cfd->u0SW.size(); k++) { + } + } + + for (int i = 0; i < cfd->kernelsToTest.size(); i++) { + for (int j = 0; j < cfd->viscosity.size(); j++) { + for (int k = 0; k < cfd->u0TGVux.size(); k++) + if (shouldSimulationGroupRun(cfd->tgvUx)) + makeTaylorGreenUxSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0TGVux.at(k), cfd->amplitudeTGVux.at(k), cfd->basisTimeStepLengthTGVux.at(k)); + + for (int k = 0; k < cfd->v0TGVuz.size(); k++) + if (shouldSimulationGroupRun(cfd->tgvUz)) + makeTaylorGreenUzSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->v0TGVuz.at(k), cfd->amplitudeTGVuz.at(k), cfd->basisTimeStepLengthTGVuz.at(k)); + + for (int k = 0; k < cfd->u0SW.size(); k++) if (shouldSimulationGroupRun(cfd->sw)) - makeShearWaveSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0SW.at(k), cfd->v0SW.at(k)); - } + makeShearWaveSimulations(cfd->kernelsToTest.at(i), cfd->viscosity.at(j), cfd->u0SW.at(k), cfd->v0SW.at(k), cfd->basisTimeStepLengthSW.at(k)); + + } + } +} + +void NumericalTestFactoryImp::makeTaylorGreenUxSimulations(std::string kernelName, double viscosity, double ux, double amplitude, int basicTimeStepLength) +{ + std::vector< std::shared_ptr< SimulationParameter>> simParaTGV; + std::vector< std::shared_ptr< SimulationInfo>> simInfoTGV; + std::vector< std::shared_ptr< AnalyticalResults>> analyResultTGV; + + for (int i = 0; i < cfd->tgvUx.size(); i++) { + if (cfd->tgvUx.at(i)) { + simParaTGV.push_back(SimulationParameterTaylorGreenUx::getNewInstance(kernelName, ux, amplitude, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0TGVux, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); + simInfoTGV.push_back(SimulationInfoTaylorGreenUx::getNewInstance(ux, amplitude, cfd->l0TGVux, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); + analyResultTGV.push_back(AnalyticalResultsTaylorGreenUx::getNewInstance(viscosity, ux, amplitude, cfd->l0TGVux, cfd->rho0)); } } + std::shared_ptr<LogFileInformationTaylorGreenUx> tgInfo = LogFileInformationTaylorGreenUx::getNewInstance(ux, amplitude, cfd->tgvUx, cfd->lx, cfd->l0TGVux); + + makePeriodicBoundaryConditionSimulationAndTests(simParaTGV, simInfoTGV, analyResultTGV, tgInfo, kernelName, cfd->tgvUx, viscosity, basicTimeStepLength); } -void NumericalTestFactoryImp::makeTaylorGreenSimulations(std::string kernelName, double viscosity, double u0, double amplitude) +void NumericalTestFactoryImp::makeTaylorGreenUzSimulations(std::string kernelName, double viscosity, double uz, double amplitude, int basicTimeStepLength) { std::vector< std::shared_ptr< SimulationParameter>> simParaTGV; std::vector< std::shared_ptr< SimulationInfo>> simInfoTGV; std::vector< std::shared_ptr< AnalyticalResults>> analyResultTGV; - for (int i = 0; i < cfd->tgv.size(); i++) { - if (cfd->tgv.at(i)) { - simParaTGV.push_back(TaylorGreenSimulationParameter::getNewInstance(kernelName, u0, amplitude, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0, cfd->numberOfTimeSteps, cfd->basisTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); - simInfoTGV.push_back(TaylorGreenVortexSimulationInfo::getNewInstance(u0, amplitude, cfd->l0, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); - analyResultTGV.push_back(TaylorGreenAnalyticalResults::getNewInstance(viscosity, u0, amplitude, cfd->l0, cfd->rho0)); + for (int i = 0; i < cfd->tgvUz.size(); i++) { + if (cfd->tgvUz.at(i)) { + simParaTGV.push_back(SimulationParameterTaylorGreenUz::getNewInstance(kernelName, uz, amplitude, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0TGVuz, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); + simInfoTGV.push_back(SimulationInfoTaylorGreenUz::getNewInstance(uz, amplitude, cfd->l0TGVuz, cfd->lz.at(i), viscosity, kernelName, numberOfSimulations)); + analyResultTGV.push_back(AnalyticalResultsTaylorGreenUz::getNewInstance(viscosity, uz, amplitude, cfd->l0TGVuz, cfd->rho0)); } } - std::shared_ptr< TaylorGreenInformation> tgInfo = TaylorGreenInformation::getNewInstance(u0, amplitude, cfd->tgv, cfd->lx, cfd->l0); + std::shared_ptr< LogFileInformationTaylorGreenUz> tgInfo = LogFileInformationTaylorGreenUz::getNewInstance(uz, amplitude, cfd->tgvUz, cfd->lz, cfd->l0TGVuz); - makePeriodicBoundaryConditionSimulationAndTests(simParaTGV, simInfoTGV, analyResultTGV, tgInfo, kernelName, cfd->tgv, viscosity, cfd->nuAndPhiTestTGV, cfd->l2NormTestTGV); + makePeriodicBoundaryConditionSimulationAndTests(simParaTGV, simInfoTGV, analyResultTGV, tgInfo, kernelName, cfd->tgvUz, viscosity, basicTimeStepLength); } -void NumericalTestFactoryImp::makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0) +void NumericalTestFactoryImp::makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0, int basicTimeStepLength) { std::vector< std::shared_ptr< SimulationParameter>> simParaSW; std::vector< std::shared_ptr< SimulationInfo>> simInfoSW; @@ -99,91 +150,102 @@ void NumericalTestFactoryImp::makeShearWaveSimulations(std::string kernelName, d for (int i = 0; i < cfd->sw.size(); i++) if (cfd->sw.at(i)) { - simParaSW.push_back(ShearWaveSimulationParameter::getNewInstance(kernelName, u0, v0, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0, cfd->numberOfTimeSteps, cfd->basisTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); - simInfoSW.push_back(ShearWaveSimulationInfo::getNewInstance(u0, v0, cfd->l0, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); - analyResultSW.push_back(ShearWaveAnalyticalResults::getNewInstance(viscosity, u0, v0, cfd->l0, cfd->rho0)); + simParaSW.push_back(ShearWaveSimulationParameter::getNewInstance(kernelName, u0, v0, viscosity, cfd->rho0, cfd->lx.at(i), cfd->lz.at(i), cfd->l0SW, cfd->numberOfTimeSteps, basicTimeStepLength, calcStartStepForToVectorWriter(), cfd->ySliceForCalculation, cfd->grids.at(i), cfd->maxLevel, cfd->numberOfGridLevels, cfd->writeFiles, cfd->startStepFileWriter, cfd->filePath, cfd->devices)); + simInfoSW.push_back(ShearWaveSimulationInfo::getNewInstance(u0, v0, cfd->l0SW, cfd->lx.at(i), viscosity, kernelName, numberOfSimulations)); + analyResultSW.push_back(ShearWaveAnalyticalResults::getNewInstance(viscosity, u0, v0, cfd->l0SW, cfd->rho0)); } - std::shared_ptr< ShearWaveInformation> swInfo = ShearWaveInformation::getNewInstance(u0, v0, cfd->sw, cfd->lx, cfd->l0); + std::shared_ptr< ShearWaveInformation> swInfo = ShearWaveInformation::getNewInstance(u0, v0, cfd->sw, cfd->lx, cfd->l0SW); - makePeriodicBoundaryConditionSimulationAndTests(simParaSW, simInfoSW, analyResultSW, swInfo, kernelName, cfd->sw, viscosity, cfd->nuAndPhiTestSW, cfd->l2NormTestSW); + makePeriodicBoundaryConditionSimulationAndTests(simParaSW, simInfoSW, analyResultSW, swInfo, kernelName, cfd->sw, viscosity, basicTimeStepLength); } -void NumericalTestFactoryImp::makePeriodicBoundaryConditionSimulationAndTests(std::vector<std::shared_ptr<SimulationParameter>> simPara, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector<std::shared_ptr<AnalyticalResults>> analyResult, std::shared_ptr<SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector<bool> simulationsRun, double viscosity, bool nuAndPhiTest, bool l2NormTest) +void NumericalTestFactoryImp::makePeriodicBoundaryConditionSimulationAndTests(std::vector<std::shared_ptr<SimulationParameter>> simPara, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector<std::shared_ptr<AnalyticalResults>> analyResult, std::shared_ptr<SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector<bool> simulationsRun, double viscosity, int basicTimeStepLength) { std::vector< std::shared_ptr< SimulationResults>> simResults; - std::vector< std::shared_ptr< PostProcessingResults>> postProResults; for (int i = 0; i < simPara.size(); i++) { std::shared_ptr< SimulationResults> simResult = SimulationResults::getNewInstance(simPara.at(i)->getLx(), 1, simPara.at(i)->getLz(), simPara.at(i)->getTimeStepLength()); simResults.push_back(simResult); - postProResults.push_back(PostProcessingResultsImp::getNewInstance(simResult, analyResult.at(i), cfd->dataToCalcPhiAndNuTest, cfd->dataToCalcL2Test, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm)); } - std::vector< std::shared_ptr< TestSimulation>> testSim = buildTestSimulation(simPara, simInfo, simResults); + std::vector< std::shared_ptr< TestSimulation>> testSim = buildTestSimulation(simPara, simInfo, simResults, analyResult); std::vector< std::shared_ptr< TestLogFileInformation>> testLogFileInfo; - if (nuAndPhiTest && checkNuAndPhiTestCouldRun(simulationsRun)) { - std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests = makePhiAndNuTests(testSim, simInfo, postProResults, viscosity); - std::shared_ptr< PhiAndNuInformation> phiNuLogFileInfo = PhiAndNuInformation::getNewInstance(phiAndNuTests, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); + if (cfd->nuAndPhiTest && checkNuAndPhiTestCouldRun(simulationsRun)) { + std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy; + for(int i = 0; i < testSim.size();i++) + phiAndNuPostProStrategy.push_back(PhiAndNuTestPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->dataToCalcPhiAndNuTest, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu)); + std::shared_ptr< PhiAndNuInformation> phiNuLogFileInfo = PhiAndNuInformation::getNewInstance(cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); + for (int i = 0; i < cfd->dataToCalcPhiAndNuTest.size(); i++) { + std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests = makePhiAndNuTests(testSim, simInfo, phiAndNuPostProStrategy, viscosity, cfd->dataToCalcPhiAndNuTest.at(i)); + phiNuLogFileInfo->addTestGroup(phiAndNuTests); + } testLogFileInfo.push_back(phiNuLogFileInfo); } - if (l2NormTest) { - std::vector< std::shared_ptr< L2NormTest>> l2NormTests = makeL2NormTests(testSim, simInfo, postProResults); + if (cfd->l2NormTest) { + std::vector< std::shared_ptr< L2NormTest>> l2NormTests = makeL2NormTests(testSim, simInfo, simResults, analyResult); std::shared_ptr< L2NormInformation> l2NormLogFileInfo = L2NormInformation::getNewInstance(l2NormTests, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); testLogFileInfo.push_back(l2NormLogFileInfo); } + if (cfd->l2NormBetweenKernelTest){ + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests = makeL2NormTestsBetweenKernels(testSim, simInfo, simResults, analyResult); + if (tests.size() > 0){ + std::shared_ptr<L2NormBetweenKernelsInformation> l2NormBetweenKernelLogFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, cfd->basicKernelL2NormTest, cfd->timeStepsL2NormBetweenKernel, cfd->dataToCalcL2NormBetweenKernel); + testLogFileInfo.push_back(l2NormBetweenKernelLogFileInfo); + } + } + for (int i = 0; i < testSim.size(); i++) testSimulations.push_back(testSim.at(i)); std::shared_ptr< LogFileTimeInformation> logFileTimeInfo = LogFileTimeInformation::getNewInstance(testSim, cfd->writeFiles); - makeLogFileWriter(testLogFileInfo, logFileTimeInfo, simlogFileInfo, kernelName, viscosity); + makeLogFileWriter(testLogFileInfo, logFileTimeInfo, simlogFileInfo, kernelName, viscosity, basicTimeStepLength); } -std::vector<std::shared_ptr<TestSimulation>> NumericalTestFactoryImp::buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults) +std::vector<std::shared_ptr<TestSimulation>> NumericalTestFactoryImp::buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector< std::shared_ptr< AnalyticalResults>> analyResult) { std::vector< std::shared_ptr< TestSimulation>> testSim; testSim.resize(0); for (int i = 0; i < simPara.size(); i++) { - testSim.push_back(TestSimulationImp::getNewInsance(simID, simPara.at(i), simInfo.at(i), colorOutput, simResults.at(i))); + testSim.push_back(TestSimulationImp::getNewInsance(simID, simPara.at(i), simInfo.at(i), colorOutput, simResults.at(i), analyResult.at(i), anaResultWriter, cfd->writeAnalyticalToVTK)); simID++; } return testSim; } -std::vector<std::shared_ptr<PhiAndNuTest>> NumericalTestFactoryImp::makePhiAndNuTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PostProcessingResults>> postProResults, double viscosity) +std::vector<std::shared_ptr<PhiAndNuTest>> NumericalTestFactoryImp::makePhiAndNuTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate) { std::vector< std::shared_ptr< PhiAndNuTest>> phiAndNuTests; for (int i = 1; i < testSim.size(); i++) { for (int j = 0; j < i; j++) { - for (int k = 0; k < cfd->dataToCalcPhiAndNuTest.size(); k++) { - std::shared_ptr< PhiAndNuTest> test = PhiAndNuTest::getNewInstance(colorOutput, cfd->dataToCalcPhiAndNuTest.at(k), cfd->minOrderOfAccuracy, viscosity, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); - test->addSimulation(testSim.at(j), simInfo.at(j), postProResults.at(j)); - test->addSimulation(testSim.at(i), simInfo.at(i), postProResults.at(i)); + std::shared_ptr< PhiAndNuTest> test = PhiAndNuTest::getNewInstance(colorOutput, dataToCalculate, cfd->minOrderOfAccuracy, viscosity, cfd->startTimeStepCalculationPhiNu, cfd->endTimeStepCalculationPhiNu); + test->addSimulation(testSim.at(j), simInfo.at(j), phiAndNuPostProStrategy.at(j)); + test->addSimulation(testSim.at(i), simInfo.at(i), phiAndNuPostProStrategy.at(i)); testSim.at(j)->registerSimulationObserver(test); testSim.at(i)->registerSimulationObserver(test); phiAndNuTests.push_back(test); testQueue->addTest(test); - } } } return phiAndNuTests; } -std::vector<std::shared_ptr<L2NormTest>> NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PostProcessingResults>> postProResults) +std::vector<std::shared_ptr<L2NormTest>> NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult) { std::vector<std::shared_ptr<L2NormTest>> l2Tests; for (int i = 0; i < testSim.size(); i++) { + std::shared_ptr< L2NormPostProcessingStrategy> l2NormPostProStrategy = L2NormPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->dataToCalcL2Test, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); for (int j = 0; j < cfd->dataToCalcL2Test.size(); j++) { - std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(postProResults.at(i), colorOutput, cfd->dataToCalcL2Test.at(j), cfd->maxL2NormDiff, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); - test->addSimulation(testSim.at(i), simInfo.at(i), postProResults.at(i)); + std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, cfd->dataToCalcL2Test.at(j), cfd->maxL2NormDiff, cfd->basicTimeStepL2Norm, cfd->divergentTimeStepL2Norm); + test->addSimulation(testSim.at(i), simInfo.at(i), l2NormPostProStrategy); testSim.at(i)->registerSimulationObserver(test); l2Tests.push_back(test); testQueue->addTest(test); @@ -193,12 +255,65 @@ std::vector<std::shared_ptr<L2NormTest>> NumericalTestFactoryImp::makeL2NormTest return l2Tests; } -void NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation>> testLogFiles, std::shared_ptr<LogFileTimeInformation> logFileTimeInfo, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity) +std::vector<std::shared_ptr<L2NormTestBetweenKernels>> NumericalTestFactoryImp::makeL2NormTestsBetweenKernels(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector<std::shared_ptr<SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult) +{ + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> tests; + for (int i = 0; i < testSim.size(); i++) + { + std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy = L2NormBetweenKernelPostProcessingStrategy::getNewInstance(simResults.at(i), analyResult.at(i), cfd->timeStepsL2NormBetweenKernel, cfd->dataToCalcL2NormBetweenKernel); + if (simID - 1 <= simPerKernel) + { + for (int j = 0; j < numberOfTestsForOneSimulation; j++) + { + for (int k = 0; k < cfd->kernelsToTest.size() - 1; k++) + { + l2KernelTests.at(posBasicSimulationForL2Test + simPerKernel * k)->setBasicSimulation(testSim.at(i), simInfo.at(i), postProcessingStrategy); + testSim.at(i)->registerSimulationObserver(l2KernelTests.at(posBasicSimulationForL2Test + simPerKernel * k)); + } + posBasicSimulationForL2Test++; + } + } + else + { + for (int j = 0; j < numberOfTestsForOneSimulation; j++) + { + l2KernelTests.at(posDivergentSimulationForL2Test)->setDivergentKernelSimulation(testSim.at(i), simInfo.at(i), postProcessingStrategy); + tests.push_back(l2KernelTests.at(posDivergentSimulationForL2Test)); + testQueue->addTest(l2KernelTests.at(posDivergentSimulationForL2Test)); + testSim.at(i)->registerSimulationObserver(l2KernelTests.at(posDivergentSimulationForL2Test)); + posDivergentSimulationForL2Test++; + } + } + } + return tests; +} + +void NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation>> testLogFiles, std::shared_ptr<LogFileTimeInformation> logFileTimeInfo, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, int basicTimeStepLength) { - std::shared_ptr< LogFileWriterImp> logFileWriter = LogFileWriterImp::getNewInstance(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, cfd->devices, cfd->numberOfTimeSteps, cfd->basisTimeStepLength, calcStartStepForToVectorWriter()); + std::shared_ptr< LogFileWriterImp> logFileWriter = LogFileWriterImp::getNewInstance(testLogFiles, logFileTimeInfo, simLogInfo, kernelName, viscosity, cfd->devices, cfd->numberOfTimeSteps, calcStartStepForToVectorWriter(), basicTimeStepLength); logFileWriterQueue->addLogFileWriter(logFileWriter); } +void NumericalTestFactoryImp::sortKernels() +{ + bool basicKernelInKernelList = false; + for (int i = 0; i < cfd->kernelsToTest.size(); i++) { + if (cfd->kernelsToTest.at(i) == cfd->basicKernelL2NormTest) + basicKernelInKernelList = true; + } + if (!basicKernelInKernelList) + cfd->kernelsToTest.push_back(cfd->basicKernelL2NormTest); + + std::vector< std::string> kernels = cfd->kernelsToTest; + + while (kernels.at(0)!= cfd->basicKernelL2NormTest){ + kernels.push_back(kernels.at(0)); + std::vector< std::string>::iterator it = kernels.begin(); + kernels.erase(it); + } + cfd->kernelsToTest = kernels; +} + bool NumericalTestFactoryImp::shouldSimulationGroupRun(std::vector<bool> test) { for (int i = 0; i < test.size(); i++) { @@ -233,12 +348,20 @@ void NumericalTestFactoryImp::calcNumberOfSimulations() { int counter = 0; - int tgvCounter = 0; - for (int i = 0; i < cfd->tgv.size(); i++) - if (cfd->tgv.at(i)) - tgvCounter++; - tgvCounter *= cfd->u0TGV.size(); - counter += tgvCounter; + int tgvCounterU0 = 0; + for (int i = 0; i < cfd->tgvUx.size(); i++) + if (cfd->tgvUx.at(i)) + tgvCounterU0++; + tgvCounterU0 *= cfd->u0TGVux.size(); + counter += tgvCounterU0; + + int tgvCounterV0 = 0; + for (int i = 0; i < cfd->tgvUz.size(); i++) + if (cfd->tgvUz.at(i)) + tgvCounterV0++; + tgvCounterV0 *= cfd->v0TGVuz.size(); + counter += tgvCounterV0; + int swCounter = 0; for (int i = 0; i < cfd->sw.size(); i++) @@ -251,4 +374,4 @@ void NumericalTestFactoryImp::calcNumberOfSimulations() counter *= cfd->kernelsToTest.size(); numberOfSimulations = counter; -} +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h index 63ee9ebd87adf976a338301a873d5cd195bf20f5..9468d4fa908191d000b80a47d085f7e4a825a909 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h @@ -5,12 +5,14 @@ #include "Utilities\ConfigFileReader\ConfigData.h" class AnalyticalResults; +class AnalyticalResults2DToVTKWriter; class ColorConsoleOutput; class L2NormTest; +class L2NormTestBetweenKernels; class LogFileTimeInformation; class LogFileQueueImp; class PhiAndNuTest; -class PostProcessingResults; +class PhiAndNuTestPostProcessingStrategy; class SimulationInfo; class SimulationLogFileInformation; class SimulationParameter; @@ -32,14 +34,17 @@ private: NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData); void init(); - void makeTaylorGreenSimulations(std::string kernelName, double viscosity, double u0, double amplitude); - void makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0); - void makePeriodicBoundaryConditionSimulationAndTests(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< AnalyticalResults>> analyResult, std::shared_ptr< SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector< bool> simulationsRun, double viscosity, bool nuAndPhiTest, bool l2NormTest); - std::vector< std::shared_ptr< TestSimulation>> buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults); - std::vector< std::shared_ptr< PhiAndNuTest>> makePhiAndNuTests(std::vector< std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< PostProcessingResults>> postProResults, double viscosity); - std::vector< std::shared_ptr< L2NormTest>> makeL2NormTests(std::vector<std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< PostProcessingResults>> postProResults); - void makeLogFileWriter(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity); - + void makeTaylorGreenUxSimulations(std::string kernelName, double viscosity, double u0, double amplitude, int basicTimeStepLength); + void makeTaylorGreenUzSimulations(std::string kernelName, double viscosity, double u0, double amplitude, int basicTimeStepLength); + void makeShearWaveSimulations(std::string kernelName, double viscosity, double u0, double v0, int basicTimeStepLength); + void makePeriodicBoundaryConditionSimulationAndTests(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< AnalyticalResults>> analyResult, std::shared_ptr< SimulationLogFileInformation> simlogFileInfo, std::string kernelName, std::vector< bool> simulationsRun, double viscosity, int basicTimeStepLength); + std::vector< std::shared_ptr< TestSimulation>> buildTestSimulation(std::vector< std::shared_ptr< SimulationParameter>> simPara, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector< std::shared_ptr< AnalyticalResults>> analyResult); + std::vector< std::shared_ptr< PhiAndNuTest>> makePhiAndNuTests(std::vector<std::shared_ptr<TestSimulation>> testSim, std::vector<std::shared_ptr<SimulationInfo>> simInfo, std::vector< std::shared_ptr< PhiAndNuTestPostProcessingStrategy>> phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); + std::vector< std::shared_ptr< L2NormTest>> makeL2NormTests(std::vector<std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult); + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> makeL2NormTestsBetweenKernels(std::vector<std::shared_ptr< TestSimulation>> testSim, std::vector< std::shared_ptr< SimulationInfo>> simInfo, std::vector< std::shared_ptr< SimulationResults>> simResults, std::vector<std::shared_ptr<AnalyticalResults>> analyResult); + void makeLogFileWriter(std::vector< std::shared_ptr< TestLogFileInformation>> testLogFiles, std::shared_ptr< LogFileTimeInformation> logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation> simLogInfo, std::string kernelName, double viscosity, int basicTimeStepLength); + + void sortKernels(); bool shouldSimulationGroupRun(std::vector<bool> test); unsigned int calcStartStepForToVectorWriter(); bool checkNuAndPhiTestCouldRun(std::vector<bool> test); @@ -50,8 +55,12 @@ private: std::shared_ptr< TestQueueImp> testQueue; std::shared_ptr< LogFileQueueImp> logFileWriterQueue; std::shared_ptr< ColorConsoleOutput> colorOutput; + std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter; int simID; int numberOfSimulations; + int simPerKernel, numberOfTestGroupsBetweenKernels, numberOfTestsForOneSimulation, numberOfTestsBetweenKernels; + std::vector< std::shared_ptr< L2NormTestBetweenKernels>> l2KernelTests; + int posBasicSimulationForL2Test, posDivergentSimulationForL2Test; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResults.h b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResults.h index 581229b56d63ca883d585a0ec573243834cb38e4..2723f2ed4f204094560523d2b7826f7a2c229754 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResults.h +++ b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResults.h @@ -3,6 +3,8 @@ #include <vector> +class SimulationResults; + class PostProcessingResults { public: diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.cpp b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.cpp index cb24aa8b639170704ebf7eb4db2ebe64d79a414b..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.cpp +++ b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.cpp @@ -1,175 +1 @@ -#include "PostProcessingResultsImp.h" -#include "Utilities\Calculator\FFTCalculator\FFTCalculator.h" -#include "Utilities\Calculator\L2NormCalculator\L2NormCalculator.h" -#include "Utilities\Results\SimulationResults\SimulationResults.h" -#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" - -std::shared_ptr<PostProcessingResultsImp> PostProcessingResultsImp::getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, std::vector<std::string> dataToCalculateL2, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) -{ - return std::shared_ptr<PostProcessingResultsImp>(new PostProcessingResultsImp(simResult, analyticalResult, dataToCalculatePhiAndNu, dataToCalculateL2, startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu, basicTimeStepL2Norm, divergentTimeStepL2Norm)); -} - -PostProcessingResultsImp::PostProcessingResultsImp(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, std::vector<std::string> dataToCalculateL2, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm) - : simResult(simResult), analyticalResult(analyticalResult), dataToCalculatePhiAndNu(dataToCalculatePhiAndNu), dataToCalculateL2(dataToCalculateL2), startTimeStepCalculationPhiNu(startTimeStepCalculationPhiNu), endTimeStepCalculationPhiNu(endTimeStepCalculationPhiNu), basicTimeStepL2Norm(basicTimeStepL2Norm), divergentTimeStepL2Norm(divergentTimeStepL2Norm) -{ - isEvaluated = false; - fftCalculator = FFTCalculator::getNewInstance(simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); - l2Normcalculator = L2NormCalculator::getNewInstance(); -} - -void PostProcessingResultsImp::evaluate() -{ - if (!isEvaluated) { - analyticalResult->calc(simResult); - for (int i = 0; i < dataToCalculatePhiAndNu.size(); i++) { - if (dataToCalculatePhiAndNu.at(i) == "Vx") { - fftCalculator->calc(reduceDataToTimeSteps(simResult->getVx(), startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu)); - nuVx = fftCalculator->getNu(); - phiDiffVx = fftCalculator->getPhiDiff(); - } - if (dataToCalculatePhiAndNu.at(i) == "Vz") { - fftCalculator->calc(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculationPhiNu, endTimeStepCalculationPhiNu)); - nuVz = fftCalculator->getNu(); - phiDiffVz = fftCalculator->getPhiDiff(); - } - } - analyticalResult->calc(simResult); - int bS = calcTimeStepInResults(basicTimeStepL2Norm); - int dS = calcTimeStepInResults(divergentTimeStepL2Norm); - - for (int i = 0; i < dataToCalculateL2.size(); i++) { - if (dataToCalculateL2.at(i) == "Vx"){ - l2VxBasic = l2Normcalculator->calc(analyticalResult->getVx().at(bS), simResult->getVx().at(bS), simResult->getLevels().at(bS)); - l2VxDivergent = l2Normcalculator->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS)); - } - if (dataToCalculateL2.at(i) == "Vy") { - l2VyBasic = l2Normcalculator->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS)); - l2VyDivergent = l2Normcalculator->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS)); - } - if (dataToCalculateL2.at(i) == "Vz") { - l2VzBasic = l2Normcalculator->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS)); - l2VzDivergent = l2Normcalculator->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS)); - } - if (dataToCalculateL2.at(i) == "Press") { - l2PressBasic = l2Normcalculator->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS)); - l2PressDivergent = l2Normcalculator->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS)); - } - if (dataToCalculateL2.at(i) == "Rho") { - l2RhoBasic = l2Normcalculator->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS)); - l2RhoDivergent = l2Normcalculator->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS)); - } - } - isEvaluated = true; - } -} - -double PostProcessingResultsImp::getNuVx() -{ - return nuVx; -} - -double PostProcessingResultsImp::getNuVy() -{ - return nuVy; -} - -double PostProcessingResultsImp::getNuVz() -{ - return nuVz; -} - -double PostProcessingResultsImp::getPhiDiffVx() -{ - return phiDiffVx; -} - -double PostProcessingResultsImp::getPhiDiffVy() -{ - return phiDiffVy; -} - -double PostProcessingResultsImp::getPhiDiffVz() -{ - return phiDiffVz; -} - -std::vector<double> PostProcessingResultsImp::getL2NormVx() -{ - std::vector<double> v; - v.push_back(l2VxBasic); - v.push_back(l2VxDivergent); - return v; -} - -std::vector<double> PostProcessingResultsImp::getL2NormVy() -{ - std::vector<double> v; - v.push_back(l2VyBasic); - v.push_back(l2VyDivergent); - return v; -} - -std::vector<double> PostProcessingResultsImp::getL2NormVz() -{ - std::vector<double> v; - v.push_back(l2VzBasic); - v.push_back(l2VzDivergent); - return v; -} - -std::vector<double> PostProcessingResultsImp::getL2NormPress() -{ - std::vector<double> v; - v.push_back(l2PressBasic); - v.push_back(l2PressDivergent); - return v; -} - -std::vector<double> PostProcessingResultsImp::getL2NormRho() -{ - std::vector<double> v; - v.push_back(l2RhoBasic); - v.push_back(l2RhoDivergent); - return v; -} - -int PostProcessingResultsImp::getNumberOfXNodes() -{ - return simResult->getNumberOfXNodes(); -} - -int PostProcessingResultsImp::getNumberOfYNodes() -{ - return simResult->getNumberOfYNodes(); -} - -int PostProcessingResultsImp::getNumberOfZNodes() -{ - return simResult->getNumberOfZNodes(); -} - -std::vector<std::vector<double>> PostProcessingResultsImp::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; -} - -int PostProcessingResultsImp::calcTimeStepInResults(unsigned int timeStep) -{ - for (int i = 0; i < simResult->getTimeSteps().size(); i++) { - if (timeStep == simResult->getTimeSteps().at(i)) - return simResult->getTimeSteps().at(i); - } -} diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.h b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.h index e03776bfa2fb361be1e5e70694160c01bde357f3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.h +++ b/targets/tests/NumericalTests/Utilities/PostProcessingResults/PostProcessingResultsImp.h @@ -1,60 +0,0 @@ -#ifndef POST_PROCESSING_RESULTS_IMP_H -#define POST_PROCESSING_RESULTS_IMP_H - -#include "PostProcessingResults.h" - -#include <memory> -#include <string> - -class AnalyticalResults; -class FFTCalculator; -class L2NormCalculator; -class SimulationResults; - -class PostProcessingResultsImp : public PostProcessingResults -{ -public: - static std::shared_ptr< PostProcessingResultsImp> getNewInstance(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, std::vector<std::string> dataToCalculateL2, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); - - void evaluate(); - - double getNuVx(); - double getNuVy(); - double getNuVz(); - double getPhiDiffVx(); - double getPhiDiffVy(); - double getPhiDiffVz(); - std::vector< double> getL2NormVx(); - std::vector< double> getL2NormVy(); - std::vector< double> getL2NormVz(); - std::vector< double> getL2NormPress(); - std::vector< double> getL2NormRho(); - int getNumberOfXNodes(); - int getNumberOfYNodes(); - int getNumberOfZNodes(); - -private: - PostProcessingResultsImp() {}; - PostProcessingResultsImp(std::shared_ptr< SimulationResults> simResult, std::shared_ptr< AnalyticalResults> analyticalResult, std::vector<std::string> dataToCalculatePhiAndNu, std::vector<std::string> dataToCalculateL2, unsigned int startTimeStepCalculationPhiNu, unsigned int endTimeStepCalculationPhiNu, unsigned int basicTimeStepL2Norm, unsigned int divergentTimeStepL2Norm); - - std::vector<std::vector<double>> reduceDataToTimeSteps(std::vector<std::vector<double>> data, unsigned int startTimeStep, unsigned int endTimeStep); - int calcTimeStepInResults(unsigned int timeStep); - - std::shared_ptr< SimulationResults> simResult; - std::shared_ptr< FFTCalculator> fftCalculator; - std::shared_ptr< L2NormCalculator> l2Normcalculator; - std::shared_ptr< AnalyticalResults> analyticalResult; - std::vector<std::string> dataToCalculatePhiAndNu; - std::vector<std::string> dataToCalculateL2; - unsigned int startTimeStepCalculationPhiNu; - unsigned int endTimeStepCalculationPhiNu; - unsigned int basicTimeStepL2Norm; - unsigned int divergentTimeStepL2Norm; - bool isEvaluated; - - double nuVx, nuVy, nuVz; - double phiDiffVx, phiDiffVy, phiDiffVz; - double l2VxBasic, l2VyBasic, l2VzBasic, l2RhoBasic, l2PressBasic; - double l2VxDivergent, l2VyDivergent, l2VzDivergent, l2RhoDivergent, l2PressDivergent; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..905e82820755f0bdb5eb8f046fbdb6620de4012c --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategy.h @@ -0,0 +1,14 @@ +#ifndef POST_PROCESSING_STRATEGY_H +#define POST_PROCESSING_STRATEGY_H + +#include <vector> + +class SimulationResults; + +class PostProcessingStrategy +{ +public: + virtual void evaluate() = 0; + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f69f97b6255c67e21cb08f037683bb400b635a08 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.cpp @@ -0,0 +1,30 @@ +#include "PostProcessingStrategyImp.h" + +#include "Utilities\Results\SimulationResults\SimulationResults.h" + +int PostProcessingStrategyImp::getNumberOfXNodes() +{ + return simResult->getNumberOfXNodes(); +} + +int PostProcessingStrategyImp::getNumberOfYNodes() +{ + return simResult->getNumberOfYNodes(); +} + +int PostProcessingStrategyImp::getNumberOfZNodes() +{ + return simResult->getNumberOfZNodes(); +} + +PostProcessingStrategyImp::PostProcessingStrategyImp(std::shared_ptr<SimulationResults> simResult) : simResult(simResult) +{ +} + +int PostProcessingStrategyImp::calcTimeStepInResults(unsigned int timeStep) +{ + for (int i = 0; i < simResult->getTimeSteps().size(); i++) { + if (timeStep == simResult->getTimeSteps().at(i)) + return simResult->getTimeSteps().at(i); + } +} diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h new file mode 100644 index 0000000000000000000000000000000000000000..77b3e3b2097b4ed7b12c0c59846735dcacda75e2 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h @@ -0,0 +1,28 @@ +#ifndef POST_PROCESSING_STRATEGY_IMP_H +#define POST_PROCESSING_STRATEGY_IMP_H + +#include "PostProcessingStrategy.h" + +#include <memory> + +class SimulationResults; + +class PostProcessingStrategyImp : public PostProcessingStrategy +{ +public: + virtual void evaluate() = 0; + + int getNumberOfXNodes(); + int getNumberOfYNodes(); + int getNumberOfZNodes(); + +protected: + PostProcessingStrategyImp(std::shared_ptr< SimulationResults> simResult); + int calcTimeStepInResults(unsigned int timeStep); + + std::shared_ptr< SimulationResults> simResult; + +private: + PostProcessingStrategyImp() {}; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Utilities/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.h b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.h index e919c34ca4f2e5c6092a1246902497d51e0bf2d1..6b4a9881f43270dd4f66425f101ee4876345d37d 100644 --- a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.h +++ b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.h @@ -11,11 +11,7 @@ class AnalyticalResults : public ResultsImp { public: virtual void calc(std::shared_ptr< SimulationResults> simResults) = 0; - -protected: - void init(std::shared_ptr< SimulationResults> simResults); - -private: + virtual bool isCalculated() = 0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.cpp b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.cpp similarity index 77% rename from targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.cpp rename to targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.cpp index d2a0646c99c4a66c60fd56bd22c97c4a87c3e7da..af7c888a7cf452b2bec135ddc353527f0d96fa38 100644 --- a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResult.cpp +++ b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.cpp @@ -1,8 +1,18 @@ -#include "AnalyticalResult.h" +#include "AnalyticalResultImp.h" #include "../SimulationResults/SimulationResults.h" -void AnalyticalResults::init(std::shared_ptr<SimulationResults> simResults) +bool AnalyticalResultsImp::isCalculated() +{ + return calculated; +} + +AnalyticalResultsImp::AnalyticalResultsImp() +{ + calculated = false; +} + +void AnalyticalResultsImp::init(std::shared_ptr<SimulationResults> simResults) { this->xNodes = simResults->getNumberOfXNodes(); this->yNodes = simResults->getNumberOfYNodes(); @@ -11,6 +21,7 @@ void AnalyticalResults::init(std::shared_ptr<SimulationResults> simResults) this->timeStepLength = simResults->getTimeStepLength(); this->numberOfTimeSteps = simResults->getNumberOfTimeSteps(); this->timeStep = simResults->getTimeSteps(); + this->time = simResults->getTime(); this->x = simResults->getXNodes(); this->y = simResults->getYNodes(); this->z = simResults->getZNodes(); diff --git a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h new file mode 100644 index 0000000000000000000000000000000000000000..a68a64e2a9e5b568f731849c4bf5cce14e6b3183 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h @@ -0,0 +1,20 @@ +#ifndef ANALYTICAL_RESULTS_IMP_H +#define ANALYTICAL_RESULTS_IMP_H + +#include "AnalyticalResult.h" + +class AnalyticalResultsImp : public AnalyticalResults +{ +public: + virtual void calc(std::shared_ptr< SimulationResults> simResults) = 0; + bool isCalculated(); + +protected: + AnalyticalResultsImp(); + void init(std::shared_ptr< SimulationResults> simResults); + + bool calculated; +private: + +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp index aa2193bd43b72a410f2aa69ef34b6165d35c0244..2158ba9863dbcca982d1725b6224e17304bcdbb4 100644 --- a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp @@ -60,6 +60,11 @@ std::vector<unsigned int> ResultsImp::getTimeSteps() return timeStep; } +std::vector<int> ResultsImp::getTime() +{ + return time; +} + std::vector<std::vector<unsigned int>> ResultsImp::getLevels() { return level; diff --git a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h index f7b485e307533ea7326b76d9cb856efa591e73dc..f5f8ab5e5d39526f25d04f69ab11e79d6390a437 100644 --- a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h +++ b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h @@ -7,6 +7,9 @@ class ResultsImp : public Results { public: int getNumberOfTimeSteps(); + int getTimeStepLength(); + std::vector<unsigned int> getTimeSteps(); + std::vector<int> getTime(); std::vector<std::vector<double>> getVx(); std::vector<std::vector<double>> getVy(); std::vector<std::vector<double>> getVz(); @@ -16,8 +19,6 @@ public: std::vector<std::vector<double>> getXNodes(); std::vector<std::vector<double>> getYNodes(); std::vector<std::vector<double>> getZNodes(); - int getTimeStepLength(); - std::vector<unsigned int> getTimeSteps(); std::vector< std::vector< unsigned int> > getLevels(); std::vector<std::vector<double>> getPress(); std::vector<std::vector<double>> getRho(); @@ -31,7 +32,7 @@ protected: unsigned int numberOfNodes; std::vector<unsigned int> timeStep; - std::vector<unsigned int> time; + std::vector<int> time; std::vector<std::vector<double>> x, y, z; std::vector<std::vector<double>> vx, vy, vz; std::vector<std::vector<double>> press; diff --git a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp index b2136b373f89141acbdb153921407eb385e3db48..a07cb857e5a43d32e561c27ae64c2a66236cef0b 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp +++ b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.cpp @@ -2,7 +2,7 @@ #include <experimental/filesystem> -SimulationParameterImp::SimulationParameterImp(std::string simName, real viscosity, real lx, real lz, real l0, +SimulationParameterImp::SimulationParameterImp(std::string simName, real viscosity, real lx, real lz, real l0, real lForTimeStepLength, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, @@ -14,7 +14,7 @@ SimulationParameterImp::SimulationParameterImp(std::string simName, real viscosi gridPath(gridPath), maxLevel(maxLevel), numberOfGridLevels(numberOfGridLevels), writeFiles(writeFiles), startStepFileWriter(startStepFileWriter), devices(devices) { - timeStepLength = basisTimeStepLength*(lx / l0)*(lx / l0); + timeStepLength = basisTimeStepLength * (lForTimeStepLength / l0)*(lForTimeStepLength / l0); startTimeCalculation = timeStepLength * startStepCalculation; startTimeDataWriter = timeStepLength * startStepFileWriter; endTime = timeStepLength * numberOfTimeSteps; diff --git a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h index 1fccf31a9b899dbeb3d594db9a765d6c2cfad410..b0cc2464e34028696a7048e0309c05315ef37f56 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h +++ b/targets/tests/NumericalTests/Utilities/SimulationParameter/SimulationParameterImp.h @@ -27,7 +27,7 @@ public: protected: SimulationParameterImp() {}; SimulationParameterImp(std::string simName, real viscosity, real lx, real lz, real l0, - unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, + real lForTimeStepLength, unsigned int numberOfTimeSteps, unsigned int basisTimeStepLength, unsigned int startStepCalculation, unsigned int ySliceForCalculation, std::string gridPath, unsigned int maxLevel, unsigned int numberOfGridLevels, bool writeFiles, unsigned int startStepFileWriter, diff --git a/targets/tests/NumericalTests/Utilities/Test/Test.h b/targets/tests/NumericalTests/Utilities/Test/Test.h index 7cfe20811ff9baedfe961ce3fffc12bfa65ecb46..c4bf0106fec0887d134997cc75389e6d96ec4788 100644 --- a/targets/tests/NumericalTests/Utilities/Test/Test.h +++ b/targets/tests/NumericalTests/Utilities/Test/Test.h @@ -3,20 +3,13 @@ #include "SimulationObserver.h" -#include <memory> #include <vector> -#include <string> -class TestSimulation; -class SimulationInfo; -class PostProcessingResults; class Test : public SimulationObserver { public: virtual void update() = 0; - virtual void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResults) = 0; - virtual std::string getLogFileOutput() = 0; virtual std::vector< bool> getPassedTests() = 0; virtual void makeConsoleOutput() = 0; diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp index 8710316d39121bc15268d539137cd91c088ce789..bc12f47f47816ef1eddd411987ad973ca3792019 100644 --- a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp @@ -1,6 +1,6 @@ #include "TestImp.h" -#include "Utilities\PostProcessingResults\PostProcessingResults.h" +#include "Utilities\PostProcessingStrategy\PostProcessingStrategy.h" #include "Utilities\TestSimulation\TestSimulation.h" void TestImp::update() @@ -12,7 +12,7 @@ void TestImp::update() if (simulations.at(i)->getSimulationRun()) { simulationRun.at(i) = true; - postProResults.at(i)->evaluate(); + postProStrategies.at(i)->evaluate(); } } } @@ -21,11 +21,11 @@ void TestImp::update() evaluate(); } -void TestImp::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResult) +void TestImp::addSimulation(std::shared_ptr<TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingStrategy> postProStrategy) { simulations.push_back(sim); simInfos.push_back(simInfo); - postProResults.push_back(postProResult); + postProStrategies.push_back(postProStrategy); simulationRun.push_back(false); } @@ -48,4 +48,4 @@ bool TestImp::CheckAllSimulationRun() return false; return true; -} +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.h b/targets/tests/NumericalTests/Utilities/Test/TestImp.h index d305749800b541fc0487ae79e9cf0a34f4da66c4..80d8f20af5d57f0b1b1d82cd16f6906759e54f84 100644 --- a/targets/tests/NumericalTests/Utilities/Test/TestImp.h +++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.h @@ -4,20 +4,21 @@ #include "Utilities\Test\Test.h" #include <vector> +#include <memory> class TestSimulation; class SimulationResults; class SimulationInfo; class ColorConsoleOutput; +class PostProcessingStrategy; class TestImp : public Test { public: void update(); - void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingResults> postProResult); + void addSimulation(std::shared_ptr< TestSimulation> sim, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< PostProcessingStrategy> postProStrategy); virtual void evaluate() = 0; - virtual std::string getLogFileOutput() = 0; virtual std::vector< bool> getPassedTests() = 0; virtual void makeConsoleOutput() = 0; @@ -27,11 +28,10 @@ protected: TestImp(std::shared_ptr< ColorConsoleOutput> colorOutput); bool CheckAllSimulationRun(); - std::vector< bool> simulationRun; std::shared_ptr< ColorConsoleOutput> colorOutput; std::vector< std::shared_ptr< TestSimulation>> simulations; - std::vector< std::shared_ptr< PostProcessingResults>> postProResults; + std::vector< std::shared_ptr< PostProcessingStrategy>> postProStrategies; std::vector< std::shared_ptr< SimulationInfo>> simInfos; std::string kernelName; diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h index 01fb73e0fc47ff6afc9f00c22cbd2f1e915f2ec0..e4cb7d15373ceb7eac7c165b3f9138ee7f6f79ac 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h @@ -9,6 +9,7 @@ class SimulationParameter; class SimulationResults; class SimulationObserver; class DataWriter; +class Parameter; class TestSimulation { @@ -26,6 +27,8 @@ public: virtual void makeSimulationHeadOutput() = 0; virtual void setSimulationStartTime() = 0; virtual void setSimulationEndTimeAndNotifyObserver() = 0; + + virtual void setParameter(std::shared_ptr<Parameter> para) = 0; private: }; diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp index ed5c978206a251862a0a5265398fa76baa67bede..ad613adf62274c2ee760bdc3471dae55e182cfb8 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp @@ -5,17 +5,19 @@ #include "Utilities\SimulationParameter\SimulationParameter.h" #include "Utilities\SimulationInfo\SimulationInfo.h" #include "Utilities/Results/SimulationResults/SimulationResults.h" +#include "Utilities\Results\AnalyticalResults\AnalyticalResult.h" #include "Utilities\Test\SimulationObserver.h" #include "Utilities\DataWriter\Y2dSliceToResults\Y2dSliceToResults.h" #include "Utilities\ColorConsoleOutput\ColorConsoleOutput.h" #include "Utilities\KernelConfiguration\KernelConfiguration.h" +#include "Utilities\DataWriter\AnalyticalResults2DToVTKWriter\AnalyticalResults2DToVTKWriter.h" #include <sstream> #include <iomanip> -std::shared_ptr<TestSimulation> TestSimulationImp::getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults) +std::shared_ptr<TestSimulation> TestSimulationImp::getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults) { - return std::shared_ptr< TestSimulation>(new TestSimulationImp(simID, simPara, simInfo, colorOutput, simResults)); + return std::shared_ptr< TestSimulation>(new TestSimulationImp(simID, simPara, simInfo, colorOutput, simResults, analyticalResult, anaResultWriter, writeAnalyticalResults)); } std::shared_ptr<SimulationParameter> TestSimulationImp::getSimulationParameter() @@ -49,17 +51,20 @@ void TestSimulationImp::notifyObserver() simObserver.at(i)->update(); } -double TestSimulationImp::calcSimTime() -{ - return difftime(simulationEndTime, simulationStartTime); -} - float TestSimulationImp::calcTestTime() { float timeInMiliSec = ((float)(testEndTime - testStartTime) / CLOCKS_PER_SEC); return timeInMiliSec; } +void TestSimulationImp::writeAnalyticalResultsToVTK() +{ + if (!analyticalResult->isCalculated()) + analyticalResult->calc(simResults); + + anaResultWriter->writeAnalyticalResult(para, analyticalResult); +} + void TestSimulationImp::makeSimulationHeadOutput() { colorOutput->makeSimulationHeadOutput(simInfo); @@ -74,9 +79,16 @@ void TestSimulationImp::setSimulationEndTimeAndNotifyObserver() { simulationEndTime = time(NULL); simualtionRun = true; + setTestStartTime(); notifyObserver(); setTestEndTime(); + + if (writeAnalyticalResults) { + setAnalyticalResultWriteTimeStartTime(); + writeAnalyticalResultsToVTK(); + setAnalyticalResultWriteEndTime(); + } } void TestSimulationImp::setTestStartTime() @@ -89,19 +101,49 @@ void TestSimulationImp::setTestEndTime() testEndTime = clock(); } +void TestSimulationImp::setAnalyticalResultWriteTimeStartTime() +{ + analyticalResultWriteStartTime = time(NULL); +} + +void TestSimulationImp::setAnalyticalResultWriteEndTime() +{ + analyticalResultWriteEndTime = time(NULL); +} + +double TestSimulationImp::calcSimTime() +{ + return difftime(simulationEndTime, simulationStartTime); +} + +double TestSimulationImp::calcAnalyticalResultWriteTime() +{ + return difftime(analyticalResultWriteEndTime, analyticalResultWriteStartTime); +} + std::string TestSimulationImp::getRunTimeOutput() { std::ostringstream oss; oss << std::left << std::setfill(' ') << std::setw(11) << "Simulation" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcSimTime() << " sec" << std::endl; oss << std::left << std::setfill(' ') << std::setw(11) << "Test" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcTestTime() << " sec" << std::endl; + if (writeAnalyticalResults) + oss << std::left << std::setfill(' ') << std::setw(11) << "FileWriting" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcAnalyticalResultWriteTime() << " sec" << std::endl; return oss.str(); } -TestSimulationImp::TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults) : simID(simID), colorOutput(colorOutput), simResults(simResults) +void TestSimulationImp::setParameter(std::shared_ptr<Parameter> para) +{ + this->para = para; +} + +TestSimulationImp::TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults) : simID(simID), colorOutput(colorOutput), simResults(simResults), writeAnalyticalResults(writeAnalyticalResults) { this->simPara = simPara; this->simInfo = simInfo; this->simInfo->setSimulationID(simID); + this->analyticalResult = analyticalResult; + this->anaResultWriter = anaResultWriter; + writeToVector = Y2dSliceToResults::getNewInstance(simResults, simPara->getYSliceForCalculation(), simPara->getStartTimeCalculation(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getWriteFiles(), std::shared_ptr<FileWriter>(new FileWriter()), simPara->getStartTimeDataWriter()); diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h index 37109afabdcfc7ea75f8f5cbd6e51f43d975bc0c..bbba5b2eadef6d2fda56cab07e9c3e8c26343b52 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h @@ -9,11 +9,13 @@ class ToVectorWriter; class ColorConsoleOutput; class SimulationInfo; +class AnalyticalResults; +class AnalyticalResults2DToVTKWriter; class TestSimulationImp : public TestSimulation { public: - static std::shared_ptr< TestSimulation> getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults); + static std::shared_ptr< TestSimulation> getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults); std::shared_ptr< SimulationParameter> getSimulationParameter(); std::shared_ptr< DataWriter> getDataWriter(); @@ -26,14 +28,19 @@ public: void setSimulationStartTime(); void setSimulationEndTimeAndNotifyObserver(); std::string getRunTimeOutput(); + void setParameter(std::shared_ptr<Parameter> para); private: - TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults); + TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput, std::shared_ptr< SimulationResults> simResults, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, bool writeAnalyticalResults); void notifyObserver(); void setTestStartTime(); void setTestEndTime(); + void setAnalyticalResultWriteTimeStartTime(); + void setAnalyticalResultWriteEndTime(); double calcSimTime(); float calcTestTime(); + double calcAnalyticalResultWriteTime(); + void writeAnalyticalResultsToVTK(); std::shared_ptr< SimulationParameter> simPara; std::shared_ptr< SimulationInfo> simInfo; @@ -41,10 +48,15 @@ private: std::shared_ptr< ToVectorWriter> writeToVector; std::shared_ptr< ColorConsoleOutput> colorOutput; std::vector< std::shared_ptr< SimulationObserver>> simObserver; + std::shared_ptr<AnalyticalResults> analyticalResult; + std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter; + std::shared_ptr<Parameter> para; + bool writeAnalyticalResults; bool simualtionRun; time_t simulationStartTime, simulationEndTime; clock_t testStartTime, testEndTime; + time_t analyticalResultWriteStartTime, analyticalResultWriteEndTime; int simID; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp index f5018283d51d074a45288a5a3b4b4aef42fbe808..d8d44dacb6b9144fb582e0a578c2675ee19db0b5 100644 --- a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp +++ b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp @@ -19,9 +19,10 @@ void VirtualFluidSimulationImp::run() Simulation sim; sim.init(para, grid, dataWriter); sim.run(); - sim.free(); testSim->setSimulationEndTimeAndNotifyObserver(); + + sim.free(); } std::shared_ptr<VirtualFluidSimulationImp> VirtualFluidSimulationImp::getNewInstance() @@ -29,9 +30,9 @@ std::shared_ptr<VirtualFluidSimulationImp> VirtualFluidSimulationImp::getNewInst return std::shared_ptr<VirtualFluidSimulationImp>(new VirtualFluidSimulationImp()); } -void VirtualFluidSimulationImp::initParameter(std::shared_ptr< KernelConfiguration> kernelConfig, real viscosity, std::string aGridPath, std::string filePath, int numberOfGridLevels, unsigned int endTime, unsigned int timeStepLength, std::vector<int> devices, real velocity) +void VirtualFluidSimulationImp::initParameter(std::shared_ptr<Parameter> para, std::shared_ptr< KernelConfiguration> kernelConfig, real viscosity, std::string aGridPath, std::string filePath, int numberOfGridLevels, unsigned int endTime, unsigned int timeStepLength, std::vector<int> devices, real velocity) { - para = Parameter::make(); + this->para = para; para->setMaxDev(devices.size()); para->setDevices(devices); diff --git a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.h b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.h index b046b6d85a3cc56d6190585ed55bba9af6ada551..2102563d09d3772fbed7976706bd0699876b94ac 100644 --- a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.h +++ b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.h @@ -19,7 +19,7 @@ public: void run(); static std::shared_ptr< VirtualFluidSimulationImp> getNewInstance(); - void initParameter(std::shared_ptr< KernelConfiguration> kernelConfig, real viscosity, std::string gridPath, std::string filePath, int numberOfGridLevels, unsigned int endTime, unsigned int timeStepLength, std::vector<int> devices, real velocity); + void initParameter(std::shared_ptr<Parameter> para, std::shared_ptr< KernelConfiguration> kernelConfig, real viscosity, std::string gridPath, std::string filePath, int numberOfGridLevels, unsigned int endTime, unsigned int timeStepLength, std::vector<int> devices, real velocity); void initInitialConditions(std::shared_ptr< InitialCondition> initialCondition); void initGridProvider(); diff --git a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp index 55be8c4fbb838eab327a1230a2f95063c2d30374..0fd9ac2fd99d06e73448c7848fd35caa8d7e10cf 100644 --- a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp +++ b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulationFactory/VirtualFluidSimulationFactoryImp.cpp @@ -4,6 +4,8 @@ #include "Utilities\SimulationParameter\SimulationParameter.h" #include "Utilities\VirtualFluidSimulation\VirtualFluidSimulationImp.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + std::shared_ptr<VirtualFluidSimulationFactory> VirtualFluidSimulationFactoryImp::getNewInstance() { return std::shared_ptr< VirtualFluidSimulationFactory>(new VirtualFluidSimulationFactoryImp()); @@ -21,8 +23,10 @@ std::vector<std::shared_ptr<VirtualFluidSimulation>> VirtualFluidSimulationFacto for (int i = 0; i < testSim.size(); i++) { std::shared_ptr< SimulationParameter> simPara = testSim.at(i)->getSimulationParameter(); std::shared_ptr< VirtualFluidSimulationImp> vfSim = VirtualFluidSimulationImp::getNewInstance(); + std::shared_ptr< Parameter> para = Parameter::make(); - vfSim->initParameter(simPara->getKernelConfiguration() ,simPara->getViscosity(), simPara->getGridPath(), simPara->getFilePath(), simPara->getNumberOfGridLevels(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getDevices(), simPara->getMaxVelocity()); + testSim.at(i)->setParameter(para); + vfSim->initParameter(para, simPara->getKernelConfiguration() ,simPara->getViscosity(), simPara->getGridPath(), simPara->getFilePath(), simPara->getNumberOfGridLevels(), simPara->getEndTime(), simPara->getTimeStepLength(), simPara->getDevices(), simPara->getMaxVelocity()); vfSim->initInitialConditions(simPara->getInitialCondition()); vfSim->initGridProvider(); vfSim->setDataWriter(testSim.at(i)->getDataWriter()); diff --git a/targets/tests/NumericalTests/config.txt b/targets/tests/NumericalTests/config.txt index c30a7bf4038cba0c2a04cb2efcecc2ac901de7e5..05531f4179dc501316f231ceed88cafe7f2ed55c 100644 --- a/targets/tests/NumericalTests/config.txt +++ b/targets/tests/NumericalTests/config.txt @@ -6,27 +6,35 @@ Devices="1" ################################################## # Kernels # ################################################## -KernelsToTest="CumulantOneCompSP27" - CumulantAA2016CompSP27 CumulantAll4CompSP27" +KernelsToTest="CumulantAA2016CompSP27" + CumulantOneCompSP27 CumulantAll4CompSP27" ################################################## # Basic Simulation Parameter # ################################################## -NumberOfTimeSteps=20 -BasisTimeStepLength=1000 +NumberOfTimeSteps=200 Viscosity="0.0001" ################################################## # TaylorGreenVortex Parameter # ################################################## -u0_TGV="0.032" -Amplitude_TGV="0.01" +BasisTimeStepLength_TGV_Ux="100" +ux_TGV_Ux="0.032" +Amplitude_TGV_Ux="0.01" +l0_TGV_Ux=32 + +BasisTimeStepLength_TGV_Uz="100" +uz_TGV_Uz="0.048" +Amplitude_TGV_Uz="0.01" +l0_TGV_Uz=48 ################################################## # Shear Wave Parameter # ################################################## -u0_SW="0.032 0.016" -v0_SW="0.1 0.05" +BasisTimeStepLength_SW="1000 500 250" +u0_SW="0.032 0.064 0.128" +v0_SW="0.1 0.1 0.1" +l0_SW=32 ################################################## # Basic Test Parameter # @@ -36,31 +44,43 @@ ySliceForCalculation=0 ################################################## # PhiAndNu Test Parameter # ################################################## +PhiAndNuTest=false MinOrderOfAccuracy=1.95 DataToCalc_PhiAndNu="Vx Vz" StartTimeStepCalculation_PhiNu=11 EndTimeStepCalculation_PhiNu=20 -PhiAndNuTest_TGV=true -PhiAndNuTest_SW=true ################################################## # L2-Norm Test Parameter # ################################################## +L2NormTest=true MaxL2NormDiff=0.05 -DataToCalc_L2="Vx Vy Vz" +DataToCalc_L2="Vx Vz" BasicTimeStep_L2=0 -DivergentTimeStep_L2=20 -L2NormTest_TGV=true -L2NormTest_SW=true +DivergentTimeStep_L2=200 + +################################################## +# L2-Norm Test Between Kernels Parameter # +################################################## +L2NormBetweenKernelsTest=false +BasicKernel_L2NormBetweenKernels=CumulantOneCompSP27 +Timesteps_L2NormBetweenKernels="0 1 20" +DataToCalc_L2NormBetweenKernels="Vx Vy Vz" ################################################## # Simulation To Perform # ################################################## -TaylorGreenVortex32=true -TaylorGreenVortex64=true -TaylorGreenVortex128=true -TaylorGreenVortex256=false -TaylorGreenVortex512=false +TaylorGreenVortexUx32=true +TaylorGreenVortexUx64=false +TaylorGreenVortexUx128=false +TaylorGreenVortexUx256=false +TaylorGreenVortexUx512=false + +TaylorGreenVortexUz32=true +TaylorGreenVortexUz64=false +TaylorGreenVortexUz128=false +TaylorGreenVortexUz256=false +TaylorGreenVortexUz512=false ShearWave32=false ShearWave64=false @@ -82,7 +102,9 @@ GridPath512="C:\Users\Timon\Documents\studienarbeitIRMB\grids\gridUni512x4x768" ################################################## # File Writing Information # ################################################## -WriteFiles=true +WriteVTKFiles=true +WriteAnalyResultsToVTK=true + PathForFileWriting="C:\Users\Timon\Documents\studienarbeitIRMB\Output" StartStepFileWriter=0 diff --git a/targets/tests/NumericalTests/main.cpp b/targets/tests/NumericalTests/main.cpp index 741ed72d1c7a5b33251f6eacd2fb798100870e65..fe03da0b3515bc29f723d43bd85e78bfece8a42d 100644 --- a/targets/tests/NumericalTests/main.cpp +++ b/targets/tests/NumericalTests/main.cpp @@ -1,5 +1,7 @@ +#include <mpi.h> #include <gmock/gmock.h> -#include "mpi.h" + +#include "wstp.h" #include "Utilities/ConfigFileReader/ConfigFileReader.h" #include "Utilities\LogFileQueue\LogFileQueue.h" @@ -26,7 +28,6 @@ static void startNumericalTests(const std::string &configFile) testQueue->makeFinalOutput(); logFileQueue->writeLogFiles(); - } int main(int argc, char **argv) @@ -41,4 +42,4 @@ int main(int argc, char **argv) MPI_Finalize(); return 0; -} \ No newline at end of file +}