diff --git a/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGas.H b/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGas.H index 7ff3f054e3adfc9a42567bfbf2835eca07fd1121..566c3c972911bfdb5634ba70ac6699d47833bdcf 100644 --- a/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGas.H +++ b/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGas.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -105,7 +105,10 @@ public: // Constructors //- Construct from components - inline incompressiblePerfectGas(const Specie& sp); + inline incompressiblePerfectGas(const Specie& sp, const scalar pRef); + + //- Construct from incompressiblePerfectGas + inline incompressiblePerfectGas(const incompressiblePerfectGas& sp); //- Construct from Istream incompressiblePerfectGas(Istream&); @@ -173,6 +176,10 @@ public: // Member operators + inline incompressiblePerfectGas& operator= + ( + const incompressiblePerfectGas& + ); inline void operator+=(const incompressiblePerfectGas&); inline void operator-=(const incompressiblePerfectGas&); diff --git a/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGasI.H b/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGasI.H index 340d4b1e4c5f502320282a3256228329ee53abe2..ff2f3e233dfccfa21d08c5cb150ca4070fa0ff89 100644 --- a/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGasI.H +++ b/src/thermophysicalModels/specie/equationOfState/incompressiblePerfectGas/incompressiblePerfectGasI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,28 +25,40 @@ License #include "incompressiblePerfectGas.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Specie> inline Foam::incompressiblePerfectGas<Specie>::incompressiblePerfectGas ( - const Specie& sp + const Specie& sp, const scalar pRef ) : - Specie(sp) + Specie(sp), + pRef_(pRef) {} -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +template<class Specie> +inline Foam::incompressiblePerfectGas<Specie>::incompressiblePerfectGas +( + const incompressiblePerfectGas& ipg +) +: + Specie(ipg), + pRef_(ipg.pRef_) +{} + template<class Specie> inline Foam::incompressiblePerfectGas<Specie>::incompressiblePerfectGas ( const word& name, - const incompressiblePerfectGas<Specie>& pg + const incompressiblePerfectGas<Specie>& ipg ) : - Specie(name, pg) + Specie(name, ipg), + pRef_(ipg.pRef_) {} @@ -109,7 +121,7 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::psi scalar T ) const { - return 0.0; + return 1.0/(this->R()*T); } @@ -120,7 +132,7 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::Z scalar ) const { - return 0.0; + return 1.0; } @@ -138,23 +150,43 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::cpMcv // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +template<class Specie> +inline Foam::incompressiblePerfectGas<Specie>& +Foam::incompressiblePerfectGas<Specie>::operator= +( + const incompressiblePerfectGas<Specie>& ipg +) +{ + Specie::operator=(ipg); + + pRef_ = ipg.pRef_; + + return *this; +} + template<class Specie> inline void Foam::incompressiblePerfectGas<Specie>::operator+= ( - const incompressiblePerfectGas<Specie>& pg + const incompressiblePerfectGas<Specie>& ipg ) { - Specie::operator+=(pg); + scalar molr1 = this->nMoles(); + Specie::operator+=(ipg); + molr1 /= this->nMoles(); + scalar molr2 = ipg.nMoles()/this->nMoles(); + + pRef_ = molr1*pRef_ + molr2*ipg.pRef_; } template<class Specie> inline void Foam::incompressiblePerfectGas<Specie>::operator-= ( - const incompressiblePerfectGas<Specie>& pg + const incompressiblePerfectGas<Specie>& ipg ) { - Specie::operator-=(pg); + Specie::operator-=(ipg); + pRef_ = ipg.pRef_; } @@ -170,14 +202,19 @@ inline void Foam::incompressiblePerfectGas<Specie>::operator*=(const scalar s) template<class Specie> inline Foam::incompressiblePerfectGas<Specie> Foam::operator+ ( - const incompressiblePerfectGas<Specie>& pg1, - const incompressiblePerfectGas<Specie>& pg2 + const incompressiblePerfectGas<Specie>& ipg1, + const incompressiblePerfectGas<Specie>& ipg2 ) { + scalar nMoles = ipg1.nMoles() + ipg2.nMoles(); + scalar molr1 = ipg1.nMoles()/nMoles; + scalar molr2 = ipg2.nMoles()/nMoles; + return incompressiblePerfectGas<Specie> ( - static_cast<const Specie&>(pg1) - + static_cast<const Specie&>(pg2) + static_cast<const Specie&>(ipg1) + + static_cast<const Specie&>(ipg2), + molr1*ipg1.pRef_ + molr2*ipg2.pRef_ ); } @@ -185,14 +222,15 @@ inline Foam::incompressiblePerfectGas<Specie> Foam::operator+ template<class Specie> inline Foam::incompressiblePerfectGas<Specie> Foam::operator- ( - const incompressiblePerfectGas<Specie>& pg1, - const incompressiblePerfectGas<Specie>& pg2 + const incompressiblePerfectGas<Specie>& ipg1, + const incompressiblePerfectGas<Specie>& ipg2 ) { return incompressiblePerfectGas<Specie> ( - static_cast<const Specie&>(pg1) - - static_cast<const Specie&>(pg2) + static_cast<const Specie&>(ipg1) + - static_cast<const Specie&>(ipg2), + ipg1.pRef_ ); } @@ -201,10 +239,14 @@ template<class Specie> inline Foam::incompressiblePerfectGas<Specie> Foam::operator* ( const scalar s, - const incompressiblePerfectGas<Specie>& pg + const incompressiblePerfectGas<Specie>& ipg ) { - return incompressiblePerfectGas<Specie>(s*static_cast<const Specie&>(pg)); + return incompressiblePerfectGas<Specie> + ( + s*static_cast<const Specie&>(ipg), + ipg.pRef_ + ); }