OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

icoPolynomialI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "icoPolynomial.H"
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template<int PolySize>
00032 inline Foam::icoPolynomial<PolySize>::icoPolynomial
00033 (
00034     const specie& sp,
00035     const Polynomial<PolySize>& rhoPoly
00036 )
00037 :
00038     specie(sp),
00039     rhoPolynomial_(rhoPoly)
00040 {}
00041 
00042 
00043 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00044 
00045 template<int PolySize>
00046 inline Foam::icoPolynomial<PolySize>::icoPolynomial
00047 (
00048     const word& name,
00049     const icoPolynomial<PolySize>& ip
00050 )
00051 :
00052     specie(name, ip),
00053     rhoPolynomial_(ip.rhoPolynomial_)
00054 {}
00055 
00056 
00057 template<int PolySize>
00058 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
00059 Foam::icoPolynomial<PolySize>::clone() const
00060 {
00061     return autoPtr<icoPolynomial<PolySize> >
00062     (
00063         new icoPolynomial<PolySize>(*this)
00064     );
00065 }
00066 
00067 
00068 template<int PolySize>
00069 inline Foam::autoPtr<Foam::icoPolynomial<PolySize> >
00070 Foam::icoPolynomial<PolySize>::New(Istream& is)
00071 {
00072     return autoPtr<icoPolynomial<PolySize> >(new icoPolynomial<PolySize>(is));
00073 }
00074 
00075 
00076 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00077 
00078 template<int PolySize>
00079 inline Foam::scalar Foam::icoPolynomial<PolySize>::rho(scalar, scalar T) const
00080 {
00081     return rhoPolynomial_.evaluate(T);
00082 }
00083 
00084 
00085 template<int PolySize>
00086 inline Foam::scalar Foam::icoPolynomial<PolySize>::psi(scalar, scalar) const
00087 {
00088     return 0.0;
00089 }
00090 
00091 
00092 template<int PolySize>
00093 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
00094 {
00095     return 0.0;
00096 }
00097 
00098 
00099 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00100 
00101 template<int PolySize>
00102 inline void Foam::icoPolynomial<PolySize>::operator+=
00103 (
00104     const icoPolynomial<PolySize>& ip
00105 )
00106 {
00107     scalar molr1 = this->nMoles();
00108 
00109     specie::operator+=(ip);
00110 
00111     molr1 /= this->nMoles();
00112     scalar molr2 = ip.nMoles()/this->nMoles();
00113 
00114     rhoPolynomial_ = molr1*rhoPolynomial_ + molr2*ip.rhoPolynomial_;
00115 }
00116 
00117 
00118 template<int PolySize>
00119 inline void Foam::icoPolynomial<PolySize>::operator-=
00120 (
00121     const icoPolynomial<PolySize>& ip
00122 )
00123 {
00124     scalar molr1 = this->nMoles();
00125     specie::operator-=(ip);
00126 
00127     molr1 /= this->nMoles();
00128     scalar molr2 = ip.nMoles()/this->nMoles();
00129 
00130     rhoPolynomial_ = molr1*rhoPolynomial_ - molr2*ip.rhoPolynomial_;
00131 }
00132 
00133 
00134 template<int PolySize>
00135 inline void Foam::icoPolynomial<PolySize>::operator*=(const scalar s)
00136 {
00137     specie::operator*=(s);
00138 }
00139 
00140 
00141 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00142 
00143 template<int PolySize>
00144 Foam::icoPolynomial<PolySize> Foam::operator+
00145 (
00146     const icoPolynomial<PolySize>& ip1,
00147     const icoPolynomial<PolySize>& ip2
00148 )
00149 {
00150     scalar mol1 = ip1.nMoles();
00151     scalar mol2 = ip2.nMoles();
00152     scalar nMoles = mol1 + mol2;
00153 
00154     return icoPolynomial<PolySize>
00155     (
00156         static_cast<const specie&>(ip1)
00157       + static_cast<const specie&>(ip2),
00158         (mol1/nMoles)*ip1.rhoPolynomial_ + (mol2/nMoles)*ip2.rhoPolynomial_
00159     );
00160 }
00161 
00162 
00163 template<int PolySize>
00164 Foam::icoPolynomial<PolySize> Foam::operator-
00165 (
00166     const icoPolynomial<PolySize>& ip1,
00167     const icoPolynomial<PolySize>& ip2
00168 )
00169 {
00170     scalar mol1 = ip1.nMoles();
00171     scalar mol2 = ip2.nMoles();
00172     scalar nMoles = mol1 + mol2;
00173 
00174     return icoPolynomial<PolySize>
00175     (
00176         static_cast<const specie&>(ip1)
00177       - static_cast<const specie&>(ip2),
00178         (mol1/nMoles)*ip1.rhoPolynomial_ - (mol2/nMoles)*ip2.rhoPolynomial_
00179     );
00180 }
00181 
00182 
00183 template<int PolySize>
00184 Foam::icoPolynomial<PolySize> Foam::operator*
00185 (
00186     const scalar s,
00187     const icoPolynomial<PolySize>& ip
00188 )
00189 {
00190     return icoPolynomial<PolySize>
00191     (
00192         s*static_cast<const specie&>(ip),
00193         ip.rhoPolynomial_
00194     );
00195 }
00196 
00197 
00198 template<int PolySize>
00199 Foam::icoPolynomial<PolySize> Foam::operator==
00200 (
00201     const icoPolynomial<PolySize>& ip1,
00202     const icoPolynomial<PolySize>& ip2
00203 )
00204 {
00205     return ip2 - ip1;
00206 }
00207 
00208 
00209 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd