diff --git a/src/VirtualFluids_GPU/Init/InitLattice.cpp b/src/VirtualFluids_GPU/Init/InitLattice.cpp index d0b05a59ad9cd3e2e085575336b1965ca5bd21b7..2dff6c981acda2eb4c65dee8aed4dcf3afcb2989 100644 --- a/src/VirtualFluids_GPU/Init/InitLattice.cpp +++ b/src/VirtualFluids_GPU/Init/InitLattice.cpp @@ -14,32 +14,32 @@ void initLattice(SPtr<Parameter> para) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParD(lev)->evenOrOdd = false; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - InitSP27(para->getParD(lev)->numberofthreads, - para->getParD(lev)->neighborX_SP, - para->getParD(lev)->neighborY_SP, - para->getParD(lev)->neighborZ_SP, - para->getParD(lev)->geoSP, - para->getParD(lev)->rho_SP, - para->getParD(lev)->vx_SP, - para->getParD(lev)->vy_SP, - para->getParD(lev)->vz_SP, - para->getParD(lev)->size_Mat_SP, - para->getParD(lev)->d0SP.f[0], - para->getParD(lev)->evenOrOdd); + //InitSP27(para->getParD(lev)->numberofthreads, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->rho_SP, + // para->getParD(lev)->vx_SP, + // para->getParD(lev)->vy_SP, + // para->getParD(lev)->vz_SP, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->d0SP.f[0], + // para->getParD(lev)->evenOrOdd); + //getLastCudaError("Kernel execution failed"); + InitCompSP27( para->getParD(lev)->numberofthreads, + para->getParD(lev)->neighborX_SP, + para->getParD(lev)->neighborY_SP, + para->getParD(lev)->neighborZ_SP, + para->getParD(lev)->geoSP, + para->getParD(lev)->rho_SP, + para->getParD(lev)->vx_SP, + para->getParD(lev)->vy_SP, + para->getParD(lev)->vz_SP, + para->getParD(lev)->size_Mat_SP, + para->getParD(lev)->d0SP.f[0], + para->getParD(lev)->evenOrOdd); getLastCudaError("Kernel execution failed"); - // InitCompSP27( para->getParD(lev)->numberofthreads, - //para->getParD(lev)->neighborX_SP, - //para->getParD(lev)->neighborY_SP, - //para->getParD(lev)->neighborZ_SP, - //para->getParD(lev)->geoSP, - //para->getParD(lev)->rho_SP, - //para->getParD(lev)->vx_SP, - //para->getParD(lev)->vy_SP, - //para->getParD(lev)->vz_SP, - //para->getParD(lev)->size_Mat_SP, - //para->getParD(lev)->d0SP.f[0], - //para->getParD(lev)->evenOrOdd); - // getLastCudaError("Kernel execution failed"); InitF3( para->getParD(lev)->numberofthreads, para->getParD(lev)->neighborX_SP, para->getParD(lev)->neighborY_SP, @@ -56,32 +56,32 @@ void initLattice(SPtr<Parameter> para) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParD(lev)->evenOrOdd = true; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - InitSP27(para->getParD(lev)->numberofthreads, - para->getParD(lev)->neighborX_SP, - para->getParD(lev)->neighborY_SP, - para->getParD(lev)->neighborZ_SP, - para->getParD(lev)->geoSP, - para->getParD(lev)->rho_SP, - para->getParD(lev)->vx_SP, - para->getParD(lev)->vy_SP, - para->getParD(lev)->vz_SP, - para->getParD(lev)->size_Mat_SP, - para->getParD(lev)->d0SP.f[0], - para->getParD(lev)->evenOrOdd); + //InitSP27(para->getParD(lev)->numberofthreads, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->rho_SP, + // para->getParD(lev)->vx_SP, + // para->getParD(lev)->vy_SP, + // para->getParD(lev)->vz_SP, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->d0SP.f[0], + // para->getParD(lev)->evenOrOdd); + //getLastCudaError("Kernel execution failed"); + InitCompSP27( para->getParD(lev)->numberofthreads, + para->getParD(lev)->neighborX_SP, + para->getParD(lev)->neighborY_SP, + para->getParD(lev)->neighborZ_SP, + para->getParD(lev)->geoSP, + para->getParD(lev)->rho_SP, + para->getParD(lev)->vx_SP, + para->getParD(lev)->vy_SP, + para->getParD(lev)->vz_SP, + para->getParD(lev)->size_Mat_SP, + para->getParD(lev)->d0SP.f[0], + para->getParD(lev)->evenOrOdd); getLastCudaError("Kernel execution failed"); - // InitCompSP27( para->getParD(lev)->numberofthreads, - //para->getParD(lev)->neighborX_SP, - //para->getParD(lev)->neighborY_SP, - //para->getParD(lev)->neighborZ_SP, - //para->getParD(lev)->geoSP, - //para->getParD(lev)->rho_SP, - //para->getParD(lev)->vx_SP, - //para->getParD(lev)->vy_SP, - //para->getParD(lev)->vz_SP, - //para->getParD(lev)->size_Mat_SP, - //para->getParD(lev)->d0SP.f[0], - //para->getParD(lev)->evenOrOdd); - // getLastCudaError("Kernel execution failed"); InitF3( para->getParD(lev)->numberofthreads, para->getParD(lev)->neighborX_SP, para->getParD(lev)->neighborY_SP, @@ -96,34 +96,34 @@ void initLattice(SPtr<Parameter> para) para->getParD(lev)->evenOrOdd); getLastCudaError("Kernel execution failed"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - CalcMacSP27(para->getParD(lev)->vx_SP, - para->getParD(lev)->vy_SP, - para->getParD(lev)->vz_SP, - para->getParD(lev)->rho_SP, - para->getParD(lev)->press_SP, - para->getParD(lev)->geoSP, - para->getParD(lev)->neighborX_SP, - para->getParD(lev)->neighborY_SP, - para->getParD(lev)->neighborZ_SP, - para->getParD(lev)->size_Mat_SP, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->d0SP.f[0], - para->getParD(lev)->evenOrOdd); - getLastCudaError("Kernel CalcMacSP27 execution failed"); - // CalcMacCompSP27(para->getParD(lev)->vx_SP, - //para->getParD(lev)->vy_SP, - //para->getParD(lev)->vz_SP, - //para->getParD(lev)->rho_SP, - //para->getParD(lev)->press_SP, - //para->getParD(lev)->geoSP, - //para->getParD(lev)->neighborX_SP, - //para->getParD(lev)->neighborY_SP, - //para->getParD(lev)->neighborZ_SP, - //para->getParD(lev)->size_Mat_SP, - //para->getParD(lev)->numberofthreads, - //para->getParD(lev)->d0SP.f[0], - //para->getParD(lev)->evenOrOdd); - // getLastCudaError("Kernel execution failed"); + //CalcMacSP27(para->getParD(lev)->vx_SP, + // para->getParD(lev)->vy_SP, + // para->getParD(lev)->vz_SP, + // para->getParD(lev)->rho_SP, + // para->getParD(lev)->press_SP, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->numberofthreads, + // para->getParD(lev)->d0SP.f[0], + // para->getParD(lev)->evenOrOdd); + //getLastCudaError("Kernel CalcMacSP27 execution failed"); + CalcMacCompSP27(para->getParD(lev)->vx_SP, + para->getParD(lev)->vy_SP, + para->getParD(lev)->vz_SP, + para->getParD(lev)->rho_SP, + para->getParD(lev)->press_SP, + para->getParD(lev)->geoSP, + para->getParD(lev)->neighborX_SP, + para->getParD(lev)->neighborY_SP, + para->getParD(lev)->neighborZ_SP, + para->getParD(lev)->size_Mat_SP, + para->getParD(lev)->numberofthreads, + para->getParD(lev)->d0SP.f[0], + para->getParD(lev)->evenOrOdd); + getLastCudaError("Kernel execution failed"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (para->getCalcMedian()) { diff --git a/src/VirtualFluids_GPU/Kernel/Advection/Compressible/CumulantAA2016/CumulantAA2016CompSP27.h b/src/VirtualFluids_GPU/Kernel/Advection/Compressible/CumulantAA2016/CumulantAA2016CompSP27.h index 17caea5d0c77c324fcbbc3bf872f2fb976d1c4f2..7a0df9c00e631f376f826b8ab1ecd4400893910a 100644 --- a/src/VirtualFluids_GPU/Kernel/Advection/Compressible/CumulantAA2016/CumulantAA2016CompSP27.h +++ b/src/VirtualFluids_GPU/Kernel/Advection/Compressible/CumulantAA2016/CumulantAA2016CompSP27.h @@ -8,11 +8,14 @@ class CumulantAA2016CompSP27 : public Kernel { public: - static std::shared_ptr< Kernel> getNewInstance(std::shared_ptr< Parameter> para, int level); + static std::shared_ptr<Kernel> getNewInstance(std::shared_ptr< Parameter> para, int level); void run(); bool checkParameter(); + + private: + CumulantAA2016CompSP27(); CumulantAA2016CompSP27(std::shared_ptr< Parameter> para, int level); std::shared_ptr< Parameter> para; int level; diff --git a/src/VirtualFluids_GPU/Kernel/Kernel.h b/src/VirtualFluids_GPU/Kernel/Kernel.h index 584f4ea7cbb16ca4f6a179d625f29d78fa2e8928..6da16061f1791b2bb5884a55a46c209872af88b2 100644 --- a/src/VirtualFluids_GPU/Kernel/Kernel.h +++ b/src/VirtualFluids_GPU/Kernel/Kernel.h @@ -1,8 +1,6 @@ #ifndef KERNEL_H #define KERNEL_H -//#include "VirtualFluids_GPU\GPU\GPU_Interface.h" - #include <DataTypes.h> #include <cuda_runtime.h> @@ -16,8 +14,6 @@ class Kernel public: virtual void run()=0; virtual bool checkParameter() = 0; - -protected: }; #endif \ No newline at end of file diff --git a/src/VirtualFluids_GPU/Kernel/KernelFactory.cpp b/src/VirtualFluids_GPU/Kernel/KernelFactory.cpp deleted file mode 100644 index 47dc7aed46ccd05eccaf0dc189c15ecb00169de0..0000000000000000000000000000000000000000 --- a/src/VirtualFluids_GPU/Kernel/KernelFactory.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "KernelFactory.h" - -#include "Advection\Compressible\CumulantOne\CumulantOneCompSP27.h" -#include "Advection\Compressible\CumulantAA2016\CumulantAA2016CompSP27.h" -#include "Advection\Compressible\CumulantAll4\CumulantAll4CompSP27.h" -#include "Advection\Compressible\CumulantF3\CumulantF3CompSP27.h" -#include "Advection\Compressible\CumulantF32018\CumulantF32018CompSP27.h" - -std::shared_ptr<KernelFactory> KernelFactory::getNewInstance(std::shared_ptr<Parameter> para) -{ - return std::shared_ptr<KernelFactory>(new KernelFactory(para)); -} - -std::vector<std::shared_ptr<Kernel>> KernelFactory::makeKernels(int maxLevel, std::string kernelName) -{ - kernels.resize(0); - for (int i = 0; i <= maxLevel; i++) - { - kernels.push_back(makeKernel(kernelName, i)); - } - return kernels; -} - -void KernelFactory::setKernelAtLevel(std::vector<std::shared_ptr<Kernel>> kernels, int i, std::string kernelName) -{ - kernels.at(i) = makeKernel(kernelName, i); -} - -std::shared_ptr<Kernel> KernelFactory::makeKernel(std::string kernelName, int level) -{ - if (kernelName == "CumulantOneCompSP27") - return CumulantOneCompSP27::getNewInstance(para, level); - if (kernelName == "CumulantAA2016CompSP27") - return CumulantAA2016CompSP27::getNewInstance(para, level); - if (kernelName == "CumulantAll4CompSP27") - return CumulantAA2016CompSP27::getNewInstance(para, level); - if (kernelName == "CumulantF3CompSP27") - return CumulantF3CompSP27::getNewInstance(para, level); - if (kernelName == "CumulantF32018CompSP27") - return CumulantF32018CompSP27::getNewInstance(para, level); -} - -KernelFactory::KernelFactory(std::shared_ptr<Parameter> para) -{ - this->para = para; - kernels.resize(0); -} \ No newline at end of file diff --git a/src/VirtualFluids_GPU/Kernel/KernelFactory.h b/src/VirtualFluids_GPU/Kernel/KernelFactory.h deleted file mode 100644 index 208e47136fc8c57b9f2326ec7f3714b3df594878..0000000000000000000000000000000000000000 --- a/src/VirtualFluids_GPU/Kernel/KernelFactory.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef KERNEL_FACTORY_H -#define KERNEL_FACTORY_H - -#include <memory> -#include <vector> -#include <iostream> - -class Kernel; -class Parameter; - -class KernelFactory -{ -public: - static std::shared_ptr< KernelFactory> getNewInstance(std::shared_ptr<Parameter> para); - std::vector< std::shared_ptr< Kernel>> makeKernels(int maxLevel, std::string kernelName); - void setKernelAtLevel(std::vector< std::shared_ptr<Kernel>> kernels, int i, std::string kernelName); - -private: - std::shared_ptr< Kernel> makeKernel(std::string kernelName, int level); - KernelFactory(std::shared_ptr<Parameter> para); - KernelFactory(); - - std::vector< std::shared_ptr< Kernel>> kernels; - std::shared_ptr< Parameter> para; -}; -#endif \ No newline at end of file diff --git a/src/VirtualFluids_GPU/LBM/Simulation.cpp b/src/VirtualFluids_GPU/LBM/Simulation.cpp index 73284f286de62db05d1743211faa2533491ae00b..0774c070936ca208e3c238932b045ad89f91df2b 100644 --- a/src/VirtualFluids_GPU/LBM/Simulation.cpp +++ b/src/VirtualFluids_GPU/LBM/Simulation.cpp @@ -54,8 +54,8 @@ ////////////////////////////////////////////////////////////////////////// #include "DataStructureInitializer/GridProvider.h" #include "Output/DataWriter.h" -#include "Kernel\KernelFactory.h" -#include "Kernel\Kernel.h" +#include "Kernel/KernelFactory/KernelFactory.h" +#include "Kernel/Kernel.h" Simulation::Simulation() { diff --git a/src/VirtualFluids_GPU/Output/FileWriter.cpp b/src/VirtualFluids_GPU/Output/FileWriter.cpp index 657f534f057b9e3e77f62595b2031b12909b47c2..38bb81103c0df8dca798bbb981a23f46bc6af2d7 100644 --- a/src/VirtualFluids_GPU/Output/FileWriter.cpp +++ b/src/VirtualFluids_GPU/Output/FileWriter.cpp @@ -17,8 +17,12 @@ void FileWriter::writeInit(std::shared_ptr<Parameter> para) { unsigned int timestep = para->getTInit(); - for (int level = para->getCoarse(); level <= para->getFine(); level++) - writeTimestep(para, timestep, level); + for (int level = para->getCoarse(); level <= para->getFine(); level++) { + para->cudaCopyPrint(level); + writeTimestep(para, timestep, level); + + } + } void FileWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int timestep) diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp index 27ef7d625f98265557927ba9fc9de72ff54bbb27..df413da2f138045e709682975b092952816a2ce9 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.cpp @@ -17,10 +17,10 @@ void ShearWaveAnalyticalResults::calc(std::shared_ptr<SimulationResults> simResu 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 * 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)))*xNodes); - press.at(i).at(j) = (double)0.0; - rho.at(i).at(j) = (pow(l0, (double)2.0)*rho0*v0*sin(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes)*(-(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)))*u0*zNodes*cos(((double)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (double)2.0)) + v0*xNodes*pow(sin(((double)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (double)2.0)), (double)2.0)*sin(((double)2.0 * M_PI*z.at(i).at(j)) / zNodes))) / ((double)2.0*exp(((double)8.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)))*pow(xNodes, (double)3.0)); + vy.at(i).at(j) = (l0*v0*cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((real)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*u0) / xNodes)) / xNodes)) / (exp(time.at(i)*viscosity*(((real)4.0 * pow(M_PI, (real)2.0)) / pow(xNodes, (real)2.0) + ((real)4.0 * pow(M_PI, (real)2.0)) / pow(zNodes, (real)2.0)))*xNodes); + vz.at(i).at(j) = (real)0.0; + press.at(i).at(j) = (pow(l0, (real)2.0)*rho0*v0*sin(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*(-(real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*u0*zNodes*cos(((real)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)) + v0*xNodes*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)), (real)2.0)*sin(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes))) / ((real)2.0*exp(((real)8.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)3.0)); + rho.at(i).at(j) = (pow(l0, (real)2.0)*rho0*v0*sin(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*(-(real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*u0*zNodes*cos(((real)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)) + v0*xNodes*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*u0 + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)), (real)2.0)*sin(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes))) / ((real)2.0*exp(((real)8.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)3.0)); } } calculated = true; diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp index 45f4bd2ed42d576c8fe4f4f808e236ef940a80c8..d52f24775613c3b81da70d9217271a5cd5d89020 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/InitialConditions/InitialConditionShearWave.cpp @@ -38,24 +38,24 @@ real InitialConditionShearWave::getInitVX(int i, int level) } real InitialConditionShearWave::getInitVY(int i, int level) -{ - return (real) 0.0; -} - -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)) { - real vz = v0 * l0 / lx * cos((real)2.0 * M_PI * z /lz) * sin((real)2.0 * M_PI * x / lx); - return vz; + real vy = v0 * l0 / lx * cos((real)2.0 * M_PI * z / lz) * sin((real)2.0 * M_PI * x / lx); + return vy; } else return (real) 0.0; } +real InitialConditionShearWave::getInitVZ(int i, int level) +{ + return (real) 0.0; +} + real InitialConditionShearWave::getInitROH(int i, int level) { real x = getXCoord(i, level); @@ -63,8 +63,9 @@ real InitialConditionShearWave::getInitROH(int i, int level) real z = getZCoord(i, level); 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; + real press = (l0*l0 * v0 * rho * sin(((real)2.0 * M_PI * z) / lz) * ((real)-4.0 * lz * u0 * cos(((real)2.0 * 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); + real rho = (real)3.0 * press; + return 0.0; } else return (real) 0.0; diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h b/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h index 490c2d865e50b446806b1729fe5bccf678a14736..8388031233a8967d643b932bc1bd7ae605d8d8cd 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h +++ b/targets/tests/NumericalTests/Simulations/ShearWave/ShearWaveParameterStruct.h @@ -15,5 +15,6 @@ struct ShearWaveParameterStruct double l0; double rho0; std::string vtkFilePath; + std::vector<std::string> dataToCalcTests; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp index d6ce8e8c7021f16e4e506c4bd7d6af0805d4af15..05dd6abad5dec1f39b65390ff5060bd861e294da 100644 --- a/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp +++ b/targets/tests/NumericalTests/Simulations/ShearWave/SimulationInfo/ShearWaveSimulationInfo.cpp @@ -11,7 +11,7 @@ std::shared_ptr<ShearWaveSimulationInfo> ShearWaveSimulationInfo::getNewInstance } ShearWaveSimulationInfo::ShearWaveSimulationInfo(int simID, std::string kernelName, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations) - : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "ShearWave") + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "ShearWave", simParaStruct->dataToCalcTests) { std::ostringstream oss; oss << " ux: " << simParaStruct->ux / (gridInfoStruct->lx / simParaStruct->l0) << " uz: " << simParaStruct->uz / (gridInfoStruct->lx / simParaStruct->l0); diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp index f1c69257da46a7faa9a49517cb65fa37ac89960e..c2d16a06f59a4548446f62164c14a6163d7dbdbe 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUx.cpp @@ -16,11 +16,11 @@ void AnalyticalResultsTaylorGreenUx::calc(std::shared_ptr<SimulationResults> sim 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)); + vx.at(i).at(j) = (l0*ux) / xNodes + (amplitude*exp(time.at(i)*viscosity*((-(real)4.0 * pow(M_PI, (real)2.0)) / pow(xNodes, (real)2.0) - ((real)4.0 * pow(M_PI, (real)2.0)) / pow(zNodes, (real)2.0)))*l0*cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((real)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*ux) / xNodes)) / xNodes)) / xNodes; + vy.at(i).at(j) = (real)0.0; + vz.at(i).at(j) = -((amplitude*exp(time.at(i)*viscosity*((-(real)4.0 * pow(M_PI, (real)2.0)) / pow(xNodes, (real)2.0) - ((real)4.0 * pow(M_PI, (real)2.0)) / pow(zNodes, (real)2.0)))*l0*zNodes*cos(((real)2.0 * M_PI*(x.at(i).at(j) + (l0*time.at(i)*ux) / xNodes)) / xNodes)*sin(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)) / pow(xNodes, (real)2.0)); + press.at(i).at(j) = (amplitude*pow(l0, (real)2.0)*rho0*(amplitude*pow(zNodes, (real)2.0)*pow(cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes), (real)2.0) - (real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*ux*(pow(xNodes, (real)2.0) - pow(zNodes, (real)2.0)) * cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((real)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)) - amplitude*pow(xNodes, (real)2.0)*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)), (real)2.0))) / ((real)2.0*exp((8 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)4.0)); + rho.at(i).at(j) = (amplitude*pow(l0, (real)2.0)*rho0*(amplitude*pow(zNodes, (real)2.0)*pow(cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes), (real)2.0) - (real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*ux*(pow(xNodes, (real)2.0) - pow(zNodes, (real)2.0)) * cos(((real)2.0 * M_PI*z.at(i).at(j)) / zNodes)*sin(((real)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)) - amplitude*pow(xNodes, (real)2.0)*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*ux + x.at(i).at(j)*xNodes)) / pow(xNodes, (real)2.0)), (real)2.0))) / ((real)2.0*exp((8 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)4.0)); } } calculated = true; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp index ba906586593ec724e1c86f80131374d3942f4c31..256269ba063960073d6250fb8b6750a7077131a8 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.cpp @@ -8,10 +8,10 @@ InitialConditionTaylorGreenUx::InitialConditionTaylorGreenUx(std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct) { - this->Amp = simParaStruct->amplitude; - this->L0 = simParaStruct->l0; - this->Lx = gridInfoStruct->lx; - this->Lz = gridInfoStruct->lz; + this->amp = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + this->lx = gridInfoStruct->lx; + this->lz = gridInfoStruct->lz; this->rho = simParaStruct->rho0; this->ux = simParaStruct->ux; } @@ -28,7 +28,7 @@ real InitialConditionTaylorGreenUx::getInitVX(int i, int 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)); + 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 @@ -48,7 +48,7 @@ real InitialConditionTaylorGreenUx::getInitVZ(int i, int 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)); + 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 @@ -62,8 +62,9 @@ real InitialConditionTaylorGreenUx::getInitROH(int i, int 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; + real press = (amp*pow(l0, (real)2.0)*rho*(amp*pow(lz, (real)2.0)*pow(cos(((real)2.0 * M_PI*z) / lz), (real)2.0) - (real)4.0 * (pow(lx, (real)2.0) - pow(lz, (real)2.0))*ux*cos(((real)2.0 * M_PI*z) / lz)*sin(((real)2.0 * M_PI*x) / lx) - amp*pow(lx, (real)2.0)*pow(sin(((real)2.0 * M_PI*x) / lx), (real)2.0))) / ((real)2.0*pow(lx, (real)4.0)); + real rho = (real)3.0 * press; + return rho; } else return (real) 0.0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h index 7df830d91cb58887fcba81cdc7c52f3af0a259ba..caa8bb44ce608274b67979e65b3a4f543b6d5524 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/InitialConditions/InitialConditionTaylorGreenVortexUx.h @@ -23,10 +23,10 @@ private: InitialConditionTaylorGreenUx(std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct); InitialConditionTaylorGreenUx() {}; - real Amp; + real amp; real rho; - real L0; - real Lx, Lz; + real l0; + real lx, lz; real ux; }; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp index f45f5f63e1f828e294f2d4f6a91bf195c562fd05..0d9bbee1e6122b5ee34cdeae18d87743a59568c3 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/SimulationInfo/SimulationInfoTaylorGreenVortexUx.cpp @@ -11,7 +11,7 @@ std::shared_ptr<SimulationInfoTaylorGreenUx> SimulationInfoTaylorGreenUx::getNew } SimulationInfoTaylorGreenUx::SimulationInfoTaylorGreenUx(int simID, std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations) - : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "TaylorGreenVortex Ux") + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "TaylorGreenVortex Ux", simParaStruct->dataToCalcTests) { std::ostringstream oss; oss << " ux: " << simParaStruct->ux / (gridInfoStruct->lx / simParaStruct->l0) << " Amplitude: " << simParaStruct->amplitude / (gridInfoStruct->lx / simParaStruct->l0); diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h index 83607ec0c63ecbbb657b96e2e3dfbf1137a004b4..1a12a99eca58d11e96e411c969d856a2d065dce7 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUx/TaylorGreenVortexUxParameterStruct.h @@ -15,5 +15,6 @@ struct TaylorGreenVortexUxParameterStruct double l0; double rho0; std::string vtkFilePath; + std::vector<std::string> dataToCalcTests; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp index cfa523b361804550b8881012c1910a86f0b9ce46..fee2494506261f8408dc40f87b681e8ab736bd51 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/AnalyticalResults/AnalyticalResultsTaylorGreenVortexUz.cpp @@ -16,11 +16,11 @@ void AnalyticalResultsTaylorGreenUz::calc(std::shared_ptr<SimulationResults> sim 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); + vx.at(i).at(j) = (amplitude*exp( time.at(i)*viscosity*((-(real)4.0 * pow(M_PI, (real)2.0)) / pow(xNodes, (real)2.0) - ((real)4.0 * pow(M_PI, (real)2.0)) / pow(zNodes, (real)2.0)))*l0*cos(((real)2.0 * M_PI*((l0*time.at(i)*uz) / xNodes + z.at(i).at(j))) / zNodes)*sin(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes)) / xNodes; + vy.at(i).at(j) = (real)0.0; + vz.at(i).at(j) = (l0*uz) / zNodes - (amplitude*exp(time.at(i)*viscosity*((-(real)4.0 * pow(M_PI, (real)2.0)) / pow(xNodes, (real)2.0) - ((real)4.0 * pow(M_PI, (real)2.0)) / pow(zNodes, (real)2.0)))*l0*zNodes*cos(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((real)2.0 * M_PI*(z.at(i).at(j) + (l0*time.at(i)*uz) / zNodes)) / zNodes)) / pow(xNodes, (real)2.0); + press.at(i).at(j) = (amplitude*pow(l0, (real)2.0)*rho0*(amplitude*pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)*pow(cos(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes), (real)2.0) - (real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*uz*pow(xNodes, (real)2.0)*(pow(xNodes, (real)2.0) - pow(zNodes, (real)2.0))*cos(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((real)2.0 * M_PI*(l0*time.at(i)*uz + z.at(i).at(j)*zNodes)) / pow(zNodes, (real)2.0)) - amplitude*pow(zNodes, (real)4.0)*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*uz + z.at(i).at(j)*zNodes)) / pow(zNodes, (real)2.0)), (real)2.0))) / ((real)2.0*exp(((real)8.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)4.0)*pow(zNodes, (real)2.0)); + rho.at(i).at(j) = (amplitude*pow(l0, (real)2.0)*rho0*(amplitude*pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)*pow(cos(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes), (real)2.0) - (real)4.0 * exp(((real)4.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*uz*pow(xNodes, (real)2.0)*(pow(xNodes, (real)2.0) - pow(zNodes, (real)2.0))*cos(((real)2.0 * M_PI*x.at(i).at(j)) / xNodes)*sin(((real)2.0 * M_PI*(l0*time.at(i)*uz + z.at(i).at(j)*zNodes)) / pow(zNodes, (real)2.0)) - amplitude*pow(zNodes, (real)4.0)*pow(sin(((real)2.0 * M_PI*(l0*time.at(i)*uz + z.at(i).at(j)*zNodes)) / pow(zNodes, (real)2.0)), (real)2.0))) / ((real)2.0*exp(((real)8.0 * pow(M_PI, (real)2.0)*time.at(i)*viscosity*(pow(xNodes, (real)2.0) + pow(zNodes, (real)2.0))) / (pow(xNodes, (real)2.0)*pow(zNodes, (real)2.0)))*pow(xNodes, (real)4.0)*pow(zNodes, (real)2.0)); } } calculated = true; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp index 3e89dd1e83848df4f5bc44b6a7b2ff7a07da1410..fb544b089efb607d5b0d904d5dc232f521b45e6c 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.cpp @@ -8,10 +8,10 @@ InitialConditionTaylorGreenUz::InitialConditionTaylorGreenUz(std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct) { - this->Amp = simParaStruct->amplitude; - this->L0 = simParaStruct->l0; - this->Lx = gridInfoStruct->lx; - this->Lz = gridInfoStruct->lz; + this->amp = simParaStruct->amplitude; + this->l0 = simParaStruct->l0; + this->lx = gridInfoStruct->lx; + this->lz = gridInfoStruct->lz; this->rho = simParaStruct->rho0; this->uz = simParaStruct->uz; } @@ -28,7 +28,7 @@ real InitialConditionTaylorGreenUz::getInitVX(int i, int 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); + real vx = (amp * l0 * cos((real)2.0 * M_PI * z / lz) * sin((real)2.0 * M_PI * x / lx) / lx); return vx; } else @@ -48,7 +48,7 @@ real InitialConditionTaylorGreenUz::getInitVZ(int i, int 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)); + 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 @@ -62,8 +62,9 @@ real InitialConditionTaylorGreenUz::getInitROH(int i, int 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; + real press = (amp*pow(l0, (real)2.0)*rho*(amp*pow(lx, (real)2.0)*pow(lz, (real)2.0)*pow(cos(((real)2.0 * M_PI*x) / lx), (real)2.0) - (real)4.0 * pow(lx, (real)2.0)*(pow(lx, (real)2.0) - pow(lz, (real)2.0))*uz*cos(((real)2.0 * M_PI*x) / lx)*sin(((real)2.0 * M_PI*z) / lz) - amp*pow(lz, (real)4.0)*pow(sin(((real)2.0 * M_PI*z) / lz), (real)2.0))) / ((real)2.0*pow(lx, (real)4.0)*pow(lz, (real)2.0)); + real rho = (real)3.0 * press; + return rho; } else return (real) 0.0; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h index c793863f58450c7383a5d42270713ee406952fcf..70f85b42ec501924c536b1eb7c766525815bc5b8 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/InitialConditions/InitialConditionTaylorGreenVortexUz.h @@ -23,10 +23,10 @@ private: InitialConditionTaylorGreenUz(std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct); InitialConditionTaylorGreenUz() {}; - real Amp; + real amp; real rho; - real L0; - real Lx, Lz; + real l0; + real lx, lz; real uz; }; diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp index a7819f15615363dc5e3624b6c757c8590168b992..ed997092d7612fae2da6b83246276889187744c1 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.cpp @@ -11,19 +11,19 @@ std::string LogFileInformationTaylorGreenUz::getOutput() { makeCenterHead("TaylorGreenVortex V0 Information"); oss << "SimulationName=TaylorGreenVortexUz" << std::endl; - oss << "Lz=\""; - for (int i = 0; i < lz.size(); i++) { - oss << lz.at(i); - if (i < lz.size() - 1) + oss << "Lx=\""; + for (int i = 0; i < lx.size(); i++) { + oss << lx.at(i); + if (i < lx.size() - 1) oss << " "; else oss << "\"" << std::endl << std::endl; } for (int i = 0; i < lz.size(); i++) { - oss << "l0_" << lz.at(i) << "=" << l0 << std::endl; - oss << "uz_" << lz.at(i) << "=" << uz / (lz.at(i) / l0) << std::endl; - oss << "Amplitude_" << lz.at(i) << "=" << amplitude / (lz.at(i) / l0) << std::endl; + oss << "l0_" << lx.at(i) << "=" << l0 << std::endl; + oss << "uz_" << lx.at(i) << "=" << uz / (lz.at(i) / l0) << std::endl; + oss << "Amplitude_" << lx.at(i) << "=" << amplitude / (lz.at(i) / l0) << std::endl; oss << std::endl; } @@ -52,4 +52,6 @@ LogFileInformationTaylorGreenUz::LogFileInformationTaylorGreenUz(std::shared_ptr for (int i = 0; i < gridInfoStruct.size(); i++) lz.push_back(gridInfoStruct.at(i)->lz); + for (int i = 0; i < gridInfoStruct.size(); i++) + lx.push_back(gridInfoStruct.at(i)->lx); } diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h index 8e6154748c25d51b60dd68b447507c840e350fd6..ffcfee783832678f81fd09d1d6462a271bacfca9 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/LogFileInformation/LogFileInformationTaylorGreenVortexUz.h @@ -26,6 +26,7 @@ private: double uz; double amplitude; std::vector<double> lz; + std::vector<double> lx; int l0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp index 59756de5d787e6d4ff16a5cf9caab415962d5397..dfb6281ae07a0778f929d018bef7b5b2cb8e1d1e 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/SimulationInfo/SimulationInfoTaylorGreenVortexUz.cpp @@ -11,7 +11,7 @@ std::shared_ptr<SimulationInfoTaylorGreenUz> SimulationInfoTaylorGreenUz::getNew } SimulationInfoTaylorGreenUz::SimulationInfoTaylorGreenUz(int simID, std::string kernelName, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::shared_ptr<GridInformationStruct> gridInfoStruct, int numberOfSimulations) - : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lz, numberOfSimulations, "TaylorGreenVortex Uz") + : SimulationInfoImp(simID, kernelName, viscosity, gridInfoStruct->lx, numberOfSimulations, "TaylorGreenVortex Uz", simParaStruct->dataToCalcTests) { std::ostringstream oss; oss << " uz: " << simParaStruct->uz / (gridInfoStruct->lz / simParaStruct->l0) << " Amplitude: " << simParaStruct->amplitude / (gridInfoStruct->lz / simParaStruct->l0); diff --git a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h index 2098e779ea03616d2c1e1c6dbe9ec94911181859..2adcb573097c8decdbab30429bc18cbe7dcad1f7 100644 --- a/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h +++ b/targets/tests/NumericalTests/Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h @@ -16,5 +16,6 @@ struct TaylorGreenVortexUzParameterStruct double l0; double rho0; std::string vtkFilePath; + std::vector<std::string> dataToCalcTests; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp index 8b41bb49414a5dc0be808b27aec255c23022cb8f..b47165a25ebd84eb99bcbe0b34a8a8c309a44367 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.cpp @@ -1,12 +1,13 @@ #include "L2NormTest.h" -#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" #include "Utilities/Results/SimulationResults/SimulationResults.h" +#include "Utilities/SimulationInfo/SimulationInfo.h" #include "Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h" #include "Tests/L2NormTest/L2NormTestParameterStruct.h" #include <iomanip> +#include <sstream> std::shared_ptr<L2NormTest> L2NormTest::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate, double maxL2NormDiff, std::string normalizeData) { @@ -26,58 +27,41 @@ void L2NormTest::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std void L2NormTest::evaluate() { - std::vector<double> results; - - if (dataToCalculate == "Vx") - results = l2NormPostProStrategies.at(0)->getL2NormVx(); - if (dataToCalculate == "Vy") - results = l2NormPostProStrategies.at(0)->getL2NormVy(); - if (dataToCalculate == "Vz") - results = l2NormPostProStrategies.at(0)->getL2NormVz(); - if (dataToCalculate == "Press") - results = l2NormPostProStrategies.at(0)->getL2NormPress(); - if (dataToCalculate == "Rho") - results = l2NormPostProStrategies.at(0)->getL2NormRho(); + std::vector<double> results = l2NormPostProStrategies.at(0)->getL2Norm(dataToCalculate, normalizeData); resultBasicTimestep = results.at(0); resultDivergentTimeStep = results.at(1); diffL2Norm = resultDivergentTimeStep - resultBasicTimestep; if (resultBasicTimestep < 0 || resultDivergentTimeStep < 0) { - testError = true; - testPassed = false; + testStatus = error; } else { testPassed = maxL2NormDiff > diffL2Norm; + if (testPassed) + testStatus = passed; + else + testStatus = failed; } - makeConsoleOutput(); } std::string L2NormTest::getLogFileOutput() { std::ostringstream oss; - oss << "NormalizeData_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "=" << normalizeData << 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; + oss << "L2Norm_BasicTimeStep_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "_" << normalizeData << "=" << resultBasicTimestep << std::endl; + oss << "L2Norm_DivergentTimeStep_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "_" << normalizeData << "=" << resultDivergentTimeStep << std::endl; + oss << "L2Norm_Diff_L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "_" << normalizeData << "=" << diffL2Norm << std::endl << std::endl; return oss.str(); } -std::vector<bool> L2NormTest::getPassedTests() -{ - return std::vector<bool>(1, testPassed); -} - -void L2NormTest::makeConsoleOutput() +std::string L2NormTest::getErrorLogFileOutput() { - if (!testError) - colorOutput->makeL2NormTestOutput(testPassed, simInfos.at(0), normalizeData, basicTimeStep, divergentTimeStep, dataToCalculate, resultBasicTimestep, resultDivergentTimeStep, diffL2Norm); - else - colorOutput->makeL2NormTestErrorOutput(l2NormPostProStrategies.at(0)->getErrorMessage(), simInfos.at(0), normalizeData, basicTimeStep, divergentTimeStep, dataToCalculate); - + std::ostringstream oss; + oss << "L" << l2NormPostProStrategies.at(0)->getNumberOfXNodes() << "_" << dataToCalculate << "_" << normalizeData; + return oss.str(); } L2NormTest::L2NormTest(std::shared_ptr<ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate, double maxL2NormDiff, std::string normalizeData) @@ -86,5 +70,86 @@ L2NormTest::L2NormTest(std::shared_ptr<ColorConsoleOutput> colorOutput, std::sha basicTimeStep = testParameter->basicTimeStep; divergentTimeStep = testParameter->divergentTimeStep; this->maxL2NormDiff = maxL2NormDiff; - testError = false; -} \ No newline at end of file +} + +std::vector<std::string> L2NormTest::buildTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "L2Norm BasicTimeStep: " << resultBasicTimestep; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L2Norm DivergentTimeStep: " << resultDivergentTimeStep; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L2NormDiff: " << diffL2Norm; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} + +std::vector<std::string> L2NormTest::buildBasicTestOutput() +{ + std::vector<std::string> output; + std::ostringstream oss; + + output.push_back("L2 Norm Test"); + + oss << "Kernel: " << simInfos.at(0)->getKernelName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "Viscosity: " << simInfos.at(0)->getViscosity(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << simInfos.at(0)->getSimulationName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L: " << simInfos.at(0)->getLx() << simInfos.at(0)->getSimulationParameterString(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << "DataToCalculate: " << dataToCalculate; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "NormalizeData: " << normalizeData; + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << "BasicTimeStep: " << basicTimeStep; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "DivergentTimeStep: " << divergentTimeStep; + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + return output; +} + +std::vector<std::string> L2NormTest::buildErrorTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Error Message: " << l2NormPostProStrategies.at(0)->getErrorMessage(normalizeData); + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h index f054f2357774330a19811d447f3ad1a62f5c8787..2f83c03c9c20ac669cc478dcdb9e924390da2f8e 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/L2NormTest.h @@ -18,14 +18,17 @@ public: void update(); void addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<L2NormPostProcessingStrategy> postProStrategy); + void evaluate(); std::string getLogFileOutput(); - std::vector<bool> getPassedTests(); - void makeConsoleOutput(); - + std::string getErrorLogFileOutput(); private: L2NormTest(std::shared_ptr<ColorConsoleOutput> colorOutput, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::string dataToCalculate, double maxL2NormDiff, std::string normalizeData); + std::vector<std::string> buildTestOutput(); + std::vector<std::string> buildBasicTestOutput(); + std::vector<std::string> buildErrorTestOutput(); + unsigned int basicTimeStep, divergentTimeStep; double resultBasicTimestep, resultDivergentTimeStep; @@ -34,7 +37,6 @@ private: double maxL2NormDiff; bool testPassed; - bool testError; std::string normalizeData; std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > l2NormPostProStrategies; diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp index 50bf699a00c575c87e4142759c0e7f411d881210..01fbcd51ffde4a571b0f49fc049ff2f14f7be20e 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.cpp @@ -6,15 +6,15 @@ #include <iomanip> #include <sstream> -std::shared_ptr<L2NormInformation> L2NormInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter) +std::shared_ptr<L2NormInformation> L2NormInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::string> dataToCalcTests) { - return std::shared_ptr<L2NormInformation>(new L2NormInformation(tests, testParameter)); + return std::shared_ptr<L2NormInformation>(new L2NormInformation(tests, testParameter, dataToCalcTests)); } std::string L2NormInformation::getOutput() { std::ostringstream headName; - headName << tests.at(0)->getSimulationName() << " L2Norm Test"; + headName << " L2Norm Test"; makeCenterHead(headName.str()); oss << "BasicTimeStep_L2Norm=" << basicTimeStep << std::endl; @@ -27,17 +27,37 @@ std::string L2NormInformation::getOutput() else oss << "\"" << std::endl; } + oss << "NormalizeData_L2Norm=\""; + for (int i = 0; i < normalizeData.size(); i++) { + oss << normalizeData.at(i); + if (i < normalizeData.size() - 1) + oss << " "; + else + oss << "\"" << std::endl; + } oss << std::endl; - for (int i = 0; i < tests.size(); i++) - oss << tests.at(i)->getLogFileOutput(); - + std::ostringstream failMessage; + failMessage << "FailTests_L2Norm=\""; + for (int i = 0; i < tests.size(); i++) { + if (tests.at(i)->getTestStatus() == passed || tests.at(i)->getTestStatus() == failed) + oss << tests.at(i)->getLogFileOutput(); + if (tests.at(i)->getTestStatus() == error || tests.at(i)->getTestStatus() == simulationCrashed) + failMessage << tests.at(i)->getErrorLogFileOutput() << " "; + } + std::string fail = failMessage.str(); + if(fail.back() == ' ') + fail = fail.substr(0, fail.size() - 1); + failMessage.str(std::string()); + failMessage << fail << "\""; + oss << failMessage.str() << std::endl << std::endl; + return oss.str(); } -L2NormInformation::L2NormInformation(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter) : tests(tests) +L2NormInformation::L2NormInformation(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::string> dataToCalcTests) : tests(tests), dataToCalc(dataToCalcTests) { basicTimeStep = testParameter->basicTimeStep; divergentTimeStep = testParameter->divergentTimeStep; - dataToCalc = testParameter->basicTestParameter->dataToCalc; + normalizeData = testParameter->normalizeData; } \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h index ccba5418845c290db084aa63da37a001cf2c6ca4..f2a4bd086421bb32c2b986ac9cb25755697cf27d 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h @@ -12,17 +12,18 @@ struct L2NormTestParameterStruct; class L2NormInformation : public TestLogFileInformation { public: - static std::shared_ptr<L2NormInformation> getNewInstance(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter); + static std::shared_ptr<L2NormInformation> getNewInstance(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::string> dataToCalcTests); std::string getOutput(); private: L2NormInformation() {}; - L2NormInformation(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter); + L2NormInformation(std::vector<std::shared_ptr<L2NormTest> > tests, std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::string> dataToCalcTests); std::vector<std::shared_ptr<L2NormTest> > tests; unsigned int basicTimeStep, divergentTimeStep; std::vector<std::string> dataToCalc; + std::vector<std::string> normalizeData; }; #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 index e0527c6512edb0bec52ef5b1406373ad6dadc37f..8ead103104f98b9ea9733ec92a5a5e4c77894677 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.cpp @@ -2,100 +2,93 @@ #include "Tests/L2NormTest/L2NormTestParameterStruct.h" +#include "Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.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::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculator> l2Normcalculator) +std::shared_ptr<L2NormPostProcessingStrategy> L2NormPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests) { - return std::shared_ptr<L2NormPostProcessingStrategy>(new L2NormPostProcessingStrategy(simResult, analyticalResult, testPara, l2Normcalculator)); + return std::shared_ptr<L2NormPostProcessingStrategy>(new L2NormPostProcessingStrategy(simResult, analyticalResult, testPara, factory, dataToCalcTests)); } -L2NormPostProcessingStrategy::L2NormPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculator> l2Normcalculator) - : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) +L2NormPostProcessingStrategy::L2NormPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculate(dataToCalcTests) { - dataToCalculateL2 = testPara->basicTestParameter->dataToCalc; - basicTimeStepL2Norm = testPara->basicTimeStep; - divergentTimeStepL2Norm = testPara->divergentTimeStep; - isEvaluated = false; - this->l2Normcalculator = l2Normcalculator; + basicTimeStep = testPara->basicTimeStep; + divergentTimeStep = testPara->divergentTimeStep; + normalizeData = testPara->normalizeData; + + l2NormBasic.resize(dataToCalculate.size()); + l2NormDivergent.resize(dataToCalculate.size()); + for (int i = 0; i < l2NormBasic.size(); i++) { + l2NormBasic.at(i).resize(normalizeData.size()); + l2NormDivergent.at(i).resize(normalizeData.size()); + } + + for (int i = 0; i < normalizeData.size(); i++) + l2Normcalculator.push_back(factory->makeL2NormCalculator(normalizeData.at(i))); } void L2NormPostProcessingStrategy::evaluate() { if (!isEvaluated) { analyticalResult->calc(simResult); - int bS = calcTimeStepInResults(basicTimeStepL2Norm); - int dS = calcTimeStepInResults(divergentTimeStepL2Norm); + int bS = calcTimeStepInResults(basicTimeStep); + int dS = calcTimeStepInResults(divergentTimeStep); - 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), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - l2VxDivergent = l2Normcalculator->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - } - if (dataToCalculateL2.at(i) == "Vy") { - l2VyBasic = l2Normcalculator->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - l2VyDivergent = l2Normcalculator->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - } - if (dataToCalculateL2.at(i) == "Vz") { - l2VzBasic = l2Normcalculator->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - l2VzDivergent = l2Normcalculator->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - } - if (dataToCalculateL2.at(i) == "Press") { - l2PressBasic = l2Normcalculator->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - l2PressDivergent = l2Normcalculator->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - } - if (dataToCalculateL2.at(i) == "Rho") { - l2RhoBasic = l2Normcalculator->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); - l2RhoDivergent = l2Normcalculator->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength()); + for (int i = 0; i < dataToCalculate.size(); i++) { + for (int j = 0; j < normalizeData.size(); j++) { + if (dataToCalculate.at(i) == "Vx") { + l2NormBasic.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVx().at(bS), simResult->getVx().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + l2NormDivergent.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVx().at(dS), simResult->getVx().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } + if (dataToCalculate.at(i) == "Vy") { + l2NormBasic.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVy().at(bS), simResult->getVy().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + l2NormDivergent.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVy().at(dS), simResult->getVy().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } + if (dataToCalculate.at(i) == "Vz") { + l2NormBasic.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVz().at(bS), simResult->getVz().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + l2NormDivergent.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getVz().at(dS), simResult->getVz().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } + if (dataToCalculate.at(i) == "Press") { + l2NormBasic.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getPress().at(bS), simResult->getPress().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + l2NormDivergent.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getPress().at(dS), simResult->getPress().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } + if (dataToCalculate.at(i) == "Rho") { + l2NormBasic.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getRho().at(bS), simResult->getRho().at(bS), simResult->getLevels().at(bS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + l2NormDivergent.at(i).at(j) = l2Normcalculator.at(j)->calc(analyticalResult->getRho().at(dS), simResult->getRho().at(dS), simResult->getLevels().at(dS), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } } } 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> L2NormPostProcessingStrategy::getL2Norm(std::string aDataToCalc, std::string aNormalizeData) { - 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; -} + for (int i = 0; i < dataToCalculate.size(); i++) { + for (int j = 0; j < normalizeData.size(); j++) { + if (aDataToCalc == dataToCalculate.at(i) && aNormalizeData == normalizeData.at(j)) { + std::vector<double> v; + v.push_back(l2NormBasic.at(i).at(j)); + v.push_back(l2NormDivergent.at(i).at(j)); + return v; + } + } + } -std::vector<double> L2NormPostProcessingStrategy::getL2NormRho() -{ - std::vector<double> v; - v.push_back(l2RhoBasic); - v.push_back(l2RhoDivergent); - return v; + return std::vector<double>(); } -std::string L2NormPostProcessingStrategy::getErrorMessage() +std::string L2NormPostProcessingStrategy::getErrorMessage(std::string aNormalizeData) { - return l2Normcalculator->getErrorMessage(); + for (int i = 0; i < normalizeData.size(); i++) { + if (aNormalizeData == normalizeData.at(i)) + return l2Normcalculator.at(i)->getErrorMessage(); + } + + return std::string(); } diff --git a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h index 3e12f0c7b7b586e4ec5ac6ffc7641da566eb7c0a..59cfc269468b42699af80a4acfb78d4ffc35d69c 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h +++ b/targets/tests/NumericalTests/Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h @@ -7,32 +7,31 @@ class AnalyticalResults; class L2NormCalculator; +class L2NormCalculatorFactory; struct L2NormTestParameterStruct; class L2NormPostProcessingStrategy : public PostProcessingStrategyImp { public: - static std::shared_ptr<L2NormPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculator> l2Normcalculator); + static std::shared_ptr<L2NormPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests); void evaluate(); - std::vector<double> getL2NormVx(); - std::vector<double> getL2NormVy(); - std::vector<double> getL2NormVz(); - std::vector<double> getL2NormPress(); - std::vector<double> getL2NormRho(); + std::vector<double> getL2Norm(std::string dataToCalc, std::string normalizeData); - std::string getErrorMessage(); + std::string getErrorMessage(std::string aNormalizeData); private: - L2NormPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculator> l2Normcalculator); + L2NormPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests); 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; + std::vector<std::shared_ptr<L2NormCalculator> > l2Normcalculator; + + std::vector<std::string> dataToCalculate; + std::vector<std::string> normalizeData; + unsigned int basicTimeStep; + unsigned int divergentTimeStep; + std::vector<std::vector<double>> l2NormBasic; + std::vector<std::vector<double>> l2NormDivergent; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp index 3c3d695d209f9cad20ce0f3a9e8cd7aedd83e419..19b0a32ac77a53e3cd43a1676efb10ce035418fa 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.cpp @@ -10,9 +10,9 @@ #include <iomanip> -std::shared_ptr<L2NormTestBetweenKernels> L2NormTestBetweenKernels::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith) +std::shared_ptr<L2NormTestBetweenKernels> L2NormTestBetweenKernels::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith, std::shared_ptr<L2NormCalculatorFactory> factory) { - return std::shared_ptr<L2NormTestBetweenKernels>(new L2NormTestBetweenKernels(colorOutput, dataToCalculate, timeStep, normalizeWith)); + return std::shared_ptr<L2NormTestBetweenKernels>(new L2NormTestBetweenKernels(colorOutput, dataToCalculate, timeStep, normalizeWith, factory)); } void L2NormTestBetweenKernels::update() @@ -27,39 +27,28 @@ void L2NormTestBetweenKernels::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), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); - } - if (dataToCalculate == "Vy") { - basicL2Result = basicPostProcessingStrategy->getL2NormVy(timeStep); - divergentL2Result = divergentPostProcessingStrategy->getL2NormVy(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(tS), divergentSimResults->getVy().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); - } - if (dataToCalculate == "Vz") { - basicL2Result = basicPostProcessingStrategy->getL2NormVz(timeStep); - divergentL2Result = divergentPostProcessingStrategy->getL2NormVz(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(tS), divergentSimResults->getVz().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); - } - if (dataToCalculate == "Press") { - basicL2Result = basicPostProcessingStrategy->getL2NormPress(timeStep); - divergentL2Result = divergentPostProcessingStrategy->getL2NormPress(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(tS), divergentSimResults->getPress().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); - } - if (dataToCalculate == "Rho") { - basicL2Result = basicPostProcessingStrategy->getL2NormRho(timeStep); - divergentL2Result = divergentPostProcessingStrategy->getL2NormRho(timeStep); - resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(tS), divergentSimResults->getRho().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getTimeStepLength()); - } - if (basicL2Result < 0 || divergentL2Result < 0 || resultL2ToBasicKernel < 0) { - testError = true; - testPassed = false; - } + basicL2Result = basicPostProcessingStrategy->getL2Norm(dataToCalculate, normalizeData, timeStep); + divergentL2Result = divergentPostProcessingStrategy->getL2Norm(dataToCalculate, normalizeData, timeStep); + + if (dataToCalculate == "Vx") + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVx().at(tS), divergentSimResults->getVx().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes()); + if (dataToCalculate == "Vy") + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(tS), divergentSimResults->getVy().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes()); + if (dataToCalculate == "Vz") + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(tS), divergentSimResults->getVz().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes()); + if (dataToCalculate == "Press") + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(tS), divergentSimResults->getPress().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes()); + if (dataToCalculate == "Rho") + resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(tS), divergentSimResults->getRho().at(tS), basicSimResults->getLevels().at(tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes()); + + + + if (basicL2Result < 0 || divergentL2Result < 0 || resultL2ToBasicKernel < 0) + testStatus = error; + else if (basicL2Result <= divergentL2Result) + testStatus = passed; else - { - testPassed = basicL2Result <= divergentL2Result; - } + testStatus = failed; makeConsoleOutput(); } @@ -67,30 +56,22 @@ void L2NormTestBetweenKernels::evaluate() std::string L2NormTestBetweenKernels::getLogFileOutput() { std::ostringstream oss; - oss << "NormalizeData_L" << "_" << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "=" << normalizeWith << std::endl; - oss << "L2Norm_BasicKernel_" << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "=" << basicL2Result << std::endl; - oss << "L2Norm_DivergentKernel_" << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "=" << divergentL2Result << std::endl; - oss << "L2Norm_Between_Kernels_" << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "=" << resultL2ToBasicKernel << std::endl << std::endl; - + oss << "L2Norm_BasicKernel_" << "L" << basicPostProcessingStrategy->getNumberOfXNodes() << "_"<< dataToCalculate << "_TimeStep_" << timeStep << "_" << normalizeData << "=" << basicL2Result << std::endl; + oss << "L2Norm_DivergentKernel_" << "L" << basicPostProcessingStrategy->getNumberOfXNodes() << "_"<< dataToCalculate << "_TimeStep_" << timeStep << "_" << normalizeData << "=" << divergentL2Result << std::endl; + oss << "L2Norm_Between_Kernels_" << "L" << basicPostProcessingStrategy->getNumberOfXNodes() << "_"<< dataToCalculate << "_TimeStep_" << timeStep << "_" << normalizeData << "=" << resultL2ToBasicKernel << std::endl << std::endl; return oss.str(); } -double L2NormTestBetweenKernels::getBasicL2Result() -{ - return basicL2Result; -} - -std::vector<bool> L2NormTestBetweenKernels::getPassedTests() +std::string L2NormTestBetweenKernels::getErrorLogFileOutput() { - return std::vector<bool>(1, testPassed); + std::ostringstream oss; + oss << dataToCalculate << "_TimeStep_" << timeStep << "_L" << basicPostProcessingStrategy->getNumberOfXNodes() << "_" << normalizeData; + return oss.str(); } -void L2NormTestBetweenKernels::makeConsoleOutput() +double L2NormTestBetweenKernels::getBasicL2Result() { - if (!testError) - colorOutput->makeL2NormBetweenKernelsTestOutput(testPassed, basicSimInfo, normalizeWith, divergentSimInfo, dataToCalculate, timeStep, basicL2Result, divergentL2Result, resultL2ToBasicKernel); - else - colorOutput->makeL2NormBetweenKernelsTestErrorOutput(basicPostProcessingStrategy->getErrorMessage(), basicSimInfo, normalizeWith, divergentSimInfo, dataToCalculate, timeStep); + return basicL2Result; } void L2NormTestBetweenKernels::setBasicSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy) @@ -111,12 +92,10 @@ void L2NormTestBetweenKernels::setDivergentKernelSimulation(std::shared_ptr<Nume this->divergentSimResults = divergentPostProcessingStrategy->getSimulationResult(); } -L2NormTestBetweenKernels::L2NormTestBetweenKernels(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith) - : TestImp(colorOutput), timeStep(timeStep), dataToCalculate(dataToCalculate), normalizeWith(normalizeWith) +L2NormTestBetweenKernels::L2NormTestBetweenKernels(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith, std::shared_ptr<L2NormCalculatorFactory> factory) + : TestImp(colorOutput), timeStep(timeStep), dataToCalculate(dataToCalculate), normalizeData(normalizeWith) { - std::shared_ptr<L2NormCalculatorFactory> l2NormCalculatorFactory = L2NormCalculatorFactory::getInstance(); - l2Normcalculator = l2NormCalculatorFactory->makeL2NormCalculator(normalizeWith); - testError = false; + l2Normcalculator = factory->makeL2NormCalculator(normalizeWith); } int L2NormTestBetweenKernels::calcTimeStepInResults(unsigned int timeStep) @@ -126,3 +105,83 @@ int L2NormTestBetweenKernels::calcTimeStepInResults(unsigned int timeStep) return basicSimResults->getTimeSteps().at(i); } } + +std::vector<std::string> L2NormTestBetweenKernels::buildTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "L2Norm BasicKernel: " << basicL2Result; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L2Norm DivergentKernel: " << divergentL2Result; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L2NormDiff: " << resultL2ToBasicKernel; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} + +std::vector<std::string> L2NormTestBetweenKernels::buildBasicTestOutput() +{ + std::vector<std::string> output; + std::ostringstream oss; + + output.push_back("L2 Norm Between Kernels Test"); + + oss << "Basic Kernel: " << basicSimInfo->getKernelName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "Divergent Kernel: " << divergentSimInfo->getKernelName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "Viscosity: " << basicSimInfo->getViscosity(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << basicSimInfo->getSimulationName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "L: " << basicSimInfo->getLx() << basicSimInfo->getSimulationParameterString(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << "DataToCalculate: " << dataToCalculate; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "NormalizeData: " << normalizeData; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "TimeStep: " << timeStep; + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + return output; +} + +std::vector<std::string> L2NormTestBetweenKernels::buildErrorTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Error Message: " << basicPostProcessingStrategy->getErrorMessage(normalizeData); + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h index a7bf15d5531923c2645486262c957b9907345a79..dff57b6bcc374092805ab9db7f086aeae11c257b 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h @@ -7,49 +7,45 @@ class L2NormBetweenKernelPostProcessingStrategy; class L2NormCalculator; +class L2NormCalculatorFactory; 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, std::string normalizeWith); + static std::shared_ptr<L2NormTestBetweenKernels> getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith, std::shared_ptr<L2NormCalculatorFactory> factory); void update(); void evaluate(); std::string getLogFileOutput(); + std::string getErrorLogFileOutput(); double getBasicL2Result(); - std::vector<bool> getPassedTests(); - void makeConsoleOutput(); void setBasicSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy); void setDivergentKernelSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> postProcessingStrategy); private: - L2NormTestBetweenKernels(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith); + L2NormTestBetweenKernels(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith, std::shared_ptr<L2NormCalculatorFactory> factory); int calcTimeStepInResults(unsigned int timeStep); + std::vector<std::string> buildTestOutput(); + std::vector<std::string> buildBasicTestOutput(); + std::vector<std::string> buildErrorTestOutput(); unsigned int timeStep; std::string dataToCalculate; - bool testPassed; - bool testError; - std::shared_ptr<NumericalTestSimulation> basicSim; std::shared_ptr<SimulationInfo> basicSimInfo; std::shared_ptr<SimulationResults> basicSimResults; std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> basicPostProcessingStrategy; double basicL2Result; - std::shared_ptr<NumericalTestSimulation> divergentSim; std::shared_ptr<SimulationInfo> divergentSimInfo; std::shared_ptr<SimulationResults> divergentSimResults; std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> divergentPostProcessingStrategy; double divergentL2Result; - std::shared_ptr<L2NormCalculator> l2Normcalculator; - - std::string normalizeWith; - + std::string normalizeData; double resultL2ToBasicKernel; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h index 8d653e57779dac8e9c23115748e609e287dfd65c..ce32b89274cfc96907a67871ffbff67d833e58bc 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h @@ -16,7 +16,7 @@ struct L2NormTestBetweenKernelsParameterStruct std::vector<std::string> kernelsToTest; std::vector<int> timeSteps; - std::string normalizeWith; + std::vector<std::string> normalizeData; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp index 65918efbfa453373870c2d46758e5a23cd71a5e7..c1806a6a784830f72e47e7e17593d6db5953f9f3 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.cpp @@ -6,41 +6,58 @@ #include <iomanip> #include <sstream> -std::shared_ptr<L2NormBetweenKernelsInformation> L2NormBetweenKernelsInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) +std::shared_ptr<L2NormBetweenKernelsInformation> L2NormBetweenKernelsInformation::getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::string> dataToCalcTests) { - return std::shared_ptr<L2NormBetweenKernelsInformation>(new L2NormBetweenKernelsInformation(tests, testPara)); + return std::shared_ptr<L2NormBetweenKernelsInformation>(new L2NormBetweenKernelsInformation(tests, testPara, dataToCalcTests)); } std::string L2NormBetweenKernelsInformation::getOutput() { std::ostringstream headName; - headName << tests.at(0)->getSimulationName() << "L2Norm Test Between Kernels"; + headName << "L2Norm Test Between Kernels"; makeCenterHead(headName.str()); - oss << "BasicKernel=" << basicKernel << std::endl; + oss << "BasicKernel_L2Norm_BK=" << basicKernel << std::endl; oss << "DataToCalculate_L2Norm_BK=\""; for (int i = 0; i < dataToCalc.size(); i++) oss << dataToCalc.at(i) << " "; deleteLastCharInOss(); oss << "\"" << std::endl; - oss << "TimeSteps=\""; + oss << "TimeSteps_L2Norm_BK=\""; for (int i = 0; i < timeSteps.size(); i++) oss << timeSteps.at(i) << " "; deleteLastCharInOss(); oss << "\""<< std::endl << std::endl; + oss << "NormalizeWith_L2Norm_BK=\""; + for (int i = 0; i < normalizeData.size(); i++) + oss << normalizeData.at(i) << " "; + deleteLastCharInOss(); + oss << "\"" << std::endl << std::endl; - for (int i = 0; i < tests.size(); i++) - oss << tests.at(i)->getLogFileOutput(); + std::ostringstream failMessage; + failMessage << "FailTests_L2Norm_BK=\""; + for (int i = 0; i < tests.size(); i++) { + if (tests.at(i)->getTestStatus() == passed || tests.at(i)->getTestStatus() == failed) + oss << tests.at(i)->getLogFileOutput(); + if (tests.at(i)->getTestStatus() == error || tests.at(i)->getTestStatus() == simulationCrashed) + failMessage << tests.at(i)->getErrorLogFileOutput() << " "; + } + std::string fail = failMessage.str(); + if (fail.back() == ' ') + fail = fail.substr(0, fail.size() - 1); + failMessage.str(std::string()); + failMessage << fail << "\""; + oss << failMessage.str() << std::endl << std::endl; return oss.str(); } -L2NormBetweenKernelsInformation::L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) - : tests(tests) +L2NormBetweenKernelsInformation::L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::string> dataToCalcTests) + : tests(tests), dataToCalc(dataToCalcTests) { basicKernel = testPara->basicKernel; timeSteps = testPara->timeSteps; - dataToCalc = testPara->basicTestParameter->dataToCalc; + normalizeData = testPara->normalizeData; } void L2NormBetweenKernelsInformation::deleteLastCharInOss() diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h index 6dc52591204a173dc847eff309362f3c06de1010..738d74f35876c3589564e9cc647fb0496cbe74de 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h @@ -12,13 +12,13 @@ struct L2NormTestBetweenKernelsParameterStruct; class L2NormBetweenKernelsInformation : public TestLogFileInformation { public: - static std::shared_ptr<L2NormBetweenKernelsInformation> getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); + static std::shared_ptr<L2NormBetweenKernelsInformation> getNewInstance(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::string> dataToCalcTests); std::string getOutput(); private: L2NormBetweenKernelsInformation() {}; - L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); + L2NormBetweenKernelsInformation(std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::string> dataToCalcTests); void deleteLastCharInOss(); @@ -27,5 +27,6 @@ private: std::string basicKernel; std::vector<int> timeSteps; std::vector<std::string> dataToCalc; + std::vector<std::string> normalizeData; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp index 56ab11247267f7da86c1fc4debd1448f12358c82..ac261db65ff5ed4a6eef8b87633918f6ee715a7f 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.cpp @@ -7,9 +7,9 @@ #include "Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h" -std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> L2NormBetweenKernelPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) +std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> L2NormBetweenKernelPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests) { - return std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy>(new L2NormBetweenKernelPostProcessingStrategy(simResult, analyticalResult, testPara)); + return std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy>(new L2NormBetweenKernelPostProcessingStrategy(simResult, analyticalResult, testPara, factory, dataToCalcTests)); } void L2NormBetweenKernelPostProcessingStrategy::evaluate() @@ -17,54 +17,56 @@ 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), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); - if (dataToCalculate.at(j) == "Vy") - l2Vy.push_back(l2Normcalculator->calc(analyticalResult->getVy().at(time), simResult->getVy().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); - if (dataToCalculate.at(j) == "Vz") - l2Vz.push_back(l2Normcalculator->calc(analyticalResult->getVz().at(time), simResult->getVz().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); - if (dataToCalculate.at(j) == "Press") - l2Press.push_back(l2Normcalculator->calc(analyticalResult->getPress().at(time), simResult->getPress().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); - if (dataToCalculate.at(j) == "Rho") - l2Rho.push_back(l2Normcalculator->calc(analyticalResult->getRho().at(time), simResult->getRho().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes(), analyticalResult->getTimeStepLength())); + l2Norm.resize(dataToCalculate.size()); + for (int i = 0; i < dataToCalculate.size(); i++) { + l2Norm.at(i).resize(normalizeData.size()); + for (int j = 0; j < normalizeData.size(); j++) { + l2Norm.at(i).at(j).resize(timeSteps.size()); + } + } + + for (int i = 0; i < dataToCalculate.size(); i++) { + for (int j = 0; j < normalizeData.size(); j++) { + for (int k = 0; k < timeSteps.size(); k++) { + int time = calcTimeStepInResults(timeSteps.at(k)); + if (dataToCalculate.at(i) == "Vx") + l2Norm.at(i).at(j).at(k) = l2Normcalculator.at(j)->calc(analyticalResult->getVx().at(time), simResult->getVx().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + if (dataToCalculate.at(i) == "Vy") + l2Norm.at(i).at(j).at(k) = l2Normcalculator.at(j)->calc(analyticalResult->getVy().at(time), simResult->getVy().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + if (dataToCalculate.at(i) == "Vz") + l2Norm.at(i).at(j).at(k) = l2Normcalculator.at(j)->calc(analyticalResult->getVz().at(time), simResult->getVz().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + if (dataToCalculate.at(i) == "Press") + l2Norm.at(i).at(j).at(k) = l2Normcalculator.at(j)->calc(analyticalResult->getPress().at(time), simResult->getPress().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + if (dataToCalculate.at(i) == "Rho") + l2Norm.at(i).at(j).at(k) = l2Normcalculator.at(j)->calc(analyticalResult->getRho().at(time), simResult->getRho().at(time), simResult->getLevels().at(time), analyticalResult->getNumberOfXNodes(), analyticalResult->getNumberOfZNodes()); + } } } 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) +double L2NormBetweenKernelPostProcessingStrategy::getL2Norm(std::string aDataToCalc, std::string aNormalizeData, int aTimeStep) { - return l2Press.at(calcPosInTimeStep(timeStep)); -} + for (int i = 0; i < dataToCalculate.size(); i++) { + for (int j = 0; j < normalizeData.size(); j++) { + for (int k = 0; k < timeSteps.size(); k++) { + if (aDataToCalc == dataToCalculate.at(i) && aNormalizeData == normalizeData.at(j) && aTimeStep == timeSteps.at(k)) + return l2Norm.at(i).at(j).at(k); + } + } + } -double L2NormBetweenKernelPostProcessingStrategy::getL2NormRho(int timeStep) -{ - return l2Rho.at(calcPosInTimeStep(timeStep)); + return 0.0; } -std::string L2NormBetweenKernelPostProcessingStrategy::getErrorMessage() +std::string L2NormBetweenKernelPostProcessingStrategy::getErrorMessage(std::string aNormalizeData) { - return l2Normcalculator->getErrorMessage(); + for (int i = 0; i < normalizeData.size(); i++) { + if (aNormalizeData == normalizeData.at(i)) + return l2Normcalculator.at(i)->getErrorMessage(); + } + return std::string(); } std::shared_ptr<SimulationResults> L2NormBetweenKernelPostProcessingStrategy::getSimulationResult() @@ -72,14 +74,25 @@ std::shared_ptr<SimulationResults> L2NormBetweenKernelPostProcessingStrategy::ge return simResult; } -L2NormBetweenKernelPostProcessingStrategy::L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara) - : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult) +L2NormBetweenKernelPostProcessingStrategy::L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculate(dataToCalcTests) { - timeSteps = testPara->timeSteps; - dataToCalculate = testPara->basicTestParameter->dataToCalc; - std::shared_ptr<L2NormCalculatorFactory> l2NormCalculatorFactory = L2NormCalculatorFactory::getInstance(); - l2Normcalculator = l2NormCalculatorFactory->makeL2NormCalculator(testPara->normalizeWith); isEvaluated = false; + normalizeData = testPara->normalizeData; + timeSteps = testPara->timeSteps; + + l2Norm.resize(dataToCalculate.size()); + for (int i = 0; i < dataToCalculate.size(); i++) { + l2Norm.at(i).resize(normalizeData.size()); + for (int j = 0; j < normalizeData.size(); j++) { + l2Norm.at(i).at(j).resize(timeSteps.size()); + } + } + + + for (int i = 0; i < normalizeData.size(); i++) + l2Normcalculator.push_back(factory->makeL2NormCalculator(normalizeData.at(i))); + } int L2NormBetweenKernelPostProcessingStrategy::calcPosInTimeStep(int time) diff --git a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h index f31de0cacd8f2fc93835011a1651511a591851db..8f8ee2e37a009b99fff7db5c089abbd21e338cea 100644 --- a/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h +++ b/targets/tests/NumericalTests/Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h @@ -7,39 +7,33 @@ class AnalyticalResults; class L2NormCalculator; +class L2NormCalculatorFactory; struct L2NormTestBetweenKernelsParameterStruct; class L2NormBetweenKernelPostProcessingStrategy : public PostProcessingStrategyImp { public: - static std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); + static std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests); void evaluate(); - double getL2NormVx(int timeStep); - double getL2NormVy(int timeStep); - double getL2NormVz(int timeStep); - double getL2NormPress(int timeStep); - double getL2NormRho(int timeStep); + double getL2Norm(std::string aDataToCalc, std::string aNormalizeData, int aTimeStep); - std::string getErrorMessage(); + std::string getErrorMessage(std::string aNormalizeData); virtual std::shared_ptr<SimulationResults> getSimulationResult(); private: - L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara); + L2NormBetweenKernelPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::shared_ptr<L2NormCalculatorFactory> factory, std::vector<std::string> dataToCalcTests); 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; + std::vector<std::shared_ptr<L2NormCalculator> > l2Normcalculator; + std::vector<std::string> dataToCalculate; + std::vector<std::string> normalizeData; + std::vector<int> timeSteps; + + std::vector<std::vector<std::vector<double> > > l2Norm; bool isEvaluated; }; diff --git a/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b5e8cdb5ab9a18732a979cc3f52e6400b3df76f8 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.cpp @@ -0,0 +1,122 @@ +#include "NyTestLogFileInformation.h" + +#include "Tests/NyTest/NyTest.h" +#include "Tests/NyTest/NyTestParameterStruct.h" + +#include <iomanip> +#include <sstream> + + +std::shared_ptr<NyTestLogFileInformation> NyTestLogFileInformation::getNewInstance(std::shared_ptr<NyTestParameterStruct> testPara) +{ + return std::shared_ptr<NyTestLogFileInformation>(new NyTestLogFileInformation(testPara)); +} + +std::string NyTestLogFileInformation::getOutput() +{ + std::ostringstream headName; + headName <<"Ny Test"; + makeCenterHead(headName.str()); + + oss << "StartTimeStepCalculation_NyTest=" << startTimeStepCalculation << std::endl; + oss << "EndTimeStepCalculation_NyTest=" << endTimeStepCalculation << std::endl; + oss << "DataToCalc_NyTest=\""; + for (int i = 0; i < testGroups.size(); i++) { + oss << testGroups.at(i).at(0)->getDataToCalculate(); + if (i < testGroups.size() - 1) + oss << " "; + else + oss << "\"" << std::endl; + } + oss << std::endl; + + std::ostringstream failMessageNy; + failMessageNy << "FailTests_Ny_NyTest=\""; + std::ostringstream failMessageOOA; + failMessageOOA << "FailTests_OOA_NyTest=\""; + for (int i = 0; i < testGroups.size(); i++) { + fillMyData(testGroups.at(i)); + for (int j = 0; j < lxForErase.size(); j++) { + if (status.at(j) == passed || status.at(j) == failed) { + oss << "Ny_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << ny.at(j) << std::endl; + oss << "NyDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << nyDiff.at(j) << std::endl; + } + else + failMessageNy << lxForErase.at(j) << "_" << dataToCalc.at(j) << " "; + } + oss << std::endl; + for (int j = 0; j < orderOfAccuracyNyDiff.size(); j++) { + if (status.at(j) == passed || status.at(j) == failed) { + oss << "OrderOfAccuracy_NyDiff_" << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracyNyDiff.at(j) << std::endl; + } + else + failMessageOOA << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << " "; + } + } + std::string failNy = failMessageNy.str(); + if (failNy.back() == ' ') + failNy = failNy.substr(0, failNy.size() - 1); + failMessageNy.str(std::string()); + failMessageNy << failNy << "\""; + oss << failMessageNy.str() << std::endl << std::endl; + + std::string failOOA = failMessageOOA.str(); + if (failOOA.back() == ' ') + failOOA = failOOA.substr(0, failOOA.size() - 1); + failMessageOOA.str(std::string()); + failMessageOOA << failOOA << "\""; + oss << failMessageOOA.str() << std::endl << std::endl; + + return oss.str(); +} + +void NyTestLogFileInformation::addTestGroup(std::vector<std::shared_ptr<NyTest> > tests) +{ + testGroups.push_back(tests); +} + +void NyTestLogFileInformation::fillMyData(std::vector<std::shared_ptr<NyTest> > testGroup) +{ + lxForErase.resize(0); + lx.resize(0); + ny.resize(0); + nyDiff.resize(0); + orderOfAccuracyNyDiff.resize(0); + dataToCalc.resize(0); + status.resize(0); + for (int i = 0; i < testGroup.size(); i++) { + std::vector<int> myLx = testGroup.at(i)->getLx(); + std::vector<double> myNy = testGroup.at(i)->getNy(); + std::vector<double> myNyDiff = testGroup.at(i)->getNyDiff(); + lx.insert(lx.end(), myLx.begin(), myLx.end()); + lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end()); + ny.insert(ny.end(), myNy.begin(), myNy.end()); + nyDiff.insert(nyDiff.end(), myNyDiff.begin(), myNyDiff.end()); + orderOfAccuracyNyDiff.push_back(testGroup.at(i)->getOrderOfAccuracyNyDiff()); + dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); + dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); + status.push_back(testGroup.at(i)->getTestStatus()); + status.push_back(testGroup.at(i)->getTestStatus()); + } + + for (int i = 0; i < lxForErase.size(); i++) + for (int j = i + 1; j < lxForErase.size(); j++) + if (lxForErase.at(i) == lxForErase.at(j)) + lxForErase.at(j) = -1; + + for (int i = lxForErase.size() - 1; i >= 0; i--) { + if (lxForErase.at(i) == -1) { + ny.erase(ny.begin() + i); + nyDiff.erase(nyDiff.begin() + i); + lxForErase.erase(lxForErase.begin() + i); + } + } + + +} + +NyTestLogFileInformation::NyTestLogFileInformation(std::shared_ptr<NyTestParameterStruct> testPara) +{ + startTimeStepCalculation = testPara->startTimeStepCalculation; + endTimeStepCalculation = testPara->endTimeStepCalculation; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.h b/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.h new file mode 100644 index 0000000000000000000000000000000000000000..b554ac96574ed719c1121a579ed8531cd754fcdf --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/NyTestLogFileInformation.h @@ -0,0 +1,36 @@ +#ifndef NY_TEST_LOGFILE_INFORMATION_H +#define NY_TEST_LOGFILE_INFORMATION_H + +#include "Utilities/LogFileInformation/TestLogFileInformation/TestLogFileInformation.h" +#include "Utilities/Test/TestStatus.h" + +#include <memory> +#include <vector> + +class NyTest; +struct NyTestParameterStruct; + +class NyTestLogFileInformation : public TestLogFileInformation +{ +public: + static std::shared_ptr<NyTestLogFileInformation> getNewInstance(std::shared_ptr<NyTestParameterStruct> testPara); + + std::string getOutput(); + void addTestGroup(std::vector<std::shared_ptr<NyTest> > tests); + +private: + NyTestLogFileInformation() {}; + NyTestLogFileInformation(std::shared_ptr<NyTestParameterStruct> testPara); + + void fillMyData(std::vector<std::shared_ptr<NyTest> > testGroup); + + std::vector<std::vector<std::shared_ptr<NyTest> > > testGroups; + unsigned int startTimeStepCalculation, endTimeStepCalculation; + std::vector<int> lx; + std::vector<int> lxForErase; + std::vector<double> ny, nyDiff; + std::vector<double> orderOfAccuracyNyDiff; + std::vector<std::string> dataToCalc; + std::vector<TestStatus> status; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/package.include b/targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/package.include similarity index 100% rename from targets/tests/NumericalTests/Tests/PhiAndNyTest/package.include rename to targets/tests/NumericalTests/Tests/NyTest/LogFileInformation/package.include diff --git a/targets/tests/NumericalTests/Tests/NyTest/NyTest.cpp b/targets/tests/NumericalTests/Tests/NyTest/NyTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e2960c81c19201b03827f6ebbf027dba4f3cc78a --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/NyTest.cpp @@ -0,0 +1,205 @@ +#include "NyTest.h" + +#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" +#include "Utilities/TestSimulation/TestSimulation.h" +#include "Utilities/SimulationInfo/SimulationInfo.h" + +#include "Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.h" +#include "Tests/NyTest/NyTestParameterStruct.h" + +#include <iomanip> + +std::shared_ptr<NyTest> NyTest::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<NyTestParameterStruct> testPara, std::string dataToCalculate) +{ + return std::shared_ptr<NyTest>(new NyTest(colorOutput, viscosity, testPara, dataToCalculate)); +} + +void NyTest::evaluate() +{ + for (int i = 0; i < postProStrategies.size(); i++) + ny.push_back(postProStrategies.at(i)->getNy(dataToCalculate)); + + if (checkNy(ny)) { + nyDiff = calcNyDiff(ny); + orderOfAccuracy = calcOrderOfAccuracy(nyDiff); + testStatus = checkTestPassed(orderOfAccuracy); + } + else + testStatus = error; + + + makeConsoleOutput(); +} + +void NyTest::update() +{ + TestImp::update(); +} + +void NyTest::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<NyTestPostProcessingStrategy> postProStrategy) +{ + TestImp::addSimulation(sim, simInfo, postProStrategy); + postProStrategies.push_back(postProStrategy); + lx.push_back(postProStrategy->getNumberOfXNodes()); +} + +std::string NyTest::getDataToCalculate() +{ + return dataToCalculate; +} + +std::vector<int> NyTest::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> NyTest::getNy() +{ + return ny; +} + +std::vector<double> NyTest::getNyDiff() +{ + return nyDiff; +} + +double NyTest::getOrderOfAccuracyNyDiff() +{ + return orderOfAccuracy; +} + +NyTest::NyTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<NyTestParameterStruct> testPara, std::string dataToCalculate) + : TestImp(colorOutput), viscosity(viscosity), dataToCalculate(dataToCalculate) +{ + minOrderOfAccuracy = testPara->minOrderOfAccuracy; + startStepCalculation = testPara->startTimeStepCalculation; + endStepCalculation = testPara->endTimeStepCalculation; + + lx.resize(0); + nyDiff.resize(0); +} + +double NyTest::calcOrderOfAccuracy(std::vector<double> data) +{ + double ooa = log(data.at(0) / data.at(1)) / log(lx.at(1) / lx.at(0)); + + return ooa; +} + +TestStatus NyTest::checkTestPassed(double orderOfAccuracy) +{ + if (orderOfAccuracy > minOrderOfAccuracy) + return passed; + else + return failed; +} + +bool NyTest::checkNy(std::vector<double> ny) +{ + for(int i = 0; i < ny.size(); i++) + if(ny.at(i) < 0.0) + return false; + return true; +} + +std::vector<double> NyTest::calcNyDiff(std::vector<double> ny) +{ + std::vector<double> results; + for (int i = 0; i < ny.size(); i++) + results.push_back(abs((ny.at(i) - viscosity) / viscosity)); + return results; +} + +std::vector<std::string> NyTest::buildTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + for (int i = 0; i < ny.size(); i++) { + oss << "Ny" << simInfos.at(i)->getLx() << ": " << ny.at(i); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "NyDiff" << simInfos.at(i)->getLx() << ": " << nyDiff.at(i); + output.push_back(oss.str()); + oss.str(std::string()); + } + oss << "OrderOfAccuracy: " << orderOfAccuracy; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} + +std::vector<std::string> NyTest::buildBasicTestOutput() +{ + std::vector<std::string> output; + std::ostringstream oss; + + output.push_back("Ny Test"); + + oss << "Kernel: " << simInfos.at(0)->getKernelName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "Viscosity: " << simInfos.at(0)->getViscosity(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << simInfos.at(0)->getSimulationName(); + output.push_back(oss.str()); + oss.str(std::string()); + + for (int i = 0; i < simInfos.size(); i++) { + oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfos.at(i)->getLx() << simInfos.at(i)->getSimulationParameterString(); + output.push_back(oss.str()); + oss.str(std::string()); + } + + output.push_back(oss.str()); + + oss << "DataToCalculate: " << dataToCalculate; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "StartTimeStep: " << startStepCalculation; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "EndTimeStep: " << endStepCalculation; + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + return output; +} + +std::vector<std::string> NyTest::buildErrorTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Error Message: Ny < 0"; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} + +std::vector<std::string> NyTest::buildSimulationFailedTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Simulation crashed!"; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} diff --git a/targets/tests/NumericalTests/Tests/NyTest/NyTest.h b/targets/tests/NumericalTests/Tests/NyTest/NyTest.h new file mode 100644 index 0000000000000000000000000000000000000000..2a6469fb0785db31b8a24d9fb6a090ec9c9a43a5 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/NyTest.h @@ -0,0 +1,53 @@ +#ifndef NY_TEST_H +#define NY_TEST_H + +#include "Utilities/Test/TestImp.h" + +#include <memory> +#include <vector> +#include <iostream> + +class FFTCalculator; +class NyTestPostProcessingStrategy; +struct NyTestParameterStruct; + +class NyTest : public TestImp +{ +public: + static std::shared_ptr<NyTest> getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<NyTestParameterStruct> testPara, std::string dataToCalculate); + + void update(); + void addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<NyTestPostProcessingStrategy> postProStrategy); + + void evaluate(); + + std::string getDataToCalculate(); + std::vector<int> getLx(); + std::vector<double> getNy(); + std::vector<double> getNyDiff(); + double getOrderOfAccuracyNyDiff(); + +private: + NyTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<NyTestParameterStruct> testPara, std::string dataToCalculate); + double calcOrderOfAccuracy(std::vector<double> data); + TestStatus checkTestPassed(double orderOfAccuracy); + bool checkNy(std::vector<double> ny); + std::vector<double> calcNyDiff(std::vector<double> ny); + std::vector<std::string> buildTestOutput(); + std::vector<std::string> buildBasicTestOutput(); + std::vector<std::string> buildErrorTestOutput(); + std::vector<std::string> buildSimulationFailedTestOutput(); + + + unsigned int startStepCalculation, endStepCalculation; + std::vector<double> lx; + std::vector<double> ny, nyDiff; + double orderOfAccuracy; + double minOrderOfAccuracy; + double viscosity; + std::string dataToCalculate; + + std::vector<std::shared_ptr<NyTestPostProcessingStrategy> > postProStrategies; + +}; +#endif diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h b/targets/tests/NumericalTests/Tests/NyTest/NyTestParameterStruct.h similarity index 68% rename from targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h rename to targets/tests/NumericalTests/Tests/NyTest/NyTestParameterStruct.h index 978e175a831be52c4f8bf33367a084e103c9cd0a..577077d30b433791f4289fc79ed745687608f5d2 100644 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h +++ b/targets/tests/NumericalTests/Tests/NyTest/NyTestParameterStruct.h @@ -1,11 +1,11 @@ -#ifndef PHI_AND_NY_TEST_PARAMETER_STRUCT_H -#define PHI_AND_NY_TEST_PARAMETER_STRUCT_H +#ifndef NY_TEST_PARAMETER_STRUCT_H +#define NY_TEST_PARAMETER_STRUCT_H #include <memory> #include "Utilities/Structs/BasicTestParameterStruct.h" -struct PhiAndNyTestParameterStruct +struct NyTestParameterStruct { std::shared_ptr<BasicTestParameterStruct> basicTestParameter; diff --git a/targets/tests/NumericalTests/Tests/NyTest/NyTestStruct.h b/targets/tests/NumericalTests/Tests/NyTest/NyTestStruct.h new file mode 100644 index 0000000000000000000000000000000000000000..7997586415f2ca7cdfe3a8bf62b6e6493629a65c --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/NyTestStruct.h @@ -0,0 +1,15 @@ +#ifndef NY_TEST_STRUCT_H +#define NY_TEST_STRUCT_H + +#include <memory> +#include <vector> + +class NyTestLogFileInformation; +class NyTest; + +struct NyTestStruct +{ + std::shared_ptr<NyTestLogFileInformation> logFileInfo; + std::vector<std::shared_ptr<NyTest> > tests; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.cpp b/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ec87f5ed96a289dc06e02e94239f936518bf18c8 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.cpp @@ -0,0 +1,73 @@ +#include "NyTestPostProcessingStrategy.h" + +#include "Utilities/Results/AnalyticalResults/AnalyticalResult.h" +#include "Utilities/Calculator/FFTCalculator/FFTCalculator.h" +#include "Utilities/Results/SimulationResults/SimulationResults.h" + +#include "Tests/NyTest/NyTestParameterStruct.h" + +std::shared_ptr<NyTestPostProcessingStrategy> NyTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<NyTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests) +{ + return std::shared_ptr<NyTestPostProcessingStrategy>(new NyTestPostProcessingStrategy(simResult, analyticalResult, testPara, dataToCalcTests)); +} + +NyTestPostProcessingStrategy::NyTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<NyTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculate(dataToCalcTests) +{ + startTimeStepCalculation = testPara->startTimeStepCalculation; + endTimeStepCalculation = testPara->endTimeStepCalculation; + ny.resize(dataToCalculate.size()); + + isEvaluated = false; + fftCalculator = FFTCalculator::getInstance(); +} + +std::vector<std::vector<double> > NyTestPostProcessingStrategy::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 NyTestPostProcessingStrategy::evaluate() +{ + if (!isEvaluated) { + for (int i = 0; i < dataToCalculate.size(); i++) { + if (dataToCalculate.at(i) == "Vx") { + ny.at(i) = fftCalculator->calcNy(reduceDataToTimeSteps(simResult->getVx(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Vy") { + ny.at(i) = fftCalculator->calcNy(reduceDataToTimeSteps(simResult->getVy(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Vz") { + ny.at(i) = fftCalculator->calcNy(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculation, endTimeStepCalculation), true, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Press") { + ny.at(i) = fftCalculator->calcNy(reduceDataToTimeSteps(simResult->getVy(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Rho") { + ny.at(i) = fftCalculator->calcNy(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculation, endTimeStepCalculation), true, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + } + isEvaluated = true; + } +} + +double NyTestPostProcessingStrategy::getNy(std::string dataToCalculate) +{ + for (int i = 0; i < ny.size(); i++) { + if (dataToCalculate == this->dataToCalculate.at(i)) + return ny.at(i); + } +} + \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.h b/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..92a8ad83369611be9cee455f62add49b52b5e42a --- /dev/null +++ b/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.h @@ -0,0 +1,33 @@ +#ifndef NY_TEST_POST_PROCESSING_STRATEGY_H +#define NY_TEST_POST_PROCESSING_STRATEGY_H + +#include "Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h" + +#include <memory> + +class AnalyticalResults; +class FFTCalculator; +struct NyTestParameterStruct; + +class NyTestPostProcessingStrategy : public PostProcessingStrategyImp +{ +public: + static std::shared_ptr<NyTestPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<NyTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests); + void evaluate(); + + double getNy(std::string dataToCalculate); + +private: + NyTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<NyTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests); + + 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> dataToCalculate; + std::shared_ptr<FFTCalculator> fftCalculator; + unsigned int startTimeStepCalculation; + unsigned int endTimeStepCalculation; + std::vector<double> ny; + bool isEvaluated; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Tests/NyTest/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/NyTest/package.include b/targets/tests/NumericalTests/Tests/NyTest/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.cpp b/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.cpp deleted file mode 100644 index 50e51f55eed4e6bf950e560c9cb8484ad59a5eae..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "PhiAndNyTest.h" - -#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" -#include "Utilities/TestSimulation/TestSimulation.h" -#include "Utilities/SimulationInfo/SimulationInfo.h" - -#include "Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.h" -#include "Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h" - -#include <iomanip> - -std::shared_ptr<PhiAndNyTest> PhiAndNyTest::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNyTestParameterStruct> testPara, std::string dataToCalculate) -{ - return std::shared_ptr<PhiAndNyTest>(new PhiAndNyTest(colorOutput, viscosity, testPara, dataToCalculate)); -} - -void PhiAndNyTest::evaluate() -{ - for (int i = 0; i < phiAndNyPostProStrategies.size(); i++) { - lx.push_back(phiAndNyPostProStrategies.at(i)->getNumberOfXNodes()); - if (dataToCalculate == "Vx") { - ny.push_back(phiAndNyPostProStrategies.at(i)->getNyVx()); - phiDiff.push_back(phiAndNyPostProStrategies.at(i)->getPhiDiffVx()); - } - if (dataToCalculate == "Vy") { - ny.push_back(phiAndNyPostProStrategies.at(i)->getNyVy()); - phiDiff.push_back(phiAndNyPostProStrategies.at(i)->getPhiDiffVy()); - } - if (dataToCalculate == "Vz") { - ny.push_back(phiAndNyPostProStrategies.at(i)->getNyVz()); - phiDiff.push_back(phiAndNyPostProStrategies.at(i)->getPhiDiffVz()); - } - } - nyDiff = calcNyDiff(ny); - orderOfAccuracyPhiDiff = calcOrderOfAccuracy(phiDiff); - orderOfAccuracyNyDiff = calcOrderOfAccuracy(nyDiff); - phiDiffTestPassed = checkTestPassed(orderOfAccuracyPhiDiff); - nyDiffTestPassed = checkTestPassed(orderOfAccuracyNyDiff); - - makeConsoleOutput(); -} - -void PhiAndNyTest::update() -{ - TestImp::update(); -} - -void PhiAndNyTest::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PhiAndNyTestPostProcessingStrategy> postProStrategy) -{ - TestImp::addSimulation(sim, simInfo, postProStrategy); - phiAndNyPostProStrategies.push_back(postProStrategy); -} - -std::vector<bool> PhiAndNyTest::getPassedTests() -{ - std::vector<bool> passed; - passed.push_back(phiDiffTestPassed); - passed.push_back(nyDiffTestPassed); - return passed; -} - -void PhiAndNyTest::makeConsoleOutput() -{ - colorOutput->makeNyTestOutput(nyDiffTestPassed, simInfos.at(0), simInfos.at(1), startStepCalculation, endStepCalculation, dataToCalculate, ny.at(0), ny.at(1), nyDiff.at(0), nyDiff.at(1), orderOfAccuracyNyDiff); - colorOutput->makePhiTestOutput(phiDiffTestPassed, simInfos.at(0), simInfos.at(1), startStepCalculation, endStepCalculation, dataToCalculate, phiDiff.at(0), phiDiff.at(1), orderOfAccuracyPhiDiff); -} - -std::string PhiAndNyTest::getDataToCalculate() -{ - return dataToCalculate; -} - -std::vector<int> PhiAndNyTest::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> PhiAndNyTest::getNy() -{ - return ny; -} - -std::vector<double> PhiAndNyTest::getNyDiff() -{ - return nyDiff; -} - -std::vector<double> PhiAndNyTest::getPhiDiff() -{ - return phiDiff; -} - -double PhiAndNyTest::getOrderOfAccuracyNyDiff() -{ - return orderOfAccuracyNyDiff; -} - -double PhiAndNyTest::getOrderOfAccuracyPhiDiff() -{ - return orderOfAccuracyPhiDiff; -} - -PhiAndNyTest::PhiAndNyTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNyTestParameterStruct> testPara, std::string dataToCalculate) - : TestImp(colorOutput), viscosity(viscosity), dataToCalculate(dataToCalculate) -{ - minOrderOfAccuracy = testPara->minOrderOfAccuracy; - startStepCalculation = testPara->startTimeStepCalculation; - endStepCalculation = testPara->endTimeStepCalculation; - - lx.resize(0); - phiDiff.resize(0); - nyDiff.resize(0); -} - -double PhiAndNyTest::calcOrderOfAccuracy(std::vector<double> data) -{ - double ooa = log(data.at(0) / data.at(1)) / log(lx.at(1) / lx.at(0)); - - return ooa; -} - -bool PhiAndNyTest::checkTestPassed(double orderOfAccuracy) -{ - return orderOfAccuracy > minOrderOfAccuracy; -} - -std::vector<double> PhiAndNyTest::calcNyDiff(std::vector<double> ny) -{ - std::vector<double> results; - for(int i = 0; i < ny.size(); i++) - results.push_back((ny.at(i) - viscosity) / viscosity); - return results; -} diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.h b/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.h deleted file mode 100644 index 76dc5ac7fe8228ac62649b97cc328c54c076bb6a..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTest.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef PHI_AND_NY_TEST_H -#define PHI_AND_NY_TEST_H - -#include "Utilities/Test/TestImp.h" - -#include <memory> -#include <vector> -#include <iostream> - -class FFTCalculator; -class PhiAndNyTestPostProcessingStrategy; -struct PhiAndNyTestParameterStruct; - -class PhiAndNyTest : public TestImp -{ -public: - static std::shared_ptr<PhiAndNyTest> getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNyTestParameterStruct> testPara, std::string dataToCalculate); - - void update(); - void addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PhiAndNyTestPostProcessingStrategy> postProStrategy); - void evaluate(); - std::vector<bool> getPassedTests(); - void makeConsoleOutput(); - - std::string getDataToCalculate(); - std::vector<int> getLx(); - std::vector<double> getNy(); - std::vector<double> getNyDiff(); - std::vector<double> getPhiDiff(); - double getOrderOfAccuracyNyDiff(); - double getOrderOfAccuracyPhiDiff(); - - - -private: - PhiAndNyTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiAndNyTestParameterStruct> testPara, std::string dataToCalculate); - double calcOrderOfAccuracy(std::vector<double> data); - bool checkTestPassed(double orderOfAccuracy); - std::vector<double> calcNyDiff(std::vector<double> ny); - - unsigned int startStepCalculation, endStepCalculation; - std::vector<double> lx; - std::vector<double> phiDiff; - std::vector<double> ny, nyDiff; - double orderOfAccuracyPhiDiff; - double orderOfAccuracyNyDiff; - double minOrderOfAccuracy; - double viscosity; - bool phiDiffTestPassed; - bool nyDiffTestPassed; - std::string dataToCalculate; - - std::vector<std::shared_ptr<PhiAndNyTestPostProcessingStrategy> > phiAndNyPostProStrategies; - -}; -#endif diff --git a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestStruct.h b/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestStruct.h deleted file mode 100644 index 8867adba0f41161da55c78121af6c0c1a0db47e9..0000000000000000000000000000000000000000 --- a/targets/tests/NumericalTests/Tests/PhiAndNyTest/PhiAndNyTestStruct.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef PHI_AND_NY_TEST_STRUCT_H -#define PHI_AND_NY_TEST_STRUCT_H - -#include <memory> -#include <vector> - -class PhiAndNyInformation; -class PhiAndNyTestPostProcessingStrategy; -class PhiAndNyTest; - -struct PhiAndNyTestStruct -{ - std::shared_ptr<PhiAndNyInformation> logFileInfo; - std::vector<std::shared_ptr<PhiAndNyTest> > tests; -}; -#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.cpp b/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..61fb5dda0cd04f43ac6f0abc4a8d84677ebf0542 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.cpp @@ -0,0 +1,119 @@ +#include "PhiTestLogFileInformation.h" + +#include "Tests/PhiTest/PhiTest.h" +#include "Tests/PhiTest/PhiTestParameterStruct.h" + +#include <iomanip> +#include <sstream> + + +std::shared_ptr<PhiTestLogFileInformation> PhiTestLogFileInformation::getNewInstance(std::shared_ptr<PhiTestParameterStruct> testPara) +{ + return std::shared_ptr<PhiTestLogFileInformation>(new PhiTestLogFileInformation(testPara)); +} + +std::string PhiTestLogFileInformation::getOutput() +{ + std::ostringstream headName; + headName <<" Phi Test"; + makeCenterHead(headName.str()); + + oss << "StartTimeStepCalculation_PhiTest=" << startTimeStepCalculation << std::endl; + oss << "EndTimeStepCalculation_PhiTest=" << endTimeStepCalculation << std::endl; + oss << "DataToCalc_PhiTest=\""; + for (int i = 0; i < testGroups.size(); i++) { + oss << testGroups.at(i).at(0)->getDataToCalculate(); + if (i < testGroups.size() - 1) + oss << " "; + else + oss << "\"" << std::endl; + } + oss << std::endl; + + std::ostringstream failMessagePhi; + failMessagePhi << "FailTests_Phi_PhiTest=\""; + std::ostringstream failMessageOOA; + failMessageOOA << "FailTests_OOA_PhiTest=\""; + for (int i = 0; i < testGroups.size(); i++) { + fillMyData(testGroups.at(i)); + for (int j = 0; j < lxForErase.size(); j++) { + if (status.at(j) == passed || status.at(j) == failed) { + oss << "PhiDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << phiDiff.at(j) << std::endl; + } + else + failMessagePhi << lxForErase.at(j) << "_" << dataToCalc.at(j) << " "; + } + oss << std::endl; + for (int j = 0; j < orderOfAccuracy.size(); j++) { + if (status.at(j) == passed || status.at(j) == failed) { + oss << "OrderOfAccuracy_PhiDiff_" << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracy.at(j) << std::endl; + } + else + failMessageOOA << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << " "; + } + + } + std::string failPhi = failMessagePhi.str(); + if (failPhi.back() == ' ') + failPhi = failPhi.substr(0, failPhi.size() - 1); + failMessagePhi.str(std::string()); + failMessagePhi << failPhi << "\""; + oss << failMessagePhi.str() << std::endl << std::endl; + + std::string failOOA = failMessageOOA.str(); + if (failOOA.back() == ' ') + failOOA = failOOA.substr(0, failOOA.size() - 1); + failMessageOOA.str(std::string()); + failMessageOOA << failOOA << "\""; + oss << failMessageOOA.str() << std::endl << std::endl; + + return oss.str(); +} + +void PhiTestLogFileInformation::addTestGroup(std::vector<std::shared_ptr<PhiTest> > tests) +{ + testGroups.push_back(tests); +} + +void PhiTestLogFileInformation::fillMyData(std::vector<std::shared_ptr<PhiTest> > testGroup) +{ + lxForErase.resize(0); + lx.resize(0); + phiDiff.resize(0); + orderOfAccuracy.resize(0); + dataToCalc.resize(0); + status.resize(0); + for (int i = 0; i < testGroup.size(); i++) { + std::vector<int> myLx = testGroup.at(i)->getLx(); + std::vector<double> myPhiDiff = testGroup.at(i)->getPhiDiff(); + + lx.insert(lx.end(), myLx.begin(), myLx.end()); + lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end()); + phiDiff.insert(phiDiff.end(), myPhiDiff.begin(), myPhiDiff.end()); + orderOfAccuracy.push_back(testGroup.at(i)->getOrderOfAccuracy()); + dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); + dataToCalc.push_back(testGroup.at(i)->getDataToCalculate()); + status.push_back(testGroup.at(i)->getTestStatus()); + status.push_back(testGroup.at(i)->getTestStatus()); + } + + 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) { + phiDiff.erase(phiDiff.begin() + i); + lxForErase.erase(lxForErase.begin() + i); + } + } + + +} + +PhiTestLogFileInformation::PhiTestLogFileInformation(std::shared_ptr<PhiTestParameterStruct> testPara) +{ + startTimeStepCalculation = testPara->startTimeStepCalculation; + endTimeStepCalculation = testPara->endTimeStepCalculation; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.h b/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.h new file mode 100644 index 0000000000000000000000000000000000000000..f92b16a19f19bfbfabdf6985baf95d09090588fa --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.h @@ -0,0 +1,36 @@ +#ifndef PHI_TEST_LOGFILE_INFORMATION_H +#define PHI_TEST_LOGFILE_INFORMATION_H + +#include "Utilities/LogFileInformation/TestLogFileInformation/TestLogFileInformation.h" +#include "Utilities/Test/TestStatus.h" + +#include <memory> +#include <vector> + +class PhiTest; +struct PhiTestParameterStruct; + +class PhiTestLogFileInformation : public TestLogFileInformation +{ +public: + static std::shared_ptr<PhiTestLogFileInformation> getNewInstance(std::shared_ptr<PhiTestParameterStruct> testPara); + + std::string getOutput(); + void addTestGroup(std::vector<std::shared_ptr<PhiTest> > tests); + +private: + PhiTestLogFileInformation() {}; + PhiTestLogFileInformation(std::shared_ptr<PhiTestParameterStruct> testPara); + + void fillMyData(std::vector<std::shared_ptr<PhiTest> > testGroup); + + std::vector<std::vector<std::shared_ptr<PhiTest> > > testGroups; + unsigned int startTimeStepCalculation, endTimeStepCalculation; + std::vector<int> lx; + std::vector<int> lxForErase; + std::vector<double> phiDiff; + std::vector<double> orderOfAccuracy; + std::vector<std::string> dataToCalc; + std::vector<TestStatus> status; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/package.include b/targets/tests/NumericalTests/Tests/PhiTest/LogFileInformation/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.cpp b/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea8519cc090a8c2b0319e96a5a733a80ef6165ae --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.cpp @@ -0,0 +1,161 @@ +#include "PhiTest.h" + +#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" +#include "Utilities/TestSimulation/TestSimulation.h" +#include "Utilities/SimulationInfo/SimulationInfo.h" + +#include "Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.h" +#include "Tests/PhiTest/PhiTestParameterStruct.h" + +#include <iomanip> + +std::shared_ptr<PhiTest> PhiTest::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiTestParameterStruct> testPara, std::string dataToCalculate) +{ + return std::shared_ptr<PhiTest>(new PhiTest(colorOutput, viscosity, testPara, dataToCalculate)); +} + +void PhiTest::evaluate() +{ + for (int i = 0; i < postProStrategies.size(); i++) + phiDiff.push_back(postProStrategies.at(i)->getPhiDiff(dataToCalculate)); + orderOfAccuracy = calcOrderOfAccuracy(phiDiff); + testStatus = checkTestPassed(orderOfAccuracy); + + makeConsoleOutput(); +} + +void PhiTest::update() +{ + TestImp::update(); +} + +void PhiTest::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PhiTestPostProcessingStrategy> postProStrategy) +{ + TestImp::addSimulation(sim, simInfo, postProStrategy); + postProStrategies.push_back(postProStrategy); + lx.push_back(postProStrategy->getNumberOfXNodes()); +} + +std::string PhiTest::getDataToCalculate() +{ + return dataToCalculate; +} + +std::vector<int> PhiTest::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> PhiTest::getPhiDiff() +{ + return phiDiff; +} + +double PhiTest::getOrderOfAccuracy() +{ + return orderOfAccuracy; +} + +PhiTest::PhiTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiTestParameterStruct> testPara, std::string dataToCalculate) + : TestImp(colorOutput), viscosity(viscosity), dataToCalculate(dataToCalculate) +{ + minOrderOfAccuracy = testPara->minOrderOfAccuracy; + startStepCalculation = testPara->startTimeStepCalculation; + endStepCalculation = testPara->endTimeStepCalculation; + + lx.resize(0); + phiDiff.resize(0); +} + +double PhiTest::calcOrderOfAccuracy(std::vector<double> data) +{ + double ooa = log(data.at(0) / data.at(1)) / log(lx.at(1) / lx.at(0)); + + return ooa; +} + +TestStatus PhiTest::checkTestPassed(double orderOfAccuracy) +{ + if (orderOfAccuracy > minOrderOfAccuracy) + return passed; + else + return failed; +} + +std::vector<std::string> PhiTest::buildTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + for (int i = 0; i < phiDiff.size(); i++) { + oss << "PhiDiff" << simInfos.at(i)->getLx() << ": " << phiDiff.at(i); + output.push_back(oss.str()); + oss.str(std::string()); + } + oss << "OrderOfAccuracy: " << orderOfAccuracy; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} + +std::vector<std::string> PhiTest::buildBasicTestOutput() +{ + std::vector<std::string> output; + std::ostringstream oss; + + output.push_back("Phi Test"); + + oss << "Kernel: " << simInfos.at(0)->getKernelName(); + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "Viscosity: " << simInfos.at(0)->getViscosity(); + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + oss << simInfos.at(0)->getSimulationName(); + output.push_back(oss.str()); + oss.str(std::string()); + + for (int i = 0; i < simInfos.size(); i++) { + oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfos.at(i)->getLx() << simInfos.at(i)->getSimulationParameterString(); + output.push_back(oss.str()); + oss.str(std::string()); + } + + output.push_back(oss.str()); + + oss << "DataToCalculate: " << dataToCalculate; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "StartTimeStep: " << startStepCalculation; + output.push_back(oss.str()); + oss.str(std::string()); + + oss << "EndTimeStep: " << endStepCalculation; + output.push_back(oss.str()); + oss.str(std::string()); + + output.push_back(oss.str()); + + return output; +} + +std::vector<std::string> PhiTest::buildErrorTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Error Message: "; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.h b/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.h new file mode 100644 index 0000000000000000000000000000000000000000..84b1d33896a89834460c9d8495f1e068a2221364 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PhiTest.h @@ -0,0 +1,49 @@ +#ifndef PHI_TEST_H +#define PHI_TEST_H + +#include "Utilities/Test/TestImp.h" + +#include <memory> +#include <vector> +#include <iostream> + +class FFTCalculator; +class PhiTestPostProcessingStrategy; +struct PhiTestParameterStruct; + +class PhiTest : public TestImp +{ +public: + static std::shared_ptr<PhiTest> getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiTestParameterStruct> testPara, std::string dataToCalculate); + + void update(); + void addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PhiTestPostProcessingStrategy> postProStrategy); + void evaluate(); + + std::string getDataToCalculate(); + std::vector<int> getLx(); + std::vector<double> getPhiDiff(); + double getOrderOfAccuracy(); + + + +private: + PhiTest(std::shared_ptr<ColorConsoleOutput> colorOutput, double viscosity, std::shared_ptr<PhiTestParameterStruct> testPara, std::string dataToCalculate); + double calcOrderOfAccuracy(std::vector<double> data); + TestStatus checkTestPassed(double orderOfAccuracy); + std::vector<std::string> buildTestOutput(); + std::vector<std::string> buildBasicTestOutput(); + std::vector<std::string> buildErrorTestOutput(); + + unsigned int startStepCalculation, endStepCalculation; + std::vector<double> lx; + std::vector<double> phiDiff; + double orderOfAccuracy; + double minOrderOfAccuracy; + double viscosity; + std::string dataToCalculate; + + std::vector<std::shared_ptr<PhiTestPostProcessingStrategy> > postProStrategies; + +}; +#endif diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PhiTestParameterStruct.h b/targets/tests/NumericalTests/Tests/PhiTest/PhiTestParameterStruct.h new file mode 100644 index 0000000000000000000000000000000000000000..d46b0d6ab41ef5e69b85290cdfd00a8cee956f34 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PhiTestParameterStruct.h @@ -0,0 +1,16 @@ +#ifndef PHI_TEST_PARAMETER_STRUCT_H +#define PHI_TEST_PARAMETER_STRUCT_H + +#include <memory> + +#include "Utilities/Structs/BasicTestParameterStruct.h" + +struct PhiTestParameterStruct +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter; + + double minOrderOfAccuracy; + unsigned int startTimeStepCalculation; + unsigned int endTimeStepCalculation; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PhiTestStruct.h b/targets/tests/NumericalTests/Tests/PhiTest/PhiTestStruct.h new file mode 100644 index 0000000000000000000000000000000000000000..2531fed10189cf04739eabf42f8845d731738a63 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PhiTestStruct.h @@ -0,0 +1,15 @@ +#ifndef PHI_TEST_STRUCT_H +#define PHI_TEST_STRUCT_H + +#include <memory> +#include <vector> + +class PhiTestLogFileInformation; +class PhiTest; + +struct PhiTestStruct +{ + std::shared_ptr<PhiTestLogFileInformation> logFileInfo; + std::vector<std::shared_ptr<PhiTest> > tests; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.cpp b/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bd9c66719f9a642c700e1274649786d2d2bebd73 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.cpp @@ -0,0 +1,71 @@ +#include "PhiTestPostProcessingStrategy.h" + +#include "Utilities/Results/AnalyticalResults/AnalyticalResult.h" +#include "Utilities/Calculator/FFTCalculator/FFTCalculator.h" +#include "Utilities/Results/SimulationResults/SimulationResults.h" + +#include "Tests/PhiTest/PhiTestParameterStruct.h" + +std::shared_ptr<PhiTestPostProcessingStrategy> PhiTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests) +{ + return std::shared_ptr<PhiTestPostProcessingStrategy>(new PhiTestPostProcessingStrategy(simResult, analyticalResult, testPara, dataToCalcTests)); +} + +PhiTestPostProcessingStrategy::PhiTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests) + : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculate(dataToCalcTests) +{ + startTimeStepCalculation = testPara->startTimeStepCalculation; + endTimeStepCalculation = testPara->endTimeStepCalculation; + phiDiff.resize(dataToCalculate.size()); + + isEvaluated = false; + fftCalculator = FFTCalculator::getInstance(); +} + +std::vector<std::vector<double> > PhiTestPostProcessingStrategy::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 PhiTestPostProcessingStrategy::evaluate() +{ + if (!isEvaluated) { + for (int i = 0; i < dataToCalculate.size(); i++) { + if (dataToCalculate.at(i) == "Vx") { + phiDiff.at(i) = fftCalculator->calcPhiDiff(reduceDataToTimeSteps(simResult->getVx(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Vy") { + phiDiff.at(i) = abs(fftCalculator->calcPhiDiff(reduceDataToTimeSteps(simResult->getVy(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength())); + } + if (dataToCalculate.at(i) == "Vz") { + phiDiff.at(i) = fftCalculator->calcPhiDiff(reduceDataToTimeSteps(simResult->getVz(), startTimeStepCalculation, endTimeStepCalculation), true, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Press") { + phiDiff.at(i) = fftCalculator->calcPhiDiff(reduceDataToTimeSteps(simResult->getPress(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + if (dataToCalculate.at(i) == "Rho") { + phiDiff.at(i) = fftCalculator->calcPhiDiff(reduceDataToTimeSteps(simResult->getRho(), startTimeStepCalculation, endTimeStepCalculation), false, simResult->getNumberOfXNodes(), simResult->getNumberOfZNodes(), simResult->getTimeStepLength()); + } + } + isEvaluated = true; + } +} + +double PhiTestPostProcessingStrategy::getPhiDiff(std::string dataToCalc) +{ + for (int i = 0; i < dataToCalculate.size(); i++) + if(dataToCalculate.at(i) == dataToCalc) + return phiDiff.at(i); +} diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.h b/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..ace86051d7e5bf280a1e82d6ad97f1e03083b538 --- /dev/null +++ b/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.h @@ -0,0 +1,33 @@ +#ifndef PHIANDNY_TEST_POST_PROCESSING_STRATEGY_H +#define PHIANDNY_TEST_POST_PROCESSING_STRATEGY_H + +#include "Utilities/PostProcessingStrategy/PostProcessingStrategyImp.h" + +#include <memory> + +class AnalyticalResults; +class FFTCalculator; +struct PhiTestParameterStruct; + +class PhiTestPostProcessingStrategy : public PostProcessingStrategyImp +{ +public: + static std::shared_ptr<PhiTestPostProcessingStrategy> getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests); + void evaluate(); + + double getPhiDiff(std::string dataToCalc); + +private: + PhiTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests); + + 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> dataToCalculate; + std::shared_ptr<FFTCalculator> fftCalculator; + unsigned int startTimeStepCalculation; + unsigned int endTimeStepCalculation; + std::vector<double> phiDiff; + bool isEvaluated; +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/package.include b/targets/tests/NumericalTests/Tests/PhiTest/PostProcessingStrategy/package.include new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/targets/tests/NumericalTests/Tests/PhiTest/package.include b/targets/tests/NumericalTests/Tests/PhiTest/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 c88ac70546b33fac82bf4845e918a378650f4570..6942099bcf441e0f06b580a15a813f6eb34f5eec 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.cpp @@ -1,26 +1,42 @@ #include "FFTCalculator.h" #include "Utilities/Results/SimulationResults/SimulationResults.h" -#include "Tests/PhiAndNyTest/PhiAndNyTest.h" #define _USE_MATH_DEFINES #include <math.h> #include <stdlib.h> +#include <fstream> -std::shared_ptr<FFTCalculator> FFTCalculator::getNewInstance(int lx, int lz, int timeStepLength) +std::shared_ptr<FFTCalculator> FFTCalculator::getInstance() { - return std::shared_ptr<FFTCalculator>(new FFTCalculator(lx, lz, timeStepLength)); + static std::shared_ptr<FFTCalculator> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<FFTCalculator>(new FFTCalculator()); + return uniqueInstance; } -FFTCalculator::FFTCalculator(int lx, int lz, int timeStepLength) +double FFTCalculator::calcNy(std::vector<std::vector<double>> data, bool transposeData, int lx, int lz, int timeStepLength) { this->lx = (double)lx; this->lz = (double)lz; this->timeStepLength = (double)timeStepLength; + this->transposeData = transposeData; + if (!transposeData) + this->data = data; + else + this->data = transpose(data); + + init(); + + double ny = calcNy(); + return ny; } -void FFTCalculator::calc(std::vector<std::vector<double> > data, bool transposeData) +double FFTCalculator::calcPhiDiff(std::vector<std::vector<double>> data, bool transposeData, int lx, int lz, int timeStepLength) { + this->lx = (double)lx; + this->lz = (double)lz; + this->timeStepLength = (double)timeStepLength; this->transposeData = transposeData; if (!transposeData) this->data = data; @@ -29,12 +45,19 @@ void FFTCalculator::calc(std::vector<std::vector<double> > data, bool transposeD init(); - ny = calcNy(); - phidiff = calcPhiDiff(); + double phidiff = calcPhiDiff(); + return abs(phidiff); +} + +FFTCalculator::FFTCalculator() +{ + } -double FFTCalculator::calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData) +double FFTCalculator::calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData, int lx, int lz) { + this->lx = (double)lx; + this->lz = (double)lz; init(); this->transposeData = transposeData; this->data.resize(0); @@ -150,8 +173,10 @@ std::vector<double> FFTCalculator::calcPhiForAllSteps() else pos = 2 + (lz - 1); - for (int step = 0; step < data.size(); step++) + for (int step = 0; step < data.size(); step++) { phi.push_back(atan(fftResultsIm.at(step).at(pos) / fftResultsRe.at(step).at(pos))); + } + return phi; } @@ -239,14 +264,4 @@ void FFTCalculator::setFFTResults(fftw_complex * result, unsigned int step) } fftResultsIm.push_back(fftIm); fftResultsRe.push_back(fftRe); -} - -double FFTCalculator::getNy() -{ - return ny; -} - -double FFTCalculator::getPhiDiff() -{ - return phidiff; -} +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h index a920552442c12c6f34ecabb6abea53ab9356a2f1..7af2896f2d9ac2f98e29916db37fcd4e45b8e4cd 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/FFTCalculator/FFTCalculator.h @@ -13,18 +13,15 @@ class PhiAndNuTest; class FFTCalculator { public: - static std::shared_ptr<FFTCalculator> getNewInstance(int lx, int lz, int timeStepLength); + static std::shared_ptr<FFTCalculator> getInstance(); - void calc(std::vector<std::vector<double> > data, bool transposeData); + double calcNy(std::vector<std::vector<double> > data, bool transposeData, int lx, int lz, int timeStepLength); + double calcPhiDiff(std::vector<std::vector<double> > data, bool transposeData, int lx, int lz, int timeStepLength); - double calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData); - - double getNy(); - double getPhiDiff(); + double calcAmplitudeForTimeStep(std::vector<double> data, bool transposeData, int lx, int lz); private: - FFTCalculator() {}; - FFTCalculator(int lx, int lz, int timeStepLength); + FFTCalculator(); void init(); double calcNy(); double calcPhiDiff(); @@ -45,7 +42,5 @@ private: bool transposeData; double lx, lz; double timeStepLength; - double ny; - double phidiff; }; #endif diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.cpp index ea215ef2b45cfc2d1b02ae2800345aef9ba49ac1..35909609ada31089d99824ac7245efcaf256aaea 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.cpp @@ -10,13 +10,13 @@ std::shared_ptr<L2NormCalculator> L2CalculatorNormalizeWithAmplitude::getInstanc return uniqueInstance; } -double L2CalculatorNormalizeWithAmplitude::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) +double L2CalculatorNormalizeWithAmplitude::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz) { - std::shared_ptr<FFTCalculator> fftCalc = FFTCalculator::getNewInstance(lx, lz, timeStepLength); - double amplitude = fftCalc->calcAmplitudeForTimeStep(basicData, false); + std::shared_ptr<FFTCalculator> fftCalc = FFTCalculator::getInstance(); + double amplitude = fftCalc->calcAmplitudeForTimeStep(basicData, false, lx, lz); if (equalDouble(amplitude, 0.0)) return -1.0; - double counter = calcCounter(basicData, divergentData, level, lx, lz, timeStepLength); + double counter = calcCounter(basicData, divergentData, level, lx, lz); return sqrt(counter / (amplitude * amplitude)); } diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h index 6308adb5624ee807abbc08208ca4a9fa1df37043..1f3638ab5dfd6b6e79c6df5d3eaed346bc2ea3a6 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h @@ -8,7 +8,7 @@ class L2CalculatorNormalizeWithAmplitude : public L2NormCalculatorImp public: static std::shared_ptr<L2NormCalculator> getInstance(); - double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength); + double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz); private: L2CalculatorNormalizeWithAmplitude(); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.cpp index eb15dacb2b8b22d1b9ceb62c5963627ebd45a88c..22d32e32f5f5616dc5dea63a2b8503b31e964420 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.cpp @@ -8,9 +8,9 @@ std::shared_ptr<L2NormCalculator> L2CalculatorNormalizeWithBasicData::getInstanc return uniqueInstance; } -double L2CalculatorNormalizeWithBasicData::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) +double L2CalculatorNormalizeWithBasicData::calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz) { - double counter = calcCounter(basicData, divergentData, level, lx, lz, timeStepLength); + double counter = calcCounter(basicData, divergentData, level, lx, lz); double denominator = 0.0; for (int i = 0; i < basicData.size(); i++) { double area = (1 / pow(2.0, level.at(i))) * (1 / pow(2.0, level.at(i))); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h index 36517aaee00ab617cffc60a997be7f191f839efc..2c6cbfb670f9eab6897b55e17106d2b97fb2fa60 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h @@ -8,7 +8,7 @@ class L2CalculatorNormalizeWithBasicData : public L2NormCalculatorImp public: static std::shared_ptr<L2NormCalculator> getInstance(); - double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength); + double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz); private: L2CalculatorNormalizeWithBasicData(); diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h index 44628af304b1c7f8e9c6a9db23c495a6e574f43b..6e7431810691ac0fb031824cd72b401ae47881eb 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculator.h @@ -8,7 +8,7 @@ class L2NormCalculator { public: - virtual double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) = 0; + virtual double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz) = 0; virtual std::string getErrorMessage() = 0; }; diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.h index 6215de9198b5de87c1fc1741f457d17de6a9ce7f..2b13f7ca3ca1337d8cbd7181ce4fc556e831a248 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.h @@ -9,11 +9,7 @@ class L2NormCalculator; class L2NormCalculatorFactory { public: - static std::shared_ptr<L2NormCalculatorFactory> getInstance(); + virtual std::shared_ptr<L2NormCalculator> makeL2NormCalculator(std::string type) = 0; - std::shared_ptr<L2NormCalculator> makeL2NormCalculator(std::string type); - -private: - L2NormCalculatorFactory(); }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e30ff286f1bc67c7ee6311fa6b48ccbf1e031c97 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.cpp @@ -0,0 +1,24 @@ +#include "L2NormCalculatorFactoryImp.h" + +#include "Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithAmplitude/L2CalculatorNormalizeWithAmplitude.h" +#include "Utilities/Calculator/L2NormCalculator/L2CalculatorNormalizeWithBasicData/L2CalculatorNormalizeWithBasicData.h" + +std::shared_ptr<L2NormCalculatorFactory> L2NormCalculatorFactoryImp::getInstance() +{ + static std::shared_ptr<L2NormCalculatorFactory> uniqueInstance; + if (!uniqueInstance) + uniqueInstance = std::shared_ptr<L2NormCalculatorFactory>(new L2NormCalculatorFactoryImp()); + return uniqueInstance; +} + +std::shared_ptr<L2NormCalculator> L2NormCalculatorFactoryImp::makeL2NormCalculator(std::string type) +{ + if(type == "Amplitude") + return L2CalculatorNormalizeWithAmplitude::getInstance(); + if (type == "BasicData") + return L2CalculatorNormalizeWithBasicData::getInstance(); +} + +L2NormCalculatorFactoryImp::L2NormCalculatorFactoryImp() +{ +} diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.h new file mode 100644 index 0000000000000000000000000000000000000000..11739a697180296735d1427701dceb3d212e448a --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.h @@ -0,0 +1,16 @@ +#ifndef L2NORM_CALCULATOR_FACTORY_IMP_H +#define L2NORM_CALCULATOR_FACTORY_IMP_H + +#include "L2NormCalculatorFactory.h" + +class L2NormCalculatorFactoryImp : public L2NormCalculatorFactory +{ +public: + static std::shared_ptr<L2NormCalculatorFactory> getInstance(); + + std::shared_ptr<L2NormCalculator> makeL2NormCalculator(std::string type); + +private: + L2NormCalculatorFactoryImp(); +}; +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.cpp b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.cpp index 1a5b7e1132fc421cfdcaaf4e32cebff1f983aa66..86059f259c42094cd635232db13b5e22dcde0276 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.cpp @@ -19,7 +19,7 @@ bool L2NormCalculatorImp::equalDouble(double num1, double num2) return false; } -double L2NormCalculatorImp::calcCounter(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) +double L2NormCalculatorImp::calcCounter(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz) { double counter = 0.0; for (int i = 0; i < basicData.size(); i++) { diff --git a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.h b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.h index 45c5b15fe410a5f9fb6b1e06e9dccc013c93c92b..fa11b09bcd7238a797d21077123738a591427ac6 100644 --- a/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.h +++ b/targets/tests/NumericalTests/Utilities/Calculator/L2NormCalculator/L2NormCalculatorImp.h @@ -10,14 +10,14 @@ class FFTCalculator; class L2NormCalculatorImp : public L2NormCalculator { public: - virtual double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength) = 0; + virtual double calc(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz) = 0; std::string getErrorMessage(); protected: L2NormCalculatorImp(std::string errorMessage); bool equalDouble(double num1, double num2); - double calcCounter(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz, double timeStepLength); + double calcCounter(std::vector<double> basicData, std::vector<double> divergentData, std::vector<unsigned int> level, double lx, double lz); std::string errorMessage; diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h index 091430710044d4be2ea49e810590a38c57474430..73b5dff2a02af7a60d3bccc9df6c0ec90c8c5940 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutput.h @@ -1,25 +1,20 @@ #ifndef COLOR_CONSOLE_OUTPUT_H #define COLOR_CONSOLE_OUTPUT_H +#include "Utilities/Test/TestStatus.h" + #include <memory> #include <sstream> +#include <vector> class SimulationInfo; class ColorConsoleOutput { public: - virtual void makeNyTestOutput(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, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc, double testWert1, double testWert2, double testWert3) = 0; - virtual void makeL2NormTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> simInfo, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc) = 0; - virtual void makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep, double l2NormBasicKernel, double l2NormDivergentKernel, double l2NormBetweenKernel) = 0; - virtual void makeL2NormBetweenKernelsTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep) = 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; - -private: - + virtual void makeTestOutput(std::vector<std::string> testOutput, TestStatus status) = 0; + virtual void makeFinalTestOutputHead(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest) = 0; + virtual void makeFinalTestOutputFoot(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest) = 0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp index 9b04ec81a11d6bf69642d96e08d1e35559de90ba..18728aac7448f017654a524c11724b901494fcc9 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.cpp @@ -1,10 +1,10 @@ #include "ColorConsoleOutputImp.h" +#include "Utilities/SimulationInfo/SimulationInfo.h" + #include <iomanip> #include <ctime> -#include "Utilities/SimulationInfo/SimulationInfo.h" - std::shared_ptr<ColorConsoleOutput> ColorConsoleOutputImp::getInstance() { @@ -14,370 +14,12 @@ std::shared_ptr<ColorConsoleOutput> ColorConsoleOutputImp::getInstance() return uniqueInstance; } -void ColorConsoleOutputImp::makeNyTestOutput(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) -{ - setColor(testPassed); - printTestStart(); - - printColor(""); - printColor("Nu Test"); - printColor(""); - - std::ostringstream oss; - oss << "Kernel: " << simInfo1->getKernelName(); - print(oss.str()); - oss.str(std::string()); - - oss << "Viscosity: " << simInfo1->getViscosity(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << simInfo1->getSimulationName(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfo1->getLx() << simInfo1->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfo2->getLx() << simInfo2->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "DataToCalculate: " << dataToCalc; - print(oss.str()); - oss.str(std::string()); - - oss << "StartTimeStep: " << startTimeStep; - print(oss.str()); - oss.str(std::string()); - - oss << "EndTimeStep: " << endTimeStep; - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "Ny" << simInfo1->getLx() << ": " << nu1; - print(oss.str()); - oss.str(std::string()); - oss << "Ny" << simInfo2->getLx() << ": " << nu2; - print(oss.str()); - oss.str(std::string()); - oss << "NyDiff" << simInfo1->getLx() << ": " << nuDiff1; - print(oss.str()); - oss.str(std::string()); - oss << "NyDiff" << simInfo2->getLx() << ": " << nuDiff2; - print(oss.str()); - oss.str(std::string()); - oss << "OrderOfAccuracy: " << ooa; - print(oss.str()); - oss.str(std::string()); - - printColor(""); - printColor("Nu Test"); - printColor(""); - - printTestEnd(testPassed); -} - -void ColorConsoleOutputImp::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) -{ - setColor(testPassed); - printTestStart(); - - printColor(""); - printColor("Phi Test"); - printColor(""); - - std::ostringstream oss; - oss << "Kernel: " << simInfo1->getKernelName(); - print(oss.str()); - oss.str(std::string()); - - oss << "Viscosity: " << simInfo1->getViscosity(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << simInfo1->getSimulationName(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfo1->getLx() << simInfo1->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << std::setfill(' ') << std::right << std::setw(4) << simInfo2->getLx() << simInfo2->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "DataToCalculate: " << dataToCalc; - print(oss.str()); - oss.str(std::string()); - - oss << "StartTimeStep: " << startTimeStep; - print(oss.str()); - oss.str(std::string()); - - oss << "EndTimeStep: " << endTimeStep; - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "PhiDiff" << simInfo1->getLx() << ": " << phiDiff1; - print(oss.str()); - oss.str(std::string()); - oss << "PhiDiff" << simInfo2->getLx() << ": " << phiDiff2; - print(oss.str()); - oss.str(std::string()); - oss << "OrderOfAccuracy: " << ooa; - print(oss.str()); - oss.str(std::string()); - - printColor(""); - printColor("Phi Test"); - printColor(""); - - printTestEnd(testPassed); -} - -void ColorConsoleOutputImp::makeL2NormTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> simInfo, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc, double testWert1, double testWert2, double testWert3) -{ - setColor(testPassed); - printTestStart(); - - printColor(""); - printColor("L2 Norm Test"); - printColor(""); - - std::ostringstream oss; - oss << "Kernel: " << simInfo->getKernelName(); - print(oss.str()); - oss.str(std::string()); - - oss << "Viscosity: " << simInfo->getViscosity(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << simInfo->getSimulationName(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << simInfo->getLx() << simInfo->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "DataToCalculate: " << dataToCalc; - print(oss.str()); - oss.str(std::string()); - oss << "NormalizeData: " << normalizeData; - print(oss.str()); - oss.str(std::string()); - oss << "BasicTimeStep: " << basicTimeStep; - print(oss.str()); - oss.str(std::string()); - - oss << "DivergentTimeStep: " << divergentTimeStep; - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "L2Norm BasicTimeStep: " << testWert1; - print(oss.str()); - oss.str(std::string()); - - oss << "L2Norm DivergentTimeStep: " << testWert2; - print(oss.str()); - oss.str(std::string()); - - oss << "L2NormDiff: " << testWert3; - print(oss.str()); - oss.str(std::string()); - - printColor(""); - printColor("L2 Norm Test"); - printColor(""); - - printTestEnd(testPassed); -} - -void ColorConsoleOutputImp::makeL2NormTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> simInfo, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc) -{ - color = testing::internal::COLOR_YELLOW; - printTestStart(); - - printColor(""); - printColor("L2 Norm Test"); - printColor(""); - - std::ostringstream oss; - oss << "Kernel: " << simInfo->getKernelName(); - print(oss.str()); - oss.str(std::string()); - - oss << "Viscosity: " << simInfo->getViscosity(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << simInfo->getSimulationName(); - print(oss.str()); - oss.str(std::string()); - - oss << "L: " << simInfo->getLx() << simInfo->getSimulationParameterString(); - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "DataToCalculate: " << dataToCalc; - print(oss.str()); - oss.str(std::string()); - oss << "NormalizeData: " << normalizeData; - print(oss.str()); - oss.str(std::string()); - oss << "BasicTimeStep: " << basicTimeStep; - print(oss.str()); - oss.str(std::string()); - - oss << "DivergentTimeStep: " << divergentTimeStep; - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "Error Message: " << errorMessage; - print(oss.str()); - oss.str(std::string()); - - printColor(""); - printColor("L2 Norm Test"); - printColor(""); - - printTestEndError(); -} - -void ColorConsoleOutputImp::makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, 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 << "NormalizeData: " << normalizeData; - 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::makeL2NormBetweenKernelsTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep) -{ - color = testing::internal::COLOR_YELLOW; - 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 << "NormalizeData: " << normalizeData; - print(oss.str()); - oss.str(std::string()); - oss << "TimeStep: " << timeStep; - print(oss.str()); - oss.str(std::string()); - - print(oss.str()); - oss << "Error Message: " << errorMessage; - print(oss.str()); - oss.str(std::string()); - - printColor(""); - printColor("L2 Norm Between Kernels Test"); - printColor(""); - - printTestEndError(); -} - void ColorConsoleOutputImp::makeSimulationHeadOutput(std::shared_ptr<SimulationInfo> simInfo) { std::ostringstream ossLine0; - ossLine0 << "# Simulation Number " << simInfo->getSimulationID() << " of " << std::setfill(' ') << std::left << std::setw(23) << simInfo->getNumberOfSimulations() << "#"; + ossLine0 << "# Simulation Number " << simInfo->getSimulationID() << " of " << simInfo->getNumberOfSimulations(); + int length = 49 - ossLine0.str().size(); + ossLine0 << std::setfill(' ') << std::right << std::setw(length) << "#"; std::ostringstream ossLine1; ossLine1 << "# Kernel: " << std::setfill(' ') << std::left << std::setw(38) << simInfo->getKernelName() << "#"; @@ -412,83 +54,126 @@ void ColorConsoleOutputImp::makeSimulationHeadOutput(std::shared_ptr<SimulationI printGreenHashLine(); } -void ColorConsoleOutputImp::makeFinalTestOutputFoot(int numberOfPassedTests, int numberOfTests) +void ColorConsoleOutputImp::makeTestOutput(std::vector<std::string> testOutput, TestStatus status) +{ + setColor(status); + printTestStart(); + + printColor(""); + printColor(testOutput.at(0)); + printColor(""); + + for (int i = 1; i < testOutput.size(); i++) + print(testOutput.at(i)); + + printColor(""); + printColor(testOutput.at(0)); + printColor(""); + + printTestEnd(status); +} + +void ColorConsoleOutputImp::makeFinalTestOutputHead(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest) { - setColor(numberOfPassedTests == numberOfTests); - printTestPassed(numberOfPassedTests, numberOfTests); + setColor(numberOfTests == numberOfPassedTest); + printTestPassed(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest, numberOfErrorTest, numberOfNotExecutedTest); printLine(); } -void ColorConsoleOutputImp::makeFinalTestOutputHead(int numberOfPassedTests, int numberOfTests) +void ColorConsoleOutputImp::makeFinalTestOutputFoot(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest) { - setColor(numberOfPassedTests == numberOfTests); + setColor(numberOfTests == numberOfPassedTest); printLine(); - printTestPassed(numberOfPassedTests, numberOfTests); + printTestPassed(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest, numberOfErrorTest, numberOfNotExecutedTest); std::cout << std::endl; } void ColorConsoleOutputImp::printTestStart() { - testing::internal::ColoredPrintf(color, "[----------]"); + testing::internal::ColoredPrintf(color, "[-----------]"); std::cout << std::endl; - testing::internal::ColoredPrintf(color, "[Run Test ]"); + testing::internal::ColoredPrintf(color, "[Run Test ]"); std::cout << std::endl; - testing::internal::ColoredPrintf(color, "[TestInfo ]"); + testing::internal::ColoredPrintf(color, "[TestInfo ]"); std::cout << std::endl; } -void ColorConsoleOutputImp::printTestEnd(bool testPassed) +void ColorConsoleOutputImp::printTestEnd(TestStatus status) { - testing::internal::ColoredPrintf(color, "[ TestInfo]"); + testing::internal::ColoredPrintf(color, "[ TestInfo]"); std::cout << std::endl; - if (testPassed) - testing::internal::ColoredPrintf(testing::internal::COLOR_GREEN, "[ PASSED]"); - else - testing::internal::ColoredPrintf(testing::internal::COLOR_RED, "[ FAILED]"); - std::cout << std::endl; - testing::internal::ColoredPrintf(color, "[----------]"); - std::cout << std::endl << std::endl; -} + switch (status) + { + case passed: testing::internal::ColoredPrintf(color , "[ PASSED]"); + break; + case failed: testing::internal::ColoredPrintf(color, "[ FAILED]"); + break; + case error: testing::internal::ColoredPrintf(color, "[ ERROR]"); + break; + case simulationCrashed: testing::internal::ColoredPrintf(color, "[Sim crashed]"); + break; + default: + break; + } -void ColorConsoleOutputImp::printTestEndError() -{ - testing::internal::ColoredPrintf(color, "[ TestInfo]"); std::cout << std::endl; - testing::internal::ColoredPrintf(color, "[ ERROR]"); - std::cout << std::endl; - testing::internal::ColoredPrintf(color, "[----------]"); + testing::internal::ColoredPrintf(color, "[-----------]"); std::cout << std::endl << std::endl; } void ColorConsoleOutputImp::print(std::string output) { - testing::internal::ColoredPrintf(color, "[ ] "); + testing::internal::ColoredPrintf(color, "[ ] "); testing::internal::ColoredPrintf(testing::internal::COLOR_DEFAULT, output.c_str()); std::cout << std::endl; } void ColorConsoleOutputImp::printColor(std::string output) { - testing::internal::ColoredPrintf(color, "[----------] "); + testing::internal::ColoredPrintf(color, "[-----------] "); testing::internal::ColoredPrintf(color, output.c_str()); std::cout << std::endl; } -void ColorConsoleOutputImp::setColor(bool testPassed) +void ColorConsoleOutputImp::setColor(TestStatus status) +{ + switch (status) + { + case passed: color = testing::internal::COLOR_GREEN; + break; + case failed: color = testing::internal::COLOR_RED; + break; + case error: color = testing::internal::COLOR_YELLOW; + break; + case simulationCrashed: color = testing::internal::COLOR_YELLOW; + break; + default: + break; + } +} + +void ColorConsoleOutputImp::setColor(bool passed) { - if (testPassed) + if (passed) color = testing::internal::COLOR_GREEN; else color = testing::internal::COLOR_RED; } -void ColorConsoleOutputImp::printTestPassed(int numberOfPassedTests, int numberOfTests) +void ColorConsoleOutputImp::printTestPassed(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest) { std::ostringstream test; - test << "[----------]" << std::endl; - test << "[----------] Test Summary" << std::endl; - test << "[----------] " << numberOfPassedTests << " out of " << numberOfTests << " tests passed" << std::endl; - test << "[----------]" << std::endl; + test << "[-----------]" << std::endl; + test << "[-----------] Test Summary" << std::endl; + test << "[-----------] " << numberOfTests << " initialized Tests" << std::endl; + test << "[-----------]" << std::endl; + test << "[-----------] " << numberOfExecutedTest << " out of " << numberOfTests << " Tests executed" << std::endl; + test << "[-----------] " << numberOfErrorTest << " out of " << numberOfTests << " Tests executed and completed with error" << std::endl; + test << "[-----------] " << numberOfNotExecutedTest << " out of " << numberOfTests << " Tests not executed" << std::endl; + test << "[-----------]" << std::endl; + test << "[-----------] " << numberOfPassedTest << " out of " << numberOfExecutedTest << " executed Tests passed" << std::endl; + test << "[-----------] " << numberOfFailedTest << " out of " << numberOfExecutedTest << " executed Tests failed" << std::endl; + test << "[-----------]" << std::endl; testing::internal::ColoredPrintf(color, test.str().c_str()); } diff --git a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h index 3887798f26fd5081f56e9b5f47b140bd725e6dec..418ef085aa7d1a319a2d0ad8fabd84c401e61d49 100644 --- a/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h +++ b/targets/tests/NumericalTests/Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h @@ -33,25 +33,20 @@ class ColorConsoleOutputImp : public ColorConsoleOutput public: static std::shared_ptr<ColorConsoleOutput> getInstance(); - void makeNyTestOutput(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, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc, double testWert1, double testWert2, double testWert3); - void makeL2NormTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> simInfo, std::string normalizeData, unsigned int basicTimeStep, unsigned int divergentTimeStep, std::string dataToCalc); - void makeL2NormBetweenKernelsTestOutput(bool testPassed, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep, double l2NormBasicKernel, double l2NormDivergentKernel, double l2NormBetweenKernel); - void makeL2NormBetweenKernelsTestErrorOutput(std::string errorMessage, std::shared_ptr<SimulationInfo> basicSimInfo, std::string normalizeData, std::shared_ptr<SimulationInfo> divergentSimInfo, std::string dataToCalc, unsigned int timeStep); void makeSimulationHeadOutput(std::shared_ptr<SimulationInfo> simInfo); - void makeFinalTestOutputHead(int numberOfPassedTests, int numberOfTests); - void makeFinalTestOutputFoot(int numberOfPassedTests, int numberOfTests); + void makeTestOutput(std::vector<std::string> testOutput, TestStatus status); + void makeFinalTestOutputHead(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest); + void makeFinalTestOutputFoot(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest); private: ColorConsoleOutputImp() {}; void printTestStart(); - void printTestEnd(bool testPassed); - void printTestEndError(); + void printTestEnd(TestStatus status); void print(std::string output); void printColor(std::string output); - void setColor(bool testPassed); - void printTestPassed(int numberOfPassedTests, int numberOfTests); + void setColor(TestStatus status); + void setColor(bool passed); + void printTestPassed(int numberOfTests, int numberOfExecutedTest, int numberOfPassedTest, int numberOfFailedTest, int numberOfErrorTest, int numberOfNotExecutedTest); void printLine(); void printGreen(std::string output); diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp index 73b53214bc34d7628088ea2305ea2913610e6d19..680580ec981aef7e010d413f9b21ce47183300d1 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.cpp @@ -43,7 +43,8 @@ void ConfigFileReader::readConfigFile(const std::string aFilePath) configData->shearWaveParameter = makeShearWaveParameter(input, basicSimPara); configData->shearWaveGridInformation = makeGridInformation(input, "ShearWave");; - configData->phiAndNuTestParameter = makePhiAndNyTestParameter(input); + configData->phiTestParameter = makePhiTestParameter(input); + configData->nyTestParameter = makeNyTestParameter(input); configData->l2NormTestParameter = makeL2NormTestParameter(input); configData->l2NormTestBetweenKernelsParameter = makeL2NormTestBetweenKernelsParameter(input); @@ -127,6 +128,7 @@ std::vector<std::shared_ptr<TaylorGreenVortexUxParameterStruct> > ConfigFileRead aParameter->l0 = l0; aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); aParameter->vtkFilePath = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Ux")); parameter.push_back(aParameter); } return parameter; @@ -149,6 +151,7 @@ std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > ConfigFileRead aParameter->l0 = l0; aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); aParameter->vtkFilePath = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_TGV_Uz")); parameter.push_back(aParameter); } return parameter; @@ -170,23 +173,38 @@ std::vector<std::shared_ptr<ShearWaveParameterStruct> > ConfigFileReader::makeSh aParameter->l0 = l0; aParameter->rho0 = StringUtil::toDouble(input->getValue("Rho0")); aParameter->vtkFilePath = StringUtil::toString(input->getValue("PathForVTKFileWriting")); + aParameter->dataToCalcTests = StringUtil::toStringVector(input->getValue("DataToCalcTests_SW")); parameter.push_back(aParameter); } return parameter; } -std::shared_ptr<PhiAndNyTestParameterStruct> ConfigFileReader::makePhiAndNyTestParameter(std::shared_ptr<input::Input> input) +std::shared_ptr<NyTestParameterStruct> ConfigFileReader::makeNyTestParameter(std::shared_ptr<input::Input> input) { std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_PhiAndNu")); - basicTestParameter->runTest= StringUtil::toBool(input->getValue("PhiAndNuTest")); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("NyTest")); basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); - std::shared_ptr<PhiAndNyTestParameterStruct> testParameter = std::shared_ptr<PhiAndNyTestParameterStruct>(new PhiAndNyTestParameterStruct); + std::shared_ptr<NyTestParameterStruct> testParameter = std::shared_ptr<NyTestParameterStruct>(new NyTestParameterStruct); testParameter->basicTestParameter = basicTestParameter; - testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_PhiNu")); - testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy")); - testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiNu")); + testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Ny")); + testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Ny")); + testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny")); + + return testParameter; +} + +std::shared_ptr<PhiTestParameterStruct> ConfigFileReader::makePhiTestParameter(std::shared_ptr<input::Input> input) +{ + std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); + basicTestParameter->runTest = StringUtil::toBool(input->getValue("PhiTest")); + basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); + + std::shared_ptr<PhiTestParameterStruct> testParameter = std::shared_ptr<PhiTestParameterStruct>(new PhiTestParameterStruct); + testParameter->basicTestParameter = basicTestParameter; + testParameter->endTimeStepCalculation = StringUtil::toInt(input->getValue("EndTimeStepCalculation_Phi")); + testParameter->minOrderOfAccuracy = StringUtil::toDouble(input->getValue("MinOrderOfAccuracy_Phi")); + testParameter->startTimeStepCalculation = StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi")); return testParameter; } @@ -194,7 +212,6 @@ std::shared_ptr<PhiAndNyTestParameterStruct> ConfigFileReader::makePhiAndNyTestP std::shared_ptr<L2NormTestParameterStruct> ConfigFileReader::makeL2NormTestParameter(std::shared_ptr<input::Input> input) { std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_L2")); basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormTest")); basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); @@ -202,20 +219,8 @@ std::shared_ptr<L2NormTestParameterStruct> ConfigFileReader::makeL2NormTestParam testParameter->basicTestParameter = basicTestParameter; testParameter->basicTimeStep = StringUtil::toInt(input->getValue("BasicTimeStep_L2")); testParameter->divergentTimeStep = StringUtil::toInt(input->getValue("DivergentTimeStep_L2")); - - bool runTest = false; - if (StringUtil::toBool(input->getValue("NormalizeWithBasicData"))) { - runTest = true; - testParameter->normalizeData.push_back("basicData"); - testParameter->maxDiff.push_back(StringUtil::toDouble(input->getValue("MaxL2NormDiffBasicData"))); - } - if (StringUtil::toBool(input->getValue("NormalizeWithAmplitude"))) { - runTest = true; - testParameter->normalizeData.push_back("amplitude"); - testParameter->maxDiff.push_back(StringUtil::toDouble(input->getValue("MaxL2NormDiffAmplitude"))); - } - if (!runTest) - basicTestParameter->runTest = false; + testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); + testParameter->maxDiff = StringUtil::toDoubleVector(input->getValue("MaxL2NormDiff")); return testParameter; } @@ -223,7 +228,6 @@ std::shared_ptr<L2NormTestParameterStruct> ConfigFileReader::makeL2NormTestParam std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> ConfigFileReader::makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input) { std::shared_ptr<BasicTestParameterStruct> basicTestParameter = std::shared_ptr<BasicTestParameterStruct>(new BasicTestParameterStruct); - basicTestParameter->dataToCalc = StringUtil::toStringVector(input->getValue("DataToCalc_L2NormBetweenKernels")); basicTestParameter->runTest = StringUtil::toBool(input->getValue("L2NormBetweenKernelsTest")); basicTestParameter->ySliceForCalculation = StringUtil::toInt(input->getValue("ySliceForCalculation")); @@ -232,17 +236,16 @@ std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> ConfigFileReader::makeL testParameter->basicKernel = StringUtil::toString(input->getValue("BasicKernel_L2NormBetweenKernels")); testParameter->kernelsToTest = readKernelList(input); testParameter->timeSteps = StringUtil::toIntVector(input->getValue("Timesteps_L2NormBetweenKernels")); - testParameter->normalizeWith = StringUtil::toString(input->getValue("NormalizeWith")); + testParameter->normalizeData = StringUtil::toStringVector(input->getValue("NormalizeData_L2Norm")); bool correct = false; - - if (testParameter->normalizeWith == "amplitude") - correct = true; - if (testParameter->normalizeWith == "basicData") - correct = true; + for (int i = 0; i < testParameter->normalizeData.size(); i++) + if (testParameter->normalizeData.at(i) == "Amplitude" || testParameter->normalizeData.at(i) == "BasicData") + correct = true; + if (!correct) { - std::cout << "invalid input in ConfigFile." << std::endl << "possible data for NormalizeWith Parameter in L2-Norm Test Between Kernels Parameter:" << std::endl << "amplitude, basicData" << std::endl << std::endl; + std::cout << "invalid input in ConfigFile." << std::endl << "possible data for NormalizeWith Parameter in L2-Norm Test Between Kernels Parameter:" << std::endl << "Amplitude, BasicData" << std::endl << std::endl; exit(1); } @@ -343,7 +346,8 @@ unsigned int ConfigFileReader::calcStartStepForToVectorWriter(std::shared_ptr<in { std::vector<unsigned int> startStepsTests; startStepsTests.push_back(StringUtil::toInt(input->getValue("BasicTimeStep_L2"))); - startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_PhiNu"))); + startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Ny"))); + startStepsTests.push_back(StringUtil::toInt(input->getValue("StartTimeStepCalculation_Phi"))); std::sort(startStepsTests.begin(), startStepsTests.end()); return startStepsTests.at(0); diff --git a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h index 5a583e0d78ffaea7ad8b812bdfbe3f4d7c8316cf..13079eb884e5aa1177601487806559f597b548fa 100644 --- a/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h +++ b/targets/tests/NumericalTests/Utilities/ConfigFileReader/ConfigFileReader.h @@ -30,7 +30,8 @@ private: std::vector<std::shared_ptr<TaylorGreenVortexUzParameterStruct> > makeTaylorGreenVortexUzParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); std::vector<std::shared_ptr<ShearWaveParameterStruct> > makeShearWaveParameter(std::shared_ptr<input::Input> input, std::shared_ptr<BasicSimulationParameterStruct> basicSimParameter); - std::shared_ptr<PhiAndNyTestParameterStruct> makePhiAndNyTestParameter(std::shared_ptr<input::Input> input); + std::shared_ptr<NyTestParameterStruct> makeNyTestParameter(std::shared_ptr<input::Input> input); + std::shared_ptr<PhiTestParameterStruct> makePhiTestParameter(std::shared_ptr<input::Input> input); std::shared_ptr<L2NormTestParameterStruct> makeL2NormTestParameter(std::shared_ptr<input::Input> input); std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> makeL2NormTestBetweenKernelsParameter(std::shared_ptr<input::Input> input); diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp index a45ef5c92c557a46269127744fc2c676268233ab..f0dc749139f21485cc1e5ecfbf6aa8f00cbf90ac 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp +++ b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.cpp @@ -31,9 +31,15 @@ void ToVectorWriter::writeTimestep(std::shared_ptr<Parameter> para, unsigned int { for (int level = para->getCoarse(); level <= para->getFine(); level++) { + if(t==0) + para->cudaCopyPrint(level); writeTimestep(para, t, level); } } if (writeVTKFiles && startTimeVTKWriter < t) vtkFileWriter->writeTimestep(para, t); } + +ToVectorWriter::ToVectorWriter() +{ +} diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h index 8853cf69eb05774faa10f5acf8df24d40faa7f16..2e05defda8826a825a44e54d635dad3978ca266f 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h +++ b/targets/tests/NumericalTests/Utilities/DataWriter/ToVectorWriter.h @@ -12,11 +12,11 @@ class ToVectorWriter : public DataWriter public: void writeInit(std::shared_ptr<Parameter> para); void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t); - + protected: + ToVectorWriter(); ToVectorWriter(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength); virtual void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level) = 0; - void writeUnstrucuredGridLT(std::shared_ptr<Parameter> para, int level, std::vector<std::string >& fname) {}; std::shared_ptr<FileWriter> vtkFileWriter; bool writeVTKFiles; diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp index 62db296c49d8c481cd4de5d46ad5e3b131194102..05dbcd34bf3292308bb9b47b5c7fd47f3276e756 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp +++ b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.cpp @@ -9,6 +9,11 @@ std::shared_ptr<Y2dSliceToResults> Y2dSliceToResults::getNewInstance(std::shared return std::shared_ptr<Y2dSliceToResults>(new Y2dSliceToResults(vectorWriterInfo, timeStepLength, simResults, ySliceForCalculation)); } +Y2dSliceToResults::Y2dSliceToResults() +{ + +} + Y2dSliceToResults::Y2dSliceToResults(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation) : ToVectorWriter(vectorWriterInfo, timeStepLength) { @@ -45,6 +50,9 @@ void Y2dSliceToResults::writeTimestep(std::shared_ptr<Parameter> para, unsigned press.at(posResults) = (double)para->getParH(level)->press_SP[posPara] / (double)3.0 * (double)para->getDensityRatio() * (double)para->getVelocityRatio() * (double)para->getVelocityRatio(); rho.at(posResults) = (double)para->getParH(level)->rho_SP[posPara] / (double)3.0 * (double)para->getDensityRatio() * (double)para->getVelocityRatio() * (double)para->getVelocityRatio(); levels.at(posResults) = level; + + if (vx.at(posResults) != vx.at(posResults)) + int t = 1; } } simResults->addTimeStep(timestep, t, levels, x, y, z, vx, vy, vz, press, rho); diff --git a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h index fa4ed54d88886e5251c2353abb369cf7001f3b47..87214e6be0c62291dcd6191551bdc53150e5da33 100644 --- a/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h +++ b/targets/tests/NumericalTests/Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h @@ -15,7 +15,9 @@ class Y2dSliceToResults : public ToVectorWriter public: static std::shared_ptr<Y2dSliceToResults> getNewInstance(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation); + private: + Y2dSliceToResults(); Y2dSliceToResults(std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr<SimulationResults> simResults, unsigned int ySliceForCalculation); void writeTimestep(std::shared_ptr<Parameter> para, unsigned int t, int level); diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.cpp b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.cpp index 8bf0b9b0673b9b668a37bd18bb588a05e039f22d..13e0989fc23a9defb716fd736850a58106e60bfa 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.cpp +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.cpp @@ -1,32 +1,23 @@ #include "BasicTestLogFileInformation.h" -std::shared_ptr<BasicTestLogFileInformation> BasicTestLogFileInformation::getInstance() +std::shared_ptr<BasicTestLogFileInformation> BasicTestLogFileInformation::getNewInstance() { - static std::shared_ptr<BasicTestLogFileInformation> uniqueInstance; - if (!uniqueInstance) - uniqueInstance = std::shared_ptr<BasicTestLogFileInformation>(new BasicTestLogFileInformation()); - return uniqueInstance; + return std::shared_ptr<BasicTestLogFileInformation>(new BasicTestLogFileInformation());; } std::string BasicTestLogFileInformation::getOutput() { - if (!outputBuild) + if (!outputBuild) { buildOutput(); + outputBuild = true; + } return oss.str(); } void BasicTestLogFileInformation::addTest(std::string testName, bool testRun) { - bool isRegistered = false; - - for (int i = 0; i < this->testName.size(); i++) { - if (this->testName.at(i) == testName) - isRegistered = true; - } - if (!isRegistered) { - this->testName.push_back(testName); - this->testRun.push_back(testRun); - } + this->testName.push_back(testName); + this->testRun.push_back(testRun); } BasicTestLogFileInformation::BasicTestLogFileInformation() diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.h b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.h index 41144eb9a1763d94819f5b3ebd168bccb416637d..635724af3f9356675138d46c6c319db61ba6a610 100644 --- a/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.h +++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/BasicTestLogFileInformation/BasicTestLogFileInformation.h @@ -10,7 +10,7 @@ class BasicTestLogFileInformation : public LogFileInformationImp { public: - static std::shared_ptr<BasicTestLogFileInformation> getInstance(); + static std::shared_ptr<BasicTestLogFileInformation> getNewInstance(); std::string getOutput(); void addTest(std::string testName, bool testRun); diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp index e75f8dc0053d50a85793a668c3ccd10bb7964190..2f4cc761379fd67f2ccfe6013356c8dab696c2b1 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.cpp @@ -24,23 +24,25 @@ #include "Simulations/ShearWave/AnalyticalResults/ShearWaveAnalyticalResults.h" #include "Simulations/ShearWave/InitialConditions/InitialConditionShearWave.h" -#include "Tests/PhiAndNyTest/PhiAndNyTest.h" -#include "Tests/PhiAndNyTest/LogFileInformation/PhiAndNyLogFileInformation.h" -#include "Tests/PhiAndNyTest/PostProcessingStrategy/PostProcessingStrategyPhiAndNyTest.h" -#include "Tests/PhiAndNyTest/PhiAndNyTestStruct.h" - +#include "Tests/NyTest/NyTest.h" +#include "Tests/NyTest/LogFileInformation/NyTestLogFileInformation.h" +#include "Tests/NyTest/PostProcessingStrategy/NyTestPostProcessingStrategy.h" +#include "Tests/NyTest/NyTestStruct.h" +#include "Tests/PhiTest/PhiTest.h" +#include "Tests/PhiTest/LogFileInformation/PhiTestLogFileInformation.h" +#include "Tests/PhiTest/PostProcessingStrategy/PhiTestPostProcessingStrategy.h" +#include "Tests/PhiTest/PhiTestStruct.h" #include "Tests/L2NormTest/L2NormTest.h" #include "Tests/L2NormTest/LogFileInformation/L2NormLogFileInformation.h" #include "Tests/L2NormTest/PostProcessingStrategy/PostProcessingStrategyL2NormTest.h" #include "Tests/L2NormTest/L2NormTestStruct.h" - #include "Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernels.h" #include "Tests/L2NormTestBetweenKernels/PostProcessingStrategy/L2NormBetweenKernelPostProcessingStrategy.h" #include "Tests/L2NormTestBetweenKernels/LogFileInformation/L2NormLogFileInformationBetweenKernels.h" #include "Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsStruct.h" #include "Utilities/ColorConsoleOutput/ColorConsoleOutputImp.h" -#include "Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactory.h" +#include "Utilities/Calculator/L2NormCalculator/L2NormCalculatorFactory/L2NormCalculatorFactoryImp.h" #include "Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.h" #include "Utilities/DataWriter/Y2dSliceToResults/Y2dSliceToResults.h" @@ -66,12 +68,11 @@ std::shared_ptr<NumericalTestFactoryImp> NumericalTestFactoryImp::getNewInstance NumericalTestFactoryImp::NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData) { - basicTestLogFileInfo = BasicTestLogFileInformation::getInstance(); colorOutput = ColorConsoleOutputImp::getInstance(); myTestQueue = TestQueueImp::getNewInstance(colorOutput); myLogFileWriterQueue = LogFileQueueImp::getNewInstance(configFileData->logFilePath); anaResultWriter = AnalyticalResults2DToVTKWriterImp::getInstance(configFileData->writeAnalyticalToVTK); - l2NormCalculatorFactory = L2NormCalculatorFactory::getInstance(); + l2NormCalculatorFactory = L2NormCalculatorFactoryImp::getInstance(); l2NormTestsBetweenKernels.resize(0); init(configFileData); } @@ -134,17 +135,29 @@ std::shared_ptr<NumericalTestStruct> NumericalTestFactoryImp::makeNumericalTestS std::vector<std::shared_ptr<TestSimulationImp> > testSim = makeTestSimulations(simDataStruct->testSimData, configFileData->vectorWriterInfo, configFileData->ySliceForCalculation); numTestStruct->testSimulations = testSim; + std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo = BasicTestLogFileInformation::getNewInstance(); std::vector<std::shared_ptr<TestLogFileInformation> > testLogFileInfo; - std::shared_ptr<PhiAndNyTestStruct> phiAndNyTestStruct = makePhiAndNyTestsStructs(configFileData->phiAndNuTestParameter, testSim, viscosity); - for (int i = 0; i < phiAndNyTestStruct->tests.size(); i++) - numTestStruct->tests.push_back(phiAndNyTestStruct->tests.at(i)); - if (phiAndNyTestStruct->tests.size() > 0) { - testLogFileInfo.push_back(phiAndNyTestStruct->logFileInfo); - basicTestLogFileInfo->addTest("PhiAndNyTest", true); + std::shared_ptr<PhiTestStruct> phiTestStruct = makePhiTestsStructs(configFileData->phiTestParameter, testSim, viscosity); + for (int i = 0; i < phiTestStruct->tests.size(); i++) + numTestStruct->tests.push_back(phiTestStruct->tests.at(i)); + if (phiTestStruct->tests.size() > 0) { + testLogFileInfo.push_back(phiTestStruct->logFileInfo); + basicTestLogFileInfo->addTest("PhiTest", true); + } + else { + basicTestLogFileInfo->addTest("PhiTest", false); + } + + std::shared_ptr<NyTestStruct> nyTestStruct = makeNyTestsStructs(configFileData->nyTestParameter, testSim, viscosity); + for (int i = 0; i < nyTestStruct->tests.size(); i++) + numTestStruct->tests.push_back(nyTestStruct->tests.at(i)); + if (nyTestStruct->tests.size() > 0) { + testLogFileInfo.push_back(nyTestStruct->logFileInfo); + basicTestLogFileInfo->addTest("NyTest", true); } else { - basicTestLogFileInfo->addTest("PhiAndNyTest", false); + basicTestLogFileInfo->addTest("NyTest", false); } @@ -174,7 +187,7 @@ std::shared_ptr<NumericalTestStruct> NumericalTestFactoryImp::makeNumericalTestS for (int i = 0; i < simDataStruct->testSimData.size(); i++) simInfo.push_back(simDataStruct->testSimData.at(i)->simInformation); - std::shared_ptr<LogFileWriter> logFileWriter = makeLogFileWriter(testLogFileInfo, simDataStruct->logFileInformation, simInfo, kernel, viscosity, basicTimeStepLength, configFileData->logFilePara); + std::shared_ptr<LogFileWriter> logFileWriter = makeLogFileWriter(testLogFileInfo, simDataStruct->logFileInformation, simInfo, kernel, viscosity, basicTimeStepLength, configFileData->logFilePara, basicTestLogFileInfo); numTestStruct->logFileWriter = logFileWriter; return numTestStruct; @@ -273,45 +286,50 @@ std::vector<std::shared_ptr<TestSimulationImp> > NumericalTestFactoryImp::makeTe return testSimumlations; } -std::shared_ptr<PhiAndNyTestStruct> NumericalTestFactoryImp::makePhiAndNyTestsStructs(std::shared_ptr<PhiAndNyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity) +std::shared_ptr<PhiTestStruct> NumericalTestFactoryImp::makePhiTestsStructs(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSimumlations, double viscosity) { - std::shared_ptr<PhiAndNyTestStruct> testStruct = std::shared_ptr<PhiAndNyTestStruct> (new PhiAndNyTestStruct); + std::shared_ptr<PhiTestStruct> testStruct = std::shared_ptr<PhiTestStruct>(new PhiTestStruct); if (testParameter->basicTestParameter->runTest && testSimumlations.size() > 1) { - testStruct->logFileInfo = PhiAndNyInformation::getNewInstance(testParameter); + testStruct->logFileInfo = PhiTestLogFileInformation::getNewInstance(testParameter); - std::vector<std::shared_ptr<PhiAndNyTestPostProcessingStrategy> > postProcessingStrategies; + std::vector<std::shared_ptr<PhiTestPostProcessingStrategy> > postProcessingStrategies; for (int i = 0; i < testSimumlations.size(); i++) - postProcessingStrategies.push_back(PhiAndNyTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter)); + postProcessingStrategies.push_back(PhiTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, testSimumlations.at(i)->getDataToCalcTests())); - for (int i = 0; i < testParameter->basicTestParameter->dataToCalc.size(); i++) { - std::vector<std::shared_ptr<PhiAndNyTest> > phiAndNyTests = makePhiAndNyTests(testParameter, testSimumlations, postProcessingStrategies, viscosity, testParameter->basicTestParameter->dataToCalc.at(i)); - testStruct->logFileInfo->addTestGroup(phiAndNyTests); - for (int j = 0; j < phiAndNyTests.size(); j++) - testStruct->tests.push_back(phiAndNyTests.at(j)); + for (int i = 0; i < testSimumlations.at(0)->getDataToCalcTests().size(); i++) { + std::vector<std::shared_ptr<PhiTest> > phiTests = makePhiTests(testParameter, testSimumlations, postProcessingStrategies, viscosity, testSimumlations.at(0)->getDataToCalcTests().at(i)); + testStruct->logFileInfo->addTestGroup(phiTests); + for (int j = 0; j < phiTests.size(); j++) + testStruct->tests.push_back(phiTests.at(j)); } } return testStruct; } -std::vector<std::shared_ptr<PhiAndNyTest> > NumericalTestFactoryImp::makePhiAndNyTests(std::shared_ptr<PhiAndNyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<PhiAndNyTestPostProcessingStrategy> > postProStrategy, double viscosity, std::string dataToCalculate) +std::shared_ptr<NyTestStruct> NumericalTestFactoryImp::makeNyTestsStructs(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSimumlations, double viscosity) { - std::vector<std::shared_ptr<PhiAndNyTest> > phiAndNyTests; - for (int i = 1; i < testSim.size(); i++) { - for (int j = 0; j < i; j++) { - std::shared_ptr<PhiAndNyTest> test = PhiAndNyTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate); - test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), postProStrategy.at(j)); - test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(i)); + std::shared_ptr<NyTestStruct> testStruct = std::shared_ptr<NyTestStruct>(new NyTestStruct); + + if (testParameter->basicTestParameter->runTest && testSimumlations.size() > 1) { + testStruct->logFileInfo = NyTestLogFileInformation::getNewInstance(testParameter); - testSim.at(j)->registerSimulationObserver(test); - testSim.at(i)->registerSimulationObserver(test); - phiAndNyTests.push_back(test); + std::vector<std::shared_ptr<NyTestPostProcessingStrategy> > postProcessingStrategies; + for (int i = 0; i < testSimumlations.size(); i++) + postProcessingStrategies.push_back(NyTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, testSimumlations.at(i)->getDataToCalcTests())); + + for (int i = 0; i < testSimumlations.at(0)->getDataToCalcTests().size(); i++) { + std::vector<std::shared_ptr<NyTest> > nyTests = makeNyTests(testParameter, testSimumlations, postProcessingStrategies, viscosity, testSimumlations.at(0)->getDataToCalcTests().at(i)); + testStruct->logFileInfo->addTestGroup(nyTests); + for (int j = 0; j < nyTests.size(); j++) + testStruct->tests.push_back(nyTests.at(j)); } } - return phiAndNyTests; + + return testStruct; } std::shared_ptr<L2NormTestStruct> NumericalTestFactoryImp::makeL2NormTestsStructs(std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations) @@ -319,30 +337,25 @@ std::shared_ptr<L2NormTestStruct> NumericalTestFactoryImp::makeL2NormTestsStruct std::shared_ptr<L2NormTestStruct> testStruct = std::shared_ptr<L2NormTestStruct> (new L2NormTestStruct); if (testParameter->basicTestParameter->runTest) { - std::vector<std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > > postProcessingStrategies; - for (int j = 0; j < testParameter->normalizeData.size(); j++) { - std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > aPostProcessingStrategiesGroup; - for (int i = 0; i < testSimumlations.size(); i++) { - std::shared_ptr<L2NormCalculator> l2NormCalculator = l2NormCalculatorFactory->makeL2NormCalculator(testParameter->normalizeData.at(j)); - aPostProcessingStrategiesGroup.push_back(L2NormPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, l2NormCalculator)); - } - postProcessingStrategies.push_back(aPostProcessingStrategiesGroup); - } + std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProcessingStrategies; + for (int i = 0; i < testSimumlations.size(); i++) + postProcessingStrategies.push_back(L2NormPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, l2NormCalculatorFactory, testSimumlations.at(i)->getDataToCalcTests())); + testStruct->tests = makeL2NormTests(testSimumlations, postProcessingStrategies, testParameter); - testStruct->logFileInfo = L2NormInformation::getNewInstance(testStruct->tests, testParameter); + testStruct->logFileInfo = L2NormInformation::getNewInstance(testStruct->tests, testParameter, testSimumlations.at(0)->getDataToCalcTests()); } return testStruct; } -std::vector<std::shared_ptr<L2NormTest> > NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > > postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter) +std::vector<std::shared_ptr<L2NormTest> > NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter) { std::vector<std::shared_ptr<L2NormTest> > l2Tests; for (int k = 0; k < testParameter->normalizeData.size(); k++) { for (int i = 0; i < testSim.size(); i++) { - for (int j = 0; j < testParameter->basicTestParameter->dataToCalc.size(); j++) { - std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, testParameter, testParameter->basicTestParameter->dataToCalc.at(j), testParameter->maxDiff.at(k), testParameter->normalizeData.at(k)); - test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(k).at(i)); + for (int j = 0; j < testSim.at(i)->getDataToCalcTests().size(); j++) { + std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, testParameter, testSim.at(i)->getDataToCalcTests().at(j), testParameter->maxDiff.at(k), testParameter->normalizeData.at(k)); + test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(i)); testSim.at(i)->registerSimulationObserver(test); l2Tests.push_back(test); } @@ -359,7 +372,7 @@ std::shared_ptr<L2NormTestBetweenKernelsStruct> NumericalTestFactoryImp::makeL2N std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies; for (int i = 0; i < testSim.size(); i++) - postProcessingStrategies.push_back(L2NormBetweenKernelPostProcessingStrategy::getNewInstance(testSim.at(i)->getSimulationResults(), testSim.at(i)->getAnalyticalResults(), testPara)); + postProcessingStrategies.push_back(L2NormBetweenKernelPostProcessingStrategy::getNewInstance(testSim.at(i)->getSimulationResults(), testSim.at(i)->getAnalyticalResults(), testPara, l2NormCalculatorFactory, testSim.at(i)->getDataToCalcTests())); if (kernelName == testPara->basicKernel) { std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > tests = makeL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies); @@ -376,12 +389,48 @@ std::shared_ptr<L2NormTestBetweenKernelsStruct> NumericalTestFactoryImp::makeL2N }else{ std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests = linkL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies); testStruct->tests = tests; - testStruct->logFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, testPara); + testStruct->logFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, testPara, testSim.at(0)->getDataToCalcTests()); } } return testStruct; } +std::vector<std::shared_ptr<PhiTest>> NumericalTestFactoryImp::makePhiTests(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector<std::shared_ptr<PhiTestPostProcessingStrategy>> phiPostProStrategy, double viscosity, std::string dataToCalculate) +{ + std::vector<std::shared_ptr<PhiTest> > phiTests; + for (int i = 1; i < testSim.size(); i++) { + for (int j = 0; j < i; j++) { + std::shared_ptr<PhiTest> test = PhiTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate); + test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), phiPostProStrategy.at(j)); + test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), phiPostProStrategy.at(i)); + + testSim.at(j)->registerSimulationObserver(test); + testSim.at(i)->registerSimulationObserver(test); + + phiTests.push_back(test); + } + } + return phiTests; +} + +std::vector<std::shared_ptr<NyTest>> NumericalTestFactoryImp::makeNyTests(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector<std::shared_ptr<NyTestPostProcessingStrategy>> nuPostProStrategy, double viscosity, std::string dataToCalculate) +{ + std::vector<std::shared_ptr<NyTest> > nyTests; + for (int i = 1; i < testSim.size(); i++) { + for (int j = 0; j < i; j++) { + std::shared_ptr<NyTest> test = NyTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate); + test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), nuPostProStrategy.at(j)); + test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), nuPostProStrategy.at(i)); + + testSim.at(j)->registerSimulationObserver(test); + testSim.at(i)->registerSimulationObserver(test); + + nyTests.push_back(test); + } + } + return nyTests; +} + std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > NumericalTestFactoryImp::makeL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies) { @@ -391,12 +440,14 @@ std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > Numerical for (int l = 0; l < testPara->kernelsToTest.size() - 1; l++) { for (int k = 0; k < testSim.size(); k++) { - for(int j = 0; j < testPara->basicTestParameter->dataToCalc.size(); j++){ - for (int i = 0; i < testPara->timeSteps.size(); i++) { - std::shared_ptr<L2NormTestBetweenKernels> aTest = L2NormTestBetweenKernels::getNewInstance(colorOutput, testPara->basicTestParameter->dataToCalc.at(j), testPara->timeSteps.at(i), testPara->normalizeWith); - aTest->setBasicSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); - testSim.at(k)->registerSimulationObserver(aTest); - testForOneKernel.push_back(aTest); + for(int j = 0; j < testSim.at(k)->getDataToCalcTests().size(); j++){ + for (int m = 0; m < testPara->normalizeData.size(); m++) { + for (int i = 0; i < testPara->timeSteps.size(); i++) { + std::shared_ptr<L2NormTestBetweenKernels> aTest = L2NormTestBetweenKernels::getNewInstance(colorOutput, testSim.at(k)->getDataToCalcTests().at(j), testPara->timeSteps.at(i), testPara->normalizeData.at(m), l2NormCalculatorFactory); + aTest->setBasicSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); + testSim.at(k)->registerSimulationObserver(aTest); + testForOneKernel.push_back(aTest); + } } } } @@ -416,20 +467,22 @@ std::vector<std::shared_ptr<L2NormTestBetweenKernels> > NumericalTestFactoryImp: l2NormTestsBetweenKernels.erase(l2NormTestsBetweenKernels.begin()); for (int k = 0; k < testSim.size(); k++) { - for (int j = 0; j < testPara->basicTestParameter->dataToCalc.size(); j++) { - for (int i = 0; i < testPara->timeSteps.size(); i++) { - std::shared_ptr<L2NormTestBetweenKernels> aTest = l2NormTestsBetweenKernels.at(0).at(0); - l2NormTestsBetweenKernels.at(0).erase(l2NormTestsBetweenKernels.at(0).begin()); - aTest->setDivergentKernelSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); - testSim.at(k)->registerSimulationObserver(aTest); - tests.push_back(aTest); + for (int j = 0; j < testSim.at(k)->getDataToCalcTests().size(); j++) { + for (int m = 0; m < testPara->normalizeData.size(); m++) { + for (int i = 0; i < testPara->timeSteps.size(); i++) { + std::shared_ptr<L2NormTestBetweenKernels> aTest = l2NormTestsBetweenKernels.at(0).at(0); + l2NormTestsBetweenKernels.at(0).erase(l2NormTestsBetweenKernels.at(0).begin()); + aTest->setDivergentKernelSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k)); + testSim.at(k)->registerSimulationObserver(aTest); + tests.push_back(aTest); + } } } } return tests; } -std::shared_ptr<LogFileWriter> NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<SimulationInfo> > simInfo, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara) +std::shared_ptr<LogFileWriter> NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<SimulationInfo> > simInfo, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara, std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo) { std::shared_ptr<LogFileHead> logFileHead = LogFileHead::getNewInstance(logFilePara->devices); std::shared_ptr<BasicSimulationInfo> basicSimInfo = BasicSimulationInfo::getNewInstance(logFilePara->numberOfTimeSteps, viscosity, basicTimeStepLength, kernelName); diff --git a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h index 06f360f94392b8e540958462b6037d0e0094e58a..9fce35d37b8899b1d3f644d4fa53236358d7a762 100644 --- a/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h +++ b/targets/tests/NumericalTests/Utilities/NumericalTestFactory/NumericalTestFactoryImp.h @@ -11,8 +11,10 @@ struct L2NormTestBetweenKernelsParameterStruct; struct L2NormTestBetweenKernelsStruct; struct LogFileParameterStruct; struct NumericalTestStruct; -struct PhiAndNyTestStruct; -struct PhiAndNyTestParameterStruct; +struct PhiTestStruct; +struct PhiTestParameterStruct; +struct NyTestStruct; +struct NyTestParameterStruct; struct ShearWaveParameterStruct; struct SimulationDataStruct; struct TaylorGreenVortexUxParameterStruct; @@ -31,8 +33,10 @@ class L2NormTestBetweenKernels; class LogFileTimeInformation; class LogFileQueueImp; class LogFileWriter; -class PhiAndNyTest; -class PhiAndNyTestPostProcessingStrategy; +class PhiTest; +class PhiTestPostProcessingStrategy; +class NyTest; +class NyTestPostProcessingStrategy; class SimulationInfo; class SimulationLogFileInformation; class SimulationParameter; @@ -66,16 +70,20 @@ private: std::vector<std::shared_ptr<TestSimulationImp> > makeTestSimulations(std::vector<std::shared_ptr<TestSimulationDataStruct> > testSimDataStruct, std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int ySliceForCalculation); - std::shared_ptr<PhiAndNyTestStruct> makePhiAndNyTestsStructs(std::shared_ptr<PhiAndNyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity); + std::shared_ptr<PhiTestStruct> makePhiTestsStructs(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity); + std::shared_ptr<NyTestStruct> makeNyTestsStructs(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations, double viscosity); std::shared_ptr<L2NormTestStruct> makeL2NormTestsStructs(std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations); std::shared_ptr<L2NormTestBetweenKernelsStruct> makeL2NormTestsBetweenKernelsStructs(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::string kernelName); - std::vector<std::shared_ptr<PhiAndNyTest> > makePhiAndNyTests(std::shared_ptr<PhiAndNyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<PhiAndNyTestPostProcessingStrategy> > phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); - std::vector<std::shared_ptr<L2NormTest> > makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > > postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter); + + std::vector<std::shared_ptr<PhiTest> > makePhiTests(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<PhiTestPostProcessingStrategy> > phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); + std::vector<std::shared_ptr<NyTest> > makeNyTests(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<NyTestPostProcessingStrategy> > phiAndNuPostProStrategy, double viscosity, std::string dataToCalculate); + + std::vector<std::shared_ptr<L2NormTest> > makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter); std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > makeL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies); std::vector<std::shared_ptr<L2NormTestBetweenKernels> > linkL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies); - std::shared_ptr<LogFileWriter> makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<SimulationInfo> > simInfo, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara); + std::shared_ptr<LogFileWriter> makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<SimulationInfo> > simInfo, std::string kernelName, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara, std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo); std::vector<std::shared_ptr<TestSimulation> > myTestSimulations; std::shared_ptr<TestQueueImp> myTestQueue; @@ -86,7 +94,6 @@ private: std::shared_ptr<ColorConsoleOutput> colorOutput; std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter; - std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo; std::shared_ptr<L2NormCalculatorFactory> l2NormCalculatorFactory; int simID; diff --git a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h index 04c2c1708bb1818629d3a12562f24028a5d11965..08079b7824182d0a0b7ac395caaacd2f3541aa35 100644 --- a/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h +++ b/targets/tests/NumericalTests/Utilities/Results/AnalyticalResults/AnalyticalResultImp.h @@ -3,6 +3,8 @@ #include "AnalyticalResult.h" +#include "VirtualFluids_GPU/LBM/LB.h" + class AnalyticalResultsImp : public AnalyticalResults { public: diff --git a/targets/tests/NumericalTests/Utilities/Results/Results.h b/targets/tests/NumericalTests/Utilities/Results/Results.h index f24832b5d6af864e00452ea15f6855c82b4ab51d..6c51f1b1f1a67dccc04f7f692a2f6840a5711c14 100644 --- a/targets/tests/NumericalTests/Utilities/Results/Results.h +++ b/targets/tests/NumericalTests/Utilities/Results/Results.h @@ -20,7 +20,7 @@ public: virtual std::vector<unsigned int> getTimeSteps() = 0; virtual std::vector < std::vector<unsigned int> > getLevels() = 0; -private: + virtual bool checkYourData() = 0; }; #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 9249374bc1b6f960ea82cf589ff0387678c8b208..4934e89ed2d34d3dfed54ae138e9d1a14337c0ca 100644 --- a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.cpp @@ -1,5 +1,7 @@ #include "ResultsImp.h" +#include <iostream> + int ResultsImp::getNumberOfTimeSteps() { return numberOfTimeSteps; @@ -79,3 +81,45 @@ std::vector<std::vector<double> > ResultsImp::getRho() { return rho; } + +bool ResultsImp::checkYourData() +{ + std::cout << "checking Simulation Results Data..."; + for (int i = 0; i < vx.size(); i++) { + for (int j = 0; j < vx.at(i).size(); j++) { + if (vx.at(i).at(j) != vx.at(i).at(j)) { + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains failure data." << std::endl; + std::cout << "Testing not possible." << std::endl; + return false; + } + if (vy.at(i).at(j) != vy.at(i).at(j)) { + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains failure data." << std::endl; + std::cout << "Testing not possible." << std::endl; + return false; + } + if (vz.at(i).at(j) != vz.at(i).at(j)) { + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains failure data." << std::endl; + std::cout << "Testing not possible." << std::endl; + return false; + } + if (rho.at(i).at(j) != rho.at(i).at(j)) { + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains failure data." << std::endl; + std::cout << "Testing not possible." << std::endl; + return false; + } + if (press.at(i).at(j) != press.at(i).at(j)) { + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains failure data." << std::endl; + std::cout << "Testing not possible." << std::endl; + return false; + } + } + } + std::cout << "done." << std::endl; + std::cout << "Simulation Result Data contains no failure data." << std::endl; + return true; +} \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h index b7fa075caec85651216c717b945dabdaacd34eb4..d58948d34849b5dea74926eb1d42fe834255ec35 100644 --- a/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h +++ b/targets/tests/NumericalTests/Utilities/Results/ResultsImp.h @@ -23,6 +23,8 @@ public: std::vector<std::vector<double> > getPress(); std::vector<std::vector<double> > getRho(); + bool checkYourData(); + protected: ResultsImp() {}; diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h index 1bd12561d491f2d8f9e7c6dd8e4c5d5005e2cc33..cd0c29e9c41765b3c877fb4830d66d41f5c98ee7 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfo.h @@ -3,6 +3,7 @@ #include <memory> #include <string> +#include <vector> class TimeInfo; @@ -17,6 +18,7 @@ public: virtual int getNumberOfSimulations() = 0; virtual int getSimulationID() = 0; virtual std::string getRunTimeOutput() = 0; + virtual std::vector<std::string> getDataToCalcTests() = 0; virtual void setTimeInfo(std::shared_ptr<TimeInfo> timeInfo) = 0; }; diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp index f2be223b590156a5eef71c286a8a28e9bb919518..6de7592a3e1c8a7df7f1b9d315b335957bc386f0 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.cpp @@ -49,12 +49,18 @@ std::string SimulationInfoImp::getRunTimeOutput() { std::ostringstream oss; oss << "SimulationTime_" << lx << "=" << timeInfo->getSimulationTime() << std::endl; + oss << "ResultsCheckTime_" << lx << "=" << timeInfo->getResultCheckTime() << std::endl; oss << "TestTime_" << lx << "=" << timeInfo->getTestTime() << std::endl; oss << "AnalyticalVTKFileWritingTime_" << lx << "=" << timeInfo->getAnalyticalResultWriteTime() << std::endl; return oss.str(); } -SimulationInfoImp::SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName) - : simID(simID), lx(lx), viscosity(viscosity), kernelName(kernelName), numberOfSimulations(numberOfSimulations), simulationName(simulationName) +std::vector<std::string> SimulationInfoImp::getDataToCalcTests() +{ + return dataToCalcTests; +} + +SimulationInfoImp::SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName, std::vector<std::string> dataToCalcTests) + : simID(simID), lx(lx), viscosity(viscosity), kernelName(kernelName), numberOfSimulations(numberOfSimulations), simulationName(simulationName), dataToCalcTests(dataToCalcTests) { } diff --git a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h index 0b150ebd0a5206e248085f82b4376b4cb73a28eb..69f3a2b57b9dc4232d20f81c96649ea43acc89b0 100644 --- a/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h +++ b/targets/tests/NumericalTests/Utilities/SimulationInfo/SimulationInfoImp.h @@ -20,10 +20,11 @@ public: int getNumberOfSimulations(); int getSimulationID(); std::string getRunTimeOutput(); + std::vector<std::string> getDataToCalcTests(); protected: SimulationInfoImp() {}; - SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName); + SimulationInfoImp(int simID, std::string kernelName, double viscosity, int lx, int numberOfSimulations, std::string simulationName, std::vector<std::string> dataToCalcTests); double viscosity; std::string kernelName; @@ -32,6 +33,7 @@ protected: int lx; int numberOfSimulations, simID; std::shared_ptr<TimeInfo> timeInfo; + std::vector<std::string> dataToCalcTests; private: diff --git a/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h b/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h index d681c072455722624b9ddeb51207ae5487b55812..658f5ac16b9f6ca3dc72a4bfeabd7c1babc99dd6 100644 --- a/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h +++ b/targets/tests/NumericalTests/Utilities/Structs/BasicTestParameterStruct.h @@ -8,6 +8,5 @@ struct BasicTestParameterStruct { unsigned int ySliceForCalculation; bool runTest; - std::vector<std::string> dataToCalc; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h b/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h index f11861836885289031e468648acadb75f7acaa8e..8c98e90298d22d6c09ac328e709c6b2469224758 100644 --- a/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h +++ b/targets/tests/NumericalTests/Utilities/Structs/ConfigDataStruct.h @@ -10,7 +10,8 @@ #include "Simulations/TaylorGreenVortexUz/TaylorGreenVortexUzParameterStruct.h" #include "Tests/L2NormTest/L2NormTestParameterStruct.h" #include "Tests/L2NormTestBetweenKernels/L2NormTestBetweenKernelsParameterStruct.h" -#include "Tests/PhiAndNyTest/PhiAndNyTestParameterStruct.h" +#include "Tests/NyTest/NyTestParameterStruct.h" +#include "Tests/PhiTest/PhiTestParameterStruct.h" #include "Utilities/Structs/BasicSimulationParameterStruct.h" #include "Utilities/Structs/VectorWriterInformationStruct.h" #include "Utilities/Structs/GridInformationStruct.h" @@ -40,7 +41,8 @@ struct ConfigDataStruct int numberOfSimulations; - std::shared_ptr<PhiAndNyTestParameterStruct> phiAndNuTestParameter; + std::shared_ptr<PhiTestParameterStruct> phiTestParameter; + std::shared_ptr<NyTestParameterStruct> nyTestParameter; std::shared_ptr<L2NormTestParameterStruct> l2NormTestParameter; std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> l2NormTestBetweenKernelsParameter; diff --git a/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h b/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h index 46e771d746a5f932a9de81e309290180d052fb95..74aa260b9b1e7ceea4cfb853c68af0ff37f2a86b 100644 --- a/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h +++ b/targets/tests/NumericalTests/Utilities/Test/SimulationObserver.h @@ -5,8 +5,7 @@ class SimulationObserver { public: virtual void update() = 0; - -private: + virtual void setSimulationCrashed() = 0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Test/Test.h b/targets/tests/NumericalTests/Utilities/Test/Test.h index 88b74c4426d501f3382f8174ea59fbc785573b16..81d44d43d083dfdcbfd475c9fb562e392aa1395f 100644 --- a/targets/tests/NumericalTests/Utilities/Test/Test.h +++ b/targets/tests/NumericalTests/Utilities/Test/Test.h @@ -2,18 +2,18 @@ #define TEST_H #include "SimulationObserver.h" +#include "TestStatus.h" #include <vector> - class Test : public SimulationObserver { public: virtual void update() = 0; - virtual std::vector<bool> getPassedTests() = 0; - virtual void makeConsoleOutput() = 0; + virtual void setSimulationCrashed() = 0; -private: + virtual TestStatus getTestStatus() = 0; + virtual void makeConsoleOutput() = 0; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp index 717978ffa844645ca1bf3ce7d00976ceeb7e4026..53f61e39f2f196441ab395aa3463e7db5bb25d52 100644 --- a/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.cpp @@ -1,24 +1,23 @@ #include "TestImp.h" +#include "Utilities/ColorConsoleOutput/ColorConsoleOutput.h" #include "Utilities/PostProcessingStrategy/PostProcessingStrategy.h" #include "Utilities/NumericalTestSimulation/NumericalTestSimulation.h" void TestImp::update() { - for (int i = 0; i < simulations.size(); i++) - { - if(simulationRun.at(i) == false) - { - if (simulations.at(i)->getSimulationRun()) - { - simulationRun.at(i) = true; - postProStrategies.at(i)->evaluate(); + if (testStatus != simulationCrashed) { + for (int i = 0; i < simulations.size(); i++){ + if (simulationRun.at(i) == false){ + if (simulations.at(i)->getSimulationRun()){ + simulationRun.at(i) = true; + postProStrategies.at(i)->evaluate(); + } } } - } - - if (CheckAllSimulationRun()) - evaluate(); + if (CheckAllSimulationRun()) + evaluate(); + } } void TestImp::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PostProcessingStrategy> postProStrategy) @@ -29,9 +28,37 @@ void TestImp::addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::s simulationRun.push_back(false); } -std::string TestImp::getSimulationName() +void TestImp::setSimulationCrashed() { - return simulationName; + testStatus = simulationCrashed; + for (int i = 0; i < simulations.size(); i++) + if (simulationRun.at(i) == false) + if (simulations.at(i)->getSimulationRun()) + simulationRun.at(i) = true; + if (CheckAllSimulationRun()) + makeConsoleOutput(); +} + +TestStatus TestImp::getTestStatus() +{ + return testStatus; +} + +void TestImp::makeConsoleOutput() +{ + switch (testStatus) + { + case passed: colorOutput->makeTestOutput(buildTestOutput(), testStatus); + break; + case failed: colorOutput->makeTestOutput(buildTestOutput(), testStatus); + break; + case error: colorOutput->makeTestOutput(buildErrorTestOutput(), testStatus); + break; + case simulationCrashed: colorOutput->makeTestOutput(buildSimulationFailedTestOutput(), testStatus); + break; + default: + break; + } } TestImp::TestImp(std::shared_ptr<ColorConsoleOutput> colorOutput) : colorOutput(colorOutput) @@ -48,4 +75,16 @@ bool TestImp::CheckAllSimulationRun() return false; return true; -} \ No newline at end of file +} + +std::vector<std::string> TestImp::buildSimulationFailedTestOutput() +{ + std::vector<std::string> output = buildBasicTestOutput(); + std::ostringstream oss; + + oss << "Simulation crashed!"; + output.push_back(oss.str()); + oss.str(std::string()); + + return output; +} diff --git a/targets/tests/NumericalTests/Utilities/Test/TestImp.h b/targets/tests/NumericalTests/Utilities/Test/TestImp.h index f757be6d8133a50cccfabc582a16d1bb984323de..097032b257f672deae635052cb6a594f3ebe99bc 100644 --- a/targets/tests/NumericalTests/Utilities/Test/TestImp.h +++ b/targets/tests/NumericalTests/Utilities/Test/TestImp.h @@ -17,25 +17,27 @@ class TestImp : public Test public: void update(); void addSimulation(std::shared_ptr<NumericalTestSimulation> sim, std::shared_ptr<SimulationInfo> simInfo, std::shared_ptr<PostProcessingStrategy> postProStrategy); + void setSimulationCrashed(); + TestStatus getTestStatus(); - virtual void evaluate() = 0; - virtual std::vector<bool> getPassedTests() = 0; - virtual void makeConsoleOutput() = 0; - - std::string getSimulationName(); + virtual void makeConsoleOutput(); + virtual void evaluate() = 0; protected: TestImp(std::shared_ptr<ColorConsoleOutput> colorOutput); bool CheckAllSimulationRun(); + virtual std::vector<std::string> buildTestOutput() = 0; + virtual std::vector<std::string> buildBasicTestOutput() = 0; + virtual std::vector<std::string> buildErrorTestOutput() = 0; + std::vector<std::string> buildSimulationFailedTestOutput(); + std::vector<std::shared_ptr<NumericalTestSimulation> > simulations; std::vector<std::shared_ptr<PostProcessingStrategy> > postProStrategies; std::vector<std::shared_ptr<SimulationInfo> > simInfos; std::vector<bool> simulationRun; std::shared_ptr<ColorConsoleOutput> colorOutput; - - std::string kernelName; - std::string simulationName; + TestStatus testStatus; private: TestImp() {}; diff --git a/targets/tests/NumericalTests/Utilities/Test/TestStatus.h b/targets/tests/NumericalTests/Utilities/Test/TestStatus.h new file mode 100644 index 0000000000000000000000000000000000000000..3ecaf5a71f67f087d778c05d5fd465238446bbc9 --- /dev/null +++ b/targets/tests/NumericalTests/Utilities/Test/TestStatus.h @@ -0,0 +1,6 @@ +#ifndef TEST_STATUS_H +#define TEST_STATUS_H + +enum TestStatus { passed, failed, error, simulationCrashed }; + +#endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp b/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp index c436337dd759de910894d27b408ed0c4a77bc280..a54f15f5e0f36beae454606194515072fe6f61e1 100644 --- a/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp +++ b/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.cpp @@ -5,11 +5,11 @@ void TestQueueImp::makeFinalOutput() { - calcNumberOfPassedTest(); - colorOutput->makeFinalTestOutputHead(numberOfPassedTest, numberOfTests); + calcTestNumbers(); + colorOutput->makeFinalTestOutputHead(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest, numberOfErrorTest, numberOfNotExecutedTest); for (int i = 0; i < tests.size(); i++) tests.at(i)->makeConsoleOutput(); - colorOutput->makeFinalTestOutputFoot(numberOfPassedTest, numberOfTests); + colorOutput->makeFinalTestOutputFoot(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest, numberOfErrorTest, numberOfNotExecutedTest); } std::shared_ptr<TestQueueImp> TestQueueImp::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput) @@ -27,22 +27,35 @@ TestQueueImp::TestQueueImp(std::shared_ptr<ColorConsoleOutput> colorOutput) : co tests.resize(0); } -void TestQueueImp::calcNumberOfPassedTest() +void TestQueueImp::calcTestNumbers() { + numberOfTests = tests.size(); + numberOfExecutedTest = 0; numberOfPassedTest = 0; - numberOfTests = 0; + numberOfFailedTest = 0; + numberOfErrorTest = 0; + numberOfNotExecutedTest = 0; for (int i = 0; i < tests.size(); i++) { - for (int j = 0; j < tests.at(i)->getPassedTests().size(); j++) { - if (tests.at(i)->getPassedTests().at(j)) { - numberOfPassedTest++; - numberOfTests++; - } - else - { - numberOfTests++; - } + switch (tests.at(i)->getTestStatus()) + { + case passed: + numberOfPassedTest++; + numberOfExecutedTest++; + break; + case failed: + numberOfFailedTest++; + numberOfExecutedTest++; + break; + case error: + numberOfErrorTest++; + break; + case simulationCrashed: + numberOfNotExecutedTest++; + break; + default: + break; } - } + } diff --git a/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h b/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h index 81210f0788e316b0611b2694c27e2ead03d6dd57..df5d12bea24224c941f571bfc64033e4f12593fe 100644 --- a/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h +++ b/targets/tests/NumericalTests/Utilities/TestQueue/TestQueueImp.h @@ -20,11 +20,17 @@ public: private: TestQueueImp(std::shared_ptr<ColorConsoleOutput> colorOutput); - void calcNumberOfPassedTest(); + void calcTestNumbers(); std::shared_ptr<ColorConsoleOutput> colorOutput; std::vector<std::shared_ptr<Test> > tests; + int numberOfPassedTest; + int numberOfFailedTest; + int numberOfErrorTest; + int numberOfExecutedTest; + int numberOfNotExecutedTest; + int numberOfTests; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp index 19c2ef7f71880139bea619cb6fdaf96ea9ff2fde..8e4f7fffd4f0d96b470fb6e18e36ca2491073897 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp @@ -9,6 +9,7 @@ #include "Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriter.h" #include "Utilities/Structs/TestSimulationDataStruct.h" #include "Utilities/Time/TimeTracking.h" +#include "Utilities/Results/SimulationResults/SimulationResults.h" std::shared_ptr<TestSimulationImp> TestSimulationImp::getNewInsance(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResult, std::shared_ptr<TimeTracking> timeTracking, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput) @@ -33,6 +34,7 @@ TestSimulationImp::TestSimulationImp(std::shared_ptr<TestSimulationDataStruct> t this->simObserver.resize(0); this->simualtionRun = false; + this->dataToCalcTests = simInfo->getDataToCalcTests(); } std::shared_ptr<SimulationParameter> TestSimulationImp::getSimulationParameter() @@ -75,12 +77,23 @@ void TestSimulationImp::registerSimulationObserver(std::shared_ptr<SimulationObs this->simObserver.push_back(simObserver); } +std::vector<std::string> TestSimulationImp::getDataToCalcTests() +{ + return dataToCalcTests; +} + void TestSimulationImp::notifyObserver() { for (int i = 0; i < simObserver.size(); i++) simObserver.at(i)->update(); } +void TestSimulationImp::notifyObserverSimulationCrashed() +{ + for (int i = 0; i < simObserver.size(); i++) + simObserver.at(i)->setSimulationCrashed(); +} + void TestSimulationImp::writeAnalyticalResultsToVTK() { if (!analyticalResult->isCalculated()) @@ -98,8 +111,15 @@ void TestSimulationImp::startPostProcessing() { simualtionRun = true; + timeTracking->setResultCheckStartTime(); + bool dataOkay = simResult->checkYourData(); + timeTracking->setResultCheckEndTime(); + timeTracking->setTestStartTime(); - notifyObserver(); + if (dataOkay) + notifyObserver(); + else + notifyObserverSimulationCrashed(); timeTracking->setTestEndTime(); timeTracking->setAnalyticalResultWriteStartTime(); diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h index 872fcfd764c58fa3581ceecd9424fec95bfae7ac..123508f3e118ccfe471d8c39bdcb3f9b4d223c9a 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h @@ -38,10 +38,12 @@ public: std::shared_ptr<SimulationResults> getSimulationResults(); std::shared_ptr<AnalyticalResults> getAnalyticalResults(); void registerSimulationObserver(std::shared_ptr<SimulationObserver> simObserver); + std::vector<std::string> getDataToCalcTests(); private: TestSimulationImp(std::shared_ptr<TestSimulationDataStruct> testSimData, std::shared_ptr<SimulationResults> simResult, std::shared_ptr<TimeTracking> timeTracking, std::shared_ptr<ToVectorWriter> toVectorWriter, std::shared_ptr<AnalyticalResults2DToVTKWriter> anaResultWriter, std::shared_ptr<ColorConsoleOutput> colorOutput); void notifyObserver(); + void notifyObserverSimulationCrashed(); void writeAnalyticalResultsToVTK(); @@ -59,6 +61,7 @@ private: std::shared_ptr<Parameter> para; std::vector<std::shared_ptr<SimulationObserver> > simObserver; + std::vector<std::string> dataToCalcTests; bool simualtionRun; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/Utilities/Time/TimeImp.cpp b/targets/tests/NumericalTests/Utilities/Time/TimeImp.cpp index 7c43b8caf5a68e8e18645b5c1d94fffdee5d1979..f9d380a0cba6211b3fdd5657003f1a4a8e4ff450 100644 --- a/targets/tests/NumericalTests/Utilities/Time/TimeImp.cpp +++ b/targets/tests/NumericalTests/Utilities/Time/TimeImp.cpp @@ -42,6 +42,16 @@ void TimeImp::setAnalyticalResultWriteEndTime() analyticalResultWriteEndTime = time(NULL); } +void TimeImp::setResultCheckStartTime() +{ + resultCheckStartTime = clock(); +} + +void TimeImp::setResultCheckEndTime() +{ + resultCheckEndTime = clock(); +} + std::string TimeImp::getSimulationTime() { std::ostringstream oss; @@ -49,6 +59,13 @@ std::string TimeImp::getSimulationTime() return oss.str(); } +std::string TimeImp::getResultCheckTime() +{ + std::ostringstream oss; + oss << calcResultCheckTime() << "sec"; + return oss.str(); +} + std::string TimeImp::getTestTime() { std::ostringstream oss; @@ -68,6 +85,12 @@ double TimeImp::calcSimulationTime() return difftime(simulationEndTime, simulationStartTime); } +float TimeImp::calcResultCheckTime() +{ + float timeInMiliSec = ((float)(resultCheckEndTime - resultCheckStartTime) / CLOCKS_PER_SEC); + return timeInMiliSec; +} + float TimeImp::calcTestTime() { float timeInMiliSec = ((float)(testEndTime - testStartTime) / CLOCKS_PER_SEC); diff --git a/targets/tests/NumericalTests/Utilities/Time/TimeImp.h b/targets/tests/NumericalTests/Utilities/Time/TimeImp.h index d73f59ca8a759342b7393339cf922f578cb3b8fa..87e14e74fb08f6e7f0ceba7923e3adf4db39d455 100644 --- a/targets/tests/NumericalTests/Utilities/Time/TimeImp.h +++ b/targets/tests/NumericalTests/Utilities/Time/TimeImp.h @@ -18,18 +18,23 @@ public: void setTestEndTime(); void setAnalyticalResultWriteStartTime(); void setAnalyticalResultWriteEndTime(); + void setResultCheckStartTime(); + void setResultCheckEndTime(); std::string getSimulationTime(); + std::string getResultCheckTime(); std::string getTestTime(); std::string getAnalyticalResultWriteTime(); private: TimeImp(); double calcSimulationTime(); + float calcResultCheckTime(); float calcTestTime(); double calcAnalyticalResultWriteTime(); time_t simulationStartTime, simulationEndTime; + clock_t resultCheckStartTime, resultCheckEndTime; clock_t testStartTime, testEndTime; time_t analyticalResultWriteStartTime, analyticalResultWriteEndTime; }; diff --git a/targets/tests/NumericalTests/Utilities/Time/TimeInfo.h b/targets/tests/NumericalTests/Utilities/Time/TimeInfo.h index f1a077a817350fbe656502c62bfc196d487db75c..11e49b28406ecf08f83f13cfc5cbe09c3ebd8a84 100644 --- a/targets/tests/NumericalTests/Utilities/Time/TimeInfo.h +++ b/targets/tests/NumericalTests/Utilities/Time/TimeInfo.h @@ -7,6 +7,7 @@ class TimeInfo { public: virtual std::string getSimulationTime() = 0; + virtual std::string getResultCheckTime() = 0; virtual std::string getTestTime() = 0; virtual std::string getAnalyticalResultWriteTime() = 0; }; diff --git a/targets/tests/NumericalTests/Utilities/Time/TimeTracking.h b/targets/tests/NumericalTests/Utilities/Time/TimeTracking.h index b8ba186ac9742fdfa3e13ba3e53e63603ec52cf4..736ca764116934dc31e18d7d7c910ead554b253b 100644 --- a/targets/tests/NumericalTests/Utilities/Time/TimeTracking.h +++ b/targets/tests/NumericalTests/Utilities/Time/TimeTracking.h @@ -7,6 +7,9 @@ public: virtual void setSimulationStartTime() = 0; virtual void setSimulationEndTime() = 0; + virtual void setResultCheckStartTime() = 0; + virtual void setResultCheckEndTime() = 0; + virtual void setTestStartTime() = 0; virtual void setTestEndTime() = 0; diff --git a/targets/tests/NumericalTests/config.txt b/targets/tests/NumericalTests/config.txt index 8e5bc52e915367f48fcc6b5f852136a7ffc0a76c..9d04151f77cfad32e23636ff4daa602e31054812 100644 --- a/targets/tests/NumericalTests/config.txt +++ b/targets/tests/NumericalTests/config.txt @@ -6,7 +6,9 @@ Devices="1" ################################################## # Basic Simulation Parameter # ################################################## -KernelsToTest="CumulantOneCompSP27 CumulantAA2016CompSP27 CumulantAll4CompSP27" +KernelsToTest="CumulantF32018CompSP27 CumulantF3CompSP27" +#CumulantAll4CompSP27 CumulantOneCompSP27 +# CumulantAA2016CompSP27 CumulantF32018CompSP27" NumberOfTimeSteps=20 Viscosity="0.001" Rho0=1.0 @@ -14,15 +16,17 @@ Rho0=1.0 ################################################## # TaylorGreenVortex Parameter # ################################################## -BasisTimeStepLength_TGV_Ux="1000 2000" -ux_TGV_Ux="0.032 0.016" -Amplitude_TGV_Ux="0.01 0.005" +BasisTimeStepLength_TGV_Ux="1000" +ux_TGV_Ux="0.032" +Amplitude_TGV_Ux="0.01" l0_TGV_Ux=32 +DataToCalcTests_TGV_Ux="Vx Vz" -BasisTimeStepLength_TGV_Uz="1000 2000" -uz_TGV_Uz="0.048 0.024" -Amplitude_TGV_Uz="0.01 0.005" +BasisTimeStepLength_TGV_Uz="1000" +uz_TGV_Uz="0.048" +Amplitude_TGV_Uz="0.01" l0_TGV_Uz=48 +DataToCalcTests_TGV_Uz="Vx Vz" ################################################## # Shear Wave Parameter # @@ -31,6 +35,7 @@ BasisTimeStepLength_SW="1000" u0_SW="0.032" v0_SW="0.1" l0_SW=32 +DataToCalcTests_SW="Vy" ################################################## # Basic Test Parameter # @@ -38,25 +43,31 @@ l0_SW=32 ySliceForCalculation=0 ################################################## -# PhiAndNu Test Parameter # +# Phi Test Parameter # ################################################## -PhiAndNuTest=false -MinOrderOfAccuracy=1.95 -DataToCalc_PhiAndNu="Vx Vz" -StartTimeStepCalculation_PhiNu=11 -EndTimeStepCalculation_PhiNu=20 +PhiTest=true + +MinOrderOfAccuracy_Phi=1.95 +StartTimeStepCalculation_Phi=11 +EndTimeStepCalculation_Phi=20 + +################################################## +# Ny Test Parameter # +################################################## +NyTest=true + +MinOrderOfAccuracy_Ny=1.95 +StartTimeStepCalculation_Ny=11 +EndTimeStepCalculation_Ny=20 ################################################## # L2-Norm Test Parameter # ################################################## -L2NormTest=false +L2NormTest=true -NormalizeWithBasicData=true -MaxL2NormDiffBasicData=0.5 -NormalizeWithAmplitude=true -MaxL2NormDiffAmplitude=2.5 +NormalizeData_L2Norm="Amplitude BasicData" +MaxL2NormDiff="4.5 0.5" -DataToCalc_L2="Vx Vz" BasicTimeStep_L2=0 DivergentTimeStep_L2=20 @@ -64,30 +75,30 @@ DivergentTimeStep_L2=20 # L2-Norm Test Between Kernels Parameter # ################################################## L2NormBetweenKernelsTest=true -BasicKernel_L2NormBetweenKernels=CumulantOneCompSP27 -Timesteps_L2NormBetweenKernels="0 20" -DataToCalc_L2NormBetweenKernels="Vx Vz" + +BasicKernel_L2NormBetweenKernels=CumulantF32018CompSP27 +Timesteps_L2NormBetweenKernels="0 10 20" NormalizeWith=amplitude ################################################## # Simulation To Perform # ################################################## -TaylorGreenVortexUx32=false -TaylorGreenVortexUx64=false -TaylorGreenVortexUx128=false -TaylorGreenVortexUx256=false +TaylorGreenVortexUx32=true +TaylorGreenVortexUx64=true +TaylorGreenVortexUx128=true +TaylorGreenVortexUx256=true TaylorGreenVortexUx512=false -TaylorGreenVortexUz32=false -TaylorGreenVortexUz64=false -TaylorGreenVortexUz128=false -TaylorGreenVortexUz256=false +TaylorGreenVortexUz32=true +TaylorGreenVortexUz64=true +TaylorGreenVortexUz128=true +TaylorGreenVortexUz256=true TaylorGreenVortexUz512=false ShearWave32=true -ShearWave64=false -ShearWave128=false -ShearWave256=false +ShearWave64=true +ShearWave128=true +ShearWave256=true ShearWave512=false ################################################## @@ -104,10 +115,10 @@ GridPath512="C:\Users\Timon\Documents\studienarbeitIRMB\grids\gridUni512x4x768" ################################################## # File Writing Information # ################################################## -WriteVTKFiles=false +WriteVTKFiles=true PathForVTKFileWriting="C:\Users\Timon\Documents\studienarbeitIRMB\Output" StartStepFileWriter=0 -WriteAnalyResultsToVTK=false +WriteAnalyResultsToVTK=true PathLogFile="C:\Users\Timon\Documents\studienarbeitIRMB\logFiles" \ No newline at end of file