FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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