perfectFluid.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) 2012-2020 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::perfectFluid
26 
27 Description
28  Simple extension of the perfect gas equation of state to liquids by
29  the addition of a constant density off-set.
30 
31  Coefficient mixing is very inaccurate and not supported,
32  so this equation of state is not applicable to mixtures.
33 
34  This equation of state is rather inaccurate and has been superseded by
35  rPolynomial which is much more accurate and supports mixtures.
36 
37 SourceFiles
38  perfectFluidI.H
39  perfectFluid.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef perfectFluid_H
44 #define perfectFluid_H
45 
46 #include "autoPtr.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of friend functions and operators
54 
55 template<class Specie> class perfectFluid;
56 
57 template<class Specie>
58 inline perfectFluid<Specie> operator+
59 (
60  const perfectFluid<Specie>&,
61  const perfectFluid<Specie>&
62 );
63 
64 template<class Specie>
65 inline perfectFluid<Specie> operator*
66 (
67  const scalar,
68  const perfectFluid<Specie>&
69 );
70 
71 template<class Specie>
72 inline perfectFluid<Specie> operator==
73 (
74  const perfectFluid<Specie>&,
75  const perfectFluid<Specie>&
76 );
77 
78 template<class Specie>
79 Ostream& operator<<
80 (
81  Ostream&,
82  const perfectFluid<Specie>&
83 );
84 
85 
86 /*---------------------------------------------------------------------------*\
87  Class perfectFluid Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 template<class Specie>
91 class perfectFluid
92 :
93  public Specie
94 {
95  // Private Data
96 
97  //- Fluid constant
98  scalar R_;
99 
100  //- The reference density
101  scalar rho0_;
102 
103 
104 public:
105 
106  // Constructors
107 
108  //- Construct from components
109  inline perfectFluid
110  (
111  const Specie& sp,
112  const scalar R,
113  const scalar rho0
114  );
115 
116  //- Construct from dictionary
117  perfectFluid(const dictionary& dict);
118 
119  //- Construct as named copy
120  inline perfectFluid(const word& name, const perfectFluid&);
121 
122  //- Construct and return a clone
123  inline autoPtr<perfectFluid> clone() const;
124 
125  // Selector from dictionary
126  inline static autoPtr<perfectFluid> New(const dictionary& dict);
127 
128 
129  // Member Functions
130 
131  //- Return the instantiated type name
132  static word typeName()
133  {
134  return "perfectFluid<" + word(Specie::typeName_()) + '>';
135  }
136 
137 
138  // Fundamental properties
139 
140  //- Is the equation of state is incompressible i.e. rho != f(p)
141  static const bool incompressible = false;
142 
143  //- Is the equation of state is isochoric i.e. rho = const
144  static const bool isochoric = false;
145 
146  //- Return fluid constant [J/kg/K]
147  inline scalar R() const;
148 
149  //- Return density [kg/m^3]
150  inline scalar rho(scalar p, scalar T) const;
151 
152  //- Return enthalpy contribution [J/kg]
153  inline scalar H(const scalar p, const scalar T) const;
154 
155  //- Return Cp contribution [J/(kg K]
156  inline scalar Cp(scalar p, scalar T) const;
157 
158  //- Return internal energy contribution [J/kg]
159  inline scalar E(const scalar p, const scalar T) const;
160 
161  //- Return Cv contribution [J/(kg K]
162  inline scalar Cv(scalar p, scalar T) const;
163 
164  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
165  inline scalar Sp(const scalar p, const scalar T) const;
166 
167  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
168  inline scalar Sv(const scalar p, const scalar T) const;
169 
170  //- Return compressibility [s^2/m^2]
171  inline scalar psi(scalar p, scalar T) const;
172 
173  //- Return compression factor []
174  inline scalar Z(scalar p, scalar T) const;
175 
176  //- Return (Cp - Cv) [J/(kg K]
177  inline scalar CpMCv(scalar p, scalar T) const;
178 
179 
180  // IO
181 
182  //- Write to Ostream
183  void write(Ostream& os) const;
184 
185 
186  // Member Operators
187 
188  inline void operator+=(const perfectFluid&);
189  inline void operator*=(const scalar);
190 
191 
192  // Friend operators
193 
194  friend perfectFluid operator+ <Specie>
195  (
196  const perfectFluid&,
197  const perfectFluid&
198  );
199 
200  friend perfectFluid operator* <Specie>
201  (
202  const scalar s,
203  const perfectFluid&
204  );
205 
206  friend perfectFluid operator== <Specie>
207  (
208  const perfectFluid&,
209  const perfectFluid&
210  );
211 
212 
213  // Ostream Operator
214 
215  friend Ostream& operator<< <Specie>
216  (
217  Ostream&,
218  const perfectFluid&
219  );
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #include "perfectFluidI.H"
230 
231 #ifdef NoRepository
232  #include "perfectFluid.C"
233 #endif
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
autoPtr< perfectFluid > clone() const
Construct and return a clone.
Definition: perfectFluidI.H:61
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
dictionary dict
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
Definition: perfectFluid.H:143
static word typeName()
Return the instantiated type name.
Definition: perfectFluid.H:131
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
Definition: perfectFluid.H:140
perfectFluid(const Specie &sp, const scalar R, const scalar rho0)
Construct from components.
Definition: perfectFluidI.H:32
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: perfectFluidI.H:88
scalar rho0
static autoPtr< perfectFluid > New(const dictionary &dict)
Definition: perfectFluidI.H:70
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
scalar R() const
Return fluid constant [J/kg/K].
Definition: perfectFluidI.H:81
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
A class for handling words, derived from string.
Definition: word.H:59
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
void operator*=(const scalar)
scalar Z(scalar p, scalar T) const
Return compression factor [].
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
Definition: perfectFluidI.H:95
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Simple extension of the perfect gas equation of state to liquids by the addition of a constant densit...
Definition: perfectFluid.H:54
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
void write(Ostream &os) const
Write to Ostream.
Definition: perfectFluid.C:43
volScalarField & p
void operator+=(const perfectFluid &)
Namespace for OpenFOAM.
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].