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-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::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 (\f$\gamma = 1\f$):
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 (\f$\gamma > 1\f$):
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 by the dimensions of the pressure field
82  to which this boundary condition is applied, the \c psi entry and the value
83  of \c gamma:
84  \table
85  Mode | dimensions | psi | gamma
86  incompressible subsonic | p/rho | |
87  compressible subsonic | p | none |
88  compressible transonic | p | psi | 1
89  compressible supersonic | p | psi | > 1
90  \endtable
91 
92 
93 Usage
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 | rho
99  psi | Compressibility field name | no | none
100  gamma | (Cp/Cv) | no | 1
101  p0 | Total pressure | yes |
102  \endtable
103 
104  Example of the boundary condition specification:
105  \verbatim
106  <patchName>
107  {
108  type totalPressure;
109  p0 uniform 1e5;
110  }
111  \endverbatim
112 
113 See also
114  Foam::fixedValueFvPatchField
115 
116 SourceFiles
117  totalPressureFvPatchScalarField.C
118 
119 \*---------------------------------------------------------------------------*/
120 
121 #ifndef totalPressureFvPatchScalarField_H
122 #define totalPressureFvPatchScalarField_H
123 
124 #include "fixedValueFvPatchFields.H"
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 namespace Foam
129 {
130 
131 /*---------------------------------------------------------------------------*\
132  Class totalPressureFvPatchScalarField Declaration
133 \*---------------------------------------------------------------------------*/
134 
135 class totalPressureFvPatchScalarField
136 :
137  public fixedValueFvPatchScalarField
138 {
139  // Private data
140 
141  //- Name of the velocity field
142  word UName_;
143 
144  //- Name of the flux transporting the field
145  word phiName_;
146 
147  //- Name of the density field used to normalise the mass flux
148  // if neccessary
149  word rhoName_;
150 
151  //- Name of the compressibility field used to calculate the wave speed
152  word psiName_;
153 
154  //- Heat capacity ratio
155  scalar gamma_;
156 
157  //- Total pressure
158  scalarField p0_;
159 
160 
161 public:
162 
163  //- Runtime type information
164  TypeName("totalPressure");
165 
166 
167  // Constructors
168 
169  //- Construct from patch and internal field
171  (
172  const fvPatch&,
173  const DimensionedField<scalar, volMesh>&
174  );
175 
176  //- Construct from patch, internal field and dictionary
178  (
179  const fvPatch&,
180  const DimensionedField<scalar, volMesh>&,
181  const dictionary&
182  );
183 
184  //- Construct by mapping given totalPressureFvPatchScalarField
185  // onto a new patch
187  (
189  const fvPatch&,
190  const DimensionedField<scalar, volMesh>&,
191  const fvPatchFieldMapper&
192  );
193 
194  //- Construct as copy
196  (
198  );
199 
200  //- Construct and return a clone
201  virtual tmp<fvPatchScalarField> clone() const
202  {
203  return tmp<fvPatchScalarField>
204  (
206  );
207  }
208 
209  //- Construct as copy setting internal field reference
211  (
213  const DimensionedField<scalar, volMesh>&
214  );
215 
216  //- Construct and return a clone setting internal field reference
217  virtual tmp<fvPatchScalarField> clone
218  (
219  const DimensionedField<scalar, volMesh>& iF
220  ) const
221  {
222  return tmp<fvPatchScalarField>
223  (
224  new totalPressureFvPatchScalarField(*this, iF)
225  );
226  }
227 
228 
229  // Member functions
230 
231  // Access
232 
233  //- Return the name of the velocity field
234  const word& UName() const
235  {
236  return UName_;
237  }
238 
239  //- Return reference to the name of the velocity field
240  // to allow adjustment
241  word& UName()
242  {
243  return UName_;
244  }
245 
246  //- Return the name of the flux field
247  const word& phiName() const
248  {
249  return phiName_;
250  }
251 
252  //- Return reference to the name of the flux field
253  // to allow adjustment
255  {
256  return phiName_;
257  }
258 
259  //- Return the name of the density field
260  const word& rhoName() const
261  {
262  return rhoName_;
263  }
264 
265  //- Return reference to the name of the density field
266  // to allow adjustment
267  word& rhoName()
268  {
269  return rhoName_;
270  }
271 
272  //- Return the name of the compressibility field
273  const word& psiName() const
274  {
275  return psiName_;
276  }
277 
278  //- Return reference to the name of the compressibility field
279  // to allow adjustment
280  word& psiName()
281  {
282  return psiName_;
283  }
284 
285  //- Return the heat capacity ratio
286  scalar gamma() const
287  {
288  return gamma_;
289  }
290 
291  //- Return reference to the heat capacity ratio to allow adjustment
292  scalar& gamma()
293  {
294  return gamma_;
295  }
296 
297  //- Return the total pressure
298  const scalarField& p0() const
299  {
300  return p0_;
301  }
302 
303  //- Return reference to the total pressure to allow adjustment
304  scalarField& p0()
305  {
306  return p0_;
307  }
308 
309 
310  // Mapping functions
311 
312  //- Map (and resize as needed) from self given a mapping object
313  virtual void autoMap
314  (
315  const fvPatchFieldMapper&
316  );
317 
318  //- Reverse map the given fvPatchField onto this fvPatchField
319  virtual void rmap
320  (
321  const fvPatchScalarField&,
322  const labelList&
323  );
324 
325 
326  // Evaluation functions
327 
328  //- Inherit updateCoeffs from fixedValueFvPatchScalarField
329  using fixedValueFvPatchScalarField::updateCoeffs;
330 
331  //- Update the coefficients associated with the patch field
332  // using the given patch total pressure and velocity fields
333  virtual void updateCoeffs
334  (
335  const scalarField& p0p,
336  const vectorField& Up
337  );
338 
339  //- Update the coefficients associated with the patch field
340  virtual void updateCoeffs();
341 
342 
343  //- Write
344  virtual void write(Ostream&) const;
345 };
346 
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 } // End namespace Foam
351 
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 #endif
355 
356 // ************************************************************************* //
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 void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
TypeName("totalPressure")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Foam::fvPatchFieldMapper.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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.
const word & rhoName() const
Return the name of the density field.
scalar gamma() const
Return the heat capacity ratio.
Namespace for OpenFOAM.
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.