average fields registered
[OpenFOAM-1.5.x.git] / src / postProcessing / fieldAverage / fieldAverage / fieldAverage.H
blobbcc21c9dfd135e73376c666e00b8bf8d5df2e71d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::fieldAverage
28 Description
29     Calculates the field averages given list of fieldAverageItems, e.g.
31     @verbatim
32     fieldAverage1
33     {
34         // Type of functionObject
35         type fieldAverage;
37         // Where to load it from (if not already in solver)
38         functionObjectLibs ("libfieldAverage.so");
40         // Fields to be probed. runTime modifiable!
41         fields
42         (
43             U
44             {
45                 mean            on;
46                 prime2Mean      on;
47                 base            time;
48             }
49             p
50             {
51                 mean            on;
52                 prime2Mean      on;
53                 base            time;
54             }
55         );
56     @endverbatim
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
62     averaging type, e.g.
63     - base field, U
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
71 SourceFiles
72     fieldAverage.C
73     fieldAverageTemplates.C
75 \*---------------------------------------------------------------------------*/
77 #ifndef fieldAverage_H
78 #define fieldAverage_H
80 #include "volFieldsFwd.H"
81 #include "pointFieldFwd.H"
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 namespace Foam
88 // Forward declaration of classes
89 class objectRegistry;
90 class dictionary;
91 class fieldAverageItem;
92 class OFstream;
93 template<class Type>
94 class List;
95 class mapPolyMesh;
97 /*---------------------------------------------------------------------------*\
98                          Class fieldAverage Declaration
99 \*---------------------------------------------------------------------------*/
101 class fieldAverage
103 protected:
105     // Private data
107         //- Name of this set of field averages.
108         word name_;
110         //- Database this class is registered to
111         const objectRegistry& obr_;
113         //- On/off switch
114         bool active_;
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
122             //- Mean average
123             static const word EXT_MEAN;
125             //- Prime-squared average
126             static const word EXT_PRIME2MEAN;
129         // Lists of averages
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_;
143         // Counters
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
164             void initialise();
166             //- Add mean average field to PtrList
167             template<class Type>
168             void addMeanField(const label, wordList&) const;
170             //- Add prime-squared average field to PtrList
171             template<class Type1, class Type2>
172             void addPrime2MeanField
173             (
174                 const label,
175                 const wordList&,
176                 wordList&
177             ) const;
180         // Calculation functions
182             //- Main calculation routine
183             virtual void calcAverages();
185             //- Calculate mean average fields
186             template<class Type>
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
192             (
193                 const wordList&,
194                 const wordList&
195             ) const;
197             //- Calculate prime-squared average fields
198             template<class Type1, class Type2>
199             void calculatePrime2MeanFields
200             (
201                 const wordList&,
202                 const wordList&
203             ) const;
206         // I-O
208             //- Write averages
209             virtual void writeAverages() const;
211             //- Write fields
212             template<class Type>
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
224             //- Update mesh
225             virtual void updateMesh(const mapPolyMesh&);
227             //- Move points
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&);
238 public:
240     //- Runtime type information
241     TypeName("fieldAverage");
244     // Constructors
246         //- Construct for given objectRegistry and dictionary.
247         //  Allow the possibility to load fields from files
248         fieldAverage
249         (
250             const word& name,
251             const objectRegistry&,
252             const dictionary&,
253             const bool loadFromFiles = false
254         );
257     //- Destructor
259         virtual ~fieldAverage();
262     // Member Functions
264         //- Return name of the set of field averages
265         virtual const word& name() const
266         {
267             return name_;
268         }
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 #ifdef NoRepository
285 #   include "fieldAverageTemplates.C"
286 #endif
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 #endif
292 // ************************************************************************* //