Commit f33061cc authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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;
  }
parent 65e94fde
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / 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
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 * * * * * * * * * * * //
void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader
......@@ -51,13 +63,13 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeHeader
Ostream& os
) const
{
if (outputTemperature_ == outputTemperatureType::FLUID)
if (outTempType_ == outputTemperatureType::WALL)
{
os << "# Values: area Tfluid qDot htc" << endl;
os << "# Values: area Twall qDot htc" << endl;
}
else
{
os << "# Values: area Twall qDot htc" << endl;
os << "# Values: area Tfluid qDot htc" << endl;
}
}
......@@ -72,7 +84,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
)
:
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),
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),
outputTemperature_(outputTemperatureType::WALL)
outTempType_(outputTemperatureType::WALL),
refTempType_
(
refTemperatureNames.lookupOrDefault
(
"htcRefTemperature",
dict,
refTemperatureType::CELL
)
),
Tref_(Zero)
{
if (dict.found("outputTemperature"))
{
outputTemperature_ =
outputTemperatureNames.get("outputTemperature", dict);
outTempType_ = outputTemperatureNames.get("outputTemperature", dict);
}
else
{
......@@ -116,6 +141,11 @@ externalCoupledTemperatureMixedFvPatchScalarField
<< endl;
}
if (refTempType_ == refTemperatureType::USER)
{
Tref_ = dict.get<scalar>("Tref");
}
if (dict.found("refValue"))
{
// Initialise same way as mixed
......@@ -156,7 +186,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
)
:
externalCoupledMixedFvPatchField<scalar>(ecmpf),
outputTemperature_(ecmpf.outputTemperature_)
outTempType_(ecmpf.outTempType_),
refTempType_(ecmpf.refTempType_),
Tref_(ecmpf.Tref_)
{}
......@@ -168,7 +200,9 @@ externalCoupledTemperatureMixedFvPatchScalarField
)
:
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]
const scalarField& Tp(*this);
// Wall temperature [K]
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]
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 =
(
outputTemperature_ == outputTemperatureType::FLUID
? Tc
: Tp
outTempType_ == outputTemperatureType::FLUID
? Tfluid
: Twall
);
forAll(patch(), facei)
......@@ -285,8 +333,18 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::write
os.writeEntry
(
"outputTemperature",
outputTemperatureNames[outputTemperature_]
outputTemperatureNames[outTempType_]
);
os.writeEntry
(
"htcRefTemperature",
refTemperatureNames[refTempType_]
);
if (refTempType_ == refTemperatureType::USER)
{
os.writeEntry("Tref", Tref_);
}
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -81,7 +81,7 @@ Description
<fileName>.in
\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.
To be used in combination with the functionObjects::externalCoupled
......@@ -89,12 +89,12 @@ Description
Usage
\table
Property | Description | Required | Default
outputTemperature | The output temperature: fluid/wall | yes |
Property | Description | Required | Default
outputTemperature | Output temperature: fluid/wall | yes |
htcRefTemperature | Fluid temperature for htc: cell/user | no | cell
Tref | Reference temperature [K] for htc | partly |
\endtable
Note the
SeeAlso
externalCoupledFunctionObject
mixedFvPatchField
......@@ -126,7 +126,7 @@ class externalCoupledTemperatureMixedFvPatchScalarField
{
// Data Types
//- Location for the ouput temperature
//- Location for the output temperature
enum outputTemperatureType
{
FLUID, //!< Use fluid (cell) temperature
......@@ -136,11 +136,27 @@ class externalCoupledTemperatureMixedFvPatchScalarField
//- Names for outputTemperatureType
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
//- Location for the ouput temperature
enum outputTemperatureType outputTemperature_;
//- Location for the output temperature
enum outputTemperatureType outTempType_;
//- Reference temperature type for HTC calculation
enum refTemperatureType refTempType_;
//- User-specified reference temperature for HTC calculation
scalar Tref_;
public:
......
Supports Markdown
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