VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
TimeMathematicaAssistant.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
40
41std::shared_ptr<TimeMathematicaAssistant> TimeMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory)
42{
43 return std::shared_ptr<TimeMathematicaAssistant>(new TimeMathematicaAssistant(functionFactory));
44}
45
46TimeMathematicaAssistant::TimeMathematicaAssistant()
47{
48
49}
50
51TimeMathematicaAssistant::TimeMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
52{
53
54}
55
56void TimeMathematicaAssistant::makeSimulationTimeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
57{
58 std::vector<std::vector<double> > simTimes(logFileData->getGroupSize());
59 for (int i = 0; i < logFileData->getGroupSize(); i++)
60 for(int j = 0; j < logFileData->getLogFileData(i)->getSimTime().size(); j++)
61 simTimes.at(i).push_back((double)logFileData->getLogFileData(i)->getSimTime().at(j));
62
63 makeTimeMathematicaOutput(logFileData, aMathmaticaFile, simTimes, "SimulationTime");
64}
65
66void TimeMathematicaAssistant::makeTestTimeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
67{
68 std::vector<std::vector<double> > testTimes;
69 for (int i = 0; i < logFileData->getGroupSize(); i++)
70 testTimes.push_back(logFileData->getLogFileData(i)->getTestTime());
71
72 makeTimeMathematicaOutput(logFileData, aMathmaticaFile, testTimes, "TestTime");
73}
74
75void TimeMathematicaAssistant::makeAnalyticalWriteTimeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
76{
77 std::vector<std::vector<double> > analyticalWriteTime(logFileData->getGroupSize());
78 for (int i = 0; i < logFileData->getGroupSize(); i++)
79 for (int j = 0; j < logFileData->getLogFileData(i)->getAnalyticalVTKWritingTime().size(); j++)
80 analyticalWriteTime.at(i).push_back((double)logFileData->getLogFileData(i)->getAnalyticalVTKWritingTime().at(j));
81
82 makeTimeMathematicaOutput(logFileData, aMathmaticaFile, analyticalWriteTime, "AnalyticalVTKWritingTime");
83}
84
85void TimeMathematicaAssistant::makeTimeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::vector<double>> times, std::string timeName)
86{
87 std::vector<std::vector<double> > grids;
88 std::vector<std::string> listNames;
89 for (int i = 0; i < logFileData->getGroupSize(); i++) {
90 grids.push_back(logFileData->getLogFileData(i)->getBasicGridLengths());
91 listNames.push_back(logFileData->getLogFileData(i)->getSimulationSigniture() + timeName);
92 }
93
94 std::vector<std::vector<std::shared_ptr<DataPoint> > > dataPointGroup;
95
96 for (int j = 0; j < grids.size(); j++) {
97 std::vector<std::shared_ptr<DataPoint> > dataPoints;
98 for (int k = 0; k < times.at(j).size(); k++)
99 dataPoints.push_back(DataPoint::getNewInstance(grids.at(j).at(k), times.at(j).at(k)));
100 dataPointGroup.push_back(dataPoints);
101 }
102 std::vector<std::shared_ptr<MathematicaPointList> > pointList;
103 for (int j = 0; j < dataPointGroup.size(); j++) {
104 std::shared_ptr<MathematicaPointList> aPointList = functionFactory->makeMathematicaPointList(aMathmaticaFile, listNames.at(j), dataPointGroup.at(j));
105 pointList.push_back(aPointList);
106 }
107 std::shared_ptr<MathematicaListPlot> listLogLogPlot = functionFactory->makeMathematicaListPlot(aMathmaticaFile, pointList, "ListLogLogPlot", "L[dx]", "Time [sec]");
108}
109
110void TimeMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
111{
112 makeSimulationTimeMathematicaOutput(logFileData, aMathmaticaFile);
113 makeTestTimeMathematicaOutput(logFileData, aMathmaticaFile);
114 makeAnalyticalWriteTimeMathematicaOutput(logFileData, aMathmaticaFile);
115}
std::shared_ptr< MathematicaFunctionFactory > functionFactory
void makeMathematicaOutput(std::shared_ptr< LogFileDataGroup > logFileData, std::shared_ptr< MathematicaFile > aMathmaticaFile)
static std::shared_ptr< DataPoint > getNewInstance(double x, double y)
Definition DataPoint.cpp:39
static std::shared_ptr< TimeMathematicaAssistant > getNewInstance(std::shared_ptr< MathematicaFunctionFactory > functionFactory)
std::shared_ptr< T > SPtr