VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
AverageValuesSimulationObserver.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//
33//=======================================================================================
34#ifndef AverageValuesSimulationObserver_H
35#define AverageValuesSimulationObserver_H
36
37#include <PointerDefinitions.h>
38#include <string>
39#include <vector>
40
41#include "SimulationObserver.h"
42#include "LBMSystem.h"
43#include "UbTuple.h"
44
45class UbScheduler;
46class WbWriter;
47class Grid3D;
48class Block3D;
49
55//
57// \f$ u_{mean}=\frac{1}{N}\sum\limits_{i=1}^n u_{i} \f$
59{
60public:
62 AverageValuesSimulationObserver(SPtr<Grid3D> grid, const std::string &path, WbWriter *const writer, SPtr<UbScheduler> s,
65 void update(real step) override;
67 void reset(real step);
68
69protected:
71 void collectData(real step);
73 void resetDataRMS(real step);
74 void resetDataMeans(real step);
76 void addData(const SPtr<Block3D> block);
77 void clearData();
79 void calculateAverageValues(real timeStep);
81 // void collectPlotDataZ(double step);
83 // void initPlotDataZ(double step);
84
85private:
86 std::vector<UbTupleFloat3> nodes;
87 std::vector<UbTupleUInt8> cells;
88 std::vector<std::string> datanames;
89 std::vector<std::vector<double>> data;
90 std::vector<std::vector<SPtr<Block3D>>> blockVector;
91 int minInitLevel; // min init level
92 int maxInitLevel;
93 int gridRank;
94 int resetStepRMS;
95 int resetStepMeans;
96 real averageInterval;
97 std::string path;
98 WbWriter *writer;
99 bool restart, compressible;
100 SPtr<UbScheduler> averageScheduler; // additional scheduler to averaging after a given interval
101 SPtr<UbScheduler> resetSchedulerRMS; // additional scheduler to restart averaging after a given interval
102 SPtr<UbScheduler> resetSchedulerMeans; // additional scheduler to restart averaging after a given interval
103 // labels for the different components, e.g. AvVxx for time averaged RMS: 1/n SUM((U-Umean)^2)
104 // you need to calculate a square root before plotting RMS
105 enum Values {
106 AvVx = 0,
107 AvVy = 1,
108 AvVz = 2,
109 AvVxx = 3,
110 AvVyy = 4,
111 AvVzz = 5,
112 AvVxy = 6,
113 AvVxz = 7,
114 AvVyz = 8,
115 AvP = 9,
116 AvPrms = 10
117 };
118
119 using CalcMacrosFct = void (*)(const real *const &, real &, real &, real &, real &);
120 CalcMacrosFct calcMacros;
121};
122#endif
123
Computes the time averaged mean velocity and RMS values and writes to parallel .vtk.
void reset(real step)
Resets averaged velocity and RMS-values according to ResetSceduler.
A class implements a block structure.
Definition Block3D.h:49
A class implements block grid.
Definition Grid3D.h:60
An abstract class implements observer design pettern.
virtual void update()=0
A class implements scheduling.
Definition UbScheduler.h:58
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
void calculateAverageValues(real timeStep)
Computes average and RMS values of macroscopic quantities.
void collectData(real step)
Prepare data and write in .vtk file.
void addData(const SPtr< Block3D > block)
prepare data