Commit 96ce5ae4 authored by Andrew Heather's avatar Andrew Heather
Browse files

Corrections and updates to turbulent heat flux temperature BC

- Corrected calculation of temperature gradient
- Option to specify the heat source in terms of a power [W] or flux [W/m2]
parent b441bb1f
......@@ -37,6 +37,22 @@ namespace Foam
namespace compressible
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char*
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>::
names[] =
{
"power",
"flux"
};
const
NamedEnum<turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType, 2>
turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
turbulentHeatFluxTemperatureFvPatchScalarField::
......@@ -47,8 +63,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(p, iF),
q_(p.size(), 0.0),
rhoName_("rho")
heatSource_(hsPower),
q_(p.size(), 0.0)
{}
......@@ -62,8 +78,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
q_(ptf.q_, mapper),
rhoName_(ptf.rhoName_)
heatSource_(ptf.heatSource_),
q_(ptf.q_, mapper)
{}
......@@ -76,8 +92,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(p, iF),
q_("q", dict, p.size()),
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
q_("q", dict, p.size())
{
fvPatchField<scalar>::operator=(patchInternalField());
gradient() = 0.0;
......@@ -91,8 +107,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(thftpsf),
q_(thftpsf.q_),
rhoName_(thftpsf.rhoName_)
heatSource_(thftpsf.heatSource_),
q_(thftpsf.q_)
{}
......@@ -104,8 +120,8 @@ turbulentHeatFluxTemperatureFvPatchScalarField
)
:
fixedGradientFvPatchScalarField(thftpsf, iF),
q_(thftpsf.q_),
rhoName_(thftpsf.rhoName_)
heatSource_(thftpsf.heatSource_),
q_(thftpsf.q_)
{}
......@@ -150,22 +166,39 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField alphaEffp = rasModel.alphaEff()().boundaryField()[patchI];
const scalarField alphaEffp = rasModel.alphaEff(patchI);
const basicThermo& thermo =
db().lookupObject<basicThermo>("thermophysicalProperties");
// const scalarField& Tp = thermo.T().boundaryField()[patchI];
const scalarField& Tp = *this;
const scalarField Cpp = thermo.Cp(Tp, patchI);
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalar Ap = gSum(patch().magSf());
const scalarField Cpp = rasModel.thermo().Cp(Tp, patchI);
gradient() = q_/(Ap*rhop*Cpp*alphaEffp);
switch (heatSource_)
{
case hsPower:
{
const scalar Ap = gSum(patch().magSf());
gradient() = q_/(Ap*Cpp*alphaEffp);
break;
}
case hsFlux:
{
gradient() = q_/(Cpp*alphaEffp);
break;
}
default:
{
FatalErrorIn
(
"turbulentHeatFluxTemperatureFvPatchScalarField"
"("
"const fvPatch&, "
"const DimensionedField<scalar, volMesh>&, "
"const dictionary&"
")"
) << "Unknown heat source type. Valid types are: "
<< heatSourceTypeNames_ << nl << exit(FatalError);
}
}
fixedGradientFvPatchScalarField::updateCoeffs();
}
......@@ -178,7 +211,6 @@ void turbulentHeatFluxTemperatureFvPatchScalarField::write
{
fvPatchScalarField::write(os);
q_.writeEntry("q", os);
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
gradient().writeEntry("gradient", os);
writeEntry("value", os);
}
......
......@@ -38,6 +38,7 @@ SourceFiles
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -47,20 +48,37 @@ namespace compressible
{
/*---------------------------------------------------------------------------*\
Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class turbulentHeatFluxTemperatureFvPatchScalarField
:
public fixedGradientFvPatchScalarField
{
// Private data
public:
// Data types
//- Enumeration listing the possible hest source input modes
enum heatSourceType
{
hsPower,
hsFlux
};
private:
// Private data
//- Heat source type names
static const NamedEnum<heatSourceType, 2> heatSourceTypeNames_;
//- Heat flux [W]
scalarField q_;
//- Heat source type
heatSourceType heatSource_;
//- Name of density field
word rhoName_;
//- Heat flux [W/m2]
scalarField q_;
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment