VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
Probe.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 Probe_H
37#define Probe_H
38
39#include "Samplers/Sampler.h"
40
41#include <string>
42
43#include <basics/DataTypes.h>
47
48namespace vf::gpu {
49
50struct LBMSimulationParameter;
51class Parameter;
52class CudaMemoryManager;
53
57class Probe : public Sampler
58{
59public:
61 Probe(std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager, const std::string& outputPath,
63 bool outputTimeSeries, bool sampleEveryTimestep, bool sampleScalar = false);
64 ~Probe() override;
65
66 void addProbePlane(real startX, real startY, real startZ, real length, real width, real height);
68 void addProbePointsFromList(std::vector<real> coordsX, std::vector<real> coordY, std::vector<real> coordZ);
69 void addProbeVolume(const std::shared_ptr<GbObject3D>& probeVolume);
77
79 {
80 this->fileNameLU = false;
81 }
82 void init() override;
83 void sample(int level, uint t) override;
85
87 struct ProbeData;
88 struct TimeseriesParams;
89 struct LevelData;
90
92 {
93 return &levelDatas[level];
94 }
95
96 struct GridParams;
98
99private:
100 void addLevelData(int level);
101 void addPointsToLevelData(LevelData& levelData, std::vector<uint>& indices, int level);
102
103 WbWriterVtkXmlBinary* getWriter()
104 {
106 };
107 std::vector<PostProcessingVariable> getPostProcessingVariables(Statistic statistic, int level) const;
108 std::vector<PostProcessingVariable> getAllPostProcessingVariables(int level) const;
109
110 void writeParallelFile(int t);
111 void writeGridFiles(int level, int t);
112 void writeGridFile(int level, int t, uint part);
113 void appendStatisticToNodeData(Statistic statistic, uint startPos, uint endPos, uint timestep, int level,
114 std::vector<std::vector<double>>& nodeData);
115 void appendTimeseriesFile(int level, int t);
116 void appendStatisticToTimestepData(int timestep, std::vector<real>& timestepData, Statistic statistic, int level);
117
118 std::vector<real> getTimestepData(real time, int timestep, int level);
119
120 std::vector<std::string> getVarNames();
121
122 uint getNumberOfTimestepsInTimeseries(int level)
123 {
125 return tBetweenWriting * exp2(level);
126 return 1;
127 }
128
129protected:
132 std::vector<LevelData> levelDatas;
134 const bool sampleScalar;
137 std::vector<std::string> fileNamesForCollectionFile;
138 std::vector<std::string> timeseriesFileNames;
139
141 bool fileNameLU = true;
142
147 std::vector<std::shared_ptr<GbObject3D>> probeObjects;
148};
149
158
173
178
192
197
198void removeInterpolationCells(std::vector<uint>& indices, Parameter* para, int level);
199void removeReceiveNodes(std::vector<uint>& indices, Parameter* para, int level);
200
201}
202#endif
static WbWriterVtkXmlBinary * getInstance()
Class for LBM-parameter management.
Definition Parameter.h:359
Computes statistics of pointwise data. Data can be written to vtk-file or timeseries file....
Definition Probe.h:58
static GridParams getGridParams(LBMSimulationParameter *para)
void addProbePointsFromList(std::vector< real > coordsX, std::vector< real > coordY, std::vector< real > coordZ)
bool enableComputationVariances
Definition Probe.h:133
bool enableComputationMeans
Definition Probe.h:133
SPtr< Parameter > para
Definition Probe.h:130
void addProbeVolume(const std::shared_ptr< GbObject3D > &probeVolume)
bool fileNameLU
if true, written file name contains time step in LU, else is the number of the written probe files
Definition Probe.h:141
void addProbePlane(real startX, real startY, real startZ, real length, real width, real height)
SPtr< CudaMemoryManager > cudaMemoryManager
Definition Probe.h:131
void getTaggedFluidNodes(GridProvider *gridProvider) override
const bool outputTimeSeries
flag initiating time series output.
Definition Probe.h:136
Probe(std::shared_ptr< Parameter > para, std::shared_ptr< CudaMemoryManager > cudaMemoryManager, const std::string &outputPath, const std::string &probeName, uint tStartSampling, uint tBetweenSamples, uint tStartWritingOutput, uint tBetweenWriting, bool outputTimeSeries, bool sampleEveryTimestep, bool sampleScalar=false)
std::vector< std::shared_ptr< GbObject3D > > probeObjects
Definition Probe.h:147
bool enableComputationInstantaneous
Definition Probe.h:133
const uint tBetweenSamples
Definition Probe.h:144
const uint tStartWritingOutput
Definition Probe.h:145
const bool sampleEveryTimestep
Definition Probe.h:136
void addProbePoint(real x, real y, real z)
void addStatistic(Statistic variable)
void sample(int level, uint t) override
void init() override
std::vector< std::string > fileNamesForCollectionFile
Definition Probe.h:137
~Probe() override
void setFileNameToNOut()
Definition Probe.h:78
LevelData * getLevelData(int level)
Definition Probe.h:91
const bool sampleScalar
Definition Probe.h:134
std::vector< LevelData > levelDatas
Definition Probe.h:132
const uint tBetweenWriting
Definition Probe.h:146
void addAllAvailableStatistics()
Definition Probe.h:71
const uint tStartSampling
Definition Probe.h:143
std::vector< std::string > timeseriesFileNames
Definition Probe.h:138
Base class for all samplers.
Definition Sampler.h:58
std::string outputPath
Definition Sampler.h:72
std::string probeName
Definition Sampler.h:73
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
#define __host__
#define __device__
@ z
Definition Axis.h:44
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
void removeReceiveNodes(std::vector< uint > &indices, Parameter *para, int level)
void removeInterpolationCells(std::vector< uint > &indices, Parameter *para, int level)
struct holds and manages the LB-parameter of the simulation
Definition Parameter.h:74
std::vector< real > coordinatesX
Definition Probe.h:183
TimeseriesParams timeseriesParams
Definition Probe.h:182
LevelData(ProbeData probeDataH, ProbeData probeDataD, std::vector< real > coordinatesX, std::vector< real > coordinatesY, std::vector< real > coordinatesZ)
Definition Probe.h:185
std::vector< real > coordinatesY
Definition Probe.h:183
std::vector< real > coordinatesZ
Definition Probe.h:183
Definition Probe.h:151
std::string name
Definition Probe.h:152
real conversionFactor
Definition Probe.h:153
PostProcessingVariable(std::string name, real conversionFactor)
Definition Probe.h:154
__device__ __host__ ProbeData(bool computeInstantaneous, bool computeMeans, bool computeVariance, bool sampleScalar, uint numberOfPoints, uint numberOfQuantities, uint numberOfTimesteps)
Definition Probe.h:165