valueAverageBase.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015 OpenFOAM Foundation
9 Copyright (C) 2016-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::functionObjects::valueAverageBase
29
30Description
31 Base class that computes the ensemble- or time-based singular-value average
32 values, with optional windowing, from the output of function objects
33 that generate non-field type values, e.g. \c Cd of \c forceCoeffs or
34 \c momentum_x in \c momentum function objects.
35
36See also
37 - Foam::functionObjects::writeFile
38
39SourceFiles
40 valueAverageBase.C
41 valueAverageBaseTemplates.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef functionObjects_valueAverageBase_H
46#define functionObjects_valueAverageBase_H
47
48#include "writeFile.H"
49#include "Enum.H"
50#include "stateFunctionObject.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56namespace functionObjects
57{
58
59/*---------------------------------------------------------------------------*\
60 Class valueAverageBase Declaration
61\*---------------------------------------------------------------------------*/
64:
66{
67public:
68
69 // Public Enumerations
70
71 //- Averaging window types
72 enum class windowType : uint8_t
73 {
74 NONE,
76 EXACT
77 };
78
79 //- Names for windowType enumeration
81
82private:
83
84 // Private Data
85
86 //- Log flag
87 bool log;
88
89
90protected:
91
92 // Protected Data
93
94 //- Reset the averaging process on restart
95 bool resetOnRestart_;
96
97 //- Window type
99
100 //- Reference to the state functionObject
102
103 //- Name of function object to retrieve data from
105
106 //- List of fields on which to operate
108
109 //- Optional tolerance to check for converged results
110 scalar tolerance_;
111
112 //- Averaging window
113 scalar window_;
114
115 //- Average time per field
117
118
119 // Protected Member Functions
120
121 //- Templated function to calculate the average
122 // Return true if processed
123 template<class Type, class Type2=Type>
124 bool calc(const label fieldi, bool& converged, dictionary& dict);
125
126 //- Output file header information
127 virtual void writeFileHeader(Ostream& os) const;
128
129 //- Read state from dictionary
130 virtual void readState(dictionary& dict);
131
132 //- Write state to dictionary for restarts
133 virtual void writeState(dictionary& dict);
134
135 //- Reset state
136 virtual void resetState(dictionary& dict);
137
138
139public:
140
141 // Constructors
142
143 //- Construct from Time and dictionary
145 (
146 const word& name,
147 const objectRegistry& obr,
148 const dictionary& dict,
149 stateFunctionObject& state,
150 const bool writeToFile = true
151 );
152
153 //- No copy construct
154 valueAverageBase(const valueAverageBase&) = delete;
155
156 //- No copy assignment
157 void operator=(const valueAverageBase&) = delete;
158
159
160 //- Destructor
161 virtual ~valueAverageBase() = default;
162
163
164 // Public Member Functions
165
166 //- Read the field value average data
167 virtual bool read(const dictionary& dict);
168
169 //- Calculate the averages
170 virtual bool calculate(dictionary& dict);
171};
172
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176} // End namespace functionObjects
177} // End namespace Foam
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181#ifdef NoRepository
183#endif
184
185// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186
187#endif
188
189// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Computes the natural logarithm of an input volScalarField.
Definition: log.H:230
Base class for function objects, adding functionality to read/write state information (data required ...
Base class that computes the ensemble- or time-based singular-value average values,...
word functionObjectName_
Name of function object to retrieve data from.
scalar tolerance_
Optional tolerance to check for converged results.
virtual void readState(dictionary &dict)
Read state from dictionary.
wordList fieldNames_
List of fields on which to operate.
virtual void writeState(dictionary &dict)
Write state to dictionary for restarts.
virtual bool calculate(dictionary &dict)
Calculate the averages.
List< scalar > totalTime_
Average time per field.
virtual bool read(const dictionary &dict)
Read the field value average data.
virtual ~valueAverageBase()=default
Destructor.
bool calc(const label fieldi, bool &converged, dictionary &dict)
Templated function to calculate the average.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
void operator=(const valueAverageBase &)=delete
No copy assignment.
bool resetOnRestart_
Reset the averaging process on restart.
static const Enum< windowType > windowTypeNames
Names for windowType enumeration.
virtual void resetState(dictionary &dict)
Reset state.
stateFunctionObject & state_
Reference to the state functionObject.
valueAverageBase(const valueAverageBase &)=delete
No copy construct.
Base class for writing single files from the function objects.
Definition: writeFile.H:120
virtual bool writeToFile() const
Flag to allow writing to file.
Definition: writeFile.C:250
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict