1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Calculates the field averages given list of fieldAverageItems, e.g.
34 // Type of functionObject
37 // Where to load it from (if not already in solver)
38 functionObjectLibs ("libfieldAverage.so");
40 // Whether to perform a clean restart, or start from previous
41 // averaging info if available
44 // Whether to reset the averaged fields after they have been written.
45 // Used to average over only the preceding write interval for transient
49 // Fields to be averaged. runTime modifiable!
67 Member function calcAverages() calculates the averages.
69 Member function fieldAverage::write() calls calcAverages(). Average
70 field names are constructed by concatenating the base field with the
73 - arithmetic mean field, UMean
74 - prime-squared field, UPrime2Mean
76 Information regarding the number of averaging steps, and total averaging
77 time are written on a (base) per-field basis to the
78 fieldAveragingProperties dictionary, located in \<time\>/uniform
82 fieldAverageTemplates.C
84 \*---------------------------------------------------------------------------*/
86 #ifndef fieldAverage_H
87 #define fieldAverage_H
89 #include "volFieldsFwd.H"
90 #include "pointFieldFwd.H"
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 // Forward declaration of classes
101 class fieldAverageItem;
107 /*---------------------------------------------------------------------------*\
108 Class fieldAverage Declaration
109 \*---------------------------------------------------------------------------*/
115 // File and field name extensions
118 static const word EXT_MEAN;
120 //- Prime-squared average
121 static const word EXT_PRIME2MEAN;
125 //- Name of this set of field averages.
128 //- Database this class is registered to
129 const objectRegistry& obr_;
134 //- Time at last call, prevents repeated averaging
135 label prevTimeIndex_;
137 //- Clean restart flag
138 Switch cleanRestart_;
140 //- resetOnOutput flag
141 Switch resetOnOutput_;
143 //- List of field average items, describing what averages to be
144 // calculated and output
145 List<fieldAverageItem> faItems_;
149 // Arithmetic mean fields
150 wordList meanScalarFields_;
151 wordList meanVectorFields_;
152 wordList meanSphericalTensorFields_;
153 wordList meanSymmTensorFields_;
154 wordList meanTensorFields_;
156 // Prime-squared fields
157 // Only applicable to volScalarFields / volVectorFields
158 wordList prime2MeanScalarFields_;
159 wordList prime2MeanSymmTensorFields_;
164 //- Iteration steps counter
165 List<label> totalIter_;
167 //- Total time counter
168 List<scalar> totalTime_;
171 // Private Member Functions
173 // Initialisation routines
175 //- Checkout fields (causes deletion) from the database
177 void resetFields(wordList&);
179 //- Reset lists (clear existing values) and initialize averaging.
180 // Check requested field averages are valid, populate field lists
183 //- Add mean average field to list
185 void addMeanField(const label, wordList&) const;
187 //- Add prime-squared average field to list
188 template<class Type1, class Type2>
189 void addPrime2MeanField
197 // Calculation functions
199 //- Main calculation routine
200 virtual void calcAverages();
202 //- Calculate mean average fields
204 void calculateMeanFields(const wordList&) const;
206 //- Add mean-squared field value to prime-squared mean field
207 template<class Type1, class Type2>
208 void addMeanSqrToPrime2Mean
214 //- Calculate prime-squared average fields
215 template<class Type1, class Type2>
216 void calculatePrime2MeanFields
226 virtual void writeAverages() const;
230 void writeFieldList(const wordList&) const;
232 //- Write averaging properties - steps and time
233 void writeAveragingProperties() const;
235 //- Read averaging properties - steps and time
236 void readAveragingProperties();
239 // Functions to be over-ridden from IOoutputFilter class
242 virtual void updateMesh(const mapPolyMesh&);
245 virtual void movePoints(const Field<point>&);
248 //- Disallow default bitwise copy construct
249 fieldAverage(const fieldAverage&);
251 //- Disallow default bitwise assignment
252 void operator=(const fieldAverage&);
257 //- Runtime type information
258 TypeName("fieldAverage");
263 //- Construct for given objectRegistry and dictionary.
264 // Allow the possibility to load fields from files
268 const objectRegistry&,
270 const bool loadFromFiles = false
276 virtual ~fieldAverage();
281 //- Return name of the set of field averages
282 virtual const word& name() const
287 //- Read the field average data
288 virtual void read(const dictionary&);
290 //- Execute the averaging
291 virtual void execute();
293 //- Execute the averaging at the final time-loop, currently does nothing
296 //- Calculate the field average data and write
297 virtual void write();
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 } // End namespace Foam
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 # include "fieldAverageTemplates.C"
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 // ************************************************************************* //