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-2016 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  return autoPtr<linear<Specie>>(new linear<Specie>(is));
72 }
73 
74 
75 template<class Specie>
78 (
79  const dictionary& dict
80 )
81 {
83 }
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
88 template<class Specie>
89 inline Foam::scalar Foam::linear<Specie>::rho(scalar p, scalar T) const
90 {
91  return rho0_ + psi_*p;
92 }
93 
94 
95 template<class Specie>
96 inline Foam::scalar Foam::linear<Specie>::h(scalar p, scalar T) const
97 {
98  return 0;
99 }
100 
101 
102 template<class Specie>
103 inline Foam::scalar Foam::linear<Specie>::cp(scalar p, scalar T) const
104 {
105  return 0;
106 }
107 
108 
109 template<class Specie>
110 inline Foam::scalar Foam::linear<Specie>::s(scalar p, scalar T) const
111 {
112  return -log((rho0_ + psi_*p)/(rho0_ + psi_*Pstd))/(T*psi_);
113 }
114 
115 
116 template<class Specie>
117 inline Foam::scalar Foam::linear<Specie>::psi(scalar p, scalar T) const
118 {
119  return psi_;
120 }
121 
122 
123 template<class Specie>
124 inline Foam::scalar Foam::linear<Specie>::Z(scalar p, scalar T) const
125 {
126  return 1;
127 }
128 
129 
130 template<class Specie>
131 inline Foam::scalar Foam::linear<Specie>::cpMcv(scalar p, scalar T) const
132 {
133  return 0;
134 }
135 
136 
137 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
138 
139 template<class Specie>
140 inline void Foam::linear<Specie>::operator+=
141 (
142  const linear<Specie>& pf
143 )
144 {
145  scalar molr1 = this->nMoles();
146 
147  Specie::operator+=(pf);
148 
149  molr1 /= this->nMoles();
150  scalar molr2 = pf.nMoles()/this->nMoles();
151 
152  psi_ = molr1*psi_ + molr2*pf.psi_;
153  rho0_ = molr1*rho0_ + molr2*pf.rho0_;
154 }
155 
156 
157 template<class Specie>
158 inline void Foam::linear<Specie>::operator-=
159 (
160  const linear<Specie>& pf
161 )
162 {
163  scalar molr1 = this->nMoles();
164 
165  Specie::operator-=(pf);
166 
167  molr1 /= this->nMoles();
168  scalar molr2 = pf.nMoles()/this->nMoles();
169 
170  psi_ = molr1*psi_ - molr2*pf.psi_;
171  rho0_ = molr1*rho0_ - molr2*pf.rho0_;
172 }
173 
174 
175 template<class Specie>
176 inline void Foam::linear<Specie>::operator*=(const scalar s)
177 {
178  Specie::operator*=(s);
179 }
180 
181 
182 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
183 
184 template<class Specie>
185 inline Foam::linear<Specie> Foam::operator+
186 (
187  const linear<Specie>& pf1,
188  const linear<Specie>& pf2
189 )
190 {
191  scalar nMoles = pf1.nMoles() + pf2.nMoles();
192  scalar molr1 = pf1.nMoles()/nMoles;
193  scalar molr2 = pf2.nMoles()/nMoles;
194 
195  return rhoConst<Specie>
196  (
197  static_cast<const Specie&>(pf1)
198  + static_cast<const Specie&>(pf2),
199  molr1*pf1.psi_ + molr2*pf2.psi_,
200  molr1*pf1.rho0_ + molr2*pf2.rho0_
201  );
202 }
203 
204 
205 template<class Specie>
206 inline Foam::linear<Specie> Foam::operator-
207 (
208  const linear<Specie>& pf1,
209  const linear<Specie>& pf2
210 )
211 {
212  scalar nMoles = pf1.nMoles() + pf2.nMoles();
213  scalar molr1 = pf1.nMoles()/nMoles;
214  scalar molr2 = pf2.nMoles()/nMoles;
215 
216  return rhoConst<Specie>
217  (
218  static_cast<const Specie&>(pf1)
219  - static_cast<const Specie&>(pf2),
220  molr1*pf1.psi_ - molr2*pf2.psi_,
221  molr1*pf1.rho0_ - molr2*pf2.rho0_
222  );
223 }
224 
225 
226 template<class Specie>
227 inline Foam::linear<Specie> Foam::operator*
228 (
229  const scalar s,
230  const linear<Specie>& pf
231 )
232 {
233  return linear<Specie>
234  (
235  s*static_cast<const Specie&>(pf),
236  pf.psi_,
237  pf.rho0_
238  );
239 }
240 
241 
242 template<class Specie>
243 inline Foam::linear<Specie> Foam::operator==
244 (
245  const linear<Specie>& pf1,
246  const linear<Specie>& pf2
247 )
248 {
249  return pf2 - pf1;
250 }
251 
252 
253 // ************************************************************************* //
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: linearI.H:110
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:89
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
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:117
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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:176
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:124
static autoPtr< linear > New(Istream &is)
Definition: linearI.H:69
scalar cp(scalar p, scalar T) const
Return cp departure [J/(kmol K].
Definition: linearI.H:103
const dimensionedScalar Pstd
Standard pressure.
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:69
scalar h(const scalar p, const scalar T) const
Return enthalpy departure [J/kmol].
Definition: linearI.H:96
const volScalarField & T
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: linearI.H:131
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
RhoConst (rho = const) of state.
Definition: rhoConst.H:47
volScalarField & p
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:61