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 | Copyright (C) 2013-2017 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 
26 #include "linear.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Specie>
32 (
33  const Specie& sp,
34  const scalar psi,
35  const scalar rho0
36 )
37 :
38  Specie(sp),
39  psi_(psi),
40  rho0_(rho0)
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 template<class Specie>
48 (
49  const word& name,
50  const linear<Specie>& pf
51 )
52 :
53  Specie(name, pf),
54  psi_(pf.psi_),
55  rho0_(pf.rho0_)
56 {}
57 
58 
59 template<class Specie>
62 {
63  return autoPtr<linear<Specie>>(new linear<Specie>(*this));
64 }
65 
66 
67 template<class Specie>
70 (
71  const dictionary& dict
72 )
73 {
75 }
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
80 template<class Specie>
81 inline Foam::scalar Foam::linear<Specie>::rho(scalar p, scalar T) const
82 {
83  return rho0_ + psi_*p;
84 }
85 
86 
87 template<class Specie>
88 inline Foam::scalar Foam::linear<Specie>::H(scalar p, scalar T) const
89 {
90  return 0;
91 }
92 
93 
94 template<class Specie>
95 inline Foam::scalar Foam::linear<Specie>::Cp(scalar p, scalar T) const
96 {
97  return 0;
98 }
99 
100 
101 template<class Specie>
102 inline Foam::scalar Foam::linear<Specie>::S(scalar p, scalar T) const
103 {
104  return -log((rho0_ + psi_*p)/(rho0_ + psi_*Pstd))/(T*psi_);
105 }
106 
107 
108 template<class Specie>
109 inline Foam::scalar Foam::linear<Specie>::psi(scalar p, scalar T) const
110 {
111  return psi_;
112 }
113 
114 
115 template<class Specie>
116 inline Foam::scalar Foam::linear<Specie>::Z(scalar p, scalar T) const
117 {
118  return 1;
119 }
120 
121 
122 template<class Specie>
123 inline Foam::scalar Foam::linear<Specie>::CpMCv(scalar p, scalar T) const
124 {
125  return 0;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
130 
131 template<class Specie>
132 inline void Foam::linear<Specie>::operator+=
133 (
134  const linear<Specie>& pf
135 )
136 {
137  scalar Y1 = this->Y();
138  Specie::operator+=(pf);
139 
140  if (mag(this->Y()) > SMALL)
141  {
142  Y1 /= this->Y();
143  const scalar Y2 = pf.Y()/this->Y();
144 
145  psi_ = Y1*psi_ + Y2*pf.psi_;
146  rho0_ = Y1*rho0_ + Y2*pf.rho0_;
147  }
148 }
149 
150 
151 template<class Specie>
152 inline void Foam::linear<Specie>::operator*=(const scalar s)
153 {
154  Specie::operator*=(s);
155 }
156 
157 
158 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
159 
160 template<class Specie>
161 inline Foam::linear<Specie> Foam::operator+
162 (
163  const linear<Specie>& pf1,
164  const linear<Specie>& pf2
165 )
166 {
167  Specie sp
168  (
169  static_cast<const Specie&>(pf1)
170  + static_cast<const Specie&>(pf2)
171  );
172 
173  if (mag(sp.Y()) < SMALL)
174  {
175  return linear<Specie>
176  (
177  sp,
178  pf1.psi_,
179  pf1.rho0_
180  );
181  }
182  else
183  {
184  const scalar Y1 = pf1.Y()/sp.Y();
185  const scalar Y2 = pf2.Y()/sp.Y();
186 
187  return linear<Specie>
188  (
189  sp,
190  Y1*pf1.psi_ + Y2*pf2.psi_,
191  Y1*pf1.rho0_ + Y2*pf2.rho0_
192  );
193  }
194 }
195 
196 
197 template<class Specie>
198 inline Foam::linear<Specie> Foam::operator*
199 (
200  const scalar s,
201  const linear<Specie>& pf
202 )
203 {
204  return linear<Specie>
205  (
206  s*static_cast<const Specie&>(pf),
207  pf.psi_,
208  pf.rho0_
209  );
210 }
211 
212 
213 template<class Specie>
214 inline Foam::linear<Specie> Foam::operator==
215 (
216  const linear<Specie>& pf1,
217  const linear<Specie>& pf2
218 )
219 {
220  Specie sp
221  (
222  static_cast<const Specie&>(pf1)
223  == static_cast<const Specie&>(pf2)
224  );
225 
226  const scalar Y1 = pf1.Y()/sp.Y();
227  const scalar Y2 = pf2.Y()/sp.Y();
228 
229  return linear<Specie>
230  (
231  sp,
232  Y2*pf2.psi_ - Y1*pf1.psi_,
233  Y2*pf2.rho0_ - Y1*pf1.rho0_
234  );
235 }
236 
237 
238 // ************************************************************************* //
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
Definition: linearI.H:88
PtrList< volScalarField > & Y1
Definition: YEqns.H:8
dictionary dict
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static autoPtr< linear > New(const dictionary &dict)
Definition: linearI.H:70
Central-differencing interpolation scheme class.
Definition: linear.H:50
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: linearI.H:109
scalar S(const scalar p, const scalar T) const
Return entropy [J/(kg K)].
Definition: linearI.H:102
PtrList< volScalarField > & Y2
Definition: YEqns.H:9
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
void operator*=(const scalar)
Definition: linearI.H:152
const dimensionedScalar Pstd
Standard pressure.
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:69
const volScalarField & T
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:81
PtrList< volScalarField > & Y
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
Definition: linearI.H:123
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:61
volScalarField & p
scalar Cp(scalar p, scalar T) const
Return Cp departure [J/(kg K].
Definition: linearI.H:95
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:116