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 | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::valueAverage
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  This function object calculates the average value from the output of
32  function objects that generate singular values.
33 
34  Example of function object specification:
35  \verbatim
36  valueAverage1
37  {
38  type valueAverage;
39  functionObjectLibs ("libfieldFunctionObjects.so");
40  ...
41  writeToFile yes;
42  log yes;
43  functionObjectName forceCoeffs1;
44  fields (Cm Cd Cl);
45  window 0.5;
46  }
47  \endverbatim
48 
49  \heading Function object usage
50  \table
51  Property | Description | Required | Default value
52  type | type name: valueAverage | yes |
53  writeToFile | write average data to file | no | yes
54  log | write average data to standard output | no | yes
55  fields | list of fields to process | yes |
56  \endtable
57 
58  Output data is written to the file <timeDir>/valueAverage.dat
59 
60 SeeAlso
61  Foam::functionObject
62  Foam::functionObjectFile
63  Foam::functionObjectState
64  Foam::OutputFilterFunctionObject
65 
66 SourceFiles
67  valueAverage.C
68  valueAverageTemplates.C
69  IOvalueAverage.H
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef valueAverage_H
74 #define valueAverage_H
75 
76 #include "functionObjectState.H"
77 #include "functionObjectFile.H"
78 #include "Switch.H"
79 
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 
86 // Forward declaration of classes
87 class objectRegistry;
88 class dictionary;
89 class polyMesh;
90 class mapPolyMesh;
91 
92 /*---------------------------------------------------------------------------*\
93  Class valueAverage Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class valueAverage
97 :
98  public functionObjectState,
99  public functionObjectFile
100 {
101 protected:
102 
103  // Protected data
104 
105  //- Reference to the database
106  const objectRegistry& obr_;
107 
108  //- Name of function object to retrueve data from
109  word functionObjectName_;
110 
111  //- List of fields on which to operate
113 
114  //- Averaging window
115  const scalar window_;
116 
117  //- Average time per field
119 
120  //- Reset the averaging process on restart flag
122 
123  //- Switch to send output to Info as well
124  Switch log_;
125 
126 
127  // Protected Member Functions
128 
129  //- Templated function to calculate the average
130  template<class Type>
131  void calc
132  (
133  const word& fieldName,
134  const word& meanName,
135  const scalar alpha,
136  const scalar beta,
137  bool& processed
138  );
139 
140  //- Output file header information
141  virtual void writeFileHeader(Ostream& os) const;
142 
143  //- Disallow default bitwise copy construct
144  valueAverage(const valueAverage&);
145 
146  //- Disallow default bitwise assignment
147  void operator=(const valueAverage&);
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("valueAverage");
154 
155  //- Constructor
157  (
158  const word& name,
159  const objectRegistry& obr,
160  const dictionary& dict,
161  const bool loadFromFiles = false
162  );
163 
164  //- Destructor
165  virtual ~valueAverage();
166 
167 
168  // Public Member Functions
169 
170  //- Read the field min/max data
171  virtual void read(const dictionary&);
172 
173  //- Execute, currently does nothing
174  virtual void execute();
175 
176  //- Execute at the final time-loop, currently does nothing
177  virtual void end();
178 
179  //- Called when time was set at the end of the Time::operator++
180  virtual void timeSet();
181 
182  //- Write the fieldMinMax
183  virtual void write();
184 
185  //- Update for changes of mesh
186  virtual void updateMesh(const mapPolyMesh&)
187  {}
188 
189  //- Update for changes of mesh
190  virtual void movePoints(const polyMesh&)
191  {}
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #ifdef NoRepository
202  #include "valueAverageTemplates.C"
203 #endif
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
beta
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::valueAverage::obr_
const objectRegistry & obr_
Reference to the database.
Definition: valueAverage.H:130
Foam::valueAverage::TypeName
TypeName("valueAverage")
Runtime type information.
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
functionObjectState.H
Foam::valueAverage::resetOnRestart_
Switch resetOnRestart_
Reset the averaging process on restart flag.
Definition: valueAverage.H:145
Foam::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:30
Foam::valueAverage::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: valueAverage.C:97
Foam::valueAverage::log_
Switch log_
Switch to send output to Info as well.
Definition: valueAverage.H:148
Foam::valueAverage::totalTime_
List< scalar > totalTime_
Average time per field.
Definition: valueAverage.H:142
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::valueAverage::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: valueAverage.C:39
Foam::valueAverage::write
virtual void write()
Write the fieldMinMax.
Definition: valueAverage.C:193
Switch.H
Foam::valueAverage::valueAverage
valueAverage(const valueAverage &)
Disallow default bitwise copy construct.
Foam::valueAverage::fieldNames_
wordList fieldNames_
List of fields on which to operate.
Definition: valueAverage.H:136
Foam::valueAverage::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: valueAverage.C:187
Foam::valueAverage::execute
virtual void execute()
Execute, currently does nothing.
Definition: valueAverage.C:108
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::valueAverage::~valueAverage
virtual ~valueAverage()
Destructor.
Definition: valueAverage.C:91
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::valueAverage::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: valueAverage.H:210
Foam::valueAverage::window_
const scalar window_
Averaging window.
Definition: valueAverage.H:139
functionObjectFile.H
valueAverageTemplates.C
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::valueAverage::operator=
void operator=(const valueAverage &)
Disallow default bitwise assignment.
Foam::valueAverage::functionObjectName_
word functionObjectName_
Name of function object to retrueve data from.
Definition: valueAverage.H:133
Foam::valueAverage
This function object calculates the average value from the output of function objects that generate s...
Definition: valueAverage.H:120
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::valueAverage::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: valueAverage.C:181
List
Definition: Test.C:19
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::valueAverage::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: valueAverage.H:214
Foam::functionObjectState::name
const word & name() const
Return the name.
Definition: functionObjectState.C:58