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-2013 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
166  scalarField p0_;
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
262  word& phiName()
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  (
330  const labelList&
331  );
332 
333 
334  // Evaluation functions
335 
336  //- Update the coefficients associated with the patch field
337  // using the given patch total pressure and velocity fields
338  virtual void updateCoeffs
339  (
340  const scalarField& p0p,
341  const vectorField& Up
342  );
343 
344  //- Update the coefficients associated with the patch field
345  virtual void updateCoeffs();
347 
348  //- Write
349  virtual void write(Ostream&) const;
350 };
351 
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 } // End namespace Foam
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #endif
360 
361 // ************************************************************************* //
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
fvPatchField< scalar > fvPatchScalarField
const word & psiName() const
Return the name of the compressibility field.
virtual void write(Ostream &) const
Write.
const word & UName() const
Return the name of the velocity field.
List< label > labelList
A List of labels.
Definition: labelList.H:56
const scalarField & p0() const
Return the total pressure.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word & phiName() const
Return the name of the flux field.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
TypeName("totalPressure")
Runtime type information.
const word & rhoName() const
Return the name of the density field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
scalar gamma() const
Return the heat capacity ratio.
A class for handling words, derived from string.
Definition: word.H:60
Field< vector > vectorField
Specialisation of Field<T> for vector.
totalPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.