mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added sensible enthalpy variants of (basic) rho and psi thermos
This commit is contained in:
@ -6,11 +6,13 @@ basicThermo/basicThermo.C
|
||||
psiThermo/basicPsiThermo/basicPsiThermo.C
|
||||
psiThermo/basicPsiThermo/newBasicPsiThermo.C
|
||||
psiThermo/hPsiThermo/hPsiThermos.C
|
||||
psiThermo/hsPsiThermo/hsPsiThermos.C
|
||||
psiThermo/ePsiThermo/ePsiThermos.C
|
||||
|
||||
rhoThermo/basicRhoThermo/basicRhoThermo.C
|
||||
rhoThermo/basicRhoThermo/newBasicRhoThermo.C
|
||||
rhoThermo/hRhoThermo/hRhoThermos.C
|
||||
rhoThermo/hsRhoThermo/hsRhoThermos.C
|
||||
|
||||
derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C
|
||||
derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C
|
||||
|
||||
@ -0,0 +1,347 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "hsPsiThermo.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
void Foam::hsPsiThermo<MixtureType>::calculate()
|
||||
{
|
||||
const scalarField& hsCells = hs_.internalField();
|
||||
const scalarField& pCells = this->p_.internalField();
|
||||
|
||||
scalarField& TCells = this->T_.internalField();
|
||||
scalarField& psiCells = this->psi_.internalField();
|
||||
scalarField& muCells = this->mu_.internalField();
|
||||
scalarField& alphaCells = this->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]);
|
||||
|
||||
muCells[celli] = mixture_.mu(TCells[celli]);
|
||||
alphaCells[celli] = mixture_.alpha(TCells[celli]);
|
||||
}
|
||||
|
||||
forAll(T_.boundaryField(), patchi)
|
||||
{
|
||||
fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
|
||||
fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
|
||||
fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
|
||||
|
||||
fvPatchScalarField& phs = hs_.boundaryField()[patchi];
|
||||
|
||||
fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
|
||||
fvPatchScalarField& palpha = this->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]);
|
||||
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]);
|
||||
pmu[facei] = mixture_.mu(pT[facei]);
|
||||
palpha[facei] = mixture_.alpha(pT[facei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::hsPsiThermo<MixtureType>::hsPsiThermo(const fvMesh& mesh)
|
||||
:
|
||||
basicPsiThermo(mesh),
|
||||
MixtureType(*this, mesh),
|
||||
|
||||
hs_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"hs",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimEnergy/dimMass,
|
||||
this->hBoundaryTypes()
|
||||
)
|
||||
{
|
||||
scalarField& hsCells = hs_.internalField();
|
||||
const scalarField& TCells = this->T_.internalField();
|
||||
|
||||
forAll(hsCells, celli)
|
||||
{
|
||||
hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
|
||||
}
|
||||
|
||||
forAll(hs_.boundaryField(), patchi)
|
||||
{
|
||||
hs_.boundaryField()[patchi] ==
|
||||
hs(this->T_.boundaryField()[patchi], patchi);
|
||||
}
|
||||
|
||||
hBoundaryCorrection(hs_);
|
||||
|
||||
calculate();
|
||||
|
||||
// Switch on saving old time
|
||||
this->psi_.oldTime();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::hsPsiThermo<MixtureType>::~hsPsiThermo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
void Foam::hsPsiThermo<MixtureType>::correct()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "entering hsPsiThermo<MixtureType>::correct()" << endl;
|
||||
}
|
||||
|
||||
// force the saving of the old-time values
|
||||
this->psi_.oldTime();
|
||||
|
||||
calculate();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "exiting hsPsiThermo<MixtureType>::correct()" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<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::hsPsiThermo<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::hsPsiThermo<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::hsPsiThermo<MixtureType>::Cp() const
|
||||
{
|
||||
const fvMesh& mesh = this->T_.mesh();
|
||||
|
||||
tmp<volScalarField> tCp
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Cp",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionSet(0, 2, -2, -1, 0),
|
||||
this->T_.boundaryField().types()
|
||||
)
|
||||
);
|
||||
|
||||
volScalarField& cp = tCp();
|
||||
|
||||
forAll(this->T_, celli)
|
||||
{
|
||||
cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
|
||||
}
|
||||
|
||||
forAll(this->T_.boundaryField(), patchi)
|
||||
{
|
||||
const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
|
||||
fvPatchScalarField& pCp = cp.boundaryField()[patchi];
|
||||
|
||||
forAll(pT, facei)
|
||||
{
|
||||
pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
|
||||
}
|
||||
}
|
||||
|
||||
return tCp;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::scalarField> Foam::hsPsiThermo<MixtureType>::Cv
|
||||
(
|
||||
const scalarField& T,
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
tmp<scalarField> tCv(new scalarField(T.size()));
|
||||
scalarField& cv = tCv();
|
||||
|
||||
forAll(T, facei)
|
||||
{
|
||||
cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
|
||||
}
|
||||
|
||||
return tCv;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::volScalarField> Foam::hsPsiThermo<MixtureType>::Cv() const
|
||||
{
|
||||
const fvMesh& mesh = this->T_.mesh();
|
||||
|
||||
tmp<volScalarField> tCv
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Cv",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimEnergy/dimMass/dimTemperature
|
||||
)
|
||||
);
|
||||
|
||||
volScalarField& cv = tCv();
|
||||
|
||||
forAll(this->T_, celli)
|
||||
{
|
||||
cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
|
||||
}
|
||||
|
||||
forAll(this->T_.boundaryField(), patchi)
|
||||
{
|
||||
cv.boundaryField()[patchi] =
|
||||
Cv(this->T_.boundaryField()[patchi], patchi);
|
||||
}
|
||||
|
||||
return tCv;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
bool Foam::hsPsiThermo<MixtureType>::read()
|
||||
{
|
||||
if (basicPsiThermo::read())
|
||||
{
|
||||
MixtureType::read(*this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::hsPsiThermo
|
||||
|
||||
Description
|
||||
Sensible enthalpy for a mixture based on compressibility
|
||||
|
||||
SourceFiles
|
||||
hsPsiThermo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef hsPsiThermo_H
|
||||
#define hsPsiThermo_H
|
||||
|
||||
#include "basicPsiThermo.H"
|
||||
#include "basicMixture.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class hsPsiThermo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class MixtureType>
|
||||
class hsPsiThermo
|
||||
:
|
||||
public basicPsiThermo,
|
||||
public MixtureType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Sensible enthalpy field [J/kg]
|
||||
volScalarField hs_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Calculate the thermo variables
|
||||
void calculate();
|
||||
|
||||
//- Construct as copy (not implemented)
|
||||
hsPsiThermo(const hsPsiThermo<MixtureType>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("hsPsiThermo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh
|
||||
hsPsiThermo(const fvMesh&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~hsPsiThermo();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return the compostion of the mixture
|
||||
virtual basicMixture& composition()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Return the compostion of the mixture
|
||||
virtual const basicMixture& composition() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Update properties
|
||||
virtual void correct();
|
||||
|
||||
|
||||
// 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_;
|
||||
}
|
||||
|
||||
|
||||
// Fields derived from thermodynamic state variables
|
||||
|
||||
//- Enthalpy for cell-set [J/kg]
|
||||
virtual tmp<scalarField> hs
|
||||
(
|
||||
const scalarField& T,
|
||||
const labelList& cells
|
||||
) const;
|
||||
|
||||
//- 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;
|
||||
|
||||
//- Heat capacity at constant volume for patch [J/kg/K]
|
||||
virtual tmp<scalarField> Cv
|
||||
(
|
||||
const scalarField& T,
|
||||
const label patchi
|
||||
) const;
|
||||
|
||||
//- Heat capacity at constant volume [J/kg/K]
|
||||
virtual tmp<volScalarField> Cv() const;
|
||||
|
||||
|
||||
//- Read thermophysicalProperties dictionary
|
||||
virtual bool read();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "hsPsiThermo.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "makeBasicPsiThermo.H"
|
||||
|
||||
#include "perfectGas.H"
|
||||
|
||||
#include "hConstThermo.H"
|
||||
#include "janafThermo.H"
|
||||
#include "specieThermo.H"
|
||||
|
||||
#include "constTransport.H"
|
||||
#include "sutherlandTransport.H"
|
||||
|
||||
#include "hsPsiThermo.H"
|
||||
#include "pureMixture.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
|
||||
|
||||
makeBasicPsiThermo
|
||||
(
|
||||
hsPsiThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicPsiThermo
|
||||
(
|
||||
hsPsiThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicPsiThermo
|
||||
(
|
||||
hsPsiThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
janafThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,346 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "hsRhoThermo.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
void Foam::hsRhoThermo<MixtureType>::calculate()
|
||||
{
|
||||
const scalarField& hsCells = this->hs_.internalField();
|
||||
const scalarField& pCells = this->p_.internalField();
|
||||
|
||||
scalarField& TCells = this->T_.internalField();
|
||||
scalarField& psiCells = this->psi_.internalField();
|
||||
scalarField& rhoCells = this->rho_.internalField();
|
||||
scalarField& muCells = this->mu_.internalField();
|
||||
scalarField& alphaCells = this->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(this->T_.boundaryField(), patchi)
|
||||
{
|
||||
fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
|
||||
fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
|
||||
fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
|
||||
fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
|
||||
|
||||
fvPatchScalarField& phs = this->hs_.boundaryField()[patchi];
|
||||
|
||||
fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
|
||||
fvPatchScalarField& palpha = this->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::hsRhoThermo<MixtureType>::hsRhoThermo(const fvMesh& mesh)
|
||||
:
|
||||
basicRhoThermo(mesh),
|
||||
MixtureType(*this, mesh),
|
||||
|
||||
hs_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"hs",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimEnergy/dimMass,
|
||||
this->hBoundaryTypes()
|
||||
)
|
||||
{
|
||||
scalarField& hsCells = hs_.internalField();
|
||||
const scalarField& TCells = this->T_.internalField();
|
||||
|
||||
forAll(hsCells, celli)
|
||||
{
|
||||
hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
|
||||
}
|
||||
|
||||
forAll(hs_.boundaryField(), patchi)
|
||||
{
|
||||
hs_.boundaryField()[patchi] ==
|
||||
hs(this->T_.boundaryField()[patchi], patchi);
|
||||
}
|
||||
|
||||
hBoundaryCorrection(hs_);
|
||||
|
||||
calculate();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::hsRhoThermo<MixtureType>::~hsRhoThermo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class MixtureType>
|
||||
void Foam::hsRhoThermo<MixtureType>::correct()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "entering hsRhoThermo<MixtureType>::correct()" << endl;
|
||||
}
|
||||
|
||||
calculate();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "exiting hsRhoThermo<MixtureType>::correct()" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::scalarField> Foam::hsRhoThermo<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::hsRhoThermo<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::hsRhoThermo<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::hsRhoThermo<MixtureType>::Cp() const
|
||||
{
|
||||
const fvMesh& mesh = this->T_.mesh();
|
||||
|
||||
tmp<volScalarField> tCp
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Cp",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimEnergy/dimMass/dimTemperature,
|
||||
this->T_.boundaryField().types()
|
||||
)
|
||||
);
|
||||
|
||||
volScalarField& cp = tCp();
|
||||
|
||||
forAll(this->T_, celli)
|
||||
{
|
||||
cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
|
||||
}
|
||||
|
||||
forAll(this->T_.boundaryField(), patchi)
|
||||
{
|
||||
const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
|
||||
fvPatchScalarField& pCp = cp.boundaryField()[patchi];
|
||||
|
||||
forAll(pT, facei)
|
||||
{
|
||||
pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
|
||||
}
|
||||
}
|
||||
|
||||
return tCp;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::scalarField> Foam::hsRhoThermo<MixtureType>::Cv
|
||||
(
|
||||
const scalarField& T,
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
tmp<scalarField> tCv(new scalarField(T.size()));
|
||||
scalarField& cv = tCv();
|
||||
|
||||
forAll(T, facei)
|
||||
{
|
||||
cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
|
||||
}
|
||||
|
||||
return tCv;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
Foam::tmp<Foam::volScalarField> Foam::hsRhoThermo<MixtureType>::Cv() const
|
||||
{
|
||||
const fvMesh& mesh = this->T_.mesh();
|
||||
|
||||
tmp<volScalarField> tCv
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Cv",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimEnergy/dimMass/dimTemperature
|
||||
)
|
||||
);
|
||||
|
||||
volScalarField& cv = tCv();
|
||||
|
||||
forAll(this->T_, celli)
|
||||
{
|
||||
cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
|
||||
}
|
||||
|
||||
forAll(this->T_.boundaryField(), patchi)
|
||||
{
|
||||
cv.boundaryField()[patchi] =
|
||||
Cv(this->T_.boundaryField()[patchi], patchi);
|
||||
}
|
||||
|
||||
return tCv;
|
||||
}
|
||||
|
||||
|
||||
template<class MixtureType>
|
||||
bool Foam::hsRhoThermo<MixtureType>::read()
|
||||
{
|
||||
if (basicRhoThermo::read())
|
||||
{
|
||||
MixtureType::read(*this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::hsRhoThermo
|
||||
|
||||
Description
|
||||
Sensible enthalpy for a mixture based on density
|
||||
|
||||
SourceFiles
|
||||
hsRhoThermo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef hsRhoThermo_H
|
||||
#define hsRhoThermo_H
|
||||
|
||||
#include "basicRhoThermo.H"
|
||||
#include "basicMixture.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class hsRhoThermo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class MixtureType>
|
||||
class hsRhoThermo
|
||||
:
|
||||
public basicRhoThermo,
|
||||
public MixtureType
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Sensible enthalpy field [J/kg]
|
||||
volScalarField hs_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Calculate the thermo variables
|
||||
void calculate();
|
||||
|
||||
//- Construct as copy (not implemented)
|
||||
hsRhoThermo(const hsRhoThermo<MixtureType>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("hsRhoThermo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh
|
||||
hsRhoThermo(const fvMesh&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~hsRhoThermo();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return the compostion of the combustion mixture
|
||||
virtual basicMixture& composition()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Return the compostion of the combustion mixture
|
||||
virtual const basicMixture& composition() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Update properties
|
||||
virtual void correct();
|
||||
|
||||
|
||||
// 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_;
|
||||
}
|
||||
|
||||
|
||||
// Fields derived from thermodynamic state variables
|
||||
|
||||
//- Sensible enthalpy 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;
|
||||
|
||||
//- Heat capacity at constant volume for patch [J/kg/K]
|
||||
virtual tmp<scalarField> Cv
|
||||
(
|
||||
const scalarField& T,
|
||||
const label patchi
|
||||
) const;
|
||||
|
||||
//- Heat capacity at constant volume [J/kg/K]
|
||||
virtual tmp<volScalarField> Cv() const;
|
||||
|
||||
|
||||
//- Read thermophysicalProperties dictionary
|
||||
virtual bool read();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "hsRhoThermo.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "makeBasicRhoThermo.H"
|
||||
|
||||
#include "perfectGas.H"
|
||||
|
||||
#include "hConstThermo.H"
|
||||
#include "janafThermo.H"
|
||||
#include "specieThermo.H"
|
||||
|
||||
#include "constTransport.H"
|
||||
#include "sutherlandTransport.H"
|
||||
|
||||
#include "hsRhoThermo.H"
|
||||
#include "pureMixture.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
|
||||
|
||||
makeBasicRhoThermo
|
||||
(
|
||||
hsRhoThermo,
|
||||
pureMixture,
|
||||
constTransport,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicRhoThermo
|
||||
(
|
||||
hsRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
hConstThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
makeBasicRhoThermo
|
||||
(
|
||||
hsRhoThermo,
|
||||
pureMixture,
|
||||
sutherlandTransport,
|
||||
janafThermo,
|
||||
perfectGas
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user