pressure.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::pressure
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Provides several methods to convert an input pressure
35  field into derived forms, including:
36 
37  - static pressure
38  \f[
39  p_s = p_{ref} + \rho p_k
40  \f]
41  - total pressure
42  \f[
43  p_0 = p_{ref} + p + 0.5 \rho |\vec U|^2
44  \f]
45  - isentropic pressure
46  \f[
47  p_i = p*(1 + ((\gamma-1)*M^2)/2)^{(\gamma/(\gamma - 1))}
48  \f]
49  - static pressure coefficient
50  \f[
51  Cp = \frac{p_s - p_{\inf}}{0.5 \rho_{\inf} |\vec U_{\inf}|^2}
52  \f]
53  - total pressure coefficient
54  \f[
55  Cp_0 = \frac{p_0 - p_{\inf}}{0.5 \rho_{\inf} |\vec U_{\inf}|^2}
56  \f]
57 
58  where
59  \vartable
60  \rho | Density [kg/m3]
61  \vec U | Velocity [m/s]
62  \rho_{\inf} | Freestream density [kg/m3]
63  p_{\inf} | Freestream pressure [Pa]
64  U_{\inf} | Freestream velocity [m/s]
65  p_k | Kinematic pressure (p/rho)[m2/s2]
66  p_s | Static pressure [Pa]
67  p_0 | Total pressure [Pa]
68  p_{ref} | Reference pressure level [Pa]
69  p_i | Total isentropic pressure
70  Cp | Pressure coefficient
71  Cp_0 | Total pressure coefficient
72  \gamma | Specific heat ratio
73  \endvartable
74 
75  The function object will operate on both kinematic (\f$ p_k \f$) and static
76  pressure (\f$ p \f$) fields.
77 
78  Operands:
79  \table
80  Operand | Type | Location
81  input | volScalarField | $FOAM_CASE/<time>/<inpField>
82  output file | - | -
83  output field | volScalarField | $FOAM_CASE/<time>/<outField>
84  \endtable
85 
86 Usage
87  Minimal example by using \c system/controlDict.functions:
88  \verbatim
89  pressure1
90  {
91  // Mandatory entries (unmodifiable)
92  type pressure;
93  libs (fieldFunctionObjects);
94 
95  // Mandatory entries (runtime modifiable)
96  mode <option>;
97 
98  // Optional entries (runtime modifiable)
99  field <pName>;
100  U <UName>;
101  rho <rhoName>;
102  rhoInf 1.0; // enabled if rho=rhoInf
103  pRef 0.0;
104  hydroStaticMode none;
105  g (0 -9.81 0); // enabled if hydroStaticMode != none
106  hRef 0.0; // enabled if hydroStaticMode != none
107  pInf 0.0;
108  UInf (1 0 0);
109 
110  // Optional (inherited) entries
111  ...
112  }
113  \endverbatim
114 
115  where the entries mean:
116  \table
117  Property | Description | Type | Req'd | Dflt
118  type | Type name: pressure | word | yes | -
119  libs | Library name: fieldFunctionObjects | word | yes | -
120  mode | Calculation mode (see below) | word | yes | -
121  field | Name of the pressure field | word | no | p
122  U | Name of the velocity field | word | no | U
123  rho | Name of the density field | word | no | rho
124  rhoInf | Freestream density for coefficient calculation | scalar <!--
125  --> | conditional| -
126  pRef | Reference pressure for total pressure | scalar | no | 0
127  hydrostaticMode | Hydrostatic contributions (see below) | word | no | none
128  g | Gravity vector (see below) | vector | no | -
129  hRef | Reference height (see below) | scalar | no | -
130  pInf | Freestream pressure for coefficient calculation | scalar | no | -
131  UInf | Freestream velocity for coefficient calculation | vector | no | -
132  \endtable
133 
134  Options for the \c mode entry:
135  \verbatim
136  static | static pressure
137  total | total pressure
138  isentropic | isentropic pressure
139  staticCoeff | static pressure coefficient
140  totalCoeff | total pressure coefficient
141  \endverbatim
142 
143  The optional \c hydrostaticMode entry provides handling for the term
144  \f$ \rho (\vec{g} \dot \vec{h})\f$ where options include
145  \verbatim
146  none | not included
147  add | add the term, e.g. to convert from p_rgh to p
148  subtract | subtract the term, e.g. to convert from p to p_rgh
149  \endverbatim
150 
151  If the \c hydrostaticMode is active, values are also required for
152  gravity, \c g, and reference height, \c hRef. By default these will be
153  retrieved from the database. When these values are not available
154  the user must provide them, e.g.
155  \verbatim
156  g (0 -9.81 0);
157  hRef 0;
158  \endverbatim
159 
160  The inherited entries are elaborated in:
161  - \link functionObject.H \endlink
162  - \link fieldExpression.H \endlink
163 
164  Usage by the \c postProcess utility is not available.
165 
166 See also
167  - Foam::functionObject
168  - Foam::functionObjects::fieldExpression
169  - Foam::functionObjects::fvMeshFunctionObject
170  - ExtendedCodeGuide::functionObjects::field::pressure
171 
172 SourceFiles
173  pressure.C
174 
175 \*---------------------------------------------------------------------------*/
176 
177 #ifndef functionObjects_pressure_H
178 #define functionObjects_pressure_H
179 
180 #include "fieldExpression.H"
181 #include "volFieldsFwd.H"
182 #include "dimensionedVector.H"
183 #include "dimensionedScalar.H"
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 namespace Foam
188 {
189 namespace functionObjects
190 {
191 
192 /*---------------------------------------------------------------------------*\
193  Class pressure Declaration
194 \*---------------------------------------------------------------------------*/
195 
196 class pressure
197 :
198  public fieldExpression
199 {
200 public:
201 
202  // Public Data Types
203 
204  //- Enumeration for pressure calculation mode
205  enum mode : unsigned
206  {
207  STATIC = (1 << 0),
208  TOTAL = (1 << 1),
209  ISENTROPIC = (1 << 2),
210  COEFF = (1 << 3),
211  STATIC_COEFF = (STATIC | COEFF),
212  TOTAL_COEFF = (TOTAL | COEFF),
213  };
214 
215  static const Enum<mode> modeNames;
216 
217  //- Enumeration for hydrostatic contributions
218  enum hydrostaticMode : unsigned
219  {
220  NONE = 0,
221  ADD,
222  SUBTRACT
223  };
224 
225  static const Enum<hydrostaticMode> hydrostaticModeNames;
226 
227 
228 private:
229 
230  // Private Data
231 
232  //- Calculation mode
233  mode mode_;
234 
235  //- Hydrostatic constribution mode
236  hydrostaticMode hydrostaticMode_;
237 
238  //- Name of velocity field
239  word UName_;
240 
241  //- Name of density field
242  word rhoName_;
243 
244 
245  // Total pressure calculation
246 
247  //- Reference pressure level
248  scalar pRef_;
249 
250 
251  // Pressure coefficient calculation
252 
253  //- Freestream pressure
254  scalar pInf_;
255 
256  //- Freestream velocity
257  vector UInf_;
258 
259  //- Freestream density
260  scalar rhoInf_;
261 
262  //- Flag to show whether rhoInf has been initialised
263  bool rhoInfInitialised_;
264 
265 
266  //- p +/- rgh calculation
267 
268  //- Gravity vector
269  mutable dimensionedVector g_;
270 
271  //- Flag to show whether g has been initialised
272  bool gInitialised_;
273 
274  //- Reference height
275  mutable dimensionedScalar hRef_;
276 
277  //- Flag to show whether hRef has been initialised
278  bool hRefInitialised_;
279 
280 
281  // Private Member Functions
282 
283  //- Return the name of the derived pressure field
284  word resultName() const;
285 
286  //- Multiply the static pressure p by rhoInf if necessary and return
287  tmp<volScalarField> rhoScale(const volScalarField& p) const;
288 
289  //- Multiply the given field by rho or rhoInf as appropriate and return
290  tmp<volScalarField> rhoScale
291  (
292  const volScalarField& p,
293  const tmp<volScalarField>& tsf
294  ) const;
295 
296  //- Add the hydrostatic contribution
297  void addHydrostaticContribution
298  (
299  const volScalarField& p,
300  volScalarField& prgh
301  ) const;
302 
303  //- Calculate and return the pressure
304  tmp<volScalarField> calcPressure
305  (
306  const volScalarField& p,
307  const tmp<volScalarField>& tp
308  ) const;
309 
310  //- Convert to coeff by applying the freestream dynamic pressure scaling
311  tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
312 
313  //- Calculate the derived pressure field and return true if successful
314  virtual bool calc();
315 
316 
317 public:
318 
319  //- Runtime type information
320  TypeName("pressure");
321 
322 
323  // Constructors
324 
325  //- Construct from Time and dictionary
326  pressure
327  (
328  const word& name,
329  const Time& runTime,
330  const dictionary&
331  );
332 
333  //- No copy construct
334  pressure(const pressure&) = delete;
335 
336  //- No copy assignment
337  void operator=(const pressure&) = delete;
338 
339 
340  //- Destructor
341  virtual ~pressure() = default;
342 
343 
344  // Member Functions
345 
346  //- Read the pressure data
347  virtual bool read(const dictionary&);
348 };
349 
350 
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352 
353 } // End namespace functionObjects
354 } // End namespace Foam
355 
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 
358 #endif
359 
360 // ************************************************************************* //
Foam::functionObjects::pressure::STATIC
Static pressure.
Definition: pressure.H:360
Foam::functionObjects::pressure::TypeName
TypeName("pressure")
Runtime type information.
Foam::functionObjects::pressure::mode
mode
Enumeration for pressure calculation mode.
Definition: pressure.H:358
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Enum< mode >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::pressure::ADD
Definition: pressure.H:374
Foam::functionObjects::pressure::~pressure
virtual ~pressure()=default
Destructor.
Foam::functionObjects::pressure::TOTAL_COEFF
Definition: pressure.H:365
Foam::functionObjects::pressure::hydrostaticModeNames
static const Enum< hydrostaticMode > hydrostaticModeNames
Definition: pressure.H:378
Foam::functionObjects::pressure
Provides several methods to convert an input pressure field into derived forms, including:
Definition: pressure.H:349
Foam::functionObjects::pressure::SUBTRACT
Definition: pressure.H:375
Foam::functionObjects::pressure::ISENTROPIC
Isentropic pressure.
Definition: pressure.H:362
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
Foam::functionObjects::pressure::read
virtual bool read(const dictionary &)
Read the pressure data.
Definition: pressure.C:377
Foam::functionObjects::pressure::TOTAL
Total pressure.
Definition: pressure.H:361
Foam::functionObjects::pressure::pressure
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: pressure.C:350
Foam::functionObjects::pressure::NONE
Definition: pressure.H:373
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::functionObjects::pressure::STATIC_COEFF
Definition: pressure.H:364
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dimensionedVector.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::dimensioned< vector >
Foam::functionObjects::pressure::hydrostaticMode
hydrostaticMode
Enumeration for hydrostatic contributions.
Definition: pressure.H:371
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::functionObjects::pressure::COEFF
Coefficient manipulator.
Definition: pressure.H:363
dimensionedScalar.H
Foam::functionObjects::pressure::modeNames
static const Enum< mode > modeNames
Definition: pressure.H:368
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:120
Foam::Vector< scalar >
fieldExpression.H
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::functionObjects::pressure::operator=
void operator=(const pressure &)=delete
No copy assignment.