fieldAverageItem.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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::functionObjects::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  window 200; // optional averaging window
37  windowName w1; // optional window name (default = "")
38  }
39  \endverbatim
40 
41  The averaging window corresponds to the averaging interval (iters or time)
42  If not specified, the averaging is over 'all iters/time'
43 
44 SourceFiles
45  fieldAverageItem.C
46  fieldAverageItemIO.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef fieldAverageItem_H
51 #define fieldAverageItem_H
52 
53 #include "NamedEnum.H"
54 #include "Switch.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward declaration of classes
62 class Istream;
63 class Ostream;
64 
65 namespace functionObjects
66 {
67 
68 // Forward declaration of friend functions and operators
69 class fieldAverageItem;
70 Istream& operator>>(Istream&, fieldAverageItem&);
71 Ostream& operator<<(Ostream&, const fieldAverageItem&);
72 
73 /*---------------------------------------------------------------------------*\
74  Class fieldAverageItem Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class fieldAverageItem
78 {
79 public:
80 
81  // Public data
82 
83  // File and field name extensions
84 
85  //- Mean average
86  static const word EXT_MEAN;
87 
88  //- Prime-squared average
89  static const word EXT_PRIME2MEAN;
90 
91  //- Enumeration defining the averaging base type
92  enum class baseType
93  {
94  iter,
95  time
96  };
97 
98 
99 private:
100 
101  // Private data
102 
103  //- Field name
104  word fieldName_;
105 
106  //- Compute mean flag
107  Switch mean_;
108 
109  //- Name of mean field
110  word meanFieldName_;
111 
112  //- Compute prime-squared mean flag
113  Switch prime2Mean_;
114 
115  //- Name of prime-squared mean field
116  word prime2MeanFieldName_;
117 
118  //- Averaging base type names
119  static const NamedEnum<baseType, 2> baseTypeNames_;
120 
121  //- Averaging base type
122  baseType base_;
123 
124  //- Averaging window - defaults to -1 for 'all iters/time'
125  scalar window_;
126 
127  //- Averaging window name - defaults to 'window'
128  word windowName_;
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct null
137 
138  //- Construct from Istream
140 
141  //- Construct as copy
143 
144 
145  //- Destructor
147 
148 
149  // Member Functions
150 
151  // Access
152 
153  //- Return const access to the field name
154  const word& fieldName() const
155  {
156  return fieldName_;
157  }
158 
159  //- Return const access to the mean flag
160  const Switch& mean() const
161  {
162  return mean_;
163  }
164 
165  //- Return non-const access to the mean flag
166  Switch& mean()
167  {
168  return mean_;
169  }
170 
171  //- Return const access to the mean field name
172  const word& meanFieldName() const
173  {
174  return meanFieldName_;
175  }
176 
177  //- Return const access to the prime-squared mean flag
178  const Switch& prime2Mean() const
179  {
180  return prime2Mean_;
181  }
182 
183  //- Return non-const access to the prime-squared mean flag
184  Switch& prime2Mean()
185  {
186  return prime2Mean_;
187  }
188 
189  //- Return const access to the prime-squared mean field name
190  const word& prime2MeanFieldName() const
191  {
192  return prime2MeanFieldName_;
193  }
194 
195  //- Return averaging base type name
196  const word base() const
197  {
198  return baseTypeNames_[base_];
199  }
200 
201  //- Return true if base is iter
202  Switch iterBase() const
203  {
204  return base_ == baseType::iter;
205  }
206 
207  //- Return true if base is time
208  Switch timeBase() const
209  {
210  return base_ == baseType::time;
211  }
213  scalar window() const
214  {
215  return window_;
216  }
218  const word& windowName() const
219  {
220  return windowName_;
221  }
222 
223 
224  // Member Operators
225 
226  void operator=(const fieldAverageItem&);
227 
228 
229  // Friend Operators
230 
231  friend bool operator==
232  (
233  const fieldAverageItem& a,
234  const fieldAverageItem& b
235  )
236  {
237  return
238  a.fieldName_ == b.fieldName_
239  && a.mean_ == b.mean_
240  && a.meanFieldName_ == b.meanFieldName_
241  && a.prime2Mean_ == b.prime2Mean_
242  && a.prime2MeanFieldName_ == b.prime2MeanFieldName_
243  && a.base_ == b.base_
244  && a.window_ == b.window_
245  && a.windowName_ == b.windowName_;
246  }
247 
248  friend bool operator!=
249  (
250  const fieldAverageItem& a,
251  const fieldAverageItem& b
252  )
253  {
254  return !(a == b);
255  }
256 
257 
258  // IOstream Operators
259 
261  friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
262 };
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 } // End namespace functionObjects
268 } // End namespace Foam
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 #endif
273 
274 // ************************************************************************* //
friend Istream & operator>>(Istream &, fieldAverageItem &)
friend Ostream & operator<<(Ostream &, const fieldAverageItem &)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const word & prime2MeanFieldName() const
Return const access to the prime-squared mean field name.
baseType
Enumeration defining the averaging base type.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
static const word EXT_PRIME2MEAN
Prime-squared average.
void operator=(const fieldAverageItem &)
Switch timeBase() const
Return true if base is time.
Switch iterBase() const
Return true if base is iter.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
A class for handling words, derived from string.
Definition: word.H:59
Ostream & operator<<(Ostream &, const fieldAverageItem &)
const word & meanFieldName() const
Return const access to the mean field name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word base() const
Return averaging base type name.
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step...
const Switch & prime2Mean() const
Return const access to the prime-squared mean flag.
const word & fieldName() const
Return const access to the field name.
const Switch & mean() const
Return const access to the mean flag.
Helper class to describe what form of averaging to apply. A set will be applied to each base field in...
Istream & operator>>(Istream &, fieldAverageItem &)
static const word EXT_MEAN
Mean average.
Namespace for OpenFOAM.