1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 // Fields to be probed. runTime modifiable!
58 Member function calcAverages() calculates the averages.
60 Member function fieldAverage::write() calls calcAverages(). Average
61 field names are constructed by concatenating the base field with the
64 - arithmetic mean field, UMean
65 - prime-squared field, UPrime2Mean
67 Information regarding the number of averaging steps, and total averaging
68 time are written on a (base) per-field basis to the
69 fieldAveragingProperties dictionary, located in \<time\>/uniform
73 fieldAverageTemplates.C
75 \*---------------------------------------------------------------------------*/
77 #ifndef fieldAverage_H
78 #define fieldAverage_H
80 #include "volFieldsFwd.H"
81 #include "pointFieldFwd.H"
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 // Forward declaration of classes
92 class fieldAverageItem;
98 /*---------------------------------------------------------------------------*\
99 Class fieldAverage Declaration
100 \*---------------------------------------------------------------------------*/
108 //- Name of this set of field averages.
111 //- Database this class is registered to
112 const objectRegistry& obr_;
117 //- Time at last call, prevents repeated averaging
118 label prevTimeIndex_;
120 //- resetOnOutput flag
121 Switch resetOnOutput_;
123 //- List of field average items, describing what averages to be
124 // calculated and output
125 List<fieldAverageItem> faItems_;
127 // File and field name extensions
130 static const word EXT_MEAN;
132 //- Prime-squared average
133 static const word EXT_PRIME2MEAN;
138 // Arithmetic mean fields
139 wordList meanScalarFields_;
140 wordList meanVectorFields_;
141 wordList meanSphericalTensorFields_;
142 wordList meanSymmTensorFields_;
143 wordList meanTensorFields_;
145 // Prime-squared fields - applicable to volVectorFields only
146 wordList prime2MeanScalarFields_;
147 wordList prime2MeanSymmTensorFields_;
152 //- Iteration steps counter
153 List<label> totalIter_;
155 //- Total time counter
156 List<scalar> totalTime_;
159 // Private Member Functions
161 // Initialisation routines
163 //- Checkout fields (causes deletion) from the database
164 void checkoutFields(const wordList&) const;
166 //- Reset size of lists (clear existing values)
167 void resetLists(const label nItems);
169 //- Intitialise averaging. Check requested field averages are
170 // valid, and populate field lists
173 //- Add mean average field to PtrList
175 void addMeanField(const label, wordList&) const;
177 //- Add prime-squared average field to PtrList
178 template<class Type1, class Type2>
179 void addPrime2MeanField
187 // Calculation functions
189 //- Main calculation routine
190 virtual void calcAverages();
192 //- Calculate mean average fields
194 void calculateMeanFields(const wordList&) const;
196 //- Add mean-squared field value to prime-squared mean field
197 template<class Type1, class Type2>
198 void addMeanSqrToPrime2Mean
204 //- Calculate prime-squared average fields
205 template<class Type1, class Type2>
206 void calculatePrime2MeanFields
216 virtual void writeAverages() const;
220 void writeFieldList(const wordList&) const;
222 //- Write averaging properties - steps and time
223 void writeAveragingProperties() const;
225 //- Read averaging properties - steps and time
226 void readAveragingProperties();
229 // Functions to be over-ridden from IOoutputFilter class
232 virtual void updateMesh(const mapPolyMesh&);
235 virtual void movePoints(const Field<point>&);
238 //- Disallow default bitwise copy construct
239 fieldAverage(const fieldAverage&);
241 //- Disallow default bitwise assignment
242 void operator=(const fieldAverage&);
247 //- Runtime type information
248 TypeName("fieldAverage");
253 //- Construct for given objectRegistry and dictionary.
254 // Allow the possibility to load fields from files
258 const objectRegistry&,
260 const bool loadFromFiles = false
266 virtual ~fieldAverage();
271 //- Return name of the set of field averages
272 virtual const word& name() const
277 //- Read the field average data
278 virtual void read(const dictionary&);
280 //- Calculate the field average data and write
281 virtual void write();
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 } // End namespace Foam
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 # include "fieldAverageTemplates.C"
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 // ************************************************************************* //