Forward compatibility: flex
[foam-extend-3.2.git] / src / thermophysicalModels / specie / transport / polynomial / polynomialTransportI.H
blobfc1c0a09bb689b124355f9fc2d0b7c76b7e83222
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "specie.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 template<class Thermo, int PolySize>
31 inline Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
33     const polynomialTransport& pt
36     Thermo(pt),
37     muPolynomial_(pt.muPolynomial_),
38     kappaPolynomial_(pt.kappaPolynomial_)
42 template<class Thermo, int PolySize>
43 inline Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
45     const Thermo& t,
46     const Polynomial<PolySize>& muPoly,
47     const Polynomial<PolySize>& kappaPoly
50     Thermo(t),
51     muPolynomial_(muPoly),
52     kappaPolynomial_(kappaPoly)
56 template<class Thermo, int PolySize>
57 inline Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
59     const word& name,
60     const polynomialTransport& pt
63     Thermo(name, pt),
64     muPolynomial_(pt.muPolynomial_),
65     kappaPolynomial_(pt.kappaPolynomial_)
69 template<class Thermo, int PolySize>
70 inline Foam::autoPtr<Foam::polynomialTransport<Thermo, PolySize> >
71 Foam::polynomialTransport<Thermo, PolySize>::clone() const
73     return autoPtr<polynomialTransport<Thermo, PolySize> >
74     (
75         new polynomialTransport<Thermo, PolySize>(*this)
76     );
80 template<class Thermo, int PolySize>
81 inline Foam::autoPtr<Foam::polynomialTransport<Thermo, PolySize> >
82 Foam::polynomialTransport<Thermo, PolySize>::New(Istream& is)
84     return autoPtr<polynomialTransport<Thermo, PolySize> >
85     (
86         new polynomialTransport<Thermo, PolySize>(is)
87     );
91 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
93 template<class Thermo, int PolySize>
94 inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::mu
96     const scalar T
97 ) const
99     return muPolynomial_.evaluate(T)/this->W();
103 template<class Thermo, int PolySize>
104 inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::kappa
106     const scalar T
107 ) const
109     return kappaPolynomial_.evaluate(T)/this->W();
113 template<class Thermo, int PolySize>
114 inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::alpha
116     const scalar T
117 ) const
119     scalar deltaT = T - specie::Tstd();
120     scalar CpBar =
121         (deltaT*(this->H(T) - this->H(specie::Tstd())) + this->Cp(T))
122        /(sqr(deltaT) + 1);
124     return kappa(T)/CpBar;
128 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
130 template<class Thermo, int PolySize>
131 inline Foam::polynomialTransport<Thermo, PolySize>&
132 Foam::polynomialTransport<Thermo, PolySize>::operator=
134     const polynomialTransport<Thermo, PolySize>& pt
137     Thermo::operator=(pt);
139     muPolynomial_ = pt.muPolynomial_;
140     kappaPolynomial_ = pt.kappaPolynomial_;
142     return *this;
146 template<class Thermo, int PolySize>
147 inline void Foam::polynomialTransport<Thermo, PolySize>::operator+=
149     const polynomialTransport<Thermo, PolySize>& pt
152     scalar molr1 = this->nMoles();
154     Thermo::operator+=(pt);
156     molr1 /= this->nMoles();
157     scalar molr2 = pt.nMoles()/this->nMoles();
159     muPolynomial_ = molr1*muPolynomial_ + molr2*pt.muPolynomial_;
160     kappaPolynomial_ = molr1*kappaPolynomial_ + molr2*pt.kappaPolynomial_;
164 template<class Thermo, int PolySize>
165 inline void Foam::polynomialTransport<Thermo, PolySize>::operator-=
167     const polynomialTransport<Thermo, PolySize>& pt
170     scalar molr1 = this->nMoles();
172     Thermo::operator-=(pt);
174     molr1 /= this->nMoles();
175     scalar molr2 = pt.nMoles()/this->nMoles();
177     muPolynomial_ = molr1*muPolynomial_ - molr2*pt.muPolynomial_;
178     kappaPolynomial_ = molr1*kappaPolynomial_ - molr2*pt.kappaPolynomial_;
182 template<class Thermo, int PolySize>
183 inline void Foam::polynomialTransport<Thermo, PolySize>::operator*=
185     const scalar s
188     Thermo::operator*=(s);
192 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
194 template<class Thermo, int PolySize>
195 inline Foam::polynomialTransport<Thermo, PolySize> Foam::operator+
197     const polynomialTransport<Thermo, PolySize>& pt1,
198     const polynomialTransport<Thermo, PolySize>& pt2
201     Thermo t
202     (
203         static_cast<const Thermo&>(pt1) + static_cast<const Thermo&>(pt2)
204     );
206     scalar molr1 = pt1.nMoles()/t.nMoles();
207     scalar molr2 = pt2.nMoles()/t.nMoles();
209     return polynomialTransport<Thermo, PolySize>
210     (
211         t,
212         molr1*pt1.muPolynomial_ + molr2*pt2.muPolynomial_,
213         molr1*pt1.kappaPolynomial_ + molr2*pt2.kappaPolynomial_
214     );
218 template<class Thermo, int PolySize>
219 inline Foam::polynomialTransport<Thermo, PolySize> Foam::operator-
221     const polynomialTransport<Thermo, PolySize>& pt1,
222     const polynomialTransport<Thermo, PolySize>& pt2
225     Thermo t
226     (
227         static_cast<const Thermo&>(pt1) - static_cast<const Thermo&>(pt2)
228     );
230     scalar molr1 = pt1.nMoles()/t.nMoles();
231     scalar molr2 = pt2.nMoles()/t.nMoles();
233     return polynomialTransport<Thermo, PolySize>
234     (
235         t,
236         molr1*pt1.muPolynomial_ - molr2*pt2.muPolynomial_,
237         molr1*pt1.kappaPolynomial_ - molr2*pt2.kappaPolynomial_
238     );
242 template<class Thermo, int PolySize>
243 inline Foam::polynomialTransport<Thermo, PolySize> Foam::operator*
245     const scalar s,
246     const polynomialTransport<Thermo, PolySize>& pt
249     return polynomialTransport<Thermo, PolySize>
250     (
251         s*static_cast<const Thermo&>(pt),
252         pt.muPolynomial_,
253         pt.kappaPolynomial_
254     );
258 template<class Thermo, int PolySize>
259 inline Foam::polynomialTransport<Thermo, PolySize> Foam::operator==
261     const polynomialTransport<Thermo, PolySize>& pt1,
262     const polynomialTransport<Thermo, PolySize>& pt2
265     return pt2 - pt1;
269 // ************************************************************************* //