FreeFOAM The Cross-Platform CFD Toolkit
fieldAverageItem.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::fieldAverageItem
26 
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:
30 
31  @verbatim
32  {
33  mean on;
34  prime2Mean on;
35  base time; // iteration
36  }
37  @endverbatim
38 
39 SourceFiles
40  fieldAverageItem.C
41  fieldAverageItemIO.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef fieldAverageItem_H
46 #define fieldAverageItem_H
47 
48 #include <OpenFOAM/NamedEnum.H>
49 #include <OpenFOAM/Switch.H>
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of classes
57 class Istream;
58 class Ostream;
59 
60 // Forward declaration of friend functions and operators
61 class fieldAverageItem;
62 Istream& operator>>(Istream&, fieldAverageItem&);
63 Ostream& operator<<(Ostream&, const fieldAverageItem&);
64 
65 
66 /*---------------------------------------------------------------------------*\
67  Class fieldAverageItem Declaration
68 \*---------------------------------------------------------------------------*/
69 
71 {
72 public:
73 
74  // Public data
75 
76  //- Enumeration defining the averaging base type
77  enum baseType
78  {
81  };
82 
83 
84 private:
85 
86  // Private data
87 
88  //- Field name
89  word fieldName_;
90 
91  //- Compute mean flag
92  Switch mean_;
93 
94  //- Compute prime-squared mean flag
95  Switch prime2Mean_;
96 
97  //- Averaging base type names
98  static const NamedEnum<baseType, 2> baseTypeNames_;
99 
100  //- Averaging base type
101  baseType base_;
102 
103 
104 public:
105 
106  // Constructors
107 
108  //- Construct null
110 
111  //- Construct from Istream
113 
114  //- Construct as copy
116 
117 
118  // Destructor
119 
121 
122 
123  // Member Functions
124 
125  // Access
126 
127  //- Return const access to the field name
128  const word& fieldName() const
129  {
130  return fieldName_;
131  }
132 
133  //- Return const access to the mean flag
134  const Switch& mean() const
135  {
136  return mean_;
137  }
138 
139  //- Return const access to the prime-squared mean flag
140  const Switch& prime2Mean() const
141  {
142  return prime2Mean_;
143  }
144 
145  //- Return averaging base type name
146  const word base() const
147  {
148  return baseTypeNames_[base_];
149  }
150 
151  //- Return true if base is ITER
152  Switch ITERBase() const
153  {
154  return base_ == ITER;
155  }
156 
157  //- Return true if base is time
158  Switch timeBase() const
159  {
160  return base_ == TIME;
161  }
162 
163 
164  // Member Operators
165 
166  void operator=(const fieldAverageItem&);
167 
168  // Friend Operators
169 
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  }
182 
183  friend bool operator!=
184  (
185  const fieldAverageItem& a,
186  const fieldAverageItem& b
187  )
188  {
189  return !(a == b);
190  }
191 
192  // IOstream Operators
193 
195  friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************ vim: set sw=4 sts=4 et: ************************ //