incompressiblePerfectGasI.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-2023 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 \*---------------------------------------------------------------------------*/
25 
27 
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Specie>
33 (
34  const Specie& sp,
35  const scalar pRef
36 )
37 :
38  Specie(sp),
39  pRef_(pRef)
40 {}
41 
42 
43 template<class Specie>
45 (
46  const word& name,
48 )
49 :
50  Specie(name, ipg),
51  pRef_(ipg.pRef_)
52 {}
53 
54 
55 template<class Specie>
58 {
60  (
62  );
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class Specie>
70 (
71  scalar p,
72  scalar T
73 ) const
74 {
75  return pRef_/(this->R()*T);
76 }
77 
78 
79 template<class Specie>
81 (
82  scalar p,
83  scalar T
84 ) const
85 {
86  return p/this->rho(p, T);
87 }
88 
89 
90 template<class Specie>
92 (
93  scalar p,
94  scalar T
95 ) const
96 {
97  return 0;
98 }
99 
100 
101 template<class Specie>
103 (
104  scalar p,
105  scalar T
106 ) const
107 {
108  return 0;
109 }
110 
111 
112 template<class Specie>
114 (
115  scalar p,
116  scalar T
117 ) const
118 {
119  return 0;
120 }
121 
122 
123 template<class Specie>
125 (
126  scalar p,
127  scalar T
128 ) const
129 {
130  return 0;
131 }
132 
133 
134 template<class Specie>
136 (
137  scalar p,
138  scalar T
139 ) const
140 {
141  return 0;
142 }
143 
144 
145 template<class Specie>
147 (
148  scalar p,
149  scalar T
150 ) const
151 {
152  return 0;
153 }
154 
155 
156 template<class Specie>
158 (
159  scalar p,
160  scalar T
161 ) const
162 {
163  return p/(rho(p, T)*this->R()*T);
164 }
165 
166 
167 template<class Specie>
169 (
170  scalar p,
171  scalar T
172 ) const
173 {
174  return 0;
175 }
176 
177 
178 template<class Specie>
180 (
181  scalar p,
182  scalar T
183 ) const
184 {
185  return 1/T;
186 }
187 
188 
189 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
190 
191 template<class Specie>
193 (
195 )
196 {
197  if (notEqual(pRef_, ipg.pRef_))
198  {
200  << "pRef " << pRef_ << " for "
201  << (this->name().size() ? this->name() : "others")
202  << " != " << ipg.pRef_ << " for "
203  << (ipg.name().size() ? ipg.name() : "others")
204  << exit(FatalError);
205  }
206 
207  Specie::operator+=(ipg);
208 }
209 
210 
211 template<class Specie>
213 {
214  Specie::operator*=(s);
215 }
216 
217 
218 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
219 
220 template<class Specie>
221 inline Foam::incompressiblePerfectGas<Specie> Foam::operator+
222 (
225 )
226 {
227  if (notEqual(ipg1.pRef_, ipg2.pRef_))
228  {
230  << "pRef " << ipg1.pRef_ << " for "
231  << (ipg1.name().size() ? ipg1.name() : "others")
232  << " != " << ipg2.pRef_ << " for "
233  << (ipg2.name().size() ? ipg2.name() : "others")
234  << exit(FatalError);
235  }
236 
237  return incompressiblePerfectGas<Specie>
238  (
239  static_cast<const Specie&>(ipg1) + static_cast<const Specie&>(ipg2),
240  ipg1.pRef_
241  );
242 }
243 
244 
245 template<class Specie>
246 inline Foam::incompressiblePerfectGas<Specie> Foam::operator*
247 (
248  const scalar s,
249  const incompressiblePerfectGas<Specie>& ipg
250 )
251 {
252  return incompressiblePerfectGas<Specie>
253  (
254  s*static_cast<const Specie&>(ipg),
255  ipg.pRef_
256  );
257 }
258 
259 
260 template<class Specie>
261 inline Foam::incompressiblePerfectGas<Specie> Foam::operator==
262 (
263  const incompressiblePerfectGas<Specie>& ipg1,
264  const incompressiblePerfectGas<Specie>& ipg2
265 )
266 {
267  return incompressiblePerfectGas<Specie>
268  (
269  static_cast<const Specie&>(ipg1) == static_cast<const Specie&>(ipg2),
270  NaN
271  );
272 }
273 
274 
275 // ************************************************************************* //
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Incompressible gas equation of state using a constant reference pressure in the perfect gas equation ...
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
autoPtr< incompressiblePerfectGas > clone() const
Construct and return a clone.
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
incompressiblePerfectGas(const Specie &sp, const scalar pRef)
Construct from components.
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
scalar Z(scalar p, scalar T) const
Return compression factor [].
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static Type NaN()
Return a primitive with all components set to NaN.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
bool notEqual(const Scalar s1, const Scalar s2)
Definition: Scalar.H:215
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
volScalarField & p