Forward compatibility: flex
[foam-extend-3.2.git] / src / thermophysicalModels / specie / equationOfState / icoPolynomial / icoPolynomialI.H
blobc9fbd6916fed6fda52d437be65b0497f8e8b588c
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 "icoPolynomial.H"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 template<int PolySize>
31 inline Foam::icoPolynomial<PolySize>::icoPolynomial
33     const specie& sp,
34     const Polynomial<PolySize>& rhoPoly
37     specie(sp),
38     rhoPolynomial_(rhoPoly)
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 template<int PolySize>
45 inline Foam::icoPolynomial<PolySize>::icoPolynomial
47     const icoPolynomial<PolySize>& ip
50     specie(ip),
51     rhoPolynomial_(ip.rhoPolynomial_)
55 template<int PolySize>
56 inline Foam::icoPolynomial<PolySize>::icoPolynomial
58     const word& name,
59     const icoPolynomial<PolySize>& ip
62     specie(name, ip),
63     rhoPolynomial_(ip.rhoPolynomial_)
67 template<int PolySize>
68 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
69 Foam::icoPolynomial<PolySize>::clone() const
71     return autoPtr<icoPolynomial<PolySize> >
72     (
73         new icoPolynomial<PolySize>(*this)
74     );
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 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
88 template<int PolySize>
89 inline Foam::scalar Foam::icoPolynomial<PolySize>::rho(scalar, scalar T) const
91     return rhoPolynomial_.evaluate(T)/this->W();
95 template<int PolySize>
96 inline Foam::scalar Foam::icoPolynomial<PolySize>::psi(scalar, scalar) const
98     return 0.0;
102 template<int PolySize>
103 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
105     return 0.0;
109 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
111 template<int PolySize>
112 inline Foam::icoPolynomial<PolySize>& Foam::icoPolynomial<PolySize>::operator=
114     const icoPolynomial<PolySize>& ip
117     specie::operator=(ip);
119     rhoPolynomial_ = ip.rhoPolynomial_;
121     return *this;
125 template<int PolySize>
126 inline void Foam::icoPolynomial<PolySize>::operator+=
128     const icoPolynomial<PolySize>& ip
131     scalar molr1 = this->nMoles();
133     specie::operator+=(ip);
135     molr1 /= this->nMoles();
136     scalar molr2 = ip.nMoles()/this->nMoles();
138     rhoPolynomial_ = molr1*rhoPolynomial_ + molr2*ip.rhoPolynomial_;
142 template<int PolySize>
143 inline void Foam::icoPolynomial<PolySize>::operator-=
145     const icoPolynomial<PolySize>& ip
148     scalar molr1 = this->nMoles();
150     specie::operator-=(ip);
152     molr1 /= this->nMoles();
153     scalar molr2 = ip.nMoles()/this->nMoles();
155     rhoPolynomial_ = molr1*rhoPolynomial_ - molr2*ip.rhoPolynomial_;
159 template<int PolySize>
160 inline void Foam::icoPolynomial<PolySize>::operator*=(const scalar s)
162     specie::operator*=(s);
166 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
168 template<int PolySize>
169 Foam::icoPolynomial<PolySize> Foam::operator+
171     const icoPolynomial<PolySize>& ip1,
172     const icoPolynomial<PolySize>& ip2
175     scalar nMoles = ip1.nMoles() + ip2.nMoles();
176     scalar molr1 = ip1.nMoles()/nMoles;
177     scalar molr2 = ip2.nMoles()/nMoles;
179     return icoPolynomial<PolySize>
180     (
181         static_cast<const specie&>(ip1)
182       + static_cast<const specie&>(ip2),
183         molr1*ip1.rhoPolynomial_ + molr2*ip2.rhoPolynomial_
184     );
188 template<int PolySize>
189 Foam::icoPolynomial<PolySize> Foam::operator-
191     const icoPolynomial<PolySize>& ip1,
192     const icoPolynomial<PolySize>& ip2
195     scalar nMoles = ip1.nMoles() + ip2.nMoles();
196     scalar molr1 = ip1.nMoles()/nMoles;
197     scalar molr2 = ip2.nMoles()/nMoles;
199     return icoPolynomial<PolySize>
200     (
201         static_cast<const specie&>(ip1)
202       - static_cast<const specie&>(ip2),
203         molr1*ip1.rhoPolynomial_ - molr2*ip2.rhoPolynomial_
204     );
208 template<int PolySize>
209 Foam::icoPolynomial<PolySize> Foam::operator*
211     const scalar s,
212     const icoPolynomial<PolySize>& ip
215     return icoPolynomial<PolySize>
216     (
217         s*static_cast<const specie&>(ip),
218         ip.rhoPolynomial_
219     );
223 template<int PolySize>
224 Foam::icoPolynomial<PolySize> Foam::operator==
226     const icoPolynomial<PolySize>& ip1,
227     const icoPolynomial<PolySize>& ip2
230     return ip2 - ip1;
234 // ************************************************************************* //