From c8d033f1ef24c99b314c3183778dfa3d0969c7b3 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Jun 2009 12:37:15 +0100 Subject: [PATCH] updated to current thermo spec --- .../mixtures/basicMixture/basicMixtures.C | 18 ++ .../basic/psiThermo/ePsiThermo/ePsiThermos.C | 6 +- .../specie/thermo/eConst/eConstThermo.C | 15 +- .../specie/thermo/eConst/eConstThermo.H | 32 ++-- .../specie/thermo/eConst/eConstThermoI.H | 166 +++++++++++------- 5 files changed, 147 insertions(+), 90 deletions(-) diff --git a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C index 022263ecc3..0aced02618 100644 --- a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C +++ b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C @@ -34,6 +34,8 @@ Description #include "perfectGas.H" +#include "eConstThermo.H" + #include "hConstThermo.H" #include "janafThermo.H" #include "specieThermo.H" @@ -68,6 +70,22 @@ makeBasicMixture perfectGas ); +makeBasicMixture +( + pureMixture, + constTransport, + eConstThermo, + perfectGas +); + +makeBasicMixture +( + pureMixture, + sutherlandTransport, + eConstThermo, + perfectGas +); + makeBasicMixture ( pureMixture, diff --git a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C index 2849a29ea7..0517a06ec2 100644 --- a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C +++ b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C @@ -28,7 +28,7 @@ License #include "perfectGas.H" -#include "hConstThermo.H" +#include "eConstThermo.H" #include "janafThermo.H" #include "specieThermo.H" @@ -50,7 +50,7 @@ makeBasicPsiThermo ePsiThermo, pureMixture, constTransport, - hConstThermo, + eConstThermo, perfectGas ); @@ -59,7 +59,7 @@ makeBasicPsiThermo ePsiThermo, pureMixture, sutherlandTransport, - hConstThermo, + eConstThermo, perfectGas ); diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C index 8d62be816f..e13eb5b0ab 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C @@ -29,9 +29,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::eConstThermo::eConstThermo(Istream& is) +template +Foam::eConstThermo::eConstThermo(Istream& is) : - specieThermo(is), + equationOfState(is), Cv_(readScalar(is)), Hf_(readScalar(is)) { @@ -41,9 +42,15 @@ Foam::eConstThermo::eConstThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Ostream& os, const eConstThermo& ct) +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const eConstThermo& ct +) { - os << (const specieThermo&)ct << tab << ct.Cv_ << tab << ct.Hf_; + os << static_cast(ct) << tab + << ct.Cv_ << tab << ct.Hf_; os.check("Ostream& operator<<(Ostream& os, const eConstThermo& ct)"); return os; diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H index c01600eabd..6d9bef7423 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H @@ -26,8 +26,8 @@ Class Foam::eConstThermo Description - Constant properties thermodynamics package derived from the basic - thermo package data type specieThermo. + Constant properties thermodynamics package templated on an equation of + state SourceFiles eConstThermoI.H @@ -86,12 +86,13 @@ Ostream& operator<< /*---------------------------------------------------------------------------*\ - Class eConstThermo Declaration + Class eConstThermo Declaration \*---------------------------------------------------------------------------*/ +template class eConstThermo : - public specieThermo + public equationOfState { // Private data @@ -104,7 +105,7 @@ class eConstThermo //- Construct from components inline eConstThermo ( - const specieThermo& st, + const equationOfState& st, const scalar cv, const scalar hf ); @@ -147,20 +148,10 @@ public: inline scalar s(const scalar T) const; - // Some derived properties - // Other derived properties obtained from specieThermo base type - - //- Temperature from Enthalpy given an initial temperature T0 - inline scalar TH(const scalar h, const scalar T0) const; - - //- Temperature from internal energy given an initial temperature T0 - inline scalar TE(const scalar e, const scalar T0) const; - - // Member operators - inline void operator+=(const hConstThermo&); - inline void operator-=(const hConstThermo&); + inline void operator+=(const eConstThermo&); + inline void operator-=(const eConstThermo&); // Friend operators @@ -194,7 +185,8 @@ public: friend Ostream& operator<< ( - Ostream&, const eConstThermo& + Ostream&, + const eConstThermo& ); }; @@ -207,6 +199,10 @@ public: #include "eConstThermoI.H" +#ifdef NoRepository +# include "eConstThermo.C" +#endif + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H index aba6da1eef..8e021c53ab 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H @@ -26,14 +26,15 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -inline Foam::eConstThermo::eConstThermo +template +inline Foam::eConstThermo::eConstThermo ( - const specieThermo& st, + const equationOfState& st, const scalar cv, const scalar hf ) : - specieThermo(st), + equationOfState(st), Cv_(cv), Hf_(hf) {} @@ -41,20 +42,21 @@ inline Foam::eConstThermo::eConstThermo // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::eConstThermo::eConstThermo +template +inline Foam::eConstThermo::eConstThermo ( const word& name, - const eConstThermo& ct + const eConstThermo& ct ) : - specieThermo(name, ct), + equationOfState(name, ct), Cv_(ct.Cv_), Hf_(ct.Hf_) {} template -inline Foam::autoPtr > +inline Foam::autoPtr > Foam::eConstThermo::clone() const { return autoPtr > @@ -65,7 +67,7 @@ Foam::eConstThermo::clone() const template -inline autoPtr > +inline Foam::autoPtr > Foam::eConstThermo::New(Istream& is) { return autoPtr > @@ -77,19 +79,31 @@ Foam::eConstThermo::New(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::scalar Foam::eConstThermo::cp(const scalar) const +template +inline Foam::scalar Foam::eConstThermo::cp +( + const scalar +) const { - return Cv_*W() + RR; + return Cv_*this->W() + specie::RR; } -inline Foam::scalar Foam::eConstThermo::h(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::h +( + const scalar T +) const { - return cp(T)*T + Hf_*W(); + return cp(T)*T + Hf_*this->W(); } -inline Foam::scalar Foam::eConstThermo::hs(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::hs +( + const scalar T +) const { return cp(T)*T; } @@ -102,104 +116,126 @@ inline Foam::scalar Foam::eConstThermo::hc() const } -inline Foam::scalar Foam::eConstThermo::s(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::s +( + const scalar T +) const { notImplemented("scalar eConstThermo::s(const scalar T) const"); return T; } -inline Foam::scalar Foam::eConstThermo::TH -( - const scalar h, - const scalar T0 -) const -{ - return (h - Hf_)/Cp(T0); -} - - -inline Foam::scalar Foam::eConstThermo::TE -( - const scalar e, - const scalar -) const -{ - return (e - Hf_)/Cv_; -} - - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline Foam::eConstThermo& Foam::eConstThermo::operator= +template +inline void Foam::eConstThermo::operator+= ( - const eConstThermo& ct + const eConstThermo& ct ) { - specieThermo::operator=(ct); + scalar molr1 = this->nMoles(); - Cv_ = ct.Cv_; - Hf_ = ct.Hf_; + equationOfState::operator+=(ct); - return *this; + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + Cv_ = molr1*Cv_ + molr2*ct.Cv_; + Hf_ = molr1*Hf_ + molr2*ct.Hf_; +} + + +template +inline void Foam::eConstThermo::operator-= +( + const eConstThermo& ct +) +{ + scalar molr1 = this->nMoles(); + + equationOfState::operator-=(ct); + + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + Cv_ = molr1*Cv_ - molr2*ct.Cv_; + Hf_ = molr1*Hf_ - molr2*ct.Hf_; } // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -inline Foam::eConstThermo Foam::operator+ +template +inline Foam::eConstThermo Foam::operator+ ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { - specieThermo st(((const specieThermo&)ct1) + ((const specieThermo&)ct2)); - - return eConstThermo + equationOfState eofs ( - st, - ct1.nMoles()/st.nMoles()*ct1.Cv_ + ct2.nMoles()/st.nMoles()*ct2.Cv_, - ct1.nMoles()/st.nMoles()*ct1.Hf_ + ct2.nMoles()/st.nMoles()*ct2.Hf_ + static_cast(ct1) + + static_cast(ct2) + ); + + return eConstThermo + ( + eofs, + ct1.nMoles()/eofs.nMoles()*ct1.Cv_ + + ct2.nMoles()/eofs.nMoles()*ct2.Cv_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + + ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } -inline Foam::eConstThermo Foam::operator- +template +inline Foam::eConstThermo Foam::operator- ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { - specieThermo st(((const specieThermo&)ct1) - ((const specieThermo&)ct2)); - - return eConstThermo + equationOfState eofs ( - st, - ct1.nMoles()/st.nMoles()*ct1.Cv_ - ct2.nMoles()/st.nMoles()*ct2.Cv_, - ct1.nMoles()/st.nMoles()*ct1.Hf_ - ct2.nMoles()/st.nMoles()*ct2.Hf_ + static_cast(ct1) + - static_cast(ct2) + ); + + return eConstThermo + ( + eofs, + ct1.nMoles()/eofs.nMoles()*ct1.Cv_ + - ct2.nMoles()/eofs.nMoles()*ct2.Cv_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + - ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } -inline Foam::eConstThermo Foam::operator* +template +inline Foam::eConstThermo Foam::operator* ( const scalar s, - const eConstThermo& ct + const eConstThermo& ct ) { - return eConstThermo + return eConstThermo ( - s*((const specieThermo&)ct), + s*static_cast(ct), ct.Cv_, ct.Hf_ ); } -inline Foam::eConstThermo Foam::operator== +template +inline Foam::eConstThermo Foam::operator== ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { return ct2 - ct1;