45std::shared_ptr<NyTest>
NyTest::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput,
double viscosity, std::shared_ptr<NyTestParameterStruct>
testPara, std::string dataToCalculate)
52 for (
int i = 0;
i < postProStrategies.size();
i++)
53 ny.push_back(postProStrategies.at(
i)->getNy(dataToCalculate));
56 nyDiff = calcNyDiff(ny);
57 orderOfAccuracy = calcOrderOfAccuracy(nyDiff);
81 return dataToCalculate;
86 std::vector<int>
lxINT;
87 for (
int i = 0;
i < lx.size();
i++)
88 lxINT.push_back((
int)lx.at(
i));
104 return orderOfAccuracy;
107NyTest::NyTest(std::shared_ptr<ColorConsoleOutput> colorOutput,
double viscosity, std::shared_ptr<NyTestParameterStruct>
testPara, std::string dataToCalculate)
108 :
TestImp(colorOutput), viscosity(viscosity), dataToCalculate(dataToCalculate)
110 minOrderOfAccuracy =
testPara->minOrderOfAccuracy;
111 startStepCalculation =
testPara->startTimeStepCalculation;
112 endStepCalculation =
testPara->endTimeStepCalculation;
118double NyTest::calcOrderOfAccuracy(std::vector<double> data)
120 double ooa = std::log(data.at(0) / data.at(1)) / std::log(lx.at(1) / lx.at(0));
125TestStatus NyTest::checkTestPassed(
double orderOfAccuracy)
127 if (orderOfAccuracy > minOrderOfAccuracy)
133bool NyTest::checkNy(std::vector<double> ny)
135 for(
int i = 0;
i < ny.size();
i++)
141std::vector<double> NyTest::calcNyDiff(std::vector<double> ny)
144 for (
int i = 0;
i < ny.size();
i++)
145 results.push_back(std::fabs((ny.at(
i) - viscosity) / viscosity));
149std::vector<std::string> NyTest::buildTestOutput()
151 std::vector<std::string> output = buildBasicTestOutput();
152 std::ostringstream oss;
154 for (
int i = 0;
i < ny.size();
i++) {
155 oss <<
"Ny" <<
simInfos.at(
i)->getLx() <<
": " << ny.at(
i);
156 output.push_back(oss.str());
157 oss.str(std::string());
159 oss <<
"NyDiff" <<
simInfos.at(
i)->getLx() <<
": " << nyDiff.at(
i);
160 output.push_back(oss.str());
161 oss.str(std::string());
163 oss <<
"OrderOfAccuracy: " << orderOfAccuracy;
164 output.push_back(oss.str());
165 oss.str(std::string());
170std::vector<std::string> NyTest::buildBasicTestOutput()
172 std::vector<std::string> output;
173 std::ostringstream oss;
175 output.push_back(
"Ny Test");
177 oss <<
"Kernel: " <<
simInfos.at(0)->getKernelName();
178 output.push_back(oss.str());
179 oss.str(std::string());
181 oss <<
"Viscosity: " <<
simInfos.at(0)->getViscosity();
182 output.push_back(oss.str());
183 oss.str(std::string());
185 output.push_back(oss.str());
187 oss <<
simInfos.at(0)->getSimulationName();
188 output.push_back(oss.str());
189 oss.str(std::string());
192 oss <<
"L: " << std::setfill(
' ') << std::right << std::setw(4) <<
simInfos.at(
i)->getLx() <<
simInfos.at(
i)->getSimulationParameterString();
193 output.push_back(oss.str());
194 oss.str(std::string());
197 output.push_back(oss.str());
199 oss <<
"DataToCalculate: " << dataToCalculate;
200 output.push_back(oss.str());
201 oss.str(std::string());
203 oss <<
"StartTimeStep: " << startStepCalculation;
204 output.push_back(oss.str());
205 oss.str(std::string());
207 oss <<
"EndTimeStep: " << endStepCalculation;
208 output.push_back(oss.str());
209 oss.str(std::string());
211 output.push_back(oss.str());
216std::vector<std::string> NyTest::buildErrorTestOutput()
218 std::vector<std::string> output = buildBasicTestOutput();
219 std::ostringstream oss;
221 oss <<
"Error Message: Ny < 0";
222 output.push_back(oss.str());
223 oss.str(std::string());
228std::vector<std::string> NyTest::buildSimulationFailedTestOutput()
230 std::vector<std::string> output = buildBasicTestOutput();
231 std::ostringstream oss;
233 oss <<
"Simulation crashed!";
234 output.push_back(oss.str());
235 oss.str(std::string());
std::shared_ptr< ColorConsoleOutput > colorOutput
std::vector< std::shared_ptr< SimulationInfo > > simInfos
std::vector< double > getNyDiff()
std::vector< int > getLx()
void addSimulation(std::shared_ptr< NumericalTestSimulation > sim, std::shared_ptr< SimulationInfo > simInfo, std::shared_ptr< PostProcessingStrategy > postProStrategy)
std::string getDataToCalculate()
double getOrderOfAccuracyNyDiff()
void addSimulation(std::shared_ptr< NumericalTestSimulation > sim, std::shared_ptr< SimulationInfo > simInfo, std::shared_ptr< NyTestPostProcessingStrategy > postProStrategy)
void makeConsoleOutput() override
static std::shared_ptr< NyTest > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput, double viscosity, std::shared_ptr< NyTestParameterStruct > testPara, std::string dataToCalculate)
std::vector< double > getNy()
std::shared_ptr< T > SPtr