diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index bc8fe9634f..da6a530727 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -32,6 +32,7 @@ heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoe heatTransferCoeff/heatTransferCoeffModels/heatTransferCoeffModel/heatTransferCoeffModelNew.C heatTransferCoeff/heatTransferCoeffModels/fixedReferenceTemperature/fixedReferenceTemperature.C heatTransferCoeff/heatTransferCoeffModels/localReferenceTemperature/localReferenceTemperature.C +heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.C heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.C new file mode 100644 index 0000000000..4cd8854a94 --- /dev/null +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.C @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "faceZoneReferenceTemperature.H" +#include "surfaceInterpolate.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace heatTransferCoeffModels +{ + defineTypeNameAndDebug(faceZoneReferenceTemperature, 0); + addToRunTimeSelectionTable + ( + heatTransferCoeffModel, + faceZoneReferenceTemperature, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::heatTransferCoeffModels::faceZoneReferenceTemperature:: +setFaceZoneFaces(const dictionary& dict) +{ + const auto& mesh = + mesh_.objectRegistry::db().lookupObject(refRegionName_); + + const word faceZoneName(dict.get("referenceFaceZone")); + + faceZonei_ = mesh.faceZones().findZoneID(faceZoneName); + + if (faceZonei_ < 0) + { + FatalIOErrorInFunction(dict) + << "referenceFaceZone: " << faceZoneName + << " does not exist in referenceRegion: " << refRegionName_ + << exit(FatalIOError); + } + + const faceZone& fZone = mesh.faceZones()[faceZonei_]; + + label numFaces = fZone.size(); + + if (!returnReduce(bool(numFaces), orOp())) + { + FatalIOErrorInFunction(dict) + << "referenceFaceZone: " << faceZoneName + << " contains no faces." + << exit(FatalIOError); + } + + faceId_.resize(numFaces); + facePatchId_.resize(numFaces); + + numFaces = 0; + + forAll(fZone, i) + { + const label meshFacei = fZone[i]; + + // Internal faces + label faceId = meshFacei; + label facePatchId = -1; + + // Boundary faces + if (!mesh.isInternalFace(meshFacei)) + { + facePatchId = mesh.boundaryMesh().whichPatch(meshFacei); + const polyPatch& pp = mesh.boundaryMesh()[facePatchId]; + const auto* cpp = isA(pp); + + if (cpp) + { + faceId = (cpp->owner() ? pp.whichFace(meshFacei) : -1); + } + else if (!isA(pp)) + { + faceId = pp.whichFace(meshFacei); + } + else + { + faceId = -1; + facePatchId = -1; + } + } + + if (faceId >= 0) + { + faceId_[numFaces] = faceId; + facePatchId_[numFaces] = facePatchId; + + ++numFaces; + } + } +} + + +Foam::scalar Foam::heatTransferCoeffModels::faceZoneReferenceTemperature:: +faceZoneAverageTemperature() +{ + const auto& mesh = + mesh_.objectRegistry::db().lookupObject(refRegionName_); + + const auto& T = mesh.lookupObject(TName_); + const surfaceScalarField Tf(fvc::interpolate(T)); + + const surfaceScalarField& magSf = mesh.magSf(); + + scalar Tmean = 0; + scalar sumMagSf = 0; + + forAll(faceId_, i) + { + const label facei = faceId_[i]; + if (facePatchId_[i] != -1) + { + const label patchi = facePatchId_[i]; + const scalar sf = magSf.boundaryField()[patchi][facei]; + + Tmean += Tf.boundaryField()[patchi][facei]*sf; + sumMagSf += sf; + } + else + { + const scalar sf = magSf[facei]; + Tmean += Tf[facei]*sf; + sumMagSf += sf; + } + } + reduce(Tmean, sumOp()); + reduce(sumMagSf, sumOp()); + + Tmean /= sumMagSf; + + return Tmean; +} + + +void Foam::heatTransferCoeffModels::faceZoneReferenceTemperature::htc +( + volScalarField& htc, + const FieldField& q +) +{ + // Retrieve temperature boundary fields for current region + const auto& T = mesh_.lookupObject(TName_); + const volScalarField::Boundary& Tbf = T.boundaryField(); + + // Retrieve heat-transfer coefficient boundary fields for current region + volScalarField::Boundary& htcBf = htc.boundaryFieldRef(); + + // Calculate area-averaged temperature field + // for the reference face zone and region + // (reference region can be different from current region) + const scalar Tref = faceZoneAverageTemperature(); + + // Calculate heat-transfer coefficient boundary fields for current region + for (const label patchi : patchSet_) + { + htcBf[patchi] = q[patchi]/(Tref - Tbf[patchi] + ROOTVSMALL); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::heatTransferCoeffModels::faceZoneReferenceTemperature:: +faceZoneReferenceTemperature +( + const dictionary& dict, + const fvMesh& mesh, + const word& TName +) +: + heatTransferCoeffModel(dict, mesh, TName), + faceZonei_(-1), + refRegionName_(polyMesh::defaultRegion), + faceId_(), + facePatchId_() +{ + read(dict); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::heatTransferCoeffModels::faceZoneReferenceTemperature::read +( + const dictionary& dict +) +{ + if (!heatTransferCoeffModel::read(dict)) + { + return false; + } + + dict.readIfPresent("referenceRegion", refRegionName_); + + setFaceZoneFaces(dict); + + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.H b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.H new file mode 100644 index 0000000000..617b0dfc0e --- /dev/null +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/faceZoneReferenceTemperature/faceZoneReferenceTemperature.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 3 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, see . + +Class + Foam::heatTransferCoeffModels::faceZoneReferenceTemperature + +Description + Heat transfer coefficient calculation that employs the area-average + temperature of a specified face zone as the reference temperature. + + The heat transfer coefficient is calculated by: + + \f[ + h = \frac{q}{T_{ref} - T_p} + \f] + + where + \vartable + h | Heat transfer coefficient [W/m^2/K] + q | Heat flux [W/m^2] + T_{ref} | Area average of reference face zone temperature [K] + T_p | Temperature field of current patch [K] + \endvartable + +Usage + Minimal example by using \c system/controlDict.functions: + \verbatim + heatTransferCoeff1 + { + // Inherited entries + ... + + // Mandatory entries + htcModel faceZoneReferenceTemperature; + referenceFaceZone ; + + // Optional entries + referenceRegion ; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Deflt + htcModel | Model name: faceZoneReferenceTemperature | word | yes | - + referenceFaceZone | Name of reference face zone | word | yes | - + referenceRegion | Name of region that reference face zone resides | word | no | region0 + \endtable + +SourceFiles + faceZoneReferenceTemperature.C + +\*---------------------------------------------------------------------------*/ + +#ifndef heatTransferCoeffModels_faceZoneReferenceTemperature_H +#define heatTransferCoeffModels_faceZoneReferenceTemperature_H + +#include "heatTransferCoeffModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace heatTransferCoeffModels +{ + +/*---------------------------------------------------------------------------*\ + Class faceZoneReferenceTemperature Declaration +\*---------------------------------------------------------------------------*/ + +class faceZoneReferenceTemperature +: + public heatTransferCoeffModel +{ + // Private Data + + //- Patch index of reference face zone + label faceZonei_; + + //- Name of region that the reference face zone resides + word refRegionName_; + + //- Local list of face IDs + labelList faceId_; + + //- Local list of patch ID per face + labelList facePatchId_; + + + // Private Member Functions + + //- Set faces to evaluate based on a face zone + void setFaceZoneFaces(const dictionary& dict); + + //- Return area average of face-zone temperature field + scalar faceZoneAverageTemperature(); + + //- Set the heat transfer coefficient + virtual void htc + ( + volScalarField& htc, + const FieldField& q + ); + + +public: + + //- Runtime type information + TypeName("faceZoneReferenceTemperature"); + + + // Constructors + + //- Construct from components + faceZoneReferenceTemperature + ( + const dictionary& dict, + const fvMesh& mesh, + const word& TName + ); + + //- No copy construct + faceZoneReferenceTemperature(const faceZoneReferenceTemperature&) = delete; + + //- No copy assignment + void operator=(const faceZoneReferenceTemperature&) = delete; + + + //- Destructor + virtual ~faceZoneReferenceTemperature() = default; + + + // Member Functions + + //- Read from dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace heatTransferCoeffModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //