1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "icoPolynomial.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<int PolySize>
31 inline Foam::icoPolynomial<PolySize>::icoPolynomial
34 const Polynomial<PolySize>& rhoCoeffs
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 template<int PolySize>
45 inline Foam::icoPolynomial<PolySize>::icoPolynomial
47 const icoPolynomial<PolySize>& ip
51 rhoCoeffs_(ip.rhoCoeffs_)
55 template<int PolySize>
56 inline Foam::icoPolynomial<PolySize>::icoPolynomial
59 const icoPolynomial<PolySize>& ip
63 rhoCoeffs_(ip.rhoCoeffs_)
67 template<int PolySize>
68 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
69 Foam::icoPolynomial<PolySize>::clone() const
71 return autoPtr<icoPolynomial<PolySize> >
73 new icoPolynomial<PolySize>(*this)
78 template<int PolySize>
79 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
80 Foam::icoPolynomial<PolySize>::New(Istream& is)
82 return autoPtr<icoPolynomial<PolySize> >(new icoPolynomial<PolySize>(is));
86 template<int PolySize>
87 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
88 Foam::icoPolynomial<PolySize>::New(const dictionary& dict)
90 return autoPtr<icoPolynomial<PolySize> >
92 new icoPolynomial<PolySize>(dict)
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 template<int PolySize>
100 inline Foam::scalar Foam::icoPolynomial<PolySize>::rho(scalar, scalar T) const
102 return rhoCoeffs_.value(T)/this->W();
106 template<int PolySize>
107 inline Foam::scalar Foam::icoPolynomial<PolySize>::psi(scalar, scalar) const
113 template<int PolySize>
114 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
120 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
122 template<int PolySize>
123 inline Foam::icoPolynomial<PolySize>& Foam::icoPolynomial<PolySize>::operator=
125 const icoPolynomial<PolySize>& ip
128 specie::operator=(ip);
130 rhoCoeffs_ = ip.rhoCoeffs_;
136 template<int PolySize>
137 inline void Foam::icoPolynomial<PolySize>::operator+=
139 const icoPolynomial<PolySize>& ip
142 scalar molr1 = this->nMoles();
144 specie::operator+=(ip);
146 molr1 /= this->nMoles();
147 scalar molr2 = ip.nMoles()/this->nMoles();
149 rhoCoeffs_ = molr1*rhoCoeffs_ + molr2*ip.rhoCoeffs_;
153 template<int PolySize>
154 inline void Foam::icoPolynomial<PolySize>::operator-=
156 const icoPolynomial<PolySize>& ip
159 scalar molr1 = this->nMoles();
161 specie::operator-=(ip);
163 molr1 /= this->nMoles();
164 scalar molr2 = ip.nMoles()/this->nMoles();
166 rhoCoeffs_ = molr1*rhoCoeffs_ - molr2*ip.rhoCoeffs_;
170 template<int PolySize>
171 inline void Foam::icoPolynomial<PolySize>::operator*=(const scalar s)
173 specie::operator*=(s);
177 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
179 template<int PolySize>
180 Foam::icoPolynomial<PolySize> Foam::operator+
182 const icoPolynomial<PolySize>& ip1,
183 const icoPolynomial<PolySize>& ip2
186 scalar nMoles = ip1.nMoles() + ip2.nMoles();
187 scalar molr1 = ip1.nMoles()/nMoles;
188 scalar molr2 = ip2.nMoles()/nMoles;
190 return icoPolynomial<PolySize>
192 static_cast<const specie&>(ip1)
193 + static_cast<const specie&>(ip2),
194 molr1*ip1.rhoCoeffs_ + molr2*ip2.rhoCoeffs_
199 template<int PolySize>
200 Foam::icoPolynomial<PolySize> Foam::operator-
202 const icoPolynomial<PolySize>& ip1,
203 const icoPolynomial<PolySize>& ip2
206 scalar nMoles = ip1.nMoles() + ip2.nMoles();
207 scalar molr1 = ip1.nMoles()/nMoles;
208 scalar molr2 = ip2.nMoles()/nMoles;
210 return icoPolynomial<PolySize>
212 static_cast<const specie&>(ip1)
213 - static_cast<const specie&>(ip2),
214 molr1*ip1.rhoCoeffs_ - molr2*ip2.rhoCoeffs_
219 template<int PolySize>
220 Foam::icoPolynomial<PolySize> Foam::operator*
223 const icoPolynomial<PolySize>& ip
226 return icoPolynomial<PolySize>
228 s*static_cast<const specie&>(ip),
234 template<int PolySize>
235 Foam::icoPolynomial<PolySize> Foam::operator==
237 const icoPolynomial<PolySize>& ip1,
238 const icoPolynomial<PolySize>& ip2
245 // ************************************************************************* //