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-2022 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  }
36  \endverbatim
37 
38 SourceFiles
39  fieldAverageItem.C
40  fieldAverageItemIO.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef fieldAverageItem_H
45 #define fieldAverageItem_H
46 
47 #include "NamedEnum.H"
48 #include "Switch.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class Istream;
57 
58 namespace functionObjects
59 {
60 
61 class fieldAverage;
62 
63 /*---------------------------------------------------------------------------*\
64  Class fieldAverageItem Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class fieldAverageItem
68 {
69  // Private Data
70 
71  //- Field name
72  word fieldName_;
73 
74  //- Compute mean flag
75  Switch mean_;
76 
77  //- Name of mean field
78  word meanFieldName_;
79 
80  //- Compute prime-squared mean flag
81  Switch prime2Mean_;
82 
83  //- Name of prime-squared mean field
84  word prime2MeanFieldName_;
85 
86 
87 public:
88 
89  // Static data
90 
91  // File and field name extensions
92 
93  //- Mean average
94  static const word meanExt;
95 
96  //- Prime-squared average
97  static const word prime2MeanExt;
98 
99 
100  // Constructors
101 
102  //- Construct null
104 
105  //- Construct from Istream for given fieldAverage
106  fieldAverageItem(const fieldAverage& fa, Istream& is);
107 
108  //- Copy constructor
109  fieldAverageItem(const fieldAverageItem&) = default;
110 
111  //- Clone function
113  {
114  return autoPtr<fieldAverageItem>(new fieldAverageItem(*this));
115  }
116 
117  //- Class used for the read-construction of
118  // PtrLists of fieldAverageItem
119  class iNew
120  {
121  const fieldAverage& fa_;
122 
123  public:
124 
125  iNew(const fieldAverage& fa)
126  :
127  fa_(fa)
128  {}
129 
131  {
132  return autoPtr<fieldAverageItem>(new fieldAverageItem(fa_, is));
133  }
134  };
135 
136 
137  //- Destructor
139 
140 
141  // Member Functions
142 
143  // Access
144 
145  //- Return const access to the field name
146  const word& fieldName() const
147  {
148  return fieldName_;
149  }
150 
151  //- Return const access to the mean flag
152  const Switch& mean() const
153  {
154  return mean_;
155  }
156 
157  //- Return non-const access to the mean flag
158  Switch& mean()
159  {
160  return mean_;
161  }
162 
163  //- Return const access to the mean field name
164  const word& meanFieldName() const
165  {
166  return meanFieldName_;
167  }
168 
169  //- Return const access to the prime-squared mean flag
170  const Switch& prime2Mean() const
171  {
172  return prime2Mean_;
173  }
174 
175  //- Return non-const access to the prime-squared mean flag
176  Switch& prime2Mean()
177  {
178  return prime2Mean_;
179  }
180 
181  //- Return const access to the prime-squared mean field name
182  const word& prime2MeanFieldName() const
183  {
184  return prime2MeanFieldName_;
185  }
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace functionObjects
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #endif
197 
198 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Class used for the read-construction of.
autoPtr< fieldAverageItem > operator()(Istream &is) const
Helper class to describe what form of averaging to apply. A set will be applied to each base field in...
static const word meanExt
Mean average.
const Switch & mean() const
Return const access to the mean flag.
const word & prime2MeanFieldName() const
Return const access to the prime-squared mean field name.
static const word prime2MeanExt
Prime-squared average.
const word & fieldName() const
Return const access to the field name.
autoPtr< fieldAverageItem > clone() const
Clone function.
const word & meanFieldName() const
Return const access to the mean field name.
const Switch & prime2Mean() const
Return const access to the prime-squared mean flag.
Calculates average quantities for a user-specified selection of volumetric and surface fields.
Definition: fieldAverage.H:163
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.