diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H index baceabe201..fa8e624946 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H @@ -128,7 +128,7 @@ public: // Member Functions - // fundamaental properties + // Fundamaental properties //- Heat capacity at constant pressure [J/(kmol K)] inline scalar cp(const scalar T) const; @@ -152,10 +152,8 @@ public: // Member operators - inline eConstThermo& operator= - ( - const eConstThermo& - ); + inline void operator+=(const hConstThermo&); + inline void operator-=(const hConstThermo&); // Friend operators diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H index c6ef9e4e97..2f7d1faf4c 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H @@ -24,15 +24,9 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Construct from components -inline eConstThermo::eConstThermo +inline Foam::eConstThermo::eConstThermo ( const specieThermo& st, const scalar cv, @@ -47,8 +41,11 @@ inline eConstThermo::eConstThermo // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct as named copy -inline eConstThermo::eConstThermo(const word& name, const eConstThermo& ct) +inline Foam::eConstThermo::eConstThermo +( + const word& name, + const eConstThermo& ct +) : specieThermo(name, ct), CV(ct.CV), @@ -56,10 +53,9 @@ inline eConstThermo::eConstThermo(const word& name, const eConstThermo& ct) {} -// Construct and return a clone template -inline autoPtr > eConstThermo:: -clone() const +inline Foam::autoPtr > +Foam::eConstThermo::clone() const { return autoPtr > ( @@ -68,10 +64,9 @@ clone() const } -// Selector from Istream template -inline autoPtr > eConstThermo:: -New(Istream& is) +inline autoPtr > +Foam::eConstThermo::New(Istream& is) { return autoPtr > ( @@ -82,37 +77,40 @@ New(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Heat capacity at constant pressure [J/(kmol K)] -inline scalar eConstThermo::cp(const scalar) const +inline Foam::scalar Foam::eConstThermo::cp(const scalar) const { return CV*W() + RR; } -//- Enthalpy [J/kmol] -inline scalar eConstThermo::h(const scalar T) const +inline Foam::scalar Foam::eConstThermo::h(const scalar T) const { return cp(T)*T + Hf*W(); } -//- Entropy [J/(kmol K)] -inline scalar eConstThermo::s(const scalar T) const +inline Foam::scalar Foam::eConstThermo::s(const scalar T) const { notImplemented("scalar eConstThermo::s(const scalar T) const"); return T; } -//- Temperature from Enthalpy given an initial temperature T0 -inline scalar eConstThermo::TH(const scalar h, const scalar T0) const +inline Foam::scalar Foam::eConstThermo::TH +( + const scalar h, + const scalar T0 +) const { return (h - Hf)/Cp(T0); } -//- Temperature from internal energy given an initial temperature T0 -inline scalar eConstThermo::TE(const scalar e, const scalar) const +inline Foam::scalar Foam::eConstThermo::TE +( + const scalar e, + const scalar +) const { return (e - Hf)/CV; } @@ -120,7 +118,7 @@ inline scalar eConstThermo::TE(const scalar e, const scalar) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline eConstThermo& eConstThermo::operator= +inline Foam::eConstThermo& Foam::eConstThermo::operator= ( const eConstThermo& ct ) @@ -136,7 +134,7 @@ inline eConstThermo& eConstThermo::operator= // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -inline eConstThermo operator+ +inline Foam::eConstThermo Foam::operator+ ( const eConstThermo& ct1, const eConstThermo& ct2 @@ -153,7 +151,7 @@ inline eConstThermo operator+ } -inline eConstThermo operator- +inline Foam::eConstThermo Foam::operator- ( const eConstThermo& ct1, const eConstThermo& ct2 @@ -170,7 +168,7 @@ inline eConstThermo operator- } -inline eConstThermo operator* +inline Foam::eConstThermo Foam::operator* ( const scalar s, const eConstThermo& ct @@ -185,7 +183,7 @@ inline eConstThermo operator* } -inline eConstThermo operator== +inline Foam::eConstThermo Foam::operator== ( const eConstThermo& ct1, const eConstThermo& ct2 @@ -195,8 +193,4 @@ inline eConstThermo operator== } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H index a615dd3415..1355cb67d3 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H @@ -108,6 +108,7 @@ class hConstThermo const scalar hf ); + public: // Constructors @@ -127,7 +128,7 @@ public: // Member Functions - // fundamaental properties + // Fundamaental properties //- Heat capacity at constant pressure [J/(kmol K)] inline scalar cp(const scalar T) const; @@ -141,10 +142,8 @@ public: // Member operators - inline hConstThermo& operator= - ( - const hConstThermo& - ); + inline void operator+=(const hConstThermo&); + inline void operator-=(const hConstThermo&); // Friend operators diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H index 264bce3653..acc976de05 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H @@ -24,16 +24,10 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Construct from components template -inline hConstThermo::hConstThermo +inline Foam::hConstThermo::hConstThermo ( const equationOfState& st, const scalar cp, @@ -48,9 +42,8 @@ inline hConstThermo::hConstThermo // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct as named copy template -inline hConstThermo::hConstThermo +inline Foam::hConstThermo::hConstThermo ( const word& name, const hConstThermo& ct @@ -62,10 +55,9 @@ inline hConstThermo::hConstThermo {} -// Construct and return a clone template -inline autoPtr > hConstThermo:: -clone() const +inline Foam::autoPtr > +Foam::hConstThermo::clone() const { return autoPtr > ( @@ -74,10 +66,9 @@ clone() const } -// Selector from Istream template -inline autoPtr > hConstThermo:: -New(Istream& is) +inline Foam::autoPtr > +Foam::hConstThermo::New(Istream& is) { return autoPtr > ( @@ -88,68 +79,73 @@ New(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Heat capacity at constant pressure [J/(kmol K)] template -inline scalar hConstThermo::cp(const scalar) const +inline Foam::scalar Foam::hConstThermo::cp(const scalar) const { return CP*this->W(); } -//- Enthalpy [J/kmol] template -inline scalar hConstThermo::h(const scalar T) const +inline Foam::scalar Foam::hConstThermo::h(const scalar T) const { return (CP*T + Hf)*this->W(); } -//- Entropy [J/(kmol K)] template -inline scalar hConstThermo::s(const scalar T) const +inline Foam::scalar Foam::hConstThermo::s(const scalar T) const { - notImplemented("scalar hConstThermo::s(const scalar T) const"); + notImplemented + ( + "scalar hConstThermo::s(const scalar T) const" + ); return T; } -/* -//- Temperature from Enthalpy given an initial temperature T0 -template -inline scalar hConstThermo::TH(const scalar h, const scalar T0) const -{ - return (h - Hf)/Cp(T0); -} - - -//- Temperature from internal energy given an initial temperature T0 -template -inline scalar hConstThermo::TE(const scalar e, const scalar T0) const -{ - return (e - Hf)/Cv(T0); -} -*/ // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -inline hConstThermo& hConstThermo::operator= +inline void Foam::hConstThermo::operator+= ( - const hConstThermo& ct + const hConstThermo& ct ) { - equationOfState::operator=(ct); + scalar molr1 = this->nMoles(); - CP = ct.CP; - Hf = ct.Hf; + equationOfState::operator+=(ct); - return *this; + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + CP = molr1*CP + molr2*ct.CP; + Hf = molr1*Hf + molr2*ct.Hf; +} + + +template +inline void Foam::hConstThermo::operator-= +( + const hConstThermo& ct +) +{ + scalar molr1 = this->nMoles(); + + equationOfState::operator-=(ct); + + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + CP = molr1*CP - molr2*ct.CP; + Hf = molr1*Hf - molr2*ct.Hf; } // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template -inline hConstThermo operator+ +inline Foam::hConstThermo Foam::operator+ ( const hConstThermo& ct1, const hConstThermo& ct2 @@ -158,7 +154,7 @@ inline hConstThermo operator+ equationOfState eofs ( static_cast(ct1) - + static_cast(ct2) + + static_cast(ct2) ); return hConstThermo @@ -171,7 +167,7 @@ inline hConstThermo operator+ template -inline hConstThermo operator- +inline Foam::hConstThermo Foam::operator- ( const hConstThermo& ct1, const hConstThermo& ct2 @@ -193,7 +189,7 @@ inline hConstThermo operator- template -inline hConstThermo operator* +inline Foam::hConstThermo Foam::operator* ( const scalar s, const hConstThermo& ct @@ -209,7 +205,7 @@ inline hConstThermo operator* template -inline hConstThermo operator== +inline Foam::hConstThermo Foam::operator== ( const hConstThermo& ct1, const hConstThermo& ct2 @@ -219,8 +215,4 @@ inline hConstThermo operator== } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H index 8a1a205ec4..db7807a642 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef janafThermo2_H -#define janafThermo2_H +#ifndef janafThermo_H +#define janafThermo_H #include "scalar.H" @@ -85,11 +85,6 @@ Ostream& operator<< ); -#ifdef __GNUC__ -typedef scalar coeffArray2[7]; -#endif - - /*---------------------------------------------------------------------------*\ Class janafThermo Declaration \*---------------------------------------------------------------------------*/ @@ -122,13 +117,7 @@ private: inline void checkT(const scalar T) const; //- Return the coefficients corresponding to the given temperature - inline const -# ifdef __GNUC__ - coeffArray2& -# else - coeffArray& -# endif - coeffs(const scalar T) const; + inline const coeffArray& coeffs(const scalar T) const; public: @@ -170,8 +159,6 @@ public: inline void operator+=(const janafThermo&); inline void operator-=(const janafThermo&); - inline void operator*=(const scalar); - // Friend operators diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H index c859f76f8b..f9dc5e7a0e 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H @@ -26,16 +26,10 @@ License #include "janafThermo.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Construct from components template -inline janafThermo::janafThermo +inline Foam::janafThermo::janafThermo ( const equationOfState& st, const scalar Tlow, @@ -58,9 +52,8 @@ inline janafThermo::janafThermo } -// Check given temperature is within the range of the fitted coeffs. template -inline void janafThermo::checkT(const scalar T) const +inline void Foam::janafThermo::checkT(const scalar T) const { if (T < Tlow_ || T > Thigh_) { @@ -75,15 +68,9 @@ inline void janafThermo::checkT(const scalar T) const } -// Return the coefficients corresponding to the given temperature template -inline const -#ifdef __GNUC__ -coeffArray2& -#else -typename janafThermo::coeffArray& -#endif -janafThermo::coeffs +inline const typename Foam::janafThermo::coeffArray& +Foam::janafThermo::coeffs ( const scalar T ) const @@ -103,9 +90,8 @@ janafThermo::coeffs // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct as a named copy template -inline janafThermo::janafThermo +inline Foam::janafThermo::janafThermo ( const word& name, const janafThermo& jt @@ -126,9 +112,8 @@ inline janafThermo::janafThermo // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Heat capacity at constant pressure [J/(kmol K)] template -inline scalar janafThermo::cp +inline Foam::scalar Foam::janafThermo::cp ( const scalar T ) const @@ -138,9 +123,8 @@ inline scalar janafThermo::cp } -// Enthalpy [J/kmol] template -inline scalar janafThermo::h +inline Foam::scalar Foam::janafThermo::h ( const scalar T ) const @@ -155,9 +139,8 @@ inline scalar janafThermo::h } -// Entropy [J/(kmol K)] template -inline scalar janafThermo::s +inline Foam::scalar Foam::janafThermo::s ( const scalar T ) const @@ -175,7 +158,7 @@ inline scalar janafThermo::s // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -inline void janafThermo::operator+= +inline void Foam::janafThermo::operator+= ( const janafThermo& jt ) @@ -210,7 +193,7 @@ inline void janafThermo::operator+= template -inline void janafThermo::operator-= +inline void Foam::janafThermo::operator-= ( const janafThermo& jt ) @@ -244,20 +227,10 @@ inline void janafThermo::operator-= } -template -inline void janafThermo::operator*= -( - const scalar s -) -{ - equationOfState::operator*=(s); -} - - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template -inline janafThermo operator+ +inline Foam::janafThermo Foam::operator+ ( const janafThermo& jt1, const janafThermo& jt2 @@ -301,7 +274,7 @@ inline janafThermo operator+ template -inline janafThermo operator- +inline Foam::janafThermo Foam::operator- ( const janafThermo& jt1, const janafThermo& jt2 @@ -345,7 +318,7 @@ inline janafThermo operator- template -inline janafThermo operator* +inline Foam::janafThermo Foam::operator* ( const scalar s, const janafThermo& jt @@ -364,7 +337,7 @@ inline janafThermo operator* template -inline janafThermo operator== +inline Foam::janafThermo Foam::operator== ( const janafThermo& jt1, const janafThermo& jt2 @@ -374,8 +347,4 @@ inline janafThermo operator== } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* //