From 92f46b2ab5c32945e9470acbdd45305f995be7fe Mon Sep 17 00:00:00 2001 From: andy <a.heather@opencfd.co.uk> Date: Thu, 11 Feb 2010 12:02:16 +0000 Subject: [PATCH] ENH: Added sensible enthalpy variant of reactionThermo --- .../reactionThermo/Make/files | 3 + .../hsReactionThermo/hsReactionThermo.C | 67 ++++ .../hsReactionThermo/hsReactionThermo.H | 147 ++++++++ .../hsReactionThermo/hsReactionThermos.C | 171 ++++++++++ .../hsReactionThermo/makeHsReactionThermo.H | 100 ++++++ .../hsReactionThermo/newhsReactionThermo.C | 151 +++++++++ .../hsRhoMixtureThermo/hsRhoMixtureThermo.C | 320 ++++++++++++++++++ .../hsRhoMixtureThermo/hsRhoMixtureThermo.H | 147 ++++++++ 8 files changed, 1106 insertions(+) create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.C create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/makeHsReactionThermo.H create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/newhsReactionThermo.C create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.C create mode 100644 src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H diff --git a/src/thermophysicalModels/reactionThermo/Make/files b/src/thermophysicalModels/reactionThermo/Make/files index c2f9612ec5d..a93fc9976ed 100644 --- a/src/thermophysicalModels/reactionThermo/Make/files +++ b/src/thermophysicalModels/reactionThermo/Make/files @@ -16,6 +16,9 @@ reactionThermo/hReactionThermo/hReactionThermo.C reactionThermo/hReactionThermo/newhReactionThermo.C reactionThermo/hReactionThermo/hReactionThermos.C +reactionThermo/hsReactionThermo/hsReactionThermo.C +reactionThermo/hsReactionThermo/newhsReactionThermo.C +reactionThermo/hsReactionThermo/hsReactionThermos.C derivedFvPatchFields/fixedUnburntEnthalpy/fixedUnburntEnthalpyFvPatchScalarField.C derivedFvPatchFields/gradientUnburntEnthalpy/gradientUnburntEnthalpyFvPatchScalarField.C diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.C new file mode 100644 index 00000000000..7f255de38a1 --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "hsReactionThermo.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(hsReactionThermo, 0); + defineRunTimeSelectionTable(hsReactionThermo, fvMesh); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::hsReactionThermo::hsReactionThermo(const fvMesh& mesh) +: + basicRhoThermo(mesh), + + hs_ + ( + IOobject + ( + "hs", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimEnergy/dimMass, + this->hBoundaryTypes() + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::hsReactionThermo::~hsReactionThermo() +{} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H new file mode 100644 index 00000000000..85a23c3a388 --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::hsReactionThermo + +Description + Sensible enthalpy variant for reactionThermo + +SourceFiles + hReactionThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hsReactionThermo_H +#define hsReactionThermo_H + +#include "basicRhoThermo.H" +#include "basicMultiComponentMixture.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class hsReactionThermo Declaration +\*---------------------------------------------------------------------------*/ + +class hsReactionThermo +: + public basicRhoThermo +{ + +protected: + + // Protected data + + //- Sensible enthalpy [J/kg] + volScalarField hs_; + + +public: + + //- Runtime type information + TypeName("hsReactionThermo"); + + + //- Declare run-time constructor selection tables + declareRunTimeSelectionTable + ( + autoPtr, + hsReactionThermo, + fvMesh, + (const fvMesh& mesh), + (mesh) + ); + + + // Constructors + + //- Construct from dictionary and mesh + hsReactionThermo(const fvMesh&); + + + // Selectors + + //- Standard selection based on fvMesh + static autoPtr<hsReactionThermo> New(const fvMesh&); + + //- Select and check that package contains 'thermoType' + static autoPtr<hsReactionThermo> NewType + ( + const fvMesh&, + const word& thermoType + ); + + + //- Destructor + virtual ~hsReactionThermo(); + + + // Member functions + + //- Return the composition of the multi-component mixture + virtual basicMultiComponentMixture& composition() = 0; + + //- Return the composition of the multi-component mixture + virtual const basicMultiComponentMixture& composition() const = 0; + + + // Access to thermodynamic state variables + + //- Sensible enthalpy [J/kg] + // Non-const access allowed for transport equations + virtual volScalarField& hs() + { + return hs_; + } + + //- Sensible enthalpy [J/kg] + virtual const volScalarField& hs() const + { + return hs_; + } + + + //- Chemical enthalpy [J/kg] + virtual tmp<volScalarField> hc() const = 0; + + //- Update properties + virtual void correct() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C new file mode 100644 index 00000000000..be0e7967dea --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "makeHsReactionThermo.H" + +#include "hsReactionThermo.H" +#include "hsRhoMixtureThermo.H" + +#include "perfectGas.H" + +#include "hConstThermo.H" +#include "janafThermo.H" +#include "specieThermo.H" + +#include "constTransport.H" +#include "sutherlandTransport.H" + +#include "homogeneousMixture.H" +#include "inhomogeneousMixture.H" +#include "veryInhomogeneousMixture.H" +#include "dieselMixture.H" +#include "multiComponentMixture.H" +#include "reactingMixture.H" + +#include "thermoPhysicsTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + homogeneousMixture, + constTransport, + hConstThermo, + perfectGas +); + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + inhomogeneousMixture, + constTransport, + hConstThermo, + perfectGas +); + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + veryInhomogeneousMixture, + constTransport, + hConstThermo, + perfectGas +); + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + homogeneousMixture, + sutherlandTransport, + janafThermo, + perfectGas +); + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + inhomogeneousMixture, + sutherlandTransport, + janafThermo, + perfectGas +); + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + veryInhomogeneousMixture, + sutherlandTransport, + janafThermo, + perfectGas +); + + +makeHsReactionThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + dieselMixture, + sutherlandTransport, + janafThermo, + perfectGas +); + + +// Multi-component thermo + +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + multiComponentMixture, + icoPoly8ThermoPhysics +); + +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + multiComponentMixture, + gasThermoPhysics +); + + +// Multi-component reaction thermo + +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + reactingMixture, + icoPoly8ThermoPhysics +); + +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + reactingMixture, + gasThermoPhysics +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/makeHsReactionThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/makeHsReactionThermo.H new file mode 100644 index 00000000000..7c3fadbb70d --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/makeHsReactionThermo.H @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InClass + Foam::hReactionThermo + +Description + +\*---------------------------------------------------------------------------*/ + +#ifndef makeReactionThermo_H +#define makeReactionThermo_H + +#include "addToRunTimeSelectionTable.H" +#include "basicRhoThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeHsReactionThermo(CThermo,MixtureThermo,Mixture,Transport,Thermo,EqnOfState)\ + \ +typedef MixtureThermo \ + <Mixture<Transport<specieThermo<Thermo<EqnOfState> > > > > \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + #MixtureThermo \ + "<"#Mixture"<"#Transport"<specieThermo<"#Thermo"<"#EqnOfState">>>>>", \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicRhoThermo, \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + fvMesh \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + CThermo, \ + MixtureThermo##Mixture##Transport##Thermo##EqnOfState, \ + fvMesh \ +) + + +#define makeHsReactionMixtureThermo(CThermo,MixtureThermo,Mixture,ThermoPhys) \ + \ +typedef MixtureThermo<Mixture<ThermoPhys> > \ + MixtureThermo##Mixture##ThermoPhys; \ + \ +defineTemplateTypeNameAndDebugWithName \ +( \ + MixtureThermo##Mixture##ThermoPhys, \ + #MixtureThermo"<"#Mixture"<"#ThermoPhys">>", \ + 0 \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + basicRhoThermo, \ + MixtureThermo##Mixture##ThermoPhys, \ + fvMesh \ +); \ + \ +addToRunTimeSelectionTable \ +( \ + CThermo, \ + MixtureThermo##Mixture##ThermoPhys, \ + fvMesh \ +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/newhsReactionThermo.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/newhsReactionThermo.C new file mode 100644 index 00000000000..00457f5674c --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/newhsReactionThermo.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "hsReactionThermo.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::hsReactionThermo> Foam::hsReactionThermo::New +( + const fvMesh& mesh +) +{ + word hsReactionThermoTypeName; + + // Enclose the creation of the thermophysicalProperties to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary thermoDict + ( + IOobject + ( + "thermophysicalProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + thermoDict.lookup("thermoType") >> hsReactionThermoTypeName; + } + + Info<< "Selecting thermodynamics package " << hsReactionThermoTypeName + << endl; + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(hsReactionThermoTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorIn("hsReactionThermo::New(const fvMesh&)") + << "Unknown hsReactionThermo type " + << hsReactionThermoTypeName << nl << nl + << "Valid hsReactionThermo types are:" << nl + << fvMeshConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + + return autoPtr<hsReactionThermo>(cstrIter()(mesh)); +} + + +Foam::autoPtr<Foam::hsReactionThermo> Foam::hsReactionThermo::NewType +( + const fvMesh& mesh, + const word& thermoType +) +{ + word hsReactionThermoTypeName; + + // Enclose the creation of the thermophysicalProperties to ensure it is + // deleted before the turbulenceModel is created otherwise the dictionary + // is entered in the database twice + { + IOdictionary thermoDict + ( + IOobject + ( + "thermophysicalProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + thermoDict.lookup("thermoType") >> hsReactionThermoTypeName; + + if (hsReactionThermoTypeName.find(thermoType) == string::npos) + { + wordList allModels = fvMeshConstructorTablePtr_->sortedToc(); + DynamicList<word> validModels; + forAll(allModels, i) + { + if (allModels[i].find(thermoType) != string::npos) + { + validModels.append(allModels[i]); + } + } + + FatalErrorIn + ( + "autoPtr<hsReactionThermo> hsReactionThermo::NewType" + "(" + "const fvMesh&, " + "const word&" + ")" + ) << "Inconsistent thermo package selected:" << nl << nl + << hsReactionThermoTypeName << nl << nl << "Please select a " + << "thermo package based on " << thermoType + << ". Valid options include:" << nl << validModels << nl + << exit(FatalError); + } + } + + Info<< "Selecting thermodynamics package " << hsReactionThermoTypeName + << endl; + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(hsReactionThermoTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorIn("hsReactionThermo::New(const fvMesh&)") + << "Unknown hsReactionThermo type " + << hsReactionThermoTypeName << nl << nl + << "Valid hsReactionThermo types are:" << nl + << fvMeshConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + + return autoPtr<hsReactionThermo>(cstrIter()(mesh)); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.C b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.C new file mode 100644 index 00000000000..e17bd8d120a --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.C @@ -0,0 +1,320 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "hsRhoMixtureThermo.H" +#include "fvMesh.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class MixtureType> +void Foam::hsRhoMixtureThermo<MixtureType>::calculate() +{ + const scalarField& hsCells = hs_.internalField(); + const scalarField& pCells = p_.internalField(); + + scalarField& TCells = T_.internalField(); + scalarField& psiCells = psi_.internalField(); + scalarField& rhoCells = rho_.internalField(); + scalarField& muCells = mu_.internalField(); + scalarField& alphaCells = alpha_.internalField(); + + forAll(TCells, celli) + { + const typename MixtureType::thermoType& mixture = + this->cellMixture(celli); + + TCells[celli] = mixture.THs(hsCells[celli], TCells[celli]); + psiCells[celli] = mixture.psi(pCells[celli], TCells[celli]); + rhoCells[celli] = mixture.rho(pCells[celli], TCells[celli]); + + muCells[celli] = mixture.mu(TCells[celli]); + alphaCells[celli] = mixture.alpha(TCells[celli]); + } + + forAll(T_.boundaryField(), patchi) + { + fvPatchScalarField& pp = p_.boundaryField()[patchi]; + fvPatchScalarField& pT = T_.boundaryField()[patchi]; + fvPatchScalarField& ppsi = psi_.boundaryField()[patchi]; + fvPatchScalarField& prho = rho_.boundaryField()[patchi]; + + fvPatchScalarField& phs = hs_.boundaryField()[patchi]; + + fvPatchScalarField& pmu_ = mu_.boundaryField()[patchi]; + fvPatchScalarField& palpha_ = alpha_.boundaryField()[patchi]; + + if (pT.fixesValue()) + { + forAll(pT, facei) + { + const typename MixtureType::thermoType& mixture = + this->patchFaceMixture(patchi, facei); + + phs[facei] = mixture.Hs(pT[facei]); + + ppsi[facei] = mixture.psi(pp[facei], pT[facei]); + prho[facei] = mixture.rho(pp[facei], pT[facei]); + pmu_[facei] = mixture.mu(pT[facei]); + palpha_[facei] = mixture.alpha(pT[facei]); + } + } + else + { + forAll(pT, facei) + { + const typename MixtureType::thermoType& mixture = + this->patchFaceMixture(patchi, facei); + + pT[facei] = mixture.THs(phs[facei], pT[facei]); + + ppsi[facei] = mixture.psi(pp[facei], pT[facei]); + prho[facei] = mixture.rho(pp[facei], pT[facei]); + pmu_[facei] = mixture.mu(pT[facei]); + palpha_[facei] = mixture.alpha(pT[facei]); + } + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class MixtureType> +Foam::hsRhoMixtureThermo<MixtureType>::hsRhoMixtureThermo(const fvMesh& mesh) +: + hsReactionThermo(mesh), + MixtureType(*this, mesh) +{ + scalarField& hsCells = hs_.internalField(); + const scalarField& TCells = T_.internalField(); + + forAll(hsCells, celli) + { + hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]); + } + + forAll(hs_.boundaryField(), patchi) + { + hs_.boundaryField()[patchi] == hs(T_.boundaryField()[patchi], patchi); + } + + hBoundaryCorrection(hs_); + + calculate(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class MixtureType> +Foam::hsRhoMixtureThermo<MixtureType>::~hsRhoMixtureThermo() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class MixtureType> +void Foam::hsRhoMixtureThermo<MixtureType>::correct() +{ + if (debug) + { + Info<< "entering hsRhoMixtureThermo<MixtureType>::correct()" << endl; + } + + calculate(); + + if (debug) + { + Info<< "exiting hsRhoMixtureThermo<MixtureType>::correct()" << endl; + } +} + + +template<class MixtureType> +Foam::tmp<Foam::volScalarField> +Foam::hsRhoMixtureThermo<MixtureType>::hc() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp<volScalarField> thc + ( + new volScalarField + ( + IOobject + ( + "hc", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + hs_.dimensions() + ) + ); + + volScalarField& hcf = thc(); + scalarField& hcCells = hcf.internalField(); + + forAll(hcCells, celli) + { + hcCells[celli] = this->cellMixture(celli).Hc(); + } + + forAll(hcf.boundaryField(), patchi) + { + scalarField& hcp = hcf.boundaryField()[patchi]; + + forAll(hcp, facei) + { + hcp[facei] = this->patchFaceMixture(patchi, facei).Hc(); + } + } + + return thc; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsRhoMixtureThermo<MixtureType>::hs +( + const scalarField& T, + const labelList& cells +) const +{ + tmp<scalarField> ths(new scalarField(T.size())); + scalarField& hs = ths(); + + forAll(T, celli) + { + hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]); + } + + return ths; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsRhoMixtureThermo<MixtureType>::hs +( + const scalarField& T, + const label patchi +) const +{ + tmp<scalarField> ths(new scalarField(T.size())); + scalarField& hs = ths(); + + forAll(T, facei) + { + hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]); + } + + return ths; +} + + +template<class MixtureType> +Foam::tmp<Foam::scalarField> +Foam::hsRhoMixtureThermo<MixtureType>::Cp +( + const scalarField& T, + const label patchi +) const +{ + tmp<scalarField> tCp(new scalarField(T.size())); + + scalarField& cp = tCp(); + + forAll(T, facei) + { + cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]); + } + + return tCp; +} + + +template<class MixtureType> +Foam::tmp<Foam::volScalarField> +Foam::hsRhoMixtureThermo<MixtureType>::Cp() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp<volScalarField> tCp + ( + new volScalarField + ( + IOobject + ( + "Cp", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimEnergy/dimMass/dimTemperature + ) + ); + + volScalarField& cp = tCp(); + + scalarField& cpCells = cp.internalField(); + const scalarField& TCells = T_.internalField(); + + forAll(TCells, celli) + { + cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]); + } + + forAll(T_.boundaryField(), patchi) + { + cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi); + } + + return tCp; +} + + +template<class MixtureType> +bool Foam::hsRhoMixtureThermo<MixtureType>::read() +{ + if (hsReactionThermo::read()) + { + MixtureType::read(*this); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H new file mode 100644 index 00000000000..86e86a40a2c --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::hsRhoMixtureThermo + +Description + Foam::hsRhoMixtureThermo + +SourceFiles + hsRhoMixtureThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hsRhoMixtureThermo_H +#define hsRhoMixtureThermo_H + +#include "hsReactionThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class hsRhoMixtureThermo Declaration +\*---------------------------------------------------------------------------*/ + +template<class MixtureType> +class hsRhoMixtureThermo +: + public hsReactionThermo, + public MixtureType +{ + // Private member functions + + void calculate(); + + //- Construct as copy (not implemented) + hsRhoMixtureThermo(const hsRhoMixtureThermo<MixtureType>&); + + +public: + + //- Runtime type information + TypeName("hsRhoMixtureThermo"); + + + // Constructors + + //- Construct from mesh + hsRhoMixtureThermo(const fvMesh&); + + + //- Destructor + virtual ~hsRhoMixtureThermo(); + + + // Member functions + + //- Return the compostion of the multi-component mixture + virtual basicMultiComponentMixture& composition() + { + return *this; + } + + //- Return the compostion of the multi-component mixture + virtual const basicMultiComponentMixture& composition() const + { + return *this; + } + + //- Update properties + virtual void correct(); + + //- Chemical enthalpy [J/kg] + virtual tmp<volScalarField> hc() const; + + + // Fields derived from thermodynamic state variables + + //- Sensible nthalpy for cell-set [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Sensible enthalpy for patch [J/kg] + virtual tmp<scalarField> hs + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant pressure for patch [J/kg/K] + virtual tmp<scalarField> Cp + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant pressure [J/kg/K] + virtual tmp<volScalarField> Cp() const; + + + //- Read thermophysicalProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "hsRhoMixtureThermo.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab