VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
PhiTestPostProcessingStrategy.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
40
41std::shared_ptr<PhiTestPostProcessingStrategy> PhiTestPostProcessingStrategy::getNewInstance(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests)
42{
43 return std::shared_ptr<PhiTestPostProcessingStrategy>(new PhiTestPostProcessingStrategy(simResult, analyticalResult, testPara, dataToCalcTests));
44}
45
46PhiTestPostProcessingStrategy::PhiTestPostProcessingStrategy(std::shared_ptr<SimulationResults> simResult, std::shared_ptr<AnalyticalResults> analyticalResult, std::shared_ptr<PhiTestParameterStruct> testPara, std::vector<std::string> dataToCalcTests)
47 : PostProcessingStrategyImp(simResult), analyticalResult(analyticalResult), dataToCalculate(dataToCalcTests)
48{
49 startTimeStepCalculation = testPara->startTimeStepCalculation;
50 endTimeStepCalculation = testPara->endTimeStepCalculation;
51 phiDiff.resize(dataToCalculate.size());
52
53 isEvaluated = false;
54 fftCalculator = FFTCalculator::getInstance();
55}
56
57std::vector<std::vector<double> > PhiTestPostProcessingStrategy::reduceDataToTimeSteps(std::vector<std::vector<double> > data)
58{
59 std::vector<int> timeStepsToDelete;
60
61 for (int i = simResult->getTimeSteps().size() - 1; i >= 0; i--) {
62 if (simResult->getTimeSteps().at(i) > endTimeStepCalculation)
63 timeStepsToDelete.push_back(i);
64 if (simResult->getTimeSteps().at(i) < startTimeStepCalculation)
65 timeStepsToDelete.push_back(i);
66 }
67
68 for (int i = 0; i < timeStepsToDelete.size(); i++)
69 data.erase(data.begin() + timeStepsToDelete.at(i));
70
71 return data;
72}
73
75{
76 if (!isEvaluated) {
77 bool transpose = false;
78 int xNodes = simResult->getNumberOfXNodes();
79 int zNodes = simResult->getNumberOfZNodes();
80 int timeStepLength = simResult->getTimeStepLength();
81 for (int i = 0; i < dataToCalculate.size(); i++) {
82 std::vector<std::vector<double>> basicData;
83 if (dataToCalculate.at(i) == "Vx")
84 basicData = simResult->getVx();
85 if (dataToCalculate.at(i) == "Vy")
86 basicData = simResult->getVy();
87 if (dataToCalculate.at(i) == "Vz")
88 basicData = simResult->getVz();
89 if (dataToCalculate.at(i) == "Press")
90 basicData = simResult->getPress();
91 if (dataToCalculate.at(i) == "Rho")
92 basicData = simResult->getRho();
93
94 std::vector<std::vector<double>> dataForCalculation;
95 dataForCalculation = reduceDataToTimeSteps(basicData);
96 phiDiff.at(i) = fftCalculator->calcPhiDiff(dataForCalculation, transpose, xNodes, zNodes, timeStepLength);
97 }
98 isEvaluated = true;
99 }
100}
101
102double PhiTestPostProcessingStrategy::getPhiDiff(std::string dataToCalc)
103{
104 for (int i = 0; i < dataToCalculate.size(); i++)
105 if(dataToCalculate.at(i) == dataToCalc)
106 return phiDiff.at(i);
107}
108
std::shared_ptr< SimulationResults > simResult
double getPhiDiff(std::string dataToCalc)
static std::shared_ptr< PhiTestPostProcessingStrategy > getNewInstance(std::shared_ptr< SimulationResults > simResult, std::shared_ptr< AnalyticalResults > analyticalResult, std::shared_ptr< PhiTestParameterStruct > testPara, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< FFTCalculator > getInstance()
std::shared_ptr< T > SPtr