1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
35 const Polynomial<PolySize>& rhoPoly
39 rhoPolynomial_(rhoPoly)
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 template<int PolySize>
46 inline Foam::icoPolynomial<PolySize>::icoPolynomial
49 const icoPolynomial<PolySize>& 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> >
63 new icoPolynomial<PolySize>(*this)
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
92 template<int PolySize>
93 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
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>
156 static_cast<const specie&>(ip1)
157 + static_cast<const specie&>(ip2),
158 (mol1/nMoles)*ip1.rhoPolynomial_ + (mol2/nMoles)*ip2.rhoPolynomial_
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>
176 static_cast<const specie&>(ip1)
177 - static_cast<const specie&>(ip2),
178 (mol1/nMoles)*ip1.rhoPolynomial_ - (mol2/nMoles)*ip2.rhoPolynomial_
183 template<int PolySize>
184 Foam::icoPolynomial<PolySize> Foam::operator*
187 const icoPolynomial<PolySize>& ip
190 return icoPolynomial<PolySize>
192 s*static_cast<const specie&>(ip),
198 template<int PolySize>
199 Foam::icoPolynomial<PolySize> Foam::operator==
201 const icoPolynomial<PolySize>& ip1,
202 const icoPolynomial<PolySize>& ip2
209 // ************************************************************************* //