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 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  This function object calculates the average value from the output of
35  function objects that generate singular values.
36 
37 Usage
38  Example of function object specification:
39  \verbatim
40  valueAverage1
41  {
42  type valueAverage;
43  libs ("libfieldFunctionObjects.so");
44  ...
45  writeToFile yes;
46  log yes;
47  functionObject forceCoeffs1;
48  fields (Cm Cd Cl);
49  window 0.5;
50  }
51  \endverbatim
52 
53  Where the entries comprise:
54  \table
55  Property | Description | Required | Default value
56  type | type name: valueAverage | yes |
57  writeToFile | write average data to file | no | yes
58  log | write average data to standard output | no | yes
59  fields | list of fields to process | yes |
60  functionObject | Name of function object to retrieve data from | yes |
61  resetOnRestart | Reset the averaging on restart | no | no |
62  \endtable
63 
64  Output data is written to the file <timeDir>/valueAverage.dat
65 
66 See also
67  Foam::functionObject
68  Foam::functionObjects::stateFunctionObject
69  Foam::functionObjects::writeFile
70 
71 SourceFiles
72  valueAverage.C
73  valueAverageTemplates.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef functionObjects_valueAverage_H
78 #define functionObjects_valueAverage_H
79 
80 #include "regionFunctionObject.H"
81 #include "writeFile.H"
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 namespace Foam
86 {
87 namespace functionObjects
88 {
89 
90 /*---------------------------------------------------------------------------*\
91  Class valueAverage Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 class valueAverage
95 :
96  public regionFunctionObject,
97  public writeFile
98 {
99 protected:
100 
101  // Protected data
102 
103  //- Name of function object to retrieve data from
104  word functionObjectName_;
105 
106  //- List of fields on which to operate
108 
109  //- Averaging window
110  scalar window_;
111 
112  //- Average time per field
113  List<scalar> totalTime_;
114 
115  //- Reset the averaging process on restart
116  Switch resetOnRestart_;
117 
118 
119  // Protected Member Functions
120 
121  //- Templated function to calculate the average
122  template<class Type>
123  void calc
124  (
125  const word& fieldName,
126  const word& meanName,
127  const scalar alpha,
128  const scalar beta,
129  bool& processed
130  );
131 
132  //- Output file header information
133  virtual void writeFileHeader(Ostream& os) const;
134 
135  //- No copy construct
136  valueAverage(const valueAverage&) = delete;
137 
138  //- No copy assignment
139  void operator=(const valueAverage&) = delete;
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("valueAverage");
146 
147  //- Constructor
149  (
150  const word& name,
151  const Time& runTime,
152  const dictionary& dict
153  );
154 
155  //- Destructor
156  virtual ~valueAverage();
157 
158 
159  // Public Member Functions
160 
161  //- Read the field value average data
162  virtual bool read(const dictionary&);
163 
164  //- Execute
165  virtual bool execute();
166 
167  //- Write the value average
168  virtual bool write();
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace functionObjects
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #ifdef NoRepository
180  #include "valueAverageTemplates.C"
181 #endif
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
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:70
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::valueAverage
This function object calculates the average value from the output of function objects that generate s...
Definition: valueAverage.H:129
Foam::functionObjects::valueAverage::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: valueAverage.C:53
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::valueAverage::TypeName
TypeName("valueAverage")
Runtime type information.
Foam::functionObjects::valueAverage::execute
virtual bool execute()
Execute.
Definition: valueAverage.C:137
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:148
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:59
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:110
Foam::functionObjects::valueAverage::fieldNames_
wordList fieldNames_
List of fields on which to operate.
Definition: valueAverage.H:142
beta
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Foam::functionObjects::valueAverage::functionObjectName_
word functionObjectName_
Name of function object to retrieve data from.
Definition: valueAverage.H:139
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:121
Foam::functionObjects::valueAverage::write
virtual bool write()
Write the value average.
Definition: valueAverage.C:207
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::valueAverage::valueAverage
valueAverage(const valueAverage &)=delete
No copy construct.
Foam::functionObjects::valueAverage::~valueAverage
virtual ~valueAverage()
Destructor.
Definition: valueAverage.C:104
valueAverageTemplates.C
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::List< word >
Foam::functionObjects::regionFunctionObject
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Definition: regionFunctionObject.H:87
Foam::functionObjects::writeFile
functionObject base class for writing single files
Definition: writeFile.H:59
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:151
Foam::functionObjects::valueAverage::window_
scalar window_
Averaging window.
Definition: valueAverage.H:145