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-2020 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; // (default = on)
34  prime2Mean on; // (default = off)
35  base time; // time or iteration (default = time)
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 
64 namespace functionObjects
65 {
66 
67 class fieldAverage;
68 
69 /*---------------------------------------------------------------------------*\
70  Class fieldAverageItem Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 class fieldAverageItem
74 {
75  // Private Data
76 
77  //- Field name
78  word fieldName_;
79 
80  //- Compute mean flag
81  Switch mean_;
82 
83  //- Name of mean field
84  word meanFieldName_;
85 
86  //- Compute prime-squared mean flag
87  Switch prime2Mean_;
88 
89  //- Name of prime-squared mean field
90  word prime2MeanFieldName_;
91 
92 
93 public:
94 
95  // Static data
96 
97  // File and field name extensions
98 
99  //- Mean average
100  static const word meanExt;
101 
102  //- Prime-squared average
103  static const word prime2MeanExt;
104 
105 
106  // Constructors
107 
108  //- Construct null
110 
111  //- Construct from Istream for given fieldAverage
112  fieldAverageItem(const fieldAverage& fa, Istream& is);
113 
114  //- Copy constructor
115  fieldAverageItem(const fieldAverageItem&) = default;
116 
117  //- Clone function
119  {
120  return autoPtr<fieldAverageItem>(new fieldAverageItem(*this));
121  }
122 
123  //- Class used for the read-construction of
124  // PtrLists of fieldAverageItem
125  class iNew
126  {
127  const fieldAverage& fa_;
128 
129  public:
131  iNew(const fieldAverage& fa)
132  :
133  fa_(fa)
134  {}
137  {
138  return autoPtr<fieldAverageItem>(new fieldAverageItem(fa_, is));
139  }
140  };
141 
142 
143  //- Destructor
145 
146 
147  // Member Functions
148 
149  // Access
150 
151  //- Return const access to the field name
152  const word& fieldName() const
153  {
154  return fieldName_;
155  }
156 
157  //- Return const access to the mean flag
158  const Switch& mean() const
159  {
160  return mean_;
161  }
162 
163  //- Return non-const access to the mean flag
164  Switch& mean()
165  {
166  return mean_;
167  }
168 
169  //- Return const access to the mean field name
170  const word& meanFieldName() const
171  {
172  return meanFieldName_;
173  }
174 
175  //- Return const access to the prime-squared mean flag
176  const Switch& prime2Mean() const
177  {
178  return prime2Mean_;
179  }
180 
181  //- Return non-const access to the prime-squared mean flag
182  Switch& prime2Mean()
183  {
184  return prime2Mean_;
185  }
186 
187  //- Return const access to the prime-squared mean field name
188  const word& prime2MeanFieldName() const
189  {
190  return prime2MeanFieldName_;
191  }
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace functionObjects
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Class used for the read-construction of.
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.
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
A class for handling words, derived from string.
Definition: word.H:59
Calculates average quantities for a user-specified selection of volumetric and surface fields...
Definition: fieldAverage.H:160
const word & meanFieldName() const
Return const access to the mean field name.
static const word meanExt
Mean average.
autoPtr< fieldAverageItem > operator()(Istream &is) const
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...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static const word prime2MeanExt
Prime-squared average.
Namespace for OpenFOAM.
autoPtr< fieldAverageItem > clone() const
Clone function.