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