icoPolynomialI.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) 2011-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 "icoPolynomial.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Specie, int PolySize>
32 (
33  const Specie& sp,
34  const Polynomial<PolySize>& rhoCoeffs
35 )
36 :
37  Specie(sp),
38  rhoCoeffs_(rhoCoeffs)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<class Specie, int PolySize>
46 (
47  const icoPolynomial<Specie, PolySize>& ip
48 )
49 :
50  Specie(ip),
51  rhoCoeffs_(ip.rhoCoeffs_)
52 {}
53 
54 
55 template<class Specie, int PolySize>
57 (
58  const word& name,
59  const icoPolynomial<Specie, PolySize>& ip
60 )
61 :
62  Specie(name, ip),
63  rhoCoeffs_(ip.rhoCoeffs_)
64 {}
65 
66 
67 template<class Specie, int PolySize>
70 {
72  (
74  );
75 }
76 
77 
78 template<class Specie, int PolySize>
81 {
83  (
85  );
86 }
87 
88 
89 template<class Specie, int PolySize>
92 {
94  (
96  );
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 template<class Specie, int PolySize>
104 (
105  scalar p,
106  scalar T
107 ) const
108 {
109  return rhoCoeffs_.value(T)/this->W();
110 }
111 
112 
113 template<class Specie, int PolySize>
115 (
116  scalar p,
117  scalar T
118 ) const
119 {
120  return 0;
121 }
122 
123 
124 template<class Specie, int PolySize>
126 (
127  scalar p,
128  scalar T
129 ) const
130 {
131  return 0;
132 }
133 
134 
135 template<class Specie, int PolySize>
137 (
138  scalar p,
139  scalar T
140 ) const
141 {
142  return 0;
143 }
144 
145 
146 template<class Specie, int PolySize>
148 (
149  scalar p,
150  scalar T
151 ) const
152 {
153  return -(p/sqr(rhoCoeffs_.value(T)))*rhoCoeffs_.derivative(T);
154 }
155 
156 
157 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
158 
159 template<class Specie, int PolySize>
162 (
164 )
165 {
166  Specie::operator=(ip);
167 
168  rhoCoeffs_ = ip.rhoCoeffs_;
169 
170  return *this;
171 }
172 
173 
174 template<class Specie, int PolySize>
176 (
178 )
179 {
180  scalar molr1 = this->nMoles();
181 
182  Specie::operator+=(ip);
183 
184  molr1 /= this->nMoles();
185  scalar molr2 = ip.nMoles()/this->nMoles();
186 
187  rhoCoeffs_ = molr1*rhoCoeffs_ + molr2*ip.rhoCoeffs_;
188 }
189 
190 
191 template<class Specie, int PolySize>
193 (
195 )
196 {
197  scalar molr1 = this->nMoles();
198 
199  Specie::operator-=(ip);
200 
201  molr1 /= this->nMoles();
202  scalar molr2 = ip.nMoles()/this->nMoles();
203 
204  rhoCoeffs_ = molr1*rhoCoeffs_ - molr2*ip.rhoCoeffs_;
205 }
206 
207 
208 template<class Specie, int PolySize>
210 {
211  Specie::operator*=(s);
212 }
213 
214 
215 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
216 
217 template<class Specie, int PolySize>
219 (
222 )
223 {
224  scalar nMoles = ip1.nMoles() + ip2.nMoles();
225  scalar molr1 = ip1.nMoles()/nMoles;
226  scalar molr2 = ip2.nMoles()/nMoles;
227 
229  (
230  static_cast<const Specie&>(ip1)
231  + static_cast<const Specie&>(ip2),
232  molr1*ip1.rhoCoeffs_ + molr2*ip2.rhoCoeffs_
233  );
234 }
235 
236 
237 template<class Specie, int PolySize>
239 (
240  const icoPolynomial<Specie, PolySize>& ip1,
241  const icoPolynomial<Specie, PolySize>& ip2
242 )
243 {
244  scalar nMoles = ip1.nMoles() + ip2.nMoles();
245  scalar molr1 = ip1.nMoles()/nMoles;
246  scalar molr2 = ip2.nMoles()/nMoles;
247 
248  return icoPolynomial<Specie, PolySize>
249  (
250  static_cast<const Specie&>(ip1)
251  - static_cast<const Specie&>(ip2),
252  molr1*ip1.rhoCoeffs_ - molr2*ip2.rhoCoeffs_
253  );
254 }
255 
256 
257 template<class Specie, int PolySize>
259 (
260  const scalar s,
261  const icoPolynomial<Specie, PolySize>& ip
262 )
263 {
264  return icoPolynomial<Specie, PolySize>
265  (
266  s*static_cast<const Specie&>(ip),
267  ip.rhoCoeffs_
268  );
269 }
270 
271 
272 template<class Specie, int PolySize>
274 (
275  const icoPolynomial<Specie, PolySize>& ip1,
276  const icoPolynomial<Specie, PolySize>& ip2
277 )
278 {
279  return ip2 - ip1;
280 }
281 
282 
283 // ************************************************************************* //
icoPolynomial.H
p
p
Definition: pEqn.H:62
Foam::icoPolynomial::clone
autoPtr< icoPolynomial > clone() const
Construct and return a clone.
Definition: icoPolynomialI.H:69
Foam::icoPolynomial::rho
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
Definition: icoPolynomialI.H:104
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::icoPolynomial::cpMcv
scalar cpMcv(scalar p, scalar T) const
Return (cp - cv) [J/(kmol K].
Definition: icoPolynomialI.H:148
Foam::icoPolynomial::s
scalar s(const scalar p, const scalar T) const
Return entropy [J/(kmol K)].
Definition: icoPolynomialI.H:115
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::icoPolynomial::operator*=
void operator*=(const scalar)
Definition: icoPolynomialI.H:209
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
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::icoPolynomial::New
static autoPtr< icoPolynomial > New(Istream &is)
Definition: icoPolynomialI.H:80
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
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
T
const volScalarField & T
Definition: createFields.H:25
Foam::icoPolynomial::icoPolynomial
icoPolynomial(const Specie &sp, const Polynomial< PolySize > &rhoPoly)
Construct from components.
Foam::icoPolynomial::psi
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
Definition: icoPolynomialI.H:126
Foam::icoPolynomial::Z
scalar Z(scalar p, scalar T) const
Return compression factor [].
Definition: icoPolynomialI.H:137
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::icoPolynomial
Incompressible, polynomial form of equation of state, using a polynomial function for density.
Definition: icoPolynomial.H:50