From f33061cc2a0babae70d83e6f6b7d4d9830e2292a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 23 Jan 2019 13:24:01 +0100 Subject: [PATCH] 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; } --- ...oupledTemperatureMixedFvPatchScalarField.C | 100 ++++++++++++++---- ...oupledTemperatureMixedFvPatchScalarField.H | 34 ++++-- 2 files changed, 104 insertions(+), 30 deletions(-) diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C index efa4659cab..d3c8a6414a 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C @@ -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(p, iF), - outputTemperature_(outputTemperatureType::WALL) + outTempType_(outputTemperatureType::WALL), + refTempType_(refTemperatureType::CELL), + Tref_(Zero) {} @@ -86,7 +100,9 @@ externalCoupledTemperatureMixedFvPatchScalarField ) : externalCoupledMixedFvPatchField(ptf, p, iF, mapper), - outputTemperature_(ptf.outputTemperature_) + outTempType_(ptf.outTempType_), + refTempType_(ptf.refTempType_), + Tref_(ptf.Tref_) {} @@ -100,12 +116,21 @@ externalCoupledTemperatureMixedFvPatchScalarField : //externalCoupledMixedFvPatchField(p, iF, dict) externalCoupledMixedFvPatchField(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("Tref"); + } + if (dict.found("refValue")) { // Initialise same way as mixed @@ -156,7 +186,9 @@ externalCoupledTemperatureMixedFvPatchScalarField ) : externalCoupledMixedFvPatchField(ecmpf), - outputTemperature_(ecmpf.outputTemperature_) + outTempType_(ecmpf.outTempType_), + refTempType_(ecmpf.refTempType_), + Tref_(ecmpf.Tref_) {} @@ -168,7 +200,9 @@ externalCoupledTemperatureMixedFvPatchScalarField ) : externalCoupledMixedFvPatchField(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 tfluid; + + if (refTempType_ == refTemperatureType::USER) + { + // User-specified reference temperature + tfluid = tmp::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& magSf(this->patch().magSf()); + const Field& magSf = this->patch().magSf(); const UList& 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_); + } } diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H index 3e2475e60e..9683fc7271 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.H @@ -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 .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 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 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: