Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::pressure
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Provides several methods to convert an input pressure field into derived
35 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 | <time>/inputField
82 output file | - | -
83 output field | volScalarField | <time>/outputField
84 \endtable
85
86Usage
87 Minimal example by using \c system/controlDict.functions:
88 \verbatim
89 pressureFO
90 {
91 // Mandatory entries
92 type pressure;
93 libs (fieldFunctionObjects);
94 mode <word>;>;
95
96 // Optional entries
97 field <word>;
98 U <word>;
99 rho <word>;
100 rhoInf <scalar>; // enabled if rho=rhoInf
101 pRef <scalar>;
102 hydroStaticMode <word>;
103 g <vector>; // enabled if hydroStaticMode != none
104 hRef <scalar>; // enabled if hydroStaticMode != none
105 pInf <scalar>;
106 UInf <scalar>;
107
108 // Inherited entries
109 ...
110 }
111 \endverbatim
112
113 where the entries mean:
114 \table
115 Property | Description | Type | Reqd | Deflt
116 type | Type name: pressure | word | yes | -
117 libs | Library name: fieldFunctionObjects | word | yes | -
118 mode | Calculation mode (see below) | word | yes | -
119 field | Name of the pressure field | word | no | p
120 U | Name of the velocity field | word | no | U
121 rho | Name of the density field | word | no | rho
122 rhoInf | Freestream density for coefficient calculation | scalar <!--
123 --> | conditional| -
124 pRef | Reference pressure for total pressure | scalar | no | 0
125 hydrostaticMode | Hydrostatic contributions (see below) | word | no | none
126 g | Gravity vector (see below) | vector | no | -
127 hRef | Reference height (see below) | scalar | no | -
128 pInf | Freestream pressure for coefficient calculation | scalar | no | -
129 UInf | Freestream velocity for coefficient calculation | vector | no | -
130 \endtable
131
132 Options for the \c mode entry:
133 \verbatim
134 static | static pressure
135 total | total pressure
136 isentropic | isentropic pressure
137 staticCoeff | static pressure coefficient
138 totalCoeff | total pressure coefficient
139 \endverbatim
140
141 The optional \c hydrostaticMode entry provides handling for the term
142 \f$ \rho (\vec{g} \dot \vec{h})\f$ where options include
143 \verbatim
144 none | not included
145 add | add the term, e.g. to convert from p_rgh to p
146 subtract | subtract the term, e.g. to convert from p to p_rgh
147 \endverbatim
148
149 If the \c hydrostaticMode is active, values are also required for
150 gravity, \c g, and reference height, \c hRef. By default these will be
151 retrieved from the database. When these values are not available
152 the user must provide them, e.g.
153 \verbatim
154 g (0 -9.81 0);
155 hRef 0;
156 \endverbatim
157
158 The inherited entries are elaborated in:
159 - \link fieldExpression.H \endlink
160
161SourceFiles
162 pressure.C
163
164\*---------------------------------------------------------------------------*/
165
166#ifndef Foam_functionObjects_pressure_H
167#define Foam_functionObjects_pressure_H
168
169#include "fieldExpression.H"
170#include "volFieldsFwd.H"
171#include "dimensionedVector.H"
172#include "dimensionedScalar.H"
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176namespace Foam
177{
178namespace functionObjects
179{
180
181/*---------------------------------------------------------------------------*\
182 Class pressure Declaration
183\*---------------------------------------------------------------------------*/
184
185class pressure
186:
187 public fieldExpression
188{
189public:
190
191 // Public Data Types
192
193 //- Enumeration for pressure calculation mode
194 enum mode : unsigned
195 {
196 STATIC = (1 << 0),
197 TOTAL = (1 << 1),
198 ISENTROPIC = (1 << 2),
199 COEFF = (1 << 3),
201 TOTAL_COEFF = (TOTAL | COEFF),
202 };
203
204 //- Names for mode types
205 static const Enum<mode> modeNames;
206
207 //- Enumeration for hydrostatic contributions
208 enum hydrostaticMode : unsigned
209 {
210 NONE = 0,
211 ADD,
213 };
214
215 //- Names for hydrostaticMode
216 static const Enum<hydrostaticMode> hydrostaticModeNames;
217
218
219private:
220
221 // Private Data
222
223 //- Calculation mode
224 mode mode_;
225
226 //- Hydrostatic constribution mode
227 hydrostaticMode hydrostaticMode_;
228
229 //- Name of velocity field
230 word UName_;
231
232 //- Name of density field
233 word rhoName_;
234
235
236 // Total pressure calculation
237
238 //- Reference pressure level
239 scalar pRef_;
240
241
242 // Pressure coefficient calculation
243
244 //- Freestream pressure
245 scalar pInf_;
246
247 //- Freestream velocity
248 vector UInf_;
249
250 //- Freestream density
251 scalar rhoInf_;
252
253 //- Flag to show whether rhoInf has been initialised
254 bool rhoInfInitialised_;
255
256
257 //- p +/- rgh calculation
258
259 //- Gravity vector
260 mutable dimensionedVector g_;
261
262 //- Flag to show whether g has been initialised
263 bool gInitialised_;
264
265 //- Reference height
266 mutable dimensionedScalar hRef_;
267
268 //- Flag to show whether hRef has been initialised
269 bool hRefInitialised_;
270
271
272 // Private Member Functions
273
274 //- Return the name of the derived pressure field
275 word resultName() const;
276
277 //- Multiply the static pressure p by rhoInf if necessary and return
278 tmp<volScalarField> rhoScale(const volScalarField& p) const;
279
280 //- Multiply the given field by rho or rhoInf as appropriate and return
281 tmp<volScalarField> rhoScale
282 (
283 const volScalarField& p,
284 const tmp<volScalarField>& tsf
285 ) const;
286
287 //- Add the hydrostatic contribution
288 void addHydrostaticContribution
289 (
290 const volScalarField& p,
291 volScalarField& prgh
292 ) const;
293
294 //- Calculate and return the pressure
295 tmp<volScalarField> calcPressure
296 (
297 const volScalarField& p,
298 const tmp<volScalarField>& tp
299 ) const;
300
301 //- Convert to coeff by applying the freestream dynamic pressure scaling
302 tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
303
304 //- Calculate the derived pressure field and return true if successful
305 virtual bool calc();
306
307
308public:
309
310 //- Runtime type information
311 TypeName("pressure");
312
313
314 // Constructors
315
316 //- Construct from name, Time and dictionary
318 (
319 const word& name,
320 const Time& runTime,
321 const dictionary&
322 );
323
324 //- No copy construct
325 pressure(const pressure&) = delete;
326
327 //- No copy assignment
328 void operator=(const pressure&) = delete;
329
330
331 //- Destructor
332 virtual ~pressure() = default;
333
335 // Member Functions
336
337 //- Read the function-object dictionary
338 virtual bool read(const dictionary& dict);
339};
340
341
342// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343
344} // End namespace functionObjects
345} // End namespace Foam
346
347// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349#endif
351// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
Provides several methods to convert an input pressure field into derived forms, including:
Definition pressure.H:337
pressure(const pressure &)=delete
No copy construct.
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from name, Time and dictionary.
Definition pressure.C:329
static const Enum< hydrostaticMode > hydrostaticModeNames
Names for hydrostaticMode.
Definition pressure.H:373
hydrostaticMode
Enumeration for hydrostatic contributions.
Definition pressure.H:364
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition pressure.C:356
void operator=(const pressure &)=delete
No copy assignment.
virtual ~pressure()=default
Destructor.
static const Enum< mode > modeNames
Names for mode types.
Definition pressure.H:358
mode
Enumeration for pressure calculation mode.
Definition pressure.H:346
@ COEFF
Coefficient manipulator.
Definition pressure.H:350
@ ISENTROPIC
Isentropic pressure.
Definition pressure.H:349
TypeName("pressure")
Runtime type information.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Vector< scalar > vector
Definition vector.H:57
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Forwards and collection of common volume field types.