linearI.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) 2013-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 \*---------------------------------------------------------------------------*/
27 
28 #include "linear.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class Specie>
34 (
35  const Specie& sp,
36  const scalar psi,
37  const scalar rho0
38 )
39 :
40  Specie(sp),
41  psi_(psi),
42  rho0_(rho0)
43 {}
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 template<class Specie>
50 (
51  const word& name,
52  const linear<Specie>& pf
53 )
54 :
55  Specie(name, pf),
56  psi_(pf.psi_),
57  rho0_(pf.rho0_)
58 {}
59 
60 
61 template<class Specie>
64 {
65  return autoPtr<linear<Specie>>::New(*this);
66 }
67 
68 
69 template<class Specie>
72 (
73  const dictionary& dict
74 )
75 {
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class Specie>
83 inline Foam::scalar Foam::linear<Specie>::rho(scalar p, scalar T) const
84 {
85  return rho0_ + psi_*p;
86 }
87 
88 
89 template<class Specie>
90 inline Foam::scalar Foam::linear<Specie>::H(scalar p, scalar T) const
91 {
92  return 0;
93 }
94 
95 
96 template<class Specie>
97 inline Foam::scalar Foam::linear<Specie>::Cp(scalar p, scalar T) const
98 {
99  return 0;
100 }
101 
102 template<class Specie>
103 inline Foam::scalar Foam::linear<Specie>::E(scalar p, scalar T) const
104 {
105  return 0;
106 }
107 
108 
109 template<class Specie>
110 inline Foam::scalar Foam::linear<Specie>::Cv(scalar p, scalar T) const
111 {
112  return 0;
113 }
114 
115 
116 template<class Specie>
117 inline Foam::scalar Foam::linear<Specie>::S(scalar p, scalar T) const
118 {
119  return -log((rho0_ + psi_*p)/(rho0_ + psi_*Pstd))/(T*psi_);
120 }
121 
122 
123 template<class Specie>
124 inline Foam::scalar Foam::linear<Specie>::psi(scalar p, scalar T) const
125 {
126  return psi_;
127 }
128 
129 
130 template<class Specie>
131 inline Foam::scalar Foam::linear<Specie>::Z(scalar p, scalar T) const
132 {
133  return 1;
134 }
135 
136 
137 template<class Specie>
138 inline Foam::scalar Foam::linear<Specie>::CpMCv(scalar p, scalar T) const
139 {
140  return 0;
141 }
142 
143 
144 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
145 
146 template<class Specie>
147 inline void Foam::linear<Specie>::operator+=
148 (
149  const linear<Specie>& pf
150 )
151 {
152  scalar Y1 = this->Y();
153  Specie::operator+=(pf);
154 
155  if (mag(this->Y()) > SMALL)
156  {
157  Y1 /= this->Y();
158  const scalar Y2 = pf.Y()/this->Y();
159 
160  psi_ = Y1*psi_ + Y2*pf.psi_;
161  rho0_ = Y1*rho0_ + Y2*pf.rho0_;
162  }
163 }
164 
165 
166 template<class Specie>
167 inline void Foam::linear<Specie>::operator*=(const scalar s)
168 {
169  Specie::operator*=(s);
170 }
171 
172 
173 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
174 
175 template<class Specie>
176 inline Foam::linear<Specie> Foam::operator+
177 (
178  const linear<Specie>& pf1,
179  const linear<Specie>& pf2
180 )
181 {
182  Specie sp
183  (
184  static_cast<const Specie&>(pf1)
185  + static_cast<const Specie&>(pf2)
186  );
187 
188  if (mag(sp.Y()) < SMALL)
189  {
190  return linear<Specie>
191  (
192  sp,
193  pf1.psi_,
194  pf1.rho0_
195  );
196  }
197  else
198  {
199  const scalar Y1 = pf1.Y()/sp.Y();
200  const scalar Y2 = pf2.Y()/sp.Y();
201 
202  return linear<Specie>
203  (
204  sp,
205  Y1*pf1.psi_ + Y2*pf2.psi_,
206  Y1*pf1.rho0_ + Y2*pf2.rho0_
207  );
208  }
209 }
210 
211 
212 template<class Specie>
213 inline Foam::linear<Specie> Foam::operator*
214 (
215  const scalar s,
216  const linear<Specie>& pf
217 )
218 {
219  return linear<Specie>
220  (
221  s*static_cast<const Specie&>(pf),
222  pf.psi_,
223  pf.rho0_
224  );
225 }
226 
227 
228 template<class Specie>
229 inline Foam::linear<Specie> Foam::operator==
230 (
231  const linear<Specie>& pf1,
232  const linear<Specie>& pf2
233 )
234 {
235  Specie sp
236  (
237  static_cast<const Specie&>(pf1)
238  == static_cast<const Specie&>(pf2)
239  );
240 
241  const scalar Y1 = pf1.Y()/sp.Y();
242  const scalar Y2 = pf2.Y()/sp.Y();
243 
244  return linear<Specie>
245  (
246  sp,
247  Y2*pf2.psi_ - Y1*pf1.psi_,
248  Y2*pf2.rho0_ - Y1*pf1.rho0_
249  );
250 }
251 
252 
253 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::linear::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:131
Foam::linear::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:83
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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::constant::standard::Pstd
const dimensionedScalar Pstd
Standard pressure.
Definition: thermodynamicConstants.C:48
Foam::linear::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: linearI.H:124
Foam::linear::operator*=
void operator*=(const scalar)
Definition: linearI.H:167
Foam::linear::S
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
Definition: linearI.H:117
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::linear::clone
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:63
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
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:262
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
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::linear::CpMCv
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: linearI.H:138
Foam::linear::E
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
Definition: linearI.H:103
Foam::linear::linear
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:74
Foam::linear::Cp
scalar Cp(scalar p, scalar T) const
Return Cp departure [J/(kg K].
Definition: linearI.H:97
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::linear::New
static autoPtr< linear > New(const dictionary &dict)
Definition: linearI.H:72
linear.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:55
Foam::linear::H
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
Definition: linearI.H:90
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::linear::Cv
scalar Cv(scalar p, scalar T) const
Return Cv departure [J/(kg K].
Definition: linearI.H:110