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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::totalPressureFvPatchScalarField
28 
29 Group
30  grpInletBoundaryConditions grpOutletBoundaryConditions
31 
32 Description
33  This boundary condition provides a total pressure condition. Four
34  variants are possible:
35 
36  1. incompressible subsonic:
37  \f[
38  p_p = p_0 - 0.5 |U|^2
39  \f]
40  where
41  \vartable
42  p_p | incompressible pressure at patch [m2/s2]
43  p_0 | incompressible total pressure [m2/s2]
44  U | velocity
45  \endvartable
46 
47  2. compressible subsonic:
48  \f[
49  p_p = p_0 - 0.5 \rho |U|^2
50  \f]
51  where
52  \vartable
53  p_p | pressure at patch [Pa]
54  p_0 | total pressure [Pa]
55  \rho | density [kg/m3]
56  U | velocity
57  \endvartable
58 
59  3. compressible transonic (\f$\gamma = 1\f$):
60  \f[
61  p_p = \frac{p_0}{1 + 0.5 \psi |U|^2}
62  \f]
63  where
64  \vartable
65  p_p | pressure at patch [Pa]
66  p_0 | total pressure [Pa]
67  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
68  \endvartable
69 
70  4. compressible supersonic (\f$\gamma > 1\f$):
71  \f[
72  p_p = \frac{p_0}{(1 + 0.5 \psi G |U|^2)^{\frac{1}{G}}}
73  \f]
74  where
75  \vartable
76  p_p | pressure at patch [Pa]
77  p_0 | total pressure [Pa]
78  \gamma | ratio of specific heats (Cp/Cv)
79  \psi | compressibility [m2/s2]
80  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
81  \endvartable
82 
83  The modes of operation are set by the dimensions of the pressure field
84  to which this boundary condition is applied, the \c psi entry and the value
85  of \c gamma:
86  \table
87  Mode | dimensions | psi | gamma
88  incompressible subsonic | p/rho | |
89  compressible subsonic | p | none |
90  compressible transonic | p | psi | 1
91  compressible supersonic | p | psi | > 1
92  \endtable
93 
94 
95 Usage
96  \table
97  Property | Description | Required | Default value
98  U | Velocity field name | no | U
99  phi | Flux field name | no | phi
100  rho | Density field name | no | rho
101  psi | Compressibility field name | no | none
102  gamma | (Cp/Cv) | no | 1
103  p0 | Total pressure | yes |
104  \endtable
105 
106  Example of the boundary condition specification:
107  \verbatim
108  <patchName>
109  {
110  type totalPressure;
111  p0 uniform 1e5;
112  }
113  \endverbatim
114 
115 See also
116  Foam::fixedValueFvPatchField
117 
118 SourceFiles
119  totalPressureFvPatchScalarField.C
120 
121 \*---------------------------------------------------------------------------*/
122 
123 #ifndef totalPressureFvPatchScalarField_H
124 #define totalPressureFvPatchScalarField_H
125 
126 #include "fixedValueFvPatchFields.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 namespace Foam
131 {
132 
133 /*---------------------------------------------------------------------------*\
134  Class totalPressureFvPatchScalarField Declaration
135 \*---------------------------------------------------------------------------*/
136 
137 class totalPressureFvPatchScalarField
138 :
139  public fixedValueFvPatchScalarField
140 {
141  // Private data
142 
143  //- Name of the velocity field
144  word UName_;
145 
146  //- Name of the flux transporting the field
147  word phiName_;
148 
149  //- Name of the density field used to normalise the mass flux
150  //- if necessary
151  word rhoName_;
152 
153  //- Name of the compressibility field used to calculate the wave speed
154  word psiName_;
155 
156  //- Heat capacity ratio
157  scalar gamma_;
158 
159  //- Total pressure
160  scalarField p0_;
161 
162 
163 public:
164 
165  //- Runtime type information
166  TypeName("totalPressure");
167 
168 
169  // Constructors
170 
171  //- Construct from patch and internal field
173  (
174  const fvPatch&,
175  const DimensionedField<scalar, volMesh>&
176  );
177 
178  //- Construct from patch, internal field and dictionary
180  (
181  const fvPatch&,
182  const DimensionedField<scalar, volMesh>&,
183  const dictionary&
184  );
185 
186  //- Construct by mapping given totalPressureFvPatchScalarField
187  // onto a new patch
189  (
191  const fvPatch&,
192  const DimensionedField<scalar, volMesh>&,
193  const fvPatchFieldMapper&
194  );
195 
196  //- Construct as copy
198  (
200  );
201 
202  //- Construct as copy setting internal field reference
204  (
206  const DimensionedField<scalar, volMesh>&
207  );
208 
209  //- Return a clone
210  virtual tmp<fvPatchField<scalar>> clone() const
211  {
212  return fvPatchField<scalar>::Clone(*this);
213  }
214 
215  //- Clone with an internal field reference
216  virtual tmp<fvPatchField<scalar>> clone
217  (
218  const DimensionedField<scalar, volMesh>& iF
219  ) const
220  {
221  return fvPatchField<scalar>::Clone(*this, iF);
222  }
223 
224 
225  // Member functions
226 
227  // Access
228 
229  //- Return the name of the velocity field
230  const word& UName() const
231  {
232  return UName_;
233  }
234 
235  //- Return reference to the name of the velocity field
236  // to allow adjustment
237  word& UName()
238  {
239  return UName_;
240  }
241 
242  //- Return the name of the flux field
243  const word& phiName() const
244  {
245  return phiName_;
246  }
247 
248  //- Return reference to the name of the flux field
249  // to allow adjustment
250  word& phiName()
251  {
252  return phiName_;
253  }
254 
255  //- Return the name of the density field
256  const word& rhoName() const
257  {
258  return rhoName_;
259  }
260 
261  //- Return reference to the name of the density field
262  // to allow adjustment
263  word& rhoName()
264  {
265  return rhoName_;
266  }
267 
268  //- Return the name of the compressibility field
269  const word& psiName() const
270  {
271  return psiName_;
272  }
273 
274  //- Return reference to the name of the compressibility field
275  // to allow adjustment
276  word& psiName()
277  {
278  return psiName_;
279  }
280 
281  //- Return the heat capacity ratio
282  scalar gamma() const
283  {
284  return gamma_;
285  }
286 
287  //- Return reference to the heat capacity ratio to allow adjustment
288  scalar& gamma()
289  {
290  return gamma_;
291  }
292 
293  //- Return the total pressure
294  const scalarField& p0() const
295  {
296  return p0_;
297  }
298 
299  //- Return reference to the total pressure to allow adjustment
300  scalarField& p0()
301  {
302  return p0_;
303  }
304 
305 
306  // Mapping functions
307 
308  //- Map (and resize as needed) from self given a mapping object
309  virtual void autoMap
310  (
311  const fvPatchFieldMapper&
312  );
313 
314  //- Reverse map the given fvPatchField onto this fvPatchField
315  virtual void rmap
316  (
317  const fvPatchScalarField&,
318  const labelList&
319  );
320 
321 
322  // Evaluation functions
323 
324  //- Inherit updateCoeffs from fixedValueFvPatchScalarField
325  using fixedValueFvPatchScalarField::updateCoeffs;
326 
327  //- Update the coefficients associated with the patch field
328  // using the given patch total pressure and velocity fields
329  virtual void updateCoeffs
330  (
331  const scalarField& p0p,
332  const vectorField& Up
333  );
334 
335  //- Update the coefficients associated with the patch field
336  virtual void updateCoeffs();
337 
338 
339  //- Write
340  virtual void write(Ostream&) const;
341 };
342 
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 } // End namespace Foam
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #endif
351 
352 // ************************************************************************* //
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
const word & psiName() const
Return the name of the compressibility field.
const word & UName() const
Return the name of the velocity field.
virtual tmp< fvPatchField< scalar > > clone() const
Return a clone.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void write(Ostream &) const
Write.
TypeName("totalPressure")
Runtime type information.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word & phiName() const
Return the name of the flux field.
totalPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
const scalarField & p0() const
Return the total pressure.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const word & rhoName() const
Return the name of the density field.
List< label > labelList
A List of labels.
Definition: List.H:62
scalar gamma() const
Return the heat capacity ratio.
Namespace for OpenFOAM.