From e3e62b9ef888116c81a7634f3f612f1e6aa52011 Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Tue, 4 Dec 2012 15:03:45 +0000 Subject: [PATCH] Thermo: Add support for instantiating more than one thermo package in an application --- .../basic/basicThermo/basicThermo.C | 12 ++-- .../basic/basicThermo/basicThermo.H | 16 +++-- .../basic/heThermo/heThermo.C | 64 ++++++++++++++++++- .../basic/heThermo/heThermo.H | 8 +++ .../basic/psiThermo/psiThermo.C | 4 +- .../basic/rhoThermo/rhoThermo.C | 12 ++-- .../basic/rhoThermo/rhoThermos.C | 25 ++++++++ .../solidThermo/solidThermo/solidThermo.C | 4 +- 8 files changed, 123 insertions(+), 22 deletions(-) diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index 84e30e31a47..e2fc874b5ef 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -112,7 +112,7 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("alpha"), + phasePropertyName("thermo:alpha"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -167,7 +167,7 @@ Foam::basicThermo::basicThermo ( IOobject ( - phasePropertyName("alpha"), + phasePropertyName("thermo:alpha"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -237,7 +237,7 @@ const Foam::basicThermo& Foam::basicThermo::lookupThermo void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a ) const { @@ -252,7 +252,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b ) const @@ -275,7 +275,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b, const word& c @@ -301,7 +301,7 @@ void Foam::basicThermo::validate void Foam::basicThermo::validate ( - const word& app, + const string& app, const word& a, const word& b, const word& c, diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index 659b6f35ca0..e652c30ee6c 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -185,7 +185,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word& ) const; @@ -193,7 +193,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word& ) const; @@ -202,7 +202,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word&, const word& @@ -212,7 +212,7 @@ public: // with energy forms supported by the application void validate ( - const word& app, + const string& app, const word&, const word&, const word&, @@ -263,6 +263,14 @@ public: //- Enthalpy/Internal energy [J/kg] virtual const volScalarField& he() const = 0; + //- Enthalpy/Internal energy + // for given pressure and temperature [J/kg] + virtual tmp<volScalarField> he + ( + const volScalarField& p, + const volScalarField& T + ) const = 0; + //- Enthalpy/Internal energy for cell-set [J/kg] virtual tmp<scalarField> he ( diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.C b/src/thermophysicalModels/basic/heThermo/heThermo.C index 8efaf0f5d50..29634e27693 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.C +++ b/src/thermophysicalModels/basic/heThermo/heThermo.C @@ -174,7 +174,10 @@ Foam::heThermo<BasicThermo, MixtureType>::heThermo ( IOobject ( - BasicThermo::phasePropertyName(MixtureType::thermoType::heName()), + BasicThermo::phasePropertyName + ( + MixtureType::thermoType::heName() + ), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -205,7 +208,10 @@ Foam::heThermo<BasicThermo, MixtureType>::heThermo ( IOobject ( - BasicThermo::phasePropertyName(MixtureType::thermoType::heName()), + BasicThermo::phasePropertyName + ( + MixtureType::thermoType::heName() + ), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -230,6 +236,60 @@ Foam::heThermo<BasicThermo, MixtureType>::~heThermo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class BasicThermo, class MixtureType> +Foam::tmp<Foam::volScalarField> Foam::heThermo<BasicThermo, MixtureType>::he +( + const volScalarField& p, + const volScalarField& T +) const +{ + const fvMesh& mesh = this->T_.mesh(); + + tmp<volScalarField> the + ( + new volScalarField + ( + IOobject + ( + "he", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + he_.dimensions() + ) + ); + + volScalarField& he = the(); + scalarField& heCells = he.internalField(); + const scalarField& pCells = p.internalField(); + const scalarField& TCells = T.internalField(); + + forAll(heCells, celli) + { + heCells[celli] = + this->cellMixture(celli).HE(pCells[celli], TCells[celli]); + } + + forAll(he.boundaryField(), patchi) + { + scalarField& hep = he.boundaryField()[patchi]; + const scalarField& pp = p.boundaryField()[patchi]; + const scalarField& Tp = T.boundaryField()[patchi]; + + forAll(hep, facei) + { + hep[facei] = + this->patchFaceMixture(patchi, facei).HE(pp[facei], Tp[facei]); + } + } + + return the; +} + + template<class BasicThermo, class MixtureType> Foam::tmp<Foam::scalarField> Foam::heThermo<BasicThermo, MixtureType>::he ( diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.H b/src/thermophysicalModels/basic/heThermo/heThermo.H index ef9919a99cd..f77d017e139 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.H +++ b/src/thermophysicalModels/basic/heThermo/heThermo.H @@ -161,6 +161,14 @@ public: // Fields derived from thermodynamic state variables + //- Enthalpy/Internal energy + // for given pressure and temperature [J/kg] + virtual tmp<volScalarField> he + ( + const volScalarField& p, + const volScalarField& T + ) const; + //- Enthalpy/Internal energy for cell-set [J/kg] virtual tmp<scalarField> he ( diff --git a/src/thermophysicalModels/basic/psiThermo/psiThermo.C b/src/thermophysicalModels/basic/psiThermo/psiThermo.C index fd4bc962c90..dd698903134 100644 --- a/src/thermophysicalModels/basic/psiThermo/psiThermo.C +++ b/src/thermophysicalModels/basic/psiThermo/psiThermo.C @@ -44,7 +44,7 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -58,7 +58,7 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C index 4aa7835caca..d34186eea9e 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermo.C @@ -43,7 +43,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("rhoThermo"), + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -57,7 +57,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -71,7 +71,7 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const word& phaseName) ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -95,7 +95,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("rhoThermo"), + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -109,7 +109,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("psi"), + phasePropertyName("thermo:psi"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -123,7 +123,7 @@ Foam::rhoThermo::rhoThermo ( IOobject ( - phasePropertyName("mu"), + phasePropertyName("thermo:mu"), mesh.time().timeName(), mesh, IOobject::NO_READ, diff --git a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C index fcfc3437dd3..beaa43b7350 100644 --- a/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C +++ b/src/thermophysicalModels/basic/rhoThermo/rhoThermos.C @@ -30,6 +30,7 @@ License #include "perfectGas.H" #include "incompressiblePerfectGas.H" #include "rhoConst.H" +#include "perfectFluid.H" #include "hConstThermo.H" #include "janafThermo.H" #include "sensibleEnthalpy.H" @@ -101,6 +102,18 @@ makeThermo specie ); +makeThermo +( + rhoThermo, + heRhoThermo, + pureMixture, + constTransport, + sensibleEnthalpy, + hConstThermo, + perfectFluid, + specie +); + makeThermo ( rhoThermo, @@ -200,6 +213,18 @@ makeThermo specie ); +makeThermo +( + rhoThermo, + heRhoThermo, + pureMixture, + constTransport, + sensibleInternalEnergy, + hConstThermo, + perfectFluid, + specie +); + makeThermo ( rhoThermo, diff --git a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C index 102414e3fbb..2e12bcf213d 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C +++ b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.C @@ -50,7 +50,7 @@ Foam::solidThermo::solidThermo ( IOobject ( - "rhoThermo", + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, @@ -74,7 +74,7 @@ Foam::solidThermo::solidThermo ( IOobject ( - "rhoThermo", + phasePropertyName("thermo:rho"), mesh.time().timeName(), mesh, IOobject::NO_READ, -- GitLab