VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
PhiTestLogFileInformation.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
37
38#include <iomanip>
39#include <sstream>
40
41
42std::shared_ptr<PhiTestLogFileInformation> PhiTestLogFileInformation::getNewInstance(std::shared_ptr<PhiTestParameterStruct> testPara)
43{
44 return std::shared_ptr<PhiTestLogFileInformation>(new PhiTestLogFileInformation(testPara));
45}
46
48{
49 std::ostringstream headName;
50 headName <<" Phi Test";
52
53 oss << "StartTimeStepCalculation_PhiTest=" << startTimeStepCalculation << std::endl;
54 oss << "EndTimeStepCalculation_PhiTest=" << endTimeStepCalculation << std::endl;
55 oss << "DataToCalc_PhiTest=\"";
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 failMessagePhi;
66 failMessagePhi << "FailTests_Phi_PhiTest=\"";
67 std::ostringstream failMessageOOA;
68 failMessageOOA << "FailTests_OOA_PhiTest=\"";
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 << "PhiDiff_" << lxForErase.at(j) << "_" << dataToCalc.at(j) << "=" << phiDiff.at(j) << std::endl;
74 }
75 else
76 failMessagePhi << lxForErase.at(j) << "_" << dataToCalc.at(j) << " ";
77 }
78 oss << std::endl;
79 for (int j = 0; j < orderOfAccuracy.size(); j++) {
80 if (status.at(j) == passed || status.at(j) == failed) {
81 oss << "OrderOfAccuracy_PhiDiff_" << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << "=" << orderOfAccuracy.at(j) << std::endl;
82 }
83 else
84 failMessageOOA << lx.at(2 * j) << "_" << lx.at(2 * j + 1) << "_" << dataToCalc.at(j) << " ";
85 }
86 oss << std::endl;
87
88 }
89 std::string failPhi = failMessagePhi.str();
90 if (failPhi.back() == ' ')
91 failPhi = failPhi.substr(0, failPhi.size() - 1);
92 failMessagePhi.str(std::string());
93 failMessagePhi << failPhi << "\"";
94 oss << failMessagePhi.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 PhiTestLogFileInformation::addTestGroup(std::vector<std::shared_ptr<PhiTest> > tests)
107{
108 testGroups.push_back(tests);
109}
110
111void PhiTestLogFileInformation::fillMyData(std::vector<std::shared_ptr<PhiTest> > testGroup)
112{
113 lxForErase.resize(0);
114 lx.resize(0);
115 phiDiff.resize(0);
116 orderOfAccuracy.resize(0);
117 dataToCalc.resize(0);
118 status.resize(0);
119 for (int i = 0; i < testGroup.size(); i++) {
120 status.push_back(testGroup.at(i)->getTestStatus());
121 status.push_back(testGroup.at(i)->getTestStatus());
122
123 std::vector<int> myLx = testGroup.at(i)->getLx();
124 std::vector<double> myPhiDiff;
125 if (testGroup.at(i)->getTestStatus() == simulationCrashed || testGroup.at(i)->getTestStatus() == test_error) {
126 for (int i = 0; i < myLx.size(); i++)
127 myPhiDiff.push_back((double)0.0);
128 }
129 else
130 myPhiDiff = testGroup.at(i)->getPhiDiff();
131
132 lx.insert(lx.end(), myLx.begin(), myLx.end());
133 lxForErase.insert(lxForErase.end(), myLx.begin(), myLx.end());
134 phiDiff.insert(phiDiff.end(), myPhiDiff.begin(), myPhiDiff.end());
135 orderOfAccuracy.push_back(testGroup.at(i)->getOrderOfAccuracy());
136 dataToCalc.push_back(testGroup.at(i)->getDataToCalculate());
137 dataToCalc.push_back(testGroup.at(i)->getDataToCalculate());
138
139 }
140
141 for (int i = 0; i < lxForErase.size(); i++)
142 for (int j = i + 1; j < lxForErase.size(); j++)
143 if (lxForErase.at(i) == lxForErase.at(j))
144 lxForErase.at(j) = -1;
145
146 for (int i = lxForErase.size() - 1; i >= 0; i--) {
147 if (lxForErase.at(i) == -1) {
148 phiDiff.erase(phiDiff.begin() + i);
149 lxForErase.erase(lxForErase.begin() + i);
150 }
151 }
152
153
154}
155
156PhiTestLogFileInformation::PhiTestLogFileInformation(std::shared_ptr<PhiTestParameterStruct> testPara)
157{
158 startTimeStepCalculation = testPara->startTimeStepCalculation;
159 endTimeStepCalculation = testPara->endTimeStepCalculation;
160}
static std::shared_ptr< PhiTestLogFileInformation > getNewInstance(std::shared_ptr< PhiTestParameterStruct > testPara)
void addTestGroup(std::vector< std::shared_ptr< PhiTest > > tests)
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