pressure.H 9.21 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
OpenFOAM bot's avatar
OpenFOAM bot committed
6
7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2012-2016 OpenFOAM Foundation
9
    Copyright (C) 2016-2020 OpenCFD Ltd.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
28
    Foam::functionObjects::pressure
29

30
Group
31
    grpFieldFunctionObjects
32

33
Description
34
    Includes tools to manipulate the pressure into different forms.
35

36
    These currently include:
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 |U|^2
44
        \f]
45
46
    - isentropic pressure
        \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} |U_{\inf}|^2}
52
        \f]
53
    - total pressure coefficient
54
        \f[
55
            Cp_0 = \frac{p_0 - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
56
        \f]
57

58
59
    where
    \vartable
60
61
62
63
64
65
        \rho        | Density [kg/m3]
        U           | Velocity [m/s]
        \rho_{\inf} | Freestream density [kg/m3]
        p_{\inf}    | Freestream pressure [Pa]
        U_{\inf}    | Freestream velocity [m/s]
        p_k         | Kinematic pressure (p/rho)[m2/s2]
66
        p_s         | Statoc pressure [Pa]
67
68
        p_0         | Total pressure [Pa]
        p_{ref}     | Reference pressure level [Pa]
69
        p_i         | Total isentropic pressure
70
71
        Cp          | Pressure coefficient
        Cp_0        | Total pressure coefficient
72
73
74
    \endvartable

    The function object will operate on both kinematic (\f$ p_k \f$) and static
75
    pressure (\f$ p \f$) fields, and the result is written as a
76
77
    volScalarField.

Andrew Heather's avatar
Andrew Heather committed
78
Usage
79
80
    Example of function object specification to calculate pressure coefficient:
    \verbatim
81
    pressure1
82
    {
83
        type        pressure;
84
        libs        ("libfieldFunctionObjects.so");
85
        ...
86
        mode        staticCoeff;
87
88
89
    }
    \endverbatim

Andrew Heather's avatar
Andrew Heather committed
90
    Where the entries comprise:
91
    \table
92
        Property     | Description                 | Required   | Default value
93
        type         | type name: pressure         | yes        |
94
95
96
97
        field        | Name of the pressure field  | no         | p
        U            | Name of the velocity field  | no         | U
        rho          | Name of the density field   | no         | rho
        result       | Name of the resulting field | no         | derived from p
98
        mode         | Calculation mode (see below) | yes       |
99
        pRef         | Reference pressure for total pressure | no | 0
100
101
        pInf         | Freestream pressure for coefficient calculation | no |
        UInf         | Freestream velocity for coefficient calculation | no |
102
        rhoInf       | Freestream density for coefficient calculation  | no |
103
        hydrostaticMode | Hydrostatic contributions (see below) | no | none
104
105
        g            | Gravity vector (see below) | no |
        hRef         | Reference height (see below) | no |
106
107
    \endtable

108
109
110
111
112
113
114
115
    The \c mode entry is used to select the type of pressure that is calculated.
    Selections include:
    - static
    - total
    - isentropic
    - staticCoeff
    - totalCoeff

116
117
118
119
120
121
    The optional \c hydrostaticMode entry provides handling for the term
    \f$ \rho (\vec{g} \dot \vec{h})\f$ where options include
    - \c none : not included
    - \c add : add the term, e.g. to convert from p_rgh to p
    - \c subtract : subtract the term, e.g. to convert from p to p_rgh

122
123
124
125
126
127
128
129
130
    If the \c hydrostaticMode is active, values are also required for
    gravity, \c g, and reference height, \c hRef.  By default these will be
    retrieved from the database.  When these values are not available
    the user must provide them, e.g.
    \verbatim
        g           (0 -9.81 0);
        hRef        0;
    \endverbatim

131

132
See also
133
    Foam::functionObjects::fieldExpression
134
135
    Foam::functionObjects::fvMeshFunctionObject

136
SourceFiles
137
    pressure.C
138
139
140

\*---------------------------------------------------------------------------*/

141
142
#ifndef functionObjects_pressure_H
#define functionObjects_pressure_H
143

144
#include "fieldExpression.H"
145
#include "volFieldsFwd.H"
146
#include "dimensionedVector.H"
147
148
149
150
151
152
#include "dimensionedScalar.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
153
154
155
namespace functionObjects
{

156
/*---------------------------------------------------------------------------*\
157
                        Class pressure Declaration
158
159
\*---------------------------------------------------------------------------*/

160
class pressure
161
:
162
    public fieldExpression
163
{
164
165
166
167
168
169
170
public:

    // Public Data Types

        //- Enumeration for pressure calculation mode
        enum mode : unsigned
        {
171
172
173
174
            STATIC       = (1 << 0), //!< Static pressure
            TOTAL        = (1 << 1), //!< Total pressure
            ISENTROPIC   = (1 << 2), //!< Isentropic pressure
            COEFF        = (1 << 3), //!< Coefficient manipulator
175
            STATIC_COEFF = (STATIC | COEFF),
176
            TOTAL_COEFF  = (TOTAL | COEFF),
177
178
179
180
        };

        static const Enum<mode> modeNames;

181
182
183
184
185
186
187
188
189
190
        //- Enumeration for hydrostatic contributions
        enum hydrostaticMode : unsigned
        {
            NONE = 0,
            ADD,
            SUBTRACT
        };

        static const Enum<hydrostaticMode> hydrostaticModeNames;

191
192
193

private:

194
195
    // Private data

196
197
198
        //- Calculation mode
        mode mode_;

199
200
201
        //- Hydrostatic constribution mode
        hydrostaticMode hydrostaticMode_;

202
203
204
        //- Name of velocity field, default is "U"
        word UName_;

205
206
207
        //- Name of density field, default is "rho"
        word rhoName_;

208

209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
        // Total pressure calculation

            //- Reference pressure level
            scalar pRef_;


        // Pressure coefficient calculation

            //- Freestream pressure
            scalar pInf_;

            //- Freestream velocity
            vector UInf_;

            //- Freestream density
            scalar rhoInf_;

226
227
228
            //- Flag to show whether rhoInf has been initialised
            bool rhoInfInitialised_;

229

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
        //- p +/- rgh calculation

            //- Gravity vector
            mutable dimensionedVector g_;

            //- Flag to show whether g has been initialised
            bool gInitialised_;

            //- Reference height
            mutable dimensionedScalar hRef_;

            //- Flag to show whether hRef has been initialised
            bool hRefInitialised_;


245
246
247
    // Private Member Functions

        //- Return the name of the derived pressure field
248
        word resultName() const;
249

250
251
        //- Multiply the static pressure p by rhoInf if necessary and return
        tmp<volScalarField> rhoScale(const volScalarField& p) const;
252

253
254
255
256
257
258
        //- Multiply the given field by rho or rhoInf as appropriate and return
        tmp<volScalarField> rhoScale
        (
            const volScalarField& p,
            const tmp<volScalarField>& tsf
        ) const;
259

260
        //- Add the hydrostatic contribution
261
262
263
264
265
        void addHydrostaticContribution
        (
            const volScalarField& p,
            volScalarField& prgh
        ) const;
266

267
268
        //- Calculate and return the pressure
        tmp<volScalarField> calcPressure
269
270
271
272
        (
            const volScalarField& p,
            const tmp<volScalarField>& tp
        ) const;
273

274
        //- Convert to coeff by applying the freestream dynamic pressure scaling
275
        tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
276

277
278
279
        //- Calculate the derived pressure field and return true if successful
        virtual bool calc();

280
281
282
283

public:

    //- Runtime type information
284
    TypeName("pressure");
285
286
287
288


    // Constructors

289
        //- Construct from Time and dictionary
290
        pressure
291
292
        (
            const word& name,
293
294
            const Time& runTime,
            const dictionary&
295
296
297
298
        );


    //- Destructor
299
    virtual ~pressure() = default;
300
301
302
303


    // Member Functions

304
        //- Read the pressure data
305
        virtual bool read(const dictionary&);
306
307
308
309
310
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

311
} // End namespace functionObjects
312
313
314
315
316
317
318
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //