57 basicPostProcessingStrategy->evaluate();
58 divergentPostProcessingStrategy->evaluate();
60 int tS = calcTimeStepInResults(timeStep);
62 basicL2Result = basicPostProcessingStrategy->getL2Norm(dataToCalculate, normalizeData, timeStep);
63 divergentL2Result = divergentPostProcessingStrategy->getL2Norm(dataToCalculate, normalizeData, timeStep);
65 if (dataToCalculate ==
"Vx")
66 resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVx().at(
tS), divergentSimResults->getVx().at(
tS), basicSimResults->getLevels().at(
tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getL0());
67 if (dataToCalculate ==
"Vy")
68 resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVy().at(
tS), divergentSimResults->getVy().at(
tS), basicSimResults->getLevels().at(
tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getL0());
69 if (dataToCalculate ==
"Vz")
70 resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getVz().at(
tS), divergentSimResults->getVz().at(
tS), basicSimResults->getLevels().at(
tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getL0());
71 if (dataToCalculate ==
"Press")
72 resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getPress().at(
tS), divergentSimResults->getPress().at(
tS), basicSimResults->getLevels().at(
tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getL0());
73 if (dataToCalculate ==
"Rho")
74 resultL2ToBasicKernel = l2Normcalculator->calc(basicSimResults->getRho().at(
tS), divergentSimResults->getRho().at(
tS), basicSimResults->getLevels().at(
tS), basicSimResults->getNumberOfXNodes(), basicSimResults->getNumberOfZNodes(), basicSimResults->getL0());
78 if (basicL2Result < 0 || divergentL2Result < 0 || resultL2ToBasicKernel < 0)
80 else if (basicL2Result <= divergentL2Result)
90 std::ostringstream oss;
91 oss <<
"L2Norm_BasicKernel_" <<
"L" << basicPostProcessingStrategy->getNumberOfXNodes() <<
"_"<< dataToCalculate <<
"_TimeStep_" << timeStep <<
"_" << normalizeData <<
"=" << basicL2Result << std::endl;
92 oss <<
"L2Norm_DivergentKernel_" <<
"L" << basicPostProcessingStrategy->getNumberOfXNodes() <<
"_"<< dataToCalculate <<
"_TimeStep_" << timeStep <<
"_" << normalizeData <<
"=" << divergentL2Result << std::endl;
93 oss <<
"L2Norm_Between_Kernels_" <<
"L" << basicPostProcessingStrategy->getNumberOfXNodes() <<
"_"<< dataToCalculate <<
"_TimeStep_" << timeStep <<
"_" << normalizeData <<
"=" << resultL2ToBasicKernel << std::endl << std::endl;
99 std::ostringstream oss;
100 oss <<
"L" << basicPostProcessingStrategy->getNumberOfXNodes() <<
"_"<< dataToCalculate <<
"_TimeStep_" << timeStep <<
"_" << normalizeData;
106 return basicL2Result;
112 this->basicSim = sim;
113 this->basicSimInfo = simInfo;
115 this->basicSimResults = basicPostProcessingStrategy->getSimulationResult();
121 this->divergentSim = sim;
122 this->divergentSimInfo = simInfo;
124 this->divergentSimResults = divergentPostProcessingStrategy->getSimulationResult();
127L2NormTestBetweenKernels::L2NormTestBetweenKernels(std::shared_ptr<ColorConsoleOutput> colorOutput, std::string dataToCalculate,
unsigned int timeStep, std::string
normalizeWith, std::shared_ptr<L2NormCalculatorFactory>
factory)
128 :
TestImp(colorOutput), timeStep(timeStep), dataToCalculate(dataToCalculate), normalizeData(
normalizeWith)
133int L2NormTestBetweenKernels::calcTimeStepInResults(
unsigned int timeStep)
135 for (
int i = 0;
i < basicSimResults->getTimeSteps().size();
i++) {
136 if (timeStep == basicSimResults->getTimeSteps().at(
i))
137 return basicSimResults->getTimeSteps().at(
i);
141std::vector<std::string> L2NormTestBetweenKernels::buildTestOutput()
143 std::vector<std::string> output = buildBasicTestOutput();
144 std::ostringstream oss;
146 oss <<
"L2Norm BasicKernel: " << basicL2Result;
147 output.push_back(oss.str());
148 oss.str(std::string());
150 oss <<
"L2Norm DivergentKernel: " << divergentL2Result;
151 output.push_back(oss.str());
152 oss.str(std::string());
154 oss <<
"L2NormDiff: " << resultL2ToBasicKernel;
155 output.push_back(oss.str());
156 oss.str(std::string());
161std::vector<std::string> L2NormTestBetweenKernels::buildBasicTestOutput()
163 std::vector<std::string> output;
164 std::ostringstream oss;
166 output.push_back(
"L2 Norm Between Kernels Test");
168 oss <<
"Basic Kernel: " << basicSimInfo->getKernelName();
169 output.push_back(oss.str());
170 oss.str(std::string());
172 oss <<
"Divergent Kernel: " << divergentSimInfo->getKernelName();
173 output.push_back(oss.str());
174 oss.str(std::string());
176 oss <<
"Viscosity: " << basicSimInfo->getViscosity();
177 output.push_back(oss.str());
178 oss.str(std::string());
180 output.push_back(oss.str());
182 oss << basicSimInfo->getSimulationName();
183 output.push_back(oss.str());
184 oss.str(std::string());
186 oss <<
"L: " << basicSimInfo->getLx() << basicSimInfo->getSimulationParameterString();
187 output.push_back(oss.str());
188 oss.str(std::string());
190 output.push_back(oss.str());
192 oss <<
"DataToCalculate: " << dataToCalculate;
193 output.push_back(oss.str());
194 oss.str(std::string());
196 oss <<
"NormalizeData: " << normalizeData;
197 output.push_back(oss.str());
198 oss.str(std::string());
200 oss <<
"TimeStep: " << timeStep;
201 output.push_back(oss.str());
202 oss.str(std::string());
204 output.push_back(oss.str());
209std::vector<std::string> L2NormTestBetweenKernels::buildErrorTestOutput()
211 std::vector<std::string> output = buildBasicTestOutput();
212 std::ostringstream oss;
214 oss <<
"Error Message: " << basicPostProcessingStrategy->getErrorMessage(normalizeData);
215 output.push_back(oss.str());
216 oss.str(std::string());
std::shared_ptr< ColorConsoleOutput > colorOutput
void setBasicSimulation(std::shared_ptr< NumericalTestSimulation > sim, std::shared_ptr< SimulationInfo > simInfo, std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy > postProcessingStrategy)
std::string getErrorLogFileOutput()
std::string getLogFileOutput()
void addSimulation(std::shared_ptr< NumericalTestSimulation > sim, std::shared_ptr< SimulationInfo > simInfo, std::shared_ptr< PostProcessingStrategy > postProStrategy)
double getBasicL2Result()
void setDivergentKernelSimulation(std::shared_ptr< NumericalTestSimulation > sim, std::shared_ptr< SimulationInfo > simInfo, std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy > postProcessingStrategy)
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 makeConsoleOutput() override
std::shared_ptr< T > SPtr