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-2015 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>::s(scalar p, scalar T) const
97 {
98  return -log((rho0_ + psi_*p)/(rho0_ + psi_*Pstd))/(T*psi_);
99 }
100 
101 
102 template<class Specie>
103 inline Foam::scalar Foam::linear<Specie>::psi(scalar p, scalar T) const
104 {
105  return psi_;
106 }
107 
108 
109 template<class Specie>
110 inline Foam::scalar Foam::linear<Specie>::Z(scalar p, scalar T) const
111 {
112  return 1;
113 }
114 
115 
116 template<class Specie>
117 inline Foam::scalar Foam::linear<Specie>::cpMcv(scalar p, scalar T) const
118 {
119  return 0;
120 }
121 
122 
123 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
124 
125 template<class Specie>
126 inline void Foam::linear<Specie>::operator+=
127 (
128  const linear<Specie>& pf
129 )
130 {
131  scalar molr1 = this->nMoles();
132 
133  Specie::operator+=(pf);
134 
135  molr1 /= this->nMoles();
136  scalar molr2 = pf.nMoles()/this->nMoles();
137 
138  psi_ = molr1*psi_ + molr2*pf.psi_;
139  rho0_ = molr1*rho0_ + molr2*pf.rho0_;
140 }
141 
142 
143 template<class Specie>
144 inline void Foam::linear<Specie>::operator-=
145 (
146  const linear<Specie>& pf
147 )
148 {
149  scalar molr1 = this->nMoles();
150 
151  Specie::operator-=(pf);
152 
153  molr1 /= this->nMoles();
154  scalar molr2 = pf.nMoles()/this->nMoles();
155 
156  psi_ = molr1*psi_ - molr2*pf.psi_;
157  rho0_ = molr1*rho0_ - molr2*pf.rho0_;
158 }
159 
160 
161 template<class Specie>
162 inline void Foam::linear<Specie>::operator*=(const scalar s)
163 {
164  Specie::operator*=(s);
165 }
166 
167 
168 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
169 
170 template<class Specie>
171 inline Foam::linear<Specie> Foam::operator+
172 (
173  const linear<Specie>& pf1,
174  const linear<Specie>& pf2
175 )
176 {
177  scalar nMoles = pf1.nMoles() + pf2.nMoles();
178  scalar molr1 = pf1.nMoles()/nMoles;
179  scalar molr2 = pf2.nMoles()/nMoles;
180 
181  return rhoConst<Specie>
182  (
183  static_cast<const Specie&>(pf1)
184  + static_cast<const Specie&>(pf2),
185  molr1*pf1.psi_ + molr2*pf2.psi_,
186  molr1*pf1.rho0_ + molr2*pf2.rho0_
187  );
188 }
189 
190 
191 template<class Specie>
192 inline Foam::linear<Specie> Foam::operator-
193 (
194  const linear<Specie>& pf1,
195  const linear<Specie>& pf2
196 )
197 {
198  scalar nMoles = pf1.nMoles() + pf2.nMoles();
199  scalar molr1 = pf1.nMoles()/nMoles;
200  scalar molr2 = pf2.nMoles()/nMoles;
201 
202  return rhoConst<Specie>
203  (
204  static_cast<const Specie&>(pf1)
205  - static_cast<const Specie&>(pf2),
206  molr1*pf1.psi_ - molr2*pf2.psi_,
207  molr1*pf1.rho0_ - molr2*pf2.rho0_
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  return pf2 - pf1;
236 }
237 
238 
239 // ************************************************************************* //
Foam::linear::psi_
scalar psi_
Compressibility.
Definition: linear.H:101
Foam::linear::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: linearI.H:110
Foam::linear::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: linearI.H:89
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::constant::standard::Pstd
const dimensionedScalar Pstd
Standard pressure.
Definition: thermodynamicConstants.C:46
Foam::linear::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: linearI.H:103
Foam::linear::operator*=
void operator*=(const scalar)
Definition: linearI.H:162
Foam::linear::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: linearI.H:96
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::linear::clone
autoPtr< linear > clone() const
Construct and return a clone.
Definition: linearI.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::linear::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: linearI.H:117
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:253
s
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))
Foam::linear::New
static autoPtr< linear > New(Istream &is)
Definition: linearI.H:69
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
rho0
scalar rho0
Definition: readInitialConditions.H:97
Foam::linear::rho0_
scalar rho0_
The reference density.
Definition: linear.H:104
Foam::linear::linear
linear(const fvMesh &mesh)
Construct from mesh.
Definition: linear.H:69
psi
const volScalarField & psi
Definition: setRegionFluidFields.H:13
linear.H
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:50
Foam::rhoConst
RhoConst (rho = const) of state.
Definition: rhoConst.H:47
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47