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"
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 // Forward declaration of classes
91 class fieldAverageItem;
97 /*---------------------------------------------------------------------------*\
98 Class fieldAverage Declaration
99 \*---------------------------------------------------------------------------*/
107 //- Name of this set of field averages.
110 //- Database this class is registered to
111 const objectRegistry& obr_;
116 //- List of field average items, describing what averages to be
117 // calculated and output
118 List<fieldAverageItem> faItems_;
120 // File and field name extensions
123 static const word EXT_MEAN;
125 //- Prime-squared average
126 static const word EXT_PRIME2MEAN;
131 // Arithmetic mean fields
132 wordList meanScalarFields_;
133 wordList meanVectorFields_;
134 wordList meanSphericalTensorFields_;
135 wordList meanSymmTensorFields_;
136 wordList meanTensorFields_;
138 // Prime-squared fields - applicable to volVectorFields only
139 wordList prime2MeanScalarFields_;
140 wordList prime2MeanSymmTensorFields_;
145 //- Iteration steps counter
146 List<label> totalIter_;
148 //- Total time counter
149 List<scalar> totalTime_;
152 // Private Member Functions
154 // Initialisation routines
156 //- Checkout fields (causes deletion) from the database
157 void checkoutFields(const wordList&) const;
159 //- Reset size of lists (clear existing values)
160 void resetLists(const label nItems);
162 //- Intitialise averaging. Check requested field averages are
163 // valid, and populate field lists
166 //- Add mean average field to PtrList
168 void addMeanField(const label, wordList&) const;
170 //- Add prime-squared average field to PtrList
171 template<class Type1, class Type2>
172 void addPrime2MeanField
180 // Calculation functions
182 //- Main calculation routine
183 virtual void calcAverages();
185 //- Calculate mean average fields
187 void calculateMeanFields(const wordList&) const;
189 //- Add mean-squared field value to prime-squared mean field
190 template<class Type1, class Type2>
191 void addMeanSqrToPrime2Mean
197 //- Calculate prime-squared average fields
198 template<class Type1, class Type2>
199 void calculatePrime2MeanFields
209 virtual void writeAverages() const;
213 void writeFieldList(const wordList&) const;
215 //- Write averaging properties - steps and time
216 void writeAveragingProperties() const;
218 //- Read averaging properties - steps and time
219 void readAveragingProperties();
222 // Functions to be over-ridden from IOoutputFilter class
225 virtual void updateMesh(const mapPolyMesh&);
228 virtual void movePoints(const Field<point>&);
231 //- Disallow default bitwise copy construct
232 fieldAverage(const fieldAverage&);
234 //- Disallow default bitwise assignment
235 void operator=(const fieldAverage&);
240 //- Runtime type information
241 TypeName("fieldAverage");
246 //- Construct for given objectRegistry and dictionary.
247 // Allow the possibility to load fields from files
251 const objectRegistry&,
253 const bool loadFromFiles = false
259 virtual ~fieldAverage();
264 //- Return name of the set of field averages
265 virtual const word& name() const
270 //- Read the field average data
271 virtual void read(const dictionary&);
273 //- Calculate the field average data and write
274 virtual void write();
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 } // End namespace Foam
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 # include "fieldAverageTemplates.C"
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 // ************************************************************************* //