VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
NyTestLogFileInformation.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
34
35#include "Tests/NyTest/NyTest.h"
37
38#include <iomanip>
39#include <sstream>
40
41
42std::shared_ptr<NyTestLogFileInformation> NyTestLogFileInformation::getNewInstance(std::shared_ptr<NyTestParameterStruct> testPara)
43{
44 return std::shared_ptr<NyTestLogFileInformation>(new NyTestLogFileInformation(testPara));
45}
46
48{
49 std::ostringstream headName;
50 headName <<"Ny Test";
52
53 oss << "StartTimeStepCalculation_NyTest=" << startTimeStepCalculation << std::endl;
54 oss << "EndTimeStepCalculation_NyTest=" << endTimeStepCalculation << std::endl;
55 oss << "DataToCalc_NyTest=\"";
56 for (int i = 0; i < testGroups.size(); i++) {
57 oss << testGroups.at(i).at(0)->getDataToCalculate();
58 if (i < testGroups.size() - 1)
59 oss << " ";
60 else
61 oss << "\"" << std::endl;
62 }
63 oss << std::endl;
64
65 std::ostringstream failMessageNy;
66 failMessageNy << "FailTests_Ny_NyTest=\"";
67 std::ostringstream failMessageOOA;
68 failMessageOOA << "FailTests_OOA_NyTest=\"";
69 for (int i = 0; i < testGroups.size(); i++) {
70 fillMyData(testGroups.at(i));
71 for (int j = 0; j < lxForErase.size(); j++) {
72 if (status.at(j) == passed || status.at(j) == failed) {
73 oss << "Ny_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << ny.at(j) << std::endl;
74 oss << "NyDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << nyDiff.at(j) << std::endl;
75 }
76 else
77 failMessageNy << lxForErase.at(j) << "_" << dataToCalc.at(j) << " ";
78 }
79 oss << std::endl;
80 for (int j = 0; j < orderOfAccuracyNyDiff.size(); j++) {
81 if (status.at(j) == passed || status.at(j) == failed) {
82 oss << "OrderOfAccuracy_NyDiff_" << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracyNyDiff.at(j) << std::endl;
83 }
84 else
85 failMessageOOA << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << " ";
86 }
87 oss << std::endl;
88 }
89 std::string failNy = failMessageNy.str();
90 if (failNy.back() == ' ')
91 failNy = failNy.substr(0, failNy.size() - 1);
92 failMessageNy.str(std::string());
93 failMessageNy << failNy << "\"";
94 oss << failMessageNy.str() << std::endl << std::endl;
95
96 std::string failOOA = failMessageOOA.str();
97 if (failOOA.back() == ' ')
98 failOOA = failOOA.substr(0, failOOA.size() - 1);
99 failMessageOOA.str(std::string());
100 failMessageOOA << failOOA << "\"";
101 oss << failMessageOOA.str() << std::endl << std::endl;
102
103 return oss.str();
104}
105
106void NyTestLogFileInformation::addTestGroup(std::vector<std::shared_ptr<NyTest> > tests)
107{
108 testGroups.push_back(tests);
109}
110
111void NyTestLogFileInformation::fillMyData(std::vector<std::shared_ptr<NyTest> > testGroup)
112{
113 lxForErase.resize(0);
114 lx.resize(0);
115 ny.resize(0);
116 nyDiff.resize(0);
117 orderOfAccuracyNyDiff.resize(0);
118 dataToCalc.resize(0);
119 status.resize(0);
120 for (int i = 0; i < testGroup.size(); i++) {
121 status.push_back(testGroup.at(i)->getTestStatus());
122 status.push_back(testGroup.at(i)->getTestStatus());
123
124 std::vector<int> myLx = testGroup.at(i)->getLx();
125 std::vector<double> myNy;
126 std::vector<double> myNyDiff;
127
128 if (testGroup.at(i)->getTestStatus() == simulationCrashed || testGroup.at(i)->getTestStatus() == test_error) {
129 for (int i = 0; i < myLx.size(); i++) {
130 myNy.push_back((double)0.0);
131 myNyDiff.push_back((double)0.0);
132 }
133
134 }
135 else {
136 myNy = testGroup.at(i)->getNy();
137 myNyDiff = testGroup.at(i)->getNyDiff();
138 }
139 lx.insert(lx.end(), myLx.begin(), myLx.end());
140 lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end());
141 ny.insert(ny.end(), myNy.begin(), myNy.end());
142 nyDiff.insert(nyDiff.end(), myNyDiff.begin(), myNyDiff.end());
143 orderOfAccuracyNyDiff.push_back(testGroup.at(i)->getOrderOfAccuracyNyDiff());
144 dataToCalc.push_back(testGroup.at(i)->getDataToCalculate());
145 dataToCalc.push_back(testGroup.at(i)->getDataToCalculate());
146 }
147
148 for (int i = 0; i < lxForErase.size(); i++)
149 for (int j = i + 1; j < lxForErase.size(); j++)
150 if (lxForErase.at(i) == lxForErase.at(j))
151 lxForErase.at(j) = -1;
152
153 for (int i = lxForErase.size() - 1; i >= 0; i--) {
154 if (lxForErase.at(i) == -1) {
155 ny.erase(ny.begin() + i);
156 nyDiff.erase(nyDiff.begin() + i);
157 lxForErase.erase(lxForErase.begin() + i);
158 }
159 }
160
161
162}
163
164NyTestLogFileInformation::NyTestLogFileInformation(std::shared_ptr<NyTestParameterStruct> testPara)
165{
166 startTimeStepCalculation = testPara->startTimeStepCalculation;
167 endTimeStepCalculation = testPara->endTimeStepCalculation;
168}
void addTestGroup(std::vector< std::shared_ptr< NyTest > > tests)
static std::shared_ptr< NyTestLogFileInformation > getNewInstance(std::shared_ptr< NyTestParameterStruct > testPara)
void makeCenterHead(std::string head)
@ test_error
Definition TestStatus.h:36
@ simulationCrashed
Definition TestStatus.h:36
@ failed
Definition TestStatus.h:36
@ passed
Definition TestStatus.h:36
std::shared_ptr< T > SPtr