valueAverage.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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::valueAverage
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes the ensemble- or time-based singular-value average values,
35  with optional windowing, from the output of function objects
36  that generate non-field type values (e.g. \c Cd of \c forceCoeffs or
37  \c momentum_x in \c momentum function objects).
38 
39  Operands:
40  \table
41  Operand | Type | Location
42  input | - | -
43  output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
44  output field | - | -
45  \endtable
46 
47 Usage
48  Minimal example by using \c system/controlDict.functions:
49  \verbatim
50  valueAverage1
51  {
52  // Mandatory entries (unmodifiable)
53  type valueAverage;
54  libs (fieldFunctionObjects);
55 
56  // Mandatory entries (runtime modifiable)
57  functionObject <FO>; // forceCoeffs1;
58  fields (<field1> ... <fieldN>); // (Cm Cd Cl);
59 
60  // Optional entries (runtime modifiable)
61  resetOnRestart false;
62  window 0.5;
63 
64  // Optional (inherited) entries
65  ...
66  }
67  \endverbatim
68 
69  where the entries mean:
70  \table
71  Property | Description | Type | Req'd | Dflt
72  type | Type name: valueAverage | word | yes | -
73  libs | Library name: fieldFunctionObjects | word | yes | -
74  functionObject | Name of function object to retrieve data | word | yes | -
75  fields | Names of operand fields | wordList | yes | -
76  resetOnRestart | Reset the averaging on restart | bool | no | false
77  window | Averaging window | scalar | no | VGREAT
78  \endtable
79 
80  The inherited entries are elaborated in:
81  - \link regionFunctionObject.H \endlink
82  - \link writeFile.H \endlink
83 
84  Usage by the \c postProcess utility is not available.
85 
86 See also
87  - Foam::functionObject
88  - Foam::functionObjects::stateFunctionObject
89  - Foam::functionObjects::writeFile
90  - ExtendedCodeGuide::functionObjects::field::valueAverage
91 
92 SourceFiles
93  valueAverage.C
94  valueAverageTemplates.C
95 
96 \*---------------------------------------------------------------------------*/
97 
98 #ifndef functionObjects_valueAverage_H
99 #define functionObjects_valueAverage_H
100 
101 #include "regionFunctionObject.H"
102 #include "writeFile.H"
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 namespace Foam
107 {
108 namespace functionObjects
109 {
110 
111 /*---------------------------------------------------------------------------*\
112  Class valueAverage Declaration
113 \*---------------------------------------------------------------------------*/
114 
115 class valueAverage
116 :
117  public regionFunctionObject,
118  public writeFile
119 {
120 protected:
121 
122  // Protected Data
123 
124  //- Name of function object to retrieve data from
125  word functionObjectName_;
126 
127  //- List of fields on which to operate
129 
130  //- Averaging window
131  scalar window_;
132 
133  //- Average time per field
134  List<scalar> totalTime_;
135 
136  //- Reset the averaging process on restart
137  Switch resetOnRestart_;
138 
139 
140  // Protected Member Functions
141 
142  //- Templated function to calculate the average
143  template<class Type>
144  void calc
145  (
146  const word& fieldName,
147  const word& meanName,
148  const scalar alpha,
149  const scalar beta,
150  bool& processed
151  );
152 
153  //- Output file header information
154  virtual void writeFileHeader(Ostream& os) const;
155 
156 
157 public:
158 
159  //- Runtime type information
160  TypeName("valueAverage");
161 
162 
163  // Constructors
164 
165  //- Construct from Time and dictionary
167  (
168  const word& name,
169  const Time& runTime,
170  const dictionary& dict
171  );
172 
173  //- No copy construct
174  valueAverage(const valueAverage&) = delete;
175 
176  //- No copy assignment
177  void operator=(const valueAverage&) = delete;
178 
179 
180  //- Destructor
181  virtual ~valueAverage() = default;
182 
183 
184  // Public Member Functions
185 
186  //- Read the field value average data
187  virtual bool read(const dictionary&);
188 
189  //- Execute
190  virtual bool execute();
191 
192  //- Write the value average
193  virtual bool write();
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace functionObjects
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #ifdef NoRepository
205  #include "valueAverageTemplates.C"
206 #endif
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::valueAverage
Computes the ensemble- or time-based singular-value average values, with optional windowing,...
Definition: valueAverage.H:172
Foam::functionObjects::valueAverage::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: valueAverage.C:47
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::valueAverage::TypeName
TypeName("valueAverage")
Runtime type information.
Foam::functionObjects::valueAverage::execute
virtual bool execute()
Execute.
Definition: valueAverage.C:125
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::functionObjects::valueAverage::totalTime_
List< scalar > totalTime_
Average time per field.
Definition: valueAverage.H:191
Foam::functionObjects::valueAverage::calc
void calc(const word &fieldName, const word &meanName, const scalar alpha, const scalar beta, bool &processed)
Templated function to calculate the average.
Definition: valueAverageTemplates.C:33
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::functionObjects::valueAverage::operator=
void operator=(const valueAverage &)=delete
No copy assignment.
Foam::functionObjects::valueAverage::read
virtual bool read(const dictionary &)
Read the field value average data.
Definition: valueAverage.C:98
Foam::functionObjects::valueAverage::fieldNames_
wordList fieldNames_
List of fields on which to operate.
Definition: valueAverage.H:185
beta
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Foam::functionObjects::valueAverage::functionObjectName_
word functionObjectName_
Name of function object to retrieve data from.
Definition: valueAverage.H:182
regionFunctionObject.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::functionObjects::valueAverage::write
virtual bool write()
Write the value average.
Definition: valueAverage.C:195
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::valueAverage::valueAverage
valueAverage(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: valueAverage.C:62
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
valueAverageTemplates.C
Foam::List< word >
Foam::functionObjects::valueAverage::~valueAverage
virtual ~valueAverage()=default
Destructor.
Foam::functionObjects::regionFunctionObject
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Definition: regionFunctionObject.H:90
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::valueAverage::resetOnRestart_
Switch resetOnRestart_
Reset the averaging process on restart.
Definition: valueAverage.H:194
Foam::functionObjects::valueAverage::window_
scalar window_
Averaging window.
Definition: valueAverage.H:188