BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / specie / equationOfState / icoPolynomial / icoPolynomialI.H
blobb21a9be240d19d6a75e466226f87bf9fadb5b0e7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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
33     const specie& sp,
34     const Polynomial<PolySize>& rhoCoeffs
37     specie(sp),
38     rhoCoeffs_(rhoCoeffs)
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 template<int PolySize>
45 inline Foam::icoPolynomial<PolySize>::icoPolynomial
47     const icoPolynomial<PolySize>& ip
50     specie(ip),
51     rhoCoeffs_(ip.rhoCoeffs_)
55 template<int PolySize>
56 inline Foam::icoPolynomial<PolySize>::icoPolynomial
58     const word& name,
59     const icoPolynomial<PolySize>& ip
62     specie(name, 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> >
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 template<int PolySize>
87 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
88 Foam::icoPolynomial<PolySize>::New(const dictionary& dict)
90     return autoPtr<icoPolynomial<PolySize> >
91     (
92         new icoPolynomial<PolySize>(dict)
93     );
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
109     return 0.0;
113 template<int PolySize>
114 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
116     return 0.0;
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_;
132     return *this;
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>
191     (
192         static_cast<const specie&>(ip1)
193       + static_cast<const specie&>(ip2),
194         molr1*ip1.rhoCoeffs_ + molr2*ip2.rhoCoeffs_
195     );
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>
211     (
212         static_cast<const specie&>(ip1)
213       - static_cast<const specie&>(ip2),
214         molr1*ip1.rhoCoeffs_ - molr2*ip2.rhoCoeffs_
215     );
219 template<int PolySize>
220 Foam::icoPolynomial<PolySize> Foam::operator*
222     const scalar s,
223     const icoPolynomial<PolySize>& ip
226     return icoPolynomial<PolySize>
227     (
228         s*static_cast<const specie&>(ip),
229         ip.rhoCoeffs_
230     );
234 template<int PolySize>
235 Foam::icoPolynomial<PolySize> Foam::operator==
237     const icoPolynomial<PolySize>& ip1,
238     const icoPolynomial<PolySize>& ip2
241     return ip2 - ip1;
245 // ************************************************************************* //