VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
PhiMathematicaAssistant.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
38
39
40std::shared_ptr<PhiMathematicaAssistant> PhiMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory)
41{
42 return std::shared_ptr<PhiMathematicaAssistant>(new PhiMathematicaAssistant(functionFactory));
43}
44
45void PhiMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
46{
47 std::shared_ptr<SortedDataPhi> mySortedData = sortLogFileData(logFileData);
48
49 makePhiDiffMathematicaOutput(aMathmaticaFile, mySortedData);
50 makeOrderOfAccuracyMathematicaOutput(aMathmaticaFile, mySortedData);
51
52}
53
54PhiMathematicaAssistant::PhiMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
55{
56}
57
58bool PhiMathematicaAssistant::checkTestParameter(std::shared_ptr<PhiLogFileData> logFileData1, std::shared_ptr<PhiLogFileData> logFileData2)
59{
60 if (logFileData1->getStartTimeStepCalculation() != logFileData2->getStartTimeStepCalculation())
61 return false;
62 if (logFileData1->getEndTimeStepCalculation() != logFileData2->getEndTimeStepCalculation())
63 return false;
64 if (logFileData1->getDataToCalc() != logFileData2->getDataToCalc())
65 return false;
66
67 return true;
68}
69
70std::shared_ptr<SortedDataPhi> PhiMathematicaAssistant::sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData)
71{
72 std::vector<std::vector<std::shared_ptr<PhiLogFileData> > > testLogFileData;
73 std::vector<std::vector<std::string> > basicListNames;
74 for (int i = 0; i < logFileData->getLogFileData(0)->getPhiLogFileData().size(); i++) {
75 std::vector<std::shared_ptr<PhiLogFileData> > aTestLogFileDataGroup;
76 aTestLogFileDataGroup.push_back(logFileData->getLogFileData(0)->getPhiLogFileData().at(i));
77 std::vector<std::string> aListNameGroup;
78 aListNameGroup.push_back(logFileData->getLogFileData(0)->getSimulationSigniture());
79 basicListNames.push_back(aListNameGroup);
80 }
81 for (int i = 0; i < logFileData->getGroupSize(); i++) {
82 for (int j = 0; j < logFileData->getLogFileData(i)->getPhiLogFileData().size(); j++) {
83 std::string dataToCalc = logFileData->getLogFileData(i)->getPhiLogFileData().at(j)->getDataToCalc();
84 bool added = false;
85 for (int k = 0; k < testLogFileData.size(); k++) {
86 if (checkTestParameter(logFileData->getLogFileData(i)->getPhiLogFileData().at(j), testLogFileData.at(k).at(0))) {
87 testLogFileData.at(k).push_back(logFileData->getLogFileData(i)->getPhiLogFileData().at(j));
88 basicListNames.at(k).push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
89 added = true;
90 }
91 }
92 if (!added) {
93 std::vector<std::shared_ptr<PhiLogFileData> > aTestLogFileDataGroup;
94 aTestLogFileDataGroup.push_back(logFileData->getLogFileData(i)->getPhiLogFileData().at(j));
95 testLogFileData.push_back(aTestLogFileDataGroup);
96 std::vector<std::string> aListNameGroup;
97 aListNameGroup.push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
98 basicListNames.push_back(aListNameGroup);
99 }
100 }
101 }
102 std::shared_ptr<SortedDataPhi> mySortedData = std::shared_ptr<SortedDataPhi>(new SortedDataPhi);
103 mySortedData->basicListNames = basicListNames;
104 mySortedData->testLogFileData = testLogFileData;
105
106 return mySortedData;
107}
108
109void PhiMathematicaAssistant::makePhiDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData)
110{
111 for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
112 std::vector<std::vector<double> > gridLengths;
113 std::vector<std::vector<double> > phiDiff;
114 std::vector<std::string> aBasicListNamesList;
115 for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
116 gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
117 phiDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getPhiDiff());
118 aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
119 }
120 std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, "PhiDiff", sortedData->testLogFileData.at(i).at(0)->getDataToCalc());
124 }
125}
126
127void PhiMathematicaAssistant::makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData)
128{
129 for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
130 for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
131 std::vector<std::vector<double>> ooA = sortedData->testLogFileData.at(i).at(j)->getOrderOfAccuracy();
132 std::string basicListName = sortedData->basicListNames.at(i).at(j);
133 std::string dataToCalc = sortedData->testLogFileData.at(i).at(j)->getDataToCalc();
134 std::string finalListName = finalizeListName(basicListName, "PhiDiffOrderOfAccuracy", dataToCalc);
135
137 }
138 }
139}
140
141PhiMathematicaAssistant::PhiMathematicaAssistant()
142{
143}
144
std::shared_ptr< MathematicaFunctionFactory > functionFactory
std::vector< std::string > finalizeListNames(std::vector< std::string > basicListNames, std::string testName, std::string dataToCalc)
void makeMathematicaOutput(std::shared_ptr< LogFileDataGroup > logFileData, std::shared_ptr< MathematicaFile > aMathmaticaFile)
void addListLogLogPlotToMathematicaFile(std::shared_ptr< MathematicaFile > aMathmaticaFile, std::vector< std::string > listNames, std::vector< std::vector< double > > xAxesData, std::vector< std::vector< double > > yAxesData, std::string labelXAxes, std::string labelYAxes)
void addSecondOrderOfAccuracyRef(std::vector< std::vector< double > > &xAxesData, std::vector< std::vector< double > > &yAxesData, std::vector< std::string > &listNames)
static std::shared_ptr< PhiMathematicaAssistant > getNewInstance(std::shared_ptr< MathematicaFunctionFactory > functionFactory)
void addFourthOrderOfAccuracyRef(std::vector< std::vector< double > > &xAxesData, std::vector< std::vector< double > > &yAxesData, std::vector< std::string > &listNames)
std::string finalizeListName(std::string basicListName, std::string testName, std::string dataToCalc)
void addListOfListsToMathematicaFile(std::shared_ptr< MathematicaFile > aMathmaticaFile, std::string listName, std::vector< std::vector< double > > listOfLists)
std::shared_ptr< T > SPtr