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
76 \*---------------------------------------------------------------------------*/
78 #ifndef fieldAverage_H
79 #define fieldAverage_H
81 #include "volFieldsFwd.H"
82 #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 //- List of field average items, describing waht averages to be
118 // calculated and output
119 List<fieldAverageItem> faItems_;
121 // File and field name extensions
124 static const word EXT_MEAN;
126 //- Prime-squared average
127 static const word EXT_PRIME2MEAN;
132 // Arithmetic mean fields
133 PtrList<volScalarField> meanScalarFields_;
134 PtrList<volVectorField> meanVectorFields_;
135 PtrList<volSphericalTensorField> meanSphericalTensorFields_;
136 PtrList<volSymmTensorField> meanSymmTensorFields_;
137 PtrList<volTensorField> meanTensorFields_;
139 // Prime-squared fields - applicable to volVectorFields only
140 PtrList<volScalarField> prime2MeanScalarFields_;
141 PtrList<volSymmTensorField> prime2MeanSymmTensorFields_;
146 //- Iteration steps counter
147 List<label> totalIter_;
149 //- Total time counter
150 List<scalar> totalTime_;
153 // Private Member Functions
155 // Initialisation routines
157 //- Reset size of lists (clear existing values)
158 void resetLists(const label nItems);
160 //- Intitialise averaging. Check requested field averages are
161 // valid, and populate field lists
164 //- Add mean average field to PtrList
169 PtrList<GeometricField<Type, fvPatchField, volMesh> >&
172 //- Add prime-squared average field to PtrList
173 template<class Type1, class Type2>
174 void addPrime2MeanField
177 PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
178 PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
182 // Calculation functions
184 //- Main calculation routine
185 virtual void calcAverages();
187 //- Calculate mean average fields
189 void calculateMeanFields
191 PtrList<GeometricField<Type, fvPatchField, volMesh> >&
194 //- Add mean-squared field value to prime-squared mean field
195 template<class Type1, class Type2>
196 void addMeanSqrToPrime2Mean
198 PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
199 PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
202 //- Calculate prime-squared average fields
203 template<class Type1, class Type2>
204 void calculatePrime2MeanFields
206 PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
207 PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
214 virtual void writeAverages() const;
220 const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
224 //- Write averaging properties - steps and time
225 void writeAveragingProperties() const;
227 //- Read averaging properties - steps and time
228 void readAveragingProperties();
231 // Functions to be over-ridden from IOoutputFilter class
234 virtual void updateMesh(const mapPolyMesh&);
237 virtual void movePoints(const Field<point>&);
240 //- Disallow default bitwise copy construct
241 fieldAverage(const fieldAverage&);
243 //- Disallow default bitwise assignment
244 void operator=(const fieldAverage&);
249 //- Runtime type information
250 TypeName("fieldAverage");
255 //- Construct for given objectRegistry and dictionary.
256 // Allow the possibility to load fields from files
260 const objectRegistry&,
262 const bool loadFromFiles = false
268 virtual ~fieldAverage();
273 //- Return name of the set of field averages
274 virtual const word& name() const
279 //- Read the field average data
280 virtual void read(const dictionary&);
282 //- Calculate the field average data and write
283 virtual void write();
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 } // End namespace Foam
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 # include "fieldAverageTemplates.C"
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 // ************************************************************************* //