totalPressureFvPatchScalarField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 Description
28  This boundary condition provides a total pressure condition. Four
29  variants are possible:
30 
31  1. incompressible subsonic:
32  \f[
33  p_p = p_0 - 0.5 |U|^2
34  \f]
35  where
36  \vartable
37  p_p | incompressible pressure at patch [m2/s2]
38  p_0 | incompressible total pressure [m2/s2]
39  U | velocity
40  \endvartable
41 
42  2. compressible subsonic:
43  \f[
44  p_p = p_0 - 0.5 \rho |U|^2
45  \f]
46  where
47  \vartable
48  p_p | pressure at patch [Pa]
49  p_0 | total pressure [Pa]
50  \rho | density [kg/m3]
51  U | velocity
52  \endvartable
53 
54  3. compressible transonic (\f$\gamma = 1\f$):
55  \f[
56  p_p = \frac{p_0}{1 + 0.5 \psi |U|^2}
57  \f]
58  where
59  \vartable
60  p_p | pressure at patch [Pa]
61  p_0 | total pressure [Pa]
62  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
63  \endvartable
64 
65  4. compressible supersonic (\f$\gamma > 1\f$):
66  \f[
67  p_p = \frac{p_0}{(1 + 0.5 \psi G |U|^2)^{\frac{1}{G}}}
68  \f]
69  where
70  \vartable
71  p_p | pressure at patch [Pa]
72  p_0 | total pressure [Pa]
73  \gamma | ratio of specific heats (Cp/Cv)
74  \psi | compressibility [m2/s2]
75  G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
76  \endvartable
77 
78  The modes of operation are set by the dimensions of the pressure field
79  to which this boundary condition is applied, the \c psi entry and the value
80  of \c gamma:
81  \table
82  Mode | dimensions | psi | gamma
83  incompressible subsonic | p/rho | |
84  compressible subsonic | p | none |
85  compressible transonic | p | psi | 1
86  compressible supersonic | p | psi | > 1
87  \endtable
88 
89 
90 Usage
91  \table
92  Property | Description | Required | Default value
93  U | Velocity field name | no | U
94  phi | Flux field name | no | phi
95  rho | Density field name | no | rho
96  psi | Compressibility field name | no | none
97  gamma | (Cp/Cv) | no | 1
98  p0 | Total pressure | yes |
99  \endtable
100 
101  Example of the boundary condition specification:
102  \verbatim
103  <patchName>
104  {
105  type totalPressure;
106  p0 uniform 1e5;
107  }
108  \endverbatim
109 
110 See also
111  Foam::fixedValueFvPatchField
112 
113 SourceFiles
114  totalPressureFvPatchScalarField.C
115 
116 \*---------------------------------------------------------------------------*/
117 
118 #ifndef totalPressureFvPatchScalarField_H
119 #define totalPressureFvPatchScalarField_H
120 
121 #include "fixedValueFvPatchFields.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 namespace Foam
126 {
127 
128 /*---------------------------------------------------------------------------*\
129  Class totalPressureFvPatchScalarField Declaration
130 \*---------------------------------------------------------------------------*/
131 
132 class totalPressureFvPatchScalarField
133 :
134  public fixedValueFvPatchScalarField
135 {
136  // Private data
137 
138  //- Name of the velocity field
139  word UName_;
140 
141  //- Name of the flux transporting the field
142  word phiName_;
143 
144  //- Name of the density field used to normalise the mass flux
145  // if necessary
146  word rhoName_;
147 
148  //- Name of the compressibility field used to calculate the wave speed
149  word psiName_;
150 
151  //- Heat capacity ratio
152  scalar gamma_;
153 
154  //- Total pressure
155  scalarField p0_;
156 
157 
158 public:
159 
160  //- Runtime type information
161  TypeName("totalPressure");
162 
163 
164  // Constructors
165 
166  //- Construct from patch and internal field
168  (
169  const fvPatch&,
170  const DimensionedField<scalar, volMesh>&
171  );
172 
173  //- Construct from patch, internal field and dictionary
175  (
176  const fvPatch&,
177  const DimensionedField<scalar, volMesh>&,
178  const dictionary&
179  );
180 
181  //- Construct by mapping given totalPressureFvPatchScalarField
182  // onto a new patch
184  (
186  const fvPatch&,
187  const DimensionedField<scalar, volMesh>&,
188  const fvPatchFieldMapper&
189  );
190 
191  //- Construct as copy
193  (
195  );
196 
197  //- Construct and return a clone
198  virtual tmp<fvPatchScalarField> clone() const
199  {
200  return tmp<fvPatchScalarField>
201  (
203  );
204  }
205 
206  //- Construct as copy setting internal field reference
208  (
210  const DimensionedField<scalar, volMesh>&
211  );
212 
213  //- Construct and return a clone setting internal field reference
214  virtual tmp<fvPatchScalarField> clone
215  (
216  const DimensionedField<scalar, volMesh>& iF
217  ) const
218  {
219  return tmp<fvPatchScalarField>
220  (
221  new totalPressureFvPatchScalarField(*this, iF)
222  );
223  }
224 
225 
226  // Member functions
227 
228  // Access
229 
230  //- Return the name of the velocity field
231  const word& UName() const
232  {
233  return UName_;
234  }
235 
236  //- Return reference to the name of the velocity field
237  // to allow adjustment
238  word& UName()
239  {
240  return UName_;
241  }
242 
243  //- Return the name of the flux field
244  const word& phiName() const
245  {
246  return phiName_;
247  }
248 
249  //- Return reference to the name of the flux field
250  // to allow adjustment
252  {
253  return phiName_;
254  }
255 
256  //- Return the name of the density field
257  const word& rhoName() const
258  {
259  return rhoName_;
260  }
261 
262  //- Return reference to the name of the density field
263  // to allow adjustment
264  word& rhoName()
265  {
266  return rhoName_;
267  }
268 
269  //- Return the name of the compressibility field
270  const word& psiName() const
271  {
272  return psiName_;
273  }
274 
275  //- Return reference to the name of the compressibility field
276  // to allow adjustment
277  word& psiName()
278  {
279  return psiName_;
280  }
281 
282  //- Return the heat capacity ratio
283  scalar gamma() const
284  {
285  return gamma_;
286  }
287 
288  //- Return reference to the heat capacity ratio to allow adjustment
289  scalar& gamma()
290  {
291  return gamma_;
292  }
293 
294  //- Return the total pressure
295  const scalarField& p0() const
296  {
297  return p0_;
298  }
299 
300  //- Return reference to the total pressure to allow adjustment
301  scalarField& p0()
302  {
303  return p0_;
304  }
305 
306 
307  // Mapping functions
308 
309  //- Map (and resize as needed) from self given a mapping object
310  virtual void autoMap
311  (
312  const fvPatchFieldMapper&
313  );
314 
315  //- Reverse map the given fvPatchField onto this fvPatchField
316  virtual void rmap
317  (
318  const fvPatchScalarField&,
319  const labelList&
320  );
321 
322 
323  // Evaluation functions
324 
325  //- Inherit updateCoeffs from fixedValueFvPatchScalarField
326  using fixedValueFvPatchScalarField::updateCoeffs;
327 
328  //- Update the coefficients associated with the patch field
329  // using the given patch total pressure and velocity fields
330  virtual void updateCoeffs
331  (
332  const scalarField& p0p,
333  const vectorField& Up
334  );
335 
336  //- Update the coefficients associated with the patch field
337  virtual void updateCoeffs();
338 
339 
340  //- Write
341  virtual void write(Ostream&) const;
342 };
343 
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 } // End namespace Foam
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
351 #endif
352 
353 // ************************************************************************* //
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.