initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / thermophysicalModels / specie / equationOfState / icoPolynomial / icoPolynomialI.H
blobd174c57192bac3d842188fc6a03ddda8eeb23aac
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "icoPolynomial.H"
29 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
31 template<int PolySize>
32 inline Foam::icoPolynomial<PolySize>::icoPolynomial
34     const specie& sp,
35     const Polynomial<PolySize>& rhoPoly
38     specie(sp),
39     rhoPolynomial_(rhoPoly)
43 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
45 template<int PolySize>
46 inline Foam::icoPolynomial<PolySize>::icoPolynomial
48     const word& name,
49     const icoPolynomial<PolySize>& ip
52     specie(name, ip),
53     rhoPolynomial_(ip.rhoPolynomial_)
57 template<int PolySize>
58 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
59 Foam::icoPolynomial<PolySize>::clone() const
61     return autoPtr<icoPolynomial<PolySize> >
62     (
63         new icoPolynomial<PolySize>(*this)
64     );
68 template<int PolySize>
69 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
70 Foam::icoPolynomial<PolySize>::New(Istream& is)
72     return autoPtr<icoPolynomial<PolySize> >(new icoPolynomial<PolySize>(is));
76 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
78 template<int PolySize>
79 inline Foam::scalar Foam::icoPolynomial<PolySize>::rho(scalar, scalar T) const
81     return rhoPolynomial_.evaluate(T);
85 template<int PolySize>
86 inline Foam::scalar Foam::icoPolynomial<PolySize>::psi(scalar, scalar) const
88     return 0.0;
92 template<int PolySize>
93 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
95     return 0.0;
99 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
101 template<int PolySize>
102 inline void Foam::icoPolynomial<PolySize>::operator+=
104     const icoPolynomial<PolySize>& ip
107     scalar molr1 = this->nMoles();
109     specie::operator+=(ip);
111     molr1 /= this->nMoles();
112     scalar molr2 = ip.nMoles()/this->nMoles();
114     rhoPolynomial_ = molr1*rhoPolynomial_ + molr2*ip.rhoPolynomial_;
118 template<int PolySize>
119 inline void Foam::icoPolynomial<PolySize>::operator-=
121     const icoPolynomial<PolySize>& ip
124     scalar molr1 = this->nMoles();
125     specie::operator-=(ip);
127     molr1 /= this->nMoles();
128     scalar molr2 = ip.nMoles()/this->nMoles();
130     rhoPolynomial_ = molr1*rhoPolynomial_ - molr2*ip.rhoPolynomial_;
134 template<int PolySize>
135 inline void Foam::icoPolynomial<PolySize>::operator*=(const scalar s)
137     specie::operator*=(s);
141 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
143 template<int PolySize>
144 Foam::icoPolynomial<PolySize> Foam::operator+
146     const icoPolynomial<PolySize>& ip1,
147     const icoPolynomial<PolySize>& ip2
150     scalar mol1 = ip1.nMoles();
151     scalar mol2 = ip2.nMoles();
152     scalar nMoles = mol1 + mol2;
154     return icoPolynomial<PolySize>
155     (
156         static_cast<const specie&>(ip1)
157       + static_cast<const specie&>(ip2),
158         (mol1/nMoles)*ip1.rhoPolynomial_ + (mol2/nMoles)*ip2.rhoPolynomial_
159     );
163 template<int PolySize>
164 Foam::icoPolynomial<PolySize> Foam::operator-
166     const icoPolynomial<PolySize>& ip1,
167     const icoPolynomial<PolySize>& ip2
170     scalar mol1 = ip1.nMoles();
171     scalar mol2 = ip2.nMoles();
172     scalar nMoles = mol1 + mol2;
174     return icoPolynomial<PolySize>
175     (
176         static_cast<const specie&>(ip1)
177       - static_cast<const specie&>(ip2),
178         (mol1/nMoles)*ip1.rhoPolynomial_ - (mol2/nMoles)*ip2.rhoPolynomial_
179     );
183 template<int PolySize>
184 Foam::icoPolynomial<PolySize> Foam::operator*
186     const scalar s,
187     const icoPolynomial<PolySize>& ip
190     return icoPolynomial<PolySize>
191     (
192         s*static_cast<const specie&>(ip),
193         ip.rhoPolynomial_
194     );
198 template<int PolySize>
199 Foam::icoPolynomial<PolySize> Foam::operator==
201     const icoPolynomial<PolySize>& ip1,
202     const icoPolynomial<PolySize>& ip2
205     return ip2 - ip1;
209 // ************************************************************************* //