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

hConstThermoI.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) 1991-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 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00028 
00029 template<class equationOfState>
00030 inline Foam::hConstThermo<equationOfState>::hConstThermo
00031 (
00032     const equationOfState& st,
00033     const scalar cp,
00034     const scalar hf
00035 )
00036 :
00037     equationOfState(st),
00038     Cp_(cp),
00039     Hf_(hf)
00040 {}
00041 
00042 
00043 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00044 
00045 template<class equationOfState>
00046 inline Foam::hConstThermo<equationOfState>::hConstThermo
00047 (
00048     const word& name,
00049     const hConstThermo& ct
00050 )
00051 :
00052     equationOfState(name, ct),
00053     Cp_(ct.Cp_),
00054     Hf_(ct.Hf_)
00055 {}
00056 
00057 
00058 template<class equationOfState>
00059 inline Foam::autoPtr<Foam::hConstThermo<equationOfState> >
00060 Foam::hConstThermo<equationOfState>::clone() const
00061 {
00062     return autoPtr<hConstThermo<equationOfState> >
00063     (
00064         new hConstThermo<equationOfState>(*this)
00065     );
00066 }
00067 
00068 
00069 template<class equationOfState>
00070 inline Foam::autoPtr<Foam::hConstThermo<equationOfState> >
00071 Foam::hConstThermo<equationOfState>::New(Istream& is)
00072 {
00073     return autoPtr<hConstThermo<equationOfState> >
00074     (
00075         new hConstThermo<equationOfState>(is)
00076     );
00077 }
00078 
00079 
00080 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00081 
00082 template<class equationOfState>
00083 inline Foam::scalar Foam::hConstThermo<equationOfState>::cp
00084 (
00085     const scalar
00086 ) const
00087 {
00088     return Cp_*this->W();
00089 }
00090 
00091 
00092 template<class equationOfState>
00093 inline Foam::scalar Foam::hConstThermo<equationOfState>::h
00094 (
00095     const scalar T
00096 ) const
00097 {
00098     return (Cp_*T + Hf_)*this->W();
00099 }
00100 
00101 
00102 template<class equationOfState>
00103 inline Foam::scalar Foam::hConstThermo<equationOfState>::hs
00104 (
00105     const scalar T
00106 ) const
00107 {
00108     return Cp_*T*this->W();
00109 }
00110 
00111 
00112 template<class equationOfState>
00113 inline Foam::scalar Foam::hConstThermo<equationOfState>::hc() const
00114 {
00115     return Hf_*this->W();
00116 }
00117 
00118 
00119 template<class equationOfState>
00120 inline Foam::scalar Foam::hConstThermo<equationOfState>::s
00121 (
00122     const scalar T
00123 ) const
00124 {
00125     notImplemented
00126     (
00127         "scalar hConstThermo<equationOfState>::s(const scalar T) const"
00128     );
00129     return T;
00130 }
00131 
00132 
00133 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00134 
00135 template<class equationOfState>
00136 inline void Foam::hConstThermo<equationOfState>::operator+=
00137 (
00138     const hConstThermo<equationOfState>& ct
00139 )
00140 {
00141     scalar molr1 = this->nMoles();
00142 
00143     equationOfState::operator+=(ct);
00144 
00145     molr1 /= this->nMoles();
00146     scalar molr2 = ct.nMoles()/this->nMoles();
00147 
00148     Cp_ = molr1*Cp_ + molr2*ct.Cp_;
00149     Hf_ = molr1*Hf_ + molr2*ct.Hf_;
00150 }
00151 
00152 
00153 template<class equationOfState>
00154 inline void Foam::hConstThermo<equationOfState>::operator-=
00155 (
00156     const hConstThermo<equationOfState>& ct
00157 )
00158 {
00159     scalar molr1 = this->nMoles();
00160 
00161     equationOfState::operator-=(ct);
00162 
00163     molr1 /= this->nMoles();
00164     scalar molr2 = ct.nMoles()/this->nMoles();
00165 
00166     Cp_ = molr1*Cp_ - molr2*ct.Cp_;
00167     Hf_ = molr1*Hf_ - molr2*ct.Hf_;
00168 }
00169 
00170 
00171 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00172 
00173 template<class equationOfState>
00174 inline Foam::hConstThermo<equationOfState> Foam::operator+
00175 (
00176     const hConstThermo<equationOfState>& ct1,
00177     const hConstThermo<equationOfState>& ct2
00178 )
00179 {
00180     equationOfState eofs
00181     (
00182         static_cast<const equationOfState&>(ct1)
00183       + static_cast<const equationOfState&>(ct2)
00184     );
00185 
00186     return hConstThermo<equationOfState>
00187     (
00188         eofs,
00189         ct1.nMoles()/eofs.nMoles()*ct1.Cp_
00190       + ct2.nMoles()/eofs.nMoles()*ct2.Cp_,
00191         ct1.nMoles()/eofs.nMoles()*ct1.Hf_
00192       + ct2.nMoles()/eofs.nMoles()*ct2.Hf_
00193     );
00194 }
00195 
00196 
00197 template<class equationOfState>
00198 inline Foam::hConstThermo<equationOfState> Foam::operator-
00199 (
00200     const hConstThermo<equationOfState>& ct1,
00201     const hConstThermo<equationOfState>& ct2
00202 )
00203 {
00204     equationOfState eofs
00205     (
00206         static_cast<const equationOfState&>(ct1)
00207       - static_cast<const equationOfState&>(ct2)
00208     );
00209 
00210     return hConstThermo<equationOfState>
00211     (
00212         eofs,
00213         ct1.nMoles()/eofs.nMoles()*ct1.Cp_
00214       - ct2.nMoles()/eofs.nMoles()*ct2.Cp_,
00215         ct1.nMoles()/eofs.nMoles()*ct1.Hf_
00216       - ct2.nMoles()/eofs.nMoles()*ct2.Hf_
00217     );
00218 }
00219 
00220 
00221 template<class equationOfState>
00222 inline Foam::hConstThermo<equationOfState> Foam::operator*
00223 (
00224     const scalar s,
00225     const hConstThermo<equationOfState>& ct
00226 )
00227 {
00228     return hConstThermo<equationOfState>
00229     (
00230         s*static_cast<const equationOfState&>(ct),
00231         ct.Cp_,
00232         ct.Hf_
00233     );
00234 }
00235 
00236 
00237 template<class equationOfState>
00238 inline Foam::hConstThermo<equationOfState> Foam::operator==
00239 (
00240     const hConstThermo<equationOfState>& ct1,
00241     const hConstThermo<equationOfState>& ct2
00242 )
00243 {
00244     return ct2 - ct1;
00245 }
00246 
00247 
00248 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd