ENH: user-specified ref temperature for externalCoupled mixed T BC (#1072)

- Uses the user-specified value for the HTC calculation

  {
      type  externalCoupledTemperature;

      outputTemperture    fluid;  // or wall;
      htcRefTemperature   user;   // or cell (default)

      Tref    293.15;
  }
This commit is contained in:
Mark Olesen
2019-01-23 13:24:01 +01:00
parent 65e94fde66
commit f33061cc2a
2 changed files with 104 additions and 30 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,6 +44,18 @@ Foam::externalCoupledTemperatureMixedFvPatchScalarField::outputTemperatureNames
}); });
const Foam::Enum
<
Foam::externalCoupledTemperatureMixedFvPatchScalarField::
refTemperatureType
>
Foam::externalCoupledTemperatureMixedFvPatchScalarField::refTemperatureNames
({
{ refTemperatureType::CELL, "cell" },
{ refTemperatureType::USER, "user" },
});
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader
@ -51,13 +63,13 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader
Ostream& os Ostream& os
) const ) const
{ {
if (outputTemperature_ == outputTemperatureType::FLUID) if (outTempType_ == outputTemperatureType::WALL)
{ {
os << "# Values: area Tfluid qDot htc" << endl; os << "# Values: area Twall qDot htc" << endl;
} }
else else
{ {
os << "# Values: area Twall qDot htc" << endl; os << "# Values: area Tfluid qDot htc" << endl;
} }
} }
@ -72,7 +84,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
) )
: :
externalCoupledMixedFvPatchField<scalar>(p, iF), externalCoupledMixedFvPatchField<scalar>(p, iF),
outputTemperature_(outputTemperatureType::WALL) outTempType_(outputTemperatureType::WALL),
refTempType_(refTemperatureType::CELL),
Tref_(Zero)
{} {}
@ -86,7 +100,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
) )
: :
externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper), externalCoupledMixedFvPatchField<scalar>(ptf, p, iF, mapper),
outputTemperature_(ptf.outputTemperature_) outTempType_(ptf.outTempType_),
refTempType_(ptf.refTempType_),
Tref_(ptf.Tref_)
{} {}
@ -100,12 +116,21 @@ externalCoupledTemperatureMixedFvPatchScalarField
: :
//externalCoupledMixedFvPatchField<scalar>(p, iF, dict) //externalCoupledMixedFvPatchField<scalar>(p, iF, dict)
externalCoupledMixedFvPatchField<scalar>(p, iF), externalCoupledMixedFvPatchField<scalar>(p, iF),
outputTemperature_(outputTemperatureType::WALL) outTempType_(outputTemperatureType::WALL),
refTempType_
(
refTemperatureNames.lookupOrDefault
(
"htcRefTemperature",
dict,
refTemperatureType::CELL
)
),
Tref_(Zero)
{ {
if (dict.found("outputTemperature")) if (dict.found("outputTemperature"))
{ {
outputTemperature_ = outTempType_ = outputTemperatureNames.get("outputTemperature", dict);
outputTemperatureNames.get("outputTemperature", dict);
} }
else else
{ {
@ -116,6 +141,11 @@ externalCoupledTemperatureMixedFvPatchScalarField
<< endl; << endl;
} }
if (refTempType_ == refTemperatureType::USER)
{
Tref_ = dict.get<scalar>("Tref");
}
if (dict.found("refValue")) if (dict.found("refValue"))
{ {
// Initialise same way as mixed // Initialise same way as mixed
@ -156,7 +186,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
) )
: :
externalCoupledMixedFvPatchField<scalar>(ecmpf), externalCoupledMixedFvPatchField<scalar>(ecmpf),
outputTemperature_(ecmpf.outputTemperature_) outTempType_(ecmpf.outTempType_),
refTempType_(ecmpf.refTempType_),
Tref_(ecmpf.Tref_)
{} {}
@ -168,7 +200,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
) )
: :
externalCoupledMixedFvPatchField<scalar>(ecmpf, iF), externalCoupledMixedFvPatchField<scalar>(ecmpf, iF),
outputTemperature_(ecmpf.outputTemperature_) outTempType_(ecmpf.outTempType_),
refTempType_(ecmpf.refTempType_),
Tref_(ecmpf.Tref_)
{} {}
@ -224,22 +258,36 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData
} }
// Patch (wall) temperature [K] // Wall temperature [K]
const scalarField& Tp(*this); const scalarField& Twall = *this;
// Fluid temperature [K]
tmp<scalarField> tfluid;
if (refTempType_ == refTemperatureType::USER)
{
// User-specified reference temperature
tfluid = tmp<scalarField>::New(size(), Tref_);
}
else
{
// Near wall cell temperature
tfluid = patchInternalField();
}
const scalarField Tfluid(tfluid);
// Near wall cell (fluid) temperature [K]
const scalarField Tc(patchInternalField());
// Heat transfer coefficient [W/m2/K] // Heat transfer coefficient [W/m2/K]
const scalarField htc(qDot/(Tp - Tc + 1e-3)); const scalarField htc(qDot/(Twall - Tfluid + 1e-3));
const Field<scalar>& magSf(this->patch().magSf()); const Field<scalar>& magSf = this->patch().magSf();
const UList<scalar>& Tout = const UList<scalar>& Tout =
( (
outputTemperature_ == outputTemperatureType::FLUID outTempType_ == outputTemperatureType::FLUID
? Tc ? Tfluid
: Tp : Twall
); );
forAll(patch(), facei) forAll(patch(), facei)
@ -285,8 +333,18 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::write
os.writeEntry os.writeEntry
( (
"outputTemperature", "outputTemperature",
outputTemperatureNames[outputTemperature_] outputTemperatureNames[outTempType_]
); );
os.writeEntry
(
"htcRefTemperature",
refTemperatureNames[refTempType_]
);
if (refTempType_ == refTemperatureType::USER)
{
os.writeEntry("Tref", Tref_);
}
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -81,7 +81,7 @@ Description
<fileName>.in <fileName>.in
\endverbatim \endverbatim
... and then re-instate the lock file. The boundary condition will then ... and then reinstate the lock file. The boundary condition will then
read the return values, and pass program execution back to OpenFOAM. read the return values, and pass program execution back to OpenFOAM.
To be used in combination with the functionObjects::externalCoupled To be used in combination with the functionObjects::externalCoupled
@ -89,12 +89,12 @@ Description
Usage Usage
\table \table
Property | Description | Required | Default Property | Description | Required | Default
outputTemperature | The output temperature: fluid/wall | yes | outputTemperature | Output temperature: fluid/wall | yes |
htcRefTemperature | Fluid temperature for htc: cell/user | no | cell
Tref | Reference temperature [K] for htc | partly |
\endtable \endtable
Note the
SeeAlso SeeAlso
externalCoupledFunctionObject externalCoupledFunctionObject
mixedFvPatchField mixedFvPatchField
@ -126,7 +126,7 @@ class externalCoupledTemperatureMixedFvPatchScalarField
{ {
// Data Types // Data Types
//- Location for the ouput temperature //- Location for the output temperature
enum outputTemperatureType enum outputTemperatureType
{ {
FLUID, //!< Use fluid (cell) temperature FLUID, //!< Use fluid (cell) temperature
@ -136,11 +136,27 @@ class externalCoupledTemperatureMixedFvPatchScalarField
//- Names for outputTemperatureType //- Names for outputTemperatureType
static const Enum<outputTemperatureType> outputTemperatureNames; static const Enum<outputTemperatureType> outputTemperatureNames;
//- Reference temperature type for HTC calculation
enum refTemperatureType
{
CELL, //!< Use cell temperature (default)
USER //!< User-specified reference temperature
};
//- Names for refTemperatureType
static const Enum<refTemperatureType> refTemperatureNames;
// Private Data // Private Data
//- Location for the ouput temperature //- Location for the output temperature
enum outputTemperatureType outputTemperature_; enum outputTemperatureType outTempType_;
//- Reference temperature type for HTC calculation
enum refTemperatureType refTempType_;
//- User-specified reference temperature for HTC calculation
scalar Tref_;
public: public: