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