totalPressureFvPatchScalarField.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) 2011-2015 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::totalPressureFvPatchScalarField
26 
27 Group
28  grpInletBoundaryConditions grpOutletBoundaryConditions
29 
30 Description
31  This boundary condition provides a total pressure condition. Four
32  variants are possible:
33 
34  1. incompressible subsonic:
35  \f[
36  p_p = p_0 - 0.5 |U|^2
37  \f]
38  where
39  \vartable
40  p_p | incompressible pressure at patch [m2/s2]
41  p_0 | incompressible total pressure [m2/s2]
42  U | velocity
43  \endvartable
44 
45  2. compressible subsonic:
46  \f[
47  p_p = p_0 - 0.5 \rho |U|^2
48  \f]
49  where
50  \vartable
51  p_p | pressure at patch [Pa]
52  p_0 | total pressure [Pa]
53  \rho | density [kg/m3]
54  U | velocity
55  \endvartable
56 
57  3. compressible transonic (\gamma <= 1):
58  \f[
59  p_p = \frac{p_0}{1 + 0.5 \psi |U|^2}
60  \f]
61  where
62  \vartable
63  p_p | pressure at patch [Pa]
64  p_0 | total pressure [Pa]
65  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
66  \endvartable
67 
68  4. compressible supersonic (\gamma > 1):
69  \f[
70  p_p = \frac{p_0}{(1 + 0.5 \psi G |U|^2)^{\frac{1}{G}}}
71  \f]
72  where
73  \vartable
74  p_p | pressure at patch [Pa]
75  p_0 | total pressure [Pa]
76  \gamma | ratio of specific heats (Cp/Cv)
77  \psi | compressibility [m2/s2]
78  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
79  \endvartable
80 
81  The modes of operation are set via the combination of \c phi, \c rho, and
82  \c psi entries:
83  \table
84  Mode | phi | rho | psi
85  incompressible subsonic | phi | none | none
86  compressible subsonic | phi | rho | none
87  compressible transonic | phi | none | psi
88  compressible supersonic | phi | none | psi
89  \endtable
90 
91 
92  \heading Patch usage
93 
94  \table
95  Property | Description | Required | Default value
96  U | velocity field name | no | U
97  phi | flux field name | no | phi
98  rho | density field name | no | none
99  psi | compressibility field name | no | none
100  gamma | ratio of specific heats (Cp/Cv) | yes |
101  p0 | total pressure | yes |
102  \endtable
103 
104  Example of the boundary condition specification:
105  \verbatim
106  myPatch
107  {
108  type totalPressure;
109  U U;
110  phi phi;
111  rho none;
112  psi none;
113  gamma 1.4;
114  p0 uniform 1e5;
115  }
116  \endverbatim
117 
118 Note
119  The default boundary behaviour is for subsonic, incompressible flow.
120 
121 SeeAlso
122  Foam::fixedValueFvPatchField
123 
124 SourceFiles
125  totalPressureFvPatchScalarField.C
126 
127 \*---------------------------------------------------------------------------*/
128 
129 #ifndef totalPressureFvPatchScalarField_H
130 #define totalPressureFvPatchScalarField_H
131 
132 #include "fixedValueFvPatchFields.H"
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 namespace Foam
137 {
138 
139 /*---------------------------------------------------------------------------*\
140  Class totalPressureFvPatchScalarField Declaration
141 \*---------------------------------------------------------------------------*/
142 
143 class totalPressureFvPatchScalarField
144 :
145  public fixedValueFvPatchScalarField
146 {
147  // Private data
148 
149  //- Name of the velocity field
150  word UName_;
151 
152  //- Name of the flux transporting the field
153  word phiName_;
154 
155  //- Name of the density field used to normalise the mass flux
156  // if neccessary
157  word rhoName_;
158 
159  //- Name of the compressibility field used to calculate the wave speed
160  word psiName_;
161 
162  //- Heat capacity ratio
163  scalar gamma_;
164 
165  //- Total pressure
167 
168 
169 public:
170 
171  //- Runtime type information
172  TypeName("totalPressure");
173 
174 
175  // Constructors
176 
177  //- Construct from patch and internal field
179  (
180  const fvPatch&,
181  const DimensionedField<scalar, volMesh>&
182  );
183 
184  //- Construct from patch, internal field and dictionary
186  (
187  const fvPatch&,
188  const DimensionedField<scalar, volMesh>&,
189  const dictionary&
190  );
191 
192  //- Construct by mapping given totalPressureFvPatchScalarField
193  // onto a new patch
195  (
197  const fvPatch&,
198  const DimensionedField<scalar, volMesh>&,
199  const fvPatchFieldMapper&
200  );
201 
202  //- Construct as copy
204  (
206  );
207 
208  //- Construct and return a clone
209  virtual tmp<fvPatchScalarField> clone() const
210  {
211  return tmp<fvPatchScalarField>
212  (
214  );
215  }
216 
217  //- Construct as copy setting internal field reference
219  (
221  const DimensionedField<scalar, volMesh>&
222  );
223 
224  //- Construct and return a clone setting internal field reference
225  virtual tmp<fvPatchScalarField> clone
226  (
227  const DimensionedField<scalar, volMesh>& iF
228  ) const
229  {
230  return tmp<fvPatchScalarField>
231  (
232  new totalPressureFvPatchScalarField(*this, iF)
233  );
234  }
235 
236 
237  // Member functions
238 
239  // Access
240 
241  //- Return the name of the velocity field
242  const word& UName() const
243  {
244  return UName_;
245  }
246 
247  //- Return reference to the name of the velocity field
248  // to allow adjustment
249  word& UName()
250  {
251  return UName_;
252  }
253 
254  //- Return the name of the flux field
255  const word& phiName() const
256  {
257  return phiName_;
258  }
259 
260  //- Return reference to the name of the flux field
261  // to allow adjustment
263  {
264  return phiName_;
265  }
266 
267  //- Return the name of the density field
268  const word& rhoName() const
269  {
270  return rhoName_;
271  }
272 
273  //- Return reference to the name of the density field
274  // to allow adjustment
275  word& rhoName()
276  {
277  return rhoName_;
278  }
279 
280  //- Return the name of the compressibility field
281  const word& psiName() const
282  {
283  return psiName_;
284  }
285 
286  //- Return reference to the name of the compressibility field
287  // to allow adjustment
288  word& psiName()
289  {
290  return psiName_;
291  }
292 
293  //- Return the heat capacity ratio
294  scalar gamma() const
295  {
296  return gamma_;
297  }
298 
299  //- Return reference to the heat capacity ratio to allow adjustment
300  scalar& gamma()
301  {
302  return gamma_;
303  }
304 
305  //- Return the total pressure
306  const scalarField& p0() const
307  {
308  return p0_;
309  }
310 
311  //- Return reference to the total pressure to allow adjustment
312  scalarField& p0()
313  {
314  return p0_;
315  }
316 
317 
318  // Mapping functions
319 
320  //- Map (and resize as needed) from self given a mapping object
321  virtual void autoMap
322  (
323  const fvPatchFieldMapper&
324  );
325 
326  //- Reverse map the given fvPatchField onto this fvPatchField
327  virtual void rmap
328  (
329  const fvPatchScalarField&,
330  const labelList&
331  );
332 
333 
334  // Evaluation functions
335 
336  //- Inherit updateCoeffs from fixedValueFvPatchScalarField
337  using fixedValueFvPatchScalarField::updateCoeffs;
338 
339  //- Update the coefficients associated with the patch field
340  // using the given patch total pressure and velocity fields
341  virtual void updateCoeffs
342  (
343  const scalarField& p0p,
344  const vectorField& Up
345  );
346 
347  //- Update the coefficients associated with the patch field
348  virtual void updateCoeffs();
349 
350 
351  //- Write
352  virtual void write(Ostream&) const;
353 };
354 
355 
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 
358 } // End namespace Foam
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 #endif
363 
364 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::totalPressureFvPatchScalarField::p0_
scalarField p0_
Total pressure.
Definition: totalPressureFvPatchScalarField.H:285
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::totalPressureFvPatchScalarField::gamma_
scalar gamma_
Heat capacity ratio.
Definition: totalPressureFvPatchScalarField.H:282
Foam::totalPressureFvPatchScalarField::TypeName
TypeName("totalPressure")
Runtime type information.
Foam::totalPressureFvPatchScalarField::UName_
word UName_
Name of the velocity field.
Definition: totalPressureFvPatchScalarField.H:269
Foam::totalPressureFvPatchScalarField::gamma
scalar & gamma()
Return reference to the heat capacity ratio to allow adjustment.
Definition: totalPressureFvPatchScalarField.H:419
Foam::totalPressureFvPatchScalarField
This boundary condition provides a total pressure condition. Four variants are possible:
Definition: totalPressureFvPatchScalarField.H:262
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::totalPressureFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: totalPressureFvPatchScalarField.C:132
Foam::totalPressureFvPatchScalarField::phiName
const word & phiName() const
Return the name of the flux field.
Definition: totalPressureFvPatchScalarField.H:374
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::totalPressureFvPatchScalarField::UName
const word & UName() const
Return the name of the velocity field.
Definition: totalPressureFvPatchScalarField.H:361
Foam::totalPressureFvPatchScalarField::gamma
scalar gamma() const
Return the heat capacity ratio.
Definition: totalPressureFvPatchScalarField.H:413
Foam::totalPressureFvPatchScalarField::clone
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
Definition: totalPressureFvPatchScalarField.H:328
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::totalPressureFvPatchScalarField::rhoName
const word & rhoName() const
Return the name of the density field.
Definition: totalPressureFvPatchScalarField.H:387
Foam::totalPressureFvPatchScalarField::p0
const scalarField & p0() const
Return the total pressure.
Definition: totalPressureFvPatchScalarField.H:425
Foam::totalPressureFvPatchScalarField::psiName_
word psiName_
Name of the compressibility field used to calculate the wave speed.
Definition: totalPressureFvPatchScalarField.H:279
Foam::totalPressureFvPatchScalarField::psiName
const word & psiName() const
Return the name of the compressibility field.
Definition: totalPressureFvPatchScalarField.H:400
Foam::totalPressureFvPatchScalarField::rhoName_
word rhoName_
Name of the density field used to normalise the mass flux.
Definition: totalPressureFvPatchScalarField.H:276
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
fixedValueFvPatchFields.H
Foam::totalPressureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: totalPressureFvPatchScalarField.C:223
Foam::totalPressureFvPatchScalarField::phiName_
word phiName_
Name of the flux transporting the field.
Definition: totalPressureFvPatchScalarField.H:272
Foam::totalPressureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: totalPressureFvPatchScalarField.C:233
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
totalPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: totalPressureFvPatchScalarField.C:36
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::totalPressureFvPatchScalarField::p0
scalarField & p0()
Return reference to the total pressure to allow adjustment.
Definition: totalPressureFvPatchScalarField.H:431
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::totalPressureFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: totalPressureFvPatchScalarField.C:142