VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
WallModelProbe.h
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//
34//=======================================================================================
35
36#ifndef WallModelProbe_H
37#define WallModelProbe_H
38
39#include <string>
40#include <vector>
41
43#include <logger/Logger.h>
44
45#include "Sampler.h"
46
47namespace vf::gpu {
48
49class Parameter;
50class CudaMemoryManager;
51
55class WallModelProbe : public Sampler
56{
57public:
58 WallModelProbe(SPtr<Parameter> para, SPtr<CudaMemoryManager> cudaMemoryManager, const std::string& outputPath,
59 const std::string& probeName, uint tStartSampling, uint tStartTemporalAveraging, uint tBetweenSamples,
60 uint tStartWritingOutput, uint tBetweenWriting, bool sampleEveryTimestep, bool computeTemporalAverages,
61 bool outputStress, bool evaluatePressureGradient, bool sampleSurfaceLayer)
62 : para(std::move(para)), cudaMemoryManager(std::move(cudaMemoryManager)), tStartSampling(tStartSampling),
63 tStartTemporalAveraging(tStartTemporalAveraging), tStartWritingOutput(tStartWritingOutput),
64 tBetweenSamples(tBetweenSamples), tBetweenWriting(tBetweenWriting), sampleEveryTimestep(sampleEveryTimestep),
65 computeTemporalAverages(computeTemporalAverages), outputStress(outputStress),
66 evaluatePressureGradient(evaluatePressureGradient), sampleSurfaceLayer(sampleSurfaceLayer), Sampler(outputPath, probeName)
67 {
68 if(tBetweenSamples == 0)
69 throw std::runtime_error("WallModelProbe: tBetweenSamples is 0! If you want to sample every time step set sampleEveryTimestep to true");
70 if(tBetweenWriting == 0)
71 throw std::runtime_error("WallModelProbe: tBetweenWriting is 0! tBetweenWriting must be larger than 0");
72 if (tStartTemporalAveraging < tStartSampling)
73 throw std::runtime_error("WallModelProbe: tStartTemporalAveraging must be larger than tStartSampling!");
74 if (sampleEveryTimestep)
75 VF_LOG_INFO("WallModelProbe: sampleEveryTimestep is true, ignoring tBetweenSamples");
76 if (tBetweenSamples == 0 && !sampleEveryTimestep)
77 throw std::runtime_error("WallModelProbe: tBetweenSamples must be larger than 0!");
79 "Created wall model probe, output path: " + outputPath + ", probe name: " + probeName +
80 " start sampling: {}, time steps between sampling: {}, start writing: {}, time steps between writing: {}",
81 tStartSampling, tBetweenSamples, tStartWritingOutput, tBetweenWriting);
82 }
83
84 ~WallModelProbe() override = default;
85
86 void init() override;
87 void sample(int level, uint t) override;
88 void getTaggedFluidNodes(GridProvider* /*gridProvider*/) override {};
89
90 struct LevelData;
91
92private:
93 std::vector<std::string> getVariableNames();
94 uint getNumberOfInstantaneousQuantities() const
95 {
96 uint numberOfQuantities = 6;
97 if(evaluatePressureGradient) numberOfQuantities += 3;
98 if(sampleSurfaceLayer) numberOfQuantities += 4;
99 return numberOfQuantities;
100 }
101 void calculateQuantities(LevelData* levelData, uint t, int level);
102 void write(int level);
103 uint countFluidNodes(int level);
104
105private:
106 SPtr<Parameter> para;
107 SPtr<CudaMemoryManager> cudaMemoryManager;
108 const uint tStartSampling, tStartTemporalAveraging, tBetweenSamples, tStartWritingOutput, tBetweenWriting;
109 const bool outputStress = false;
110 const bool evaluatePressureGradient = false;
111 const bool computeTemporalAverages = false;
112 const bool sampleEveryTimestep = false;
113 const bool sampleSurfaceLayer = false;
114 std::vector<LevelData> levelData;
115};
116
118{
121 std::vector<std::vector<real>> instantaneousData, averagedData;
122 std::vector<real> timestepTime;
123 bool firstWrite = true;
124 LevelData(std::string fileName, uint numberOfFluidNodes)
126 {
127 }
128};
129
130}
131
132#endif
#define VF_LOG_INFO(...)
Definition Logger.h:50
Base class for all samplers.
Definition Sampler.h:58
std::string outputPath
Definition Sampler.h:72
std::string probeName
Definition Sampler.h:73
Probe computing statistics of all relevant wall model quantities used in the StressBC kernels Compute...
void sample(int level, uint t) override
void init() override
WallModelProbe(SPtr< Parameter > para, SPtr< CudaMemoryManager > cudaMemoryManager, const std::string &outputPath, const std::string &probeName, uint tStartSampling, uint tStartTemporalAveraging, uint tBetweenSamples, uint tStartWritingOutput, uint tBetweenWriting, bool sampleEveryTimestep, bool computeTemporalAverages, bool outputStress, bool evaluatePressureGradient, bool sampleSurfaceLayer)
~WallModelProbe() override=default
void getTaggedFluidNodes(GridProvider *) override
std::shared_ptr< T > SPtr
unsigned int uint
Definition DataTypes.h:47
LevelData(std::string fileName, uint numberOfFluidNodes)
std::vector< std::vector< real > > averagedData
std::vector< std::vector< real > > instantaneousData