Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / fieldAverage / fieldAverageItem / fieldAverageItem.H
blob0c4aee6cff8959670782263f95ca65aa817494d8
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2011 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::fieldAverageItem
27 Description
28     Helper class to describe what form of averaging to apply. A set will be
29     applied to each base field in Foam::fieldAverage, of the form:
31     \verbatim
32         {
33             mean            on;
34             prime2Mean      on;
35             base            time; // iteration
36         }
37     \endverbatim
39 SourceFiles
40     fieldAverageItem.C
41     fieldAverageItemIO.C
43 \*---------------------------------------------------------------------------*/
45 #ifndef fieldAverageItem_H
46 #define fieldAverageItem_H
48 #include "NamedEnum.H"
49 #include "Switch.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 namespace Foam
56 // Forward declaration of classes
57 class Istream;
58 class Ostream;
60 // Forward declaration of friend functions and operators
61 class fieldAverageItem;
62 Istream& operator>>(Istream&, fieldAverageItem&);
63 Ostream& operator<<(Ostream&, const fieldAverageItem&);
66 /*---------------------------------------------------------------------------*\
67                       Class fieldAverageItem Declaration
68 \*---------------------------------------------------------------------------*/
70 class fieldAverageItem
72 public:
74     // Public data
76         //- Enumeration defining the averaging base type
77         enum baseType
78         {
79             ITER,
80             TIME
81         };
84 private:
86     // Private data
88         //- Field name
89         word fieldName_;
91         //- Compute mean flag
92         Switch mean_;
94         //- Compute prime-squared mean flag
95         Switch prime2Mean_;
97         //- Averaging base type names
98         static const NamedEnum<baseType, 2> baseTypeNames_;
100         //- Averaging base type
101         baseType base_;
104 public:
106     // Constructors
108         //- Construct null
109         fieldAverageItem();
111         //- Construct from Istream
112         fieldAverageItem(Istream&);
114         //- Construct as copy
115         fieldAverageItem(const fieldAverageItem&);
118     //- Destructor
119     ~fieldAverageItem();
122     // Member Functions
124         // Access
126             //- Return const access to the field name
127             const word& fieldName() const
128             {
129                 return fieldName_;
130             }
132             //- Return const access to the mean flag
133             const Switch& mean() const
134             {
135                 return mean_;
136             }
138             //- Return const access to the prime-squared mean flag
139             const Switch& prime2Mean() const
140             {
141                 return prime2Mean_;
142             }
144             //- Return averaging base type name
145             const word base() const
146             {
147                 return baseTypeNames_[base_];
148             }
150             //- Return true if base is ITER
151             Switch ITERBase() const
152             {
153                 return base_ == ITER;
154             }
156             //- Return true if base is time
157             Switch timeBase() const
158             {
159                 return base_ == TIME;
160             }
163     // Member Operators
165         void operator=(const fieldAverageItem&);
168     // Friend Operators
170         friend bool operator==
171         (
172             const fieldAverageItem& a,
173             const fieldAverageItem& b
174         )
175         {
176             return
177                 a.fieldName_ == b.fieldName_
178              && a.mean_ == b.mean_
179              && a.prime2Mean_ == b.prime2Mean_
180              && a.base_ == b.base_;
181         }
183         friend bool operator!=
184         (
185             const fieldAverageItem& a,
186             const fieldAverageItem& b
187         )
188         {
189             return !(a == b);
190         }
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 // ************************************************************************* //