pressure.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) 2012-2018 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::pressure
26 
27 Description
28  Includes tools to manipulate the pressure into different forms.
29 
30  These currently include:
31  - static pressure
32  \f[
33  p = \rho p_k
34  \f]
35  - total pressure
36  \f[
37  p_0 = p_{ref} + p + 0.5 \rho |U|^2
38  \f]
39  - static pressure coefficient
40  \f[
41  Cp = \frac{p - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
42  \f]
43  - total pressure coefficient
44  \f[
45  Cp_0 = \frac{p_0 - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
46  \f]
47 
48  where
49  \vartable
50  \rho | Density [kg/m3]
51  U | Velocity [m/s]
52  \rho_{\inf} | Freestream density [kg/m3]
53  p_{\inf} | Freestream pressure [Pa]
54  U_{\inf} | Freestream velocity [m/s]
55  p_k | Kinematic pressure (p/rho)[m2/s2]
56  p | Pressure [Pa]
57  p_0 | Total pressure [Pa]
58  p_{ref} | Reference pressure level [Pa]
59  Cp | Pressure coefficient
60  Cp_0 | Total pressure coefficient
61  \endvartable
62 
63  The function object will operate on both kinematic (\f$ p_k \f$) and static
64  pressure (\f$ p \f$) fields, and the result is written as a
65  volScalarField.
66 
67  The modes of operation are:
68  \table
69  Mode | calcTotal | calcCoeff
70  Static pressure | no | no
71  Total pressure | yes | no
72  Pressure coefficient | no | yes
73  Total pressure coefficient | yes | yes
74  \endtable
75 
76  Example of function object specification to calculate pressure coefficient:
77  \verbatim
78  pressure1
79  {
80  type pressure;
81  libs ("libfieldFunctionObjects.so");
82  ...
83  calcTotal no;
84  calcCoeff yes;
85  }
86  \endverbatim
87 
88 Usage
89  \table
90  Property | Description | Required | Default value
91  type | type name: pressure | yes |
92  field | Name of the pressure field | no | p
93  U | Name of the velocity field | no | U
94  rho | Name of the density field | no | rho
95  result | Name of the resulting field | no | derived from p
96  calcTotal | Calculate total coefficient | yes |
97  pRef | Reference pressure for total pressure | no | 0
98  calcCoeff | Calculate pressure coefficient | yes |
99  pInf | Freestream pressure for coefficient calculation | no |
100  UInf | Freestream velocity for coefficient calculation | no |
101  rhoInf | Freestream density for coefficient calculation | no |
102  \endtable
103 
104 See also
105  Foam::functionObjects::fieldExpression
106  Foam::functionObjects::fvMeshFunctionObject
107 
108 SourceFiles
109  pressure.C
110 
111 \*---------------------------------------------------------------------------*/
112 
113 #ifndef functionObjects_pressure_H
114 #define functionObjects_pressure_H
115 
116 #include "fieldExpression.H"
117 #include "volFieldsFwd.H"
118 #include "dimensionedScalar.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 namespace Foam
123 {
124 namespace functionObjects
125 {
126 
127 /*---------------------------------------------------------------------------*\
128  Class pressure Declaration
129 \*---------------------------------------------------------------------------*/
130 
131 class pressure
132 :
133  public fieldExpression
134 {
135  // Private data
136 
137  //- Name of velocity field, default is "U"
138  word UName_;
139 
140  //- Name of density field, default is "rho"
141  word rhoName_;
142 
143 
144  // Total pressure calculation
145 
146  //- Flag to calculate total pressure
147  bool calcTotal_;
148 
149  //- Reference pressure level
150  scalar pRef_;
151 
152 
153  // Pressure coefficient calculation
154 
155  //- Flag to calculate pressure coefficient
156  bool calcCoeff_;
157 
158  //- Freestream pressure
159  scalar pInf_;
160 
161  //- Freestream velocity
162  vector UInf_;
163 
164  //- Freestream density
165  scalar rhoInf_;
166 
167 
168  // Private Member Functions
169 
170  //- Return the name of the derived pressure field
171  word resultName() const;
172 
173  //- Multiply the static pressure p by rhoInf if necessary and return
174  tmp<volScalarField> rhoScale(const volScalarField& p) const;
175 
176  //- Multiply the given field by rho or rhoInf as appropriate and return
177  tmp<volScalarField> rhoScale
178  (
179  const volScalarField& p,
180  const tmp<volScalarField>& tsf
181  ) const;
182 
183  //- Return the reference pressure
184  tmp<volScalarField> pRef(const tmp<volScalarField>& tp) const;
185 
186  //- Calculate and return the dynamic pressure
187  tmp<volScalarField> pDyn
188  (
189  const volScalarField& p,
190  const tmp<volScalarField>& tp
191  ) const;
192 
193  //- Convert to coeff by applying the freestream dynamic pressure scaling
194  tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
195 
196  //- Calculate the derived pressure field and return true if successful
197  virtual bool calc();
198 
199 
200 public:
201 
202  //- Runtime type information
203  TypeName("pressure");
204 
205 
206  // Constructors
207 
208  //- Construct from Time and dictionary
209  pressure
210  (
211  const word& name,
212  const Time& runTime,
213  const dictionary&
214  );
215 
216 
217  //- Destructor
218  virtual ~pressure();
219 
220 
221  // Member Functions
222 
223  //- Read the pressure data
224  virtual bool read(const dictionary&);
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace functionObjects
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #endif
236 
237 // ************************************************************************* //
const word & name() const
Return the name of this functionObject.
TypeName("pressure")
Runtime type information.
engineTime & runTime
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: pressure.C:186
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
virtual bool read(const dictionary &)
Read the pressure data.
Definition: pressure.C:221
virtual ~pressure()
Destructor.
Definition: pressure.C:215
volScalarField & p
Namespace for OpenFOAM.