pressureTools.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-2013 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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::pressureTools
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object includes tools to manipulate the pressure into
32  different forms. These currently include:
33 
34  - static pressure
35  \f[
36  p_s = \rho p_k
37  \f]
38  - total pressure
39  \f[
40  p_T = p_{ref} + p_s + 0.5 \rho |U|^2
41  \f]
42  - static pressure coefficient
43  \f[
44  Cp_s = \frac{p_s - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
45  \f]
46  - total pressure coefficient
47  \f[
48  Cp_T = \frac{p_T - 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_s | pressure [Pa]
60  p_T | total pressure [Pa]
61  p_{ref} | reference pressure level [Pa]
62  Cp_{s} | pressure coefficient
63  Cp_{T} | 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_s \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  pressureTools1
82  {
83  type pressureTools;
84  functionObjectLibs ("libutilityFunctionObjects.so");
85  ...
86  calcTotal no;
87  calcCoeff yes;
88  }
89  \endverbatim
90 
91  \heading Function object usage
92  \table
93  Property | Description | Required | Default value
94  type | type name: pressureTools| yes |
95  calcTotal | Calculate total coefficient | yes |
96  pName | Name of pressure field | no | p
97  UName | Name of velocity field | no | U
98  rhoName | Name of density field | no | rho
99  pRef | Reference pressure for total pressure | no | 0.0
100  calcCoeff | Calculate pressure coefficient | yes |
101  pInf | Freestream pressure for coefficient calculation | no |
102  UInf | Freestream velocity for coefficient calculation | no |
103  rhoInf | Freestream density for coefficient calculation | no |
104  resultName | Name of derived pressure field | no | auto generated
105  log | log to standard output | no | yes
106  \endtable
107 
108 SourceFiles
109  pressureTools.C
110  IOpressureTools.H
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef pressureTools_H
115 #define pressureTools_H
116 
117 #include "volFieldsFwd.H"
118 #include "dimensionedScalar.H"
119 #include "Switch.H"
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 namespace Foam
124 {
125 
126 // Forward declaration of classes
127 class objectRegistry;
128 class dictionary;
129 class polyMesh;
130 class mapPolyMesh;
131 
132 /*---------------------------------------------------------------------------*\
133  Class pressureTools Declaration
134 \*---------------------------------------------------------------------------*/
135 
136 class pressureTools
137 {
138  // Private data
139 
140  //- Name of this set of pressureTools objects
141  word name_;
142 
143  //- Reference to the database
144  const objectRegistry& obr_;
145 
146  //- On/off switch
147  bool active_;
148 
149  //- Name of pressure field, default is "p"
150  word pName_;
151 
152  //- Name of velocity field, default is "U"
153  word UName_;
154 
155  //- Name of density field, default is "rho"
156  word rhoName_;
157 
158  //- Result name
159  word resultName_;
160 
161  //- Switch to send output to Info as well as to file
162  Switch log_;
163 
164 
165  // Total pressure calculation
166 
167  //- Flag to calculate total pressure
168  bool calcTotal_;
169 
170  //- Reference pressure level
171  scalar pRef_;
172 
173 
174  // Pressure coefficient calculation
175 
176  //- Flag to calculate pressure coefficient
177  bool calcCoeff_;
178 
179  //- Freestream pressure
180  scalar pInf_;
181 
182  //- Freestream velocity
183  vector UInf_;
184 
185  //- Freestream density
186  scalar rhoInf_;
187 
188  //- Flag to show whether rhoInf has been initialised
189  bool rhoInfInitialised_;
190 
191 
192  // Private Member Functions
193 
194  //- Return the density scale
196 
197  //- Return the density field
198  tmp<volScalarField> rho(const volScalarField& p) const;
199 
200  //- Return the reference pressure
201  dimensionedScalar pRef() const;
202 
203  //- Calculate and return the dynamic pressure
204  tmp<volScalarField> pDyn(const volScalarField& p) const;
205 
206  //- Convert to coeff by applying the freestream dynamic pressure scaling
207  tmp<volScalarField> convertToCoeff(const volScalarField& p) const;
208 
209  //- Disallow default bitwise copy construct
211 
212  //- Disallow default bitwise assignment
213  void operator=(const pressureTools&);
214 
215 
216 public:
217 
218  //- Runtime type information
219  TypeName("pressureTools");
220 
221 
222  // Constructors
223 
224  //- Construct for given objectRegistry and dictionary.
225  // Allow the possibility to load fields from files
227  (
228  const word& name,
229  const objectRegistry&,
230  const dictionary&,
231  const bool loadFromFiles = false
232  );
233 
234 
235  //- Destructor
236  virtual ~pressureTools();
237 
238 
239  // Member Functions
240 
241  //- Return name of the set of pressureTools
242  virtual const word& name() const
243  {
244  return name_;
245  }
246 
247  //- Read the pressureTools data
248  virtual void read(const dictionary&);
249 
250  //- Execute, currently does nothing
251  virtual void execute();
252 
253  //- Execute at the final time-loop, currently does nothing
254  virtual void end();
255 
256  //- Called when time was set at the end of the Time::operator++
257  virtual void timeSet();
258 
259  //- Calculate the pressureTools and write
260  virtual void write();
261 
262  //- Update for changes of mesh
263  virtual void updateMesh(const mapPolyMesh&)
264  {}
265 
266  //- Update for changes of mesh
267  virtual void movePoints(const polyMesh&)
268  {}
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace Foam
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #endif
279 
280 // ************************************************************************* //
volFieldsFwd.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::pressureTools::pDyn
tmp< volScalarField > pDyn(const volScalarField &p) const
Calculate and return the dynamic pressure.
Definition: pressureTools.C:112
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::pressureTools::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: pressureTools.H:391
Foam::pressureTools::rhoInf_
scalar rhoInf_
Freestream density.
Definition: pressureTools.H:314
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::pressureTools::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: pressureTools.H:290
Foam::pressureTools::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: pressureTools.C:330
Foam::pressureTools::read
virtual void read(const dictionary &)
Read the pressureTools data.
Definition: pressureTools.C:246
Foam::pressureTools::calcTotal_
bool calcTotal_
Flag to calculate total pressure.
Definition: pressureTools.H:296
Foam::pressureTools::pRef_
scalar pRef_
Reference pressure level.
Definition: pressureTools.H:299
Foam::pressureTools::pInf_
scalar pInf_
Freestream pressure.
Definition: pressureTools.H:308
Foam::pressureTools::pName_
word pName_
Name of pressure field, default is "p".
Definition: pressureTools.H:278
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::pressureTools::calcCoeff_
bool calcCoeff_
Flag to calculate pressure coefficient.
Definition: pressureTools.H:305
Foam::pressureTools::operator=
void operator=(const pressureTools &)
Disallow default bitwise assignment.
Foam::pressureTools::rhoName_
word rhoName_
Name of density field, default is "rho".
Definition: pressureTools.H:284
Foam::pressureTools::obr_
const objectRegistry & obr_
Reference to the database.
Definition: pressureTools.H:272
Foam::pressureTools::UName_
word UName_
Name of velocity field, default is "U".
Definition: pressureTools.H:281
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::pressureTools::rho
tmp< volScalarField > rho(const volScalarField &p) const
Return the density field.
Definition: pressureTools.C:57
Foam::pressureTools::active_
bool active_
On/off switch.
Definition: pressureTools.H:275
Foam::pressureTools::write
virtual void write()
Calculate the pressureTools and write.
Definition: pressureTools.C:342
Foam::pressureTools::TypeName
TypeName("pressureTools")
Runtime type information.
Foam::pressureTools::rhoInfInitialised_
bool rhoInfInitialised_
Flag to show whether rhoInf has been initialised.
Definition: pressureTools.H:317
Foam::pressureTools::pressureTools
pressureTools(const pressureTools &)
Disallow default bitwise copy construct.
Foam::pressureTools::name
virtual const word & name() const
Return name of the set of pressureTools.
Definition: pressureTools.H:370
Switch.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::pressureTools::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: pressureTools.H:395
Foam::pressureTools::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: pressureTools.C:336
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::pressureTools::rhoScale
dimensionedScalar rhoScale(const volScalarField &p) const
Return the density scale.
Definition: pressureTools.C:41
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::pressureTools::pRef
dimensionedScalar pRef() const
Return the reference pressure.
Definition: pressureTools.C:98
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::pressureTools
This function object includes tools to manipulate the pressure into different forms....
Definition: pressureTools.H:264
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::pressureTools::name_
word name_
Name of this set of pressureTools objects.
Definition: pressureTools.H:269
dimensionedScalar.H
Foam::pressureTools::execute
virtual void execute()
Execute, currently does nothing.
Definition: pressureTools.C:313
Foam::Vector< scalar >
Foam::pressureTools::~pressureTools
virtual ~pressureTools()
Destructor.
Definition: pressureTools.C:240
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::pressureTools::convertToCoeff
tmp< volScalarField > convertToCoeff(const volScalarField &p) const
Convert to coeff by applying the freestream dynamic pressure scaling.
Definition: pressureTools.C:147
Foam::pressureTools::resultName_
word resultName_
Result name.
Definition: pressureTools.H:287
Foam::pressureTools::UInf_
vector UInf_
Freestream velocity.
Definition: pressureTools.H:311
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52