perfectFluid.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) 2012-2017 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::perfectFluid
28 
29 Group
30  grpSpecieEquationOfState
31 
32 Description
33  Perfect gas equation of state.
34 
35 SourceFiles
36  perfectFluidI.H
37  perfectFluid.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef perfectFluid_H
42 #define perfectFluid_H
43 
44 #include "autoPtr.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of friend functions and operators
52 
53 template<class Specie> class perfectFluid;
54 
55 template<class Specie>
56 inline perfectFluid<Specie> operator+
57 (
58  const perfectFluid<Specie>&,
60 );
61 
62 template<class Specie>
63 inline perfectFluid<Specie> operator*
64 (
65  const scalar,
67 );
68 
69 template<class Specie>
70 inline perfectFluid<Specie> operator==
71 (
72  const perfectFluid<Specie>&,
74 );
75 
76 template<class Specie>
77 Ostream& operator<<
78 (
79  Ostream&,
81 );
82 
83 
84 /*---------------------------------------------------------------------------*\
85  Class perfectFluid Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 template<class Specie>
89 class perfectFluid
90 :
91  public Specie
92 {
93  // Private data
94 
95  //- Fluid constant
96  scalar R_;
97 
98  //- The reference density
99  scalar rho0_;
100 
101 
102 public:
103 
104  // Constructors
105 
106  //- Construct from components
107  inline perfectFluid
108  (
109  const Specie& sp,
110  const scalar R,
111  const scalar rho0
112  );
113 
114  //- Construct from dictionary
115  perfectFluid(const dictionary& dict);
116 
117  //- Construct as named copy
118  inline perfectFluid(const word& name, const perfectFluid&);
119 
120  //- Construct and return a clone
121  inline autoPtr<perfectFluid> clone() const;
122 
123  // Selector from dictionary
124  inline static autoPtr<perfectFluid> New(const dictionary& dict);
125 
126 
127  // Member functions
128 
129  //- Return the instantiated type name
130  static word typeName()
131  {
132  return "perfectFluid<" + word(Specie::typeName_()) + '>';
133  }
134 
135 
136  // Fundamental properties
137 
138  //- Is the equation of state is incompressible i.e. rho != f(p)
139  static const bool incompressible = false;
140 
141  //- Is the equation of state is isochoric i.e. rho = const
142  static const bool isochoric = false;
143 
144  //- Return fluid constant [J/(kg K)]
145  inline scalar R() const;
146 
147  //- Return density [kg/m^3]
148  inline scalar rho(scalar p, scalar T) const;
149 
150  //- Return enthalpy departure [J/kg]
151  inline scalar H(const scalar p, const scalar T) const;
152 
153  //- Return Cp departure [J/(kg K]
154  inline scalar Cp(scalar p, scalar T) const;
155 
156  //- Return internal energy departure [J/kg]
157  inline scalar E(const scalar p, const scalar T) const;
158 
159  //- Return Cv departure [J/(kg K]
160  inline scalar Cv(scalar p, scalar T) const;
161 
162  //- Return entropy [J/(kg K)]
163  inline scalar S(const scalar p, const scalar T) const;
164 
165  //- Return compressibility rho/p [s^2/m^2]
166  inline scalar psi(scalar p, scalar T) const;
167 
168  //- Return compression factor []
169  inline scalar Z(scalar p, scalar T) const;
170 
171  //- Return (Cp - Cv) [J/(kg K]
172  inline scalar CpMCv(scalar p, scalar T) const;
173 
174 
175  // IO
176 
177  //- Write to Ostream
178  void write(Ostream& os) const;
179 
180 
181  // Member operators
182 
183  inline void operator+=(const perfectFluid&);
184  inline void operator*=(const scalar);
185 
186 
187  // Friend operators
188 
189  friend perfectFluid operator+ <Specie>
190  (
191  const perfectFluid&,
192  const perfectFluid&
193  );
194 
195  friend perfectFluid operator* <Specie>
196  (
197  const scalar s,
198  const perfectFluid&
199  );
200 
201  friend perfectFluid operator== <Specie>
202  (
203  const perfectFluid&,
204  const perfectFluid&
205  );
206 
207 
208  // Ostream Operator
209 
210  friend Ostream& operator<< <Specie>
211  (
212  Ostream&,
213  const perfectFluid&
214  );
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #include "perfectFluidI.H"
225 
226 #ifdef NoRepository
227  #include "perfectFluid.C"
228 #endif
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
Foam::perfectFluid::incompressible
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: perfectFluid.H:138
Foam::perfectFluid
Perfect gas equation of state.
Definition: perfectFluid.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::perfectFluid::perfectFluid
perfectFluid(const Specie &sp, const scalar R, const scalar rho0)
Construct from components.
Definition: perfectFluidI.H:35
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::perfectFluid::E
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
Definition: perfectFluidI.H:112
Foam::perfectFluid::write
void write(Ostream &os) const
Write to Ostream.
Definition: perfectFluid.C:45
Foam::perfectFluid::CpMCv
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: perfectFluidI.H:147
Foam::perfectFluid::typeName
static word typeName()
Return the instantiated type name.
Definition: perfectFluid.H:129
Foam::perfectFluid::clone
autoPtr< perfectFluid > clone() const
Construct and return a clone.
Definition: perfectFluidI.H:64
Foam::perfectFluid::operator*=
void operator*=(const scalar)
Definition: perfectFluidI.H:179
Foam::perfectFluid::H
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
Definition: perfectFluidI.H:98
Foam::perfectFluid::Cv
scalar Cv(scalar p, scalar T) const
Return Cv departure [J/(kg K].
Definition: perfectFluidI.H:119
Foam::perfectFluid::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: perfectFluidI.H:133
Foam::perfectFluid::New
static autoPtr< perfectFluid > New(const dictionary &dict)
Definition: perfectFluidI.H:73
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::perfectFluid::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: perfectFluidI.H:91
Foam::perfectFluid::Cp
scalar Cp(scalar p, scalar T) const
Return Cp departure [J/(kg K].
Definition: perfectFluidI.H:105
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::perfectFluid::operator+=
void operator+=(const perfectFluid &)
Definition: perfectFluidI.H:160
perfectFluidI.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
rho0
scalar rho0
Definition: readInitialConditions.H:89
Foam::perfectFluid::R
scalar R() const
Return fluid constant [J/(kg K)].
Definition: perfectFluidI.H:84
Foam::perfectFluid::isochoric
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: perfectFluid.H:141
Foam::perfectFluid::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: perfectFluidI.H:140
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
perfectFluid.C
Foam::perfectFluid::S
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
Definition: perfectFluidI.H:126
autoPtr.H