initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / field / fieldAverage / fieldAverageItem / fieldAverageItem.H
blobbeffadd573cd7b463766200156109b9ff0d6d393
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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::fieldAverageItem
28 Description
29     Helper class to describe what form of averaging to apply. A set will be
30     applied to each base field in Foam::fieldAverage, of the form:
32     @verbatim
33         {
34             mean            on;
35             prime2Mean      on;
36             base            time; // iteration
37         }
38     @endverbatim
40 SourceFiles
41     fieldAverageItem.C
42     fieldAverageItemIO.C
44 \*---------------------------------------------------------------------------*/
46 #ifndef fieldAverageItem_H
47 #define fieldAverageItem_H
49 #include "NamedEnum.H"
50 #include "Switch.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 // Forward declaration of classes
58 class Istream;
59 class Ostream;
61 // Forward declaration of friend functions and operators
62 class fieldAverageItem;
63 Istream& operator>>(Istream&, fieldAverageItem&);
64 Ostream& operator<<(Ostream&, const fieldAverageItem&);
67 /*---------------------------------------------------------------------------*\
68                       Class fieldAverageItem Declaration
69 \*---------------------------------------------------------------------------*/
71 class fieldAverageItem
73 public:
75     // Public data
77         //- Enumeration defining the averaging base type
78         enum baseType
79         {
80             ITER,
81             TIME
82         };
85 private:
87     // Private data
89         //- Field name
90         word fieldName_;
92         //- Compute mean flag
93         Switch mean_;
95         //- Compute prime-squared mean flag
96         Switch prime2Mean_;
98         //- Averaging base type names
99         static const NamedEnum<baseType, 2> baseTypeNames_;
101         //- Averaging base type
102         baseType base_;
105 public:
107     // Constructors
109         //- Construct null
110         fieldAverageItem();
112         //- Construct from Istream
113         fieldAverageItem(Istream&);
115         //- Construct as copy
116         fieldAverageItem(const fieldAverageItem&);
119     // Destructor
121         ~fieldAverageItem();
124     // Member Functions
126         // Access
128             //- Return const access to the field name
129             const word& fieldName() const
130             {
131                 return fieldName_;
132             }
134             //- Return const access to the mean flag
135             const Switch& mean() const
136             {
137                 return mean_;
138             }
140             //- Return const access to the prime-squared mean flag
141             const Switch& prime2Mean() const
142             {
143                 return prime2Mean_;
144             }
146             //- Return averaging base type name
147             const word base() const
148             {
149                 return baseTypeNames_[base_];
150             }
152             //- Return true if base is ITER
153             Switch ITERBase() const
154             {
155                 return base_ == ITER;
156             }
158             //- Return true if base is time
159             Switch timeBase() const
160             {
161                 return base_ == TIME;
162             }
165     // Member Operators
167         void operator=(const fieldAverageItem&);
169     // Friend Operators
171         friend bool operator==
172         (
173             const fieldAverageItem& a,
174             const fieldAverageItem& b
175         )
176         {
177             return
178                 a.fieldName_ == b.fieldName_
179              && a.mean_ == b.mean_
180              && a.prime2Mean_ == b.prime2Mean_
181              && a.base_ == b.base_;
182         }
184         friend bool operator!=
185         (
186             const fieldAverageItem& a,
187             const fieldAverageItem& b
188         )
189         {
190             return !(a == b);
191         }
193     // IOstream Operators
195         friend Istream& operator>>(Istream&, fieldAverageItem&);
196         friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 } // End namespace Foam
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 #endif
208 // ************************************************************************* //