diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index 992fe8dc23..6e433e7e91 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -54,7 +54,11 @@ yPlus/yPlus.C turbulenceIntensity/turbulenceIntensity.C wallShearStress/wallShearStress.C wallHeatFlux/wallHeatFlux.C + wallHeatTransferCoeff/wallHeatTransferCoeff.C +wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.C +wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.C +wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C writeCellCentres/writeCellCentres.C writeCellVolumes/writeCellVolumes.C diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.C b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.C index 700012be18..fad99fe1a8 100644 --- a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.C +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "wallHeatTransferCoeff.H" #include "kinematicMomentumTransportModel.H" +#include "fluidThermoMomentumTransportModel.H" #include "wallPolyPatch.H" #include "addToRunTimeSelectionTable.H" @@ -45,7 +46,7 @@ namespace functionObjects } -// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void Foam::functionObjects::wallHeatTransferCoeff::writeFileHeader ( @@ -58,51 +59,11 @@ void Foam::functionObjects::wallHeatTransferCoeff::writeFileHeader writeTabbed(file(), "patch"); writeTabbed(file(), "min"); writeTabbed(file(), "max"); - writeTabbed(file(), "integral"); + writeTabbed(file(), "average"); file() << endl; } -Foam::tmp -Foam::functionObjects::wallHeatTransferCoeff::calcHeatTransferCoeff -( - const volScalarField& nu, - const volScalarField& nut -) -{ - tmp twallHeatTransferCoeff - ( - volScalarField::New - ( - type(), - mesh_, - dimensionedScalar - ( - dimMass/pow3(dimTime)/(dimTemperature/dimLength), - 0 - ) - ) - ); - - volScalarField::Boundary& wallHeatTransferCoeffBf = - twallHeatTransferCoeff.ref().boundaryFieldRef(); - - const volScalarField::Boundary& nuBf = nu.boundaryField(); - const volScalarField::Boundary& nutBf = nut.boundaryField(); - - forAll(wallHeatTransferCoeffBf, patchi) - { - if (!wallHeatTransferCoeffBf[patchi].coupled()) - { - wallHeatTransferCoeffBf[patchi] = - rho_*Cp_*(nuBf[patchi]/Prl_ + nutBf[patchi]/Prt_); - } - } - - return twallHeatTransferCoeff; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::wallHeatTransferCoeff::wallHeatTransferCoeff @@ -115,8 +76,12 @@ Foam::functionObjects::wallHeatTransferCoeff::wallHeatTransferCoeff fvMeshFunctionObject(name, runTime, dict), logFiles(obr_, name), writeLocalObjects(obr_, log), + rho_("rho", dimDensity, Zero), + Cp_("Cp", dimArea/sqr(dimTime)/dimTemperature, Zero), + runTime_(runTime), patchSet_() { + coeffModel_ = wallHeatTransferCoeffModel::New(dict.name(), mesh_, dict); read(dict); resetName(typeName); resetLocalObjectName(typeName); @@ -136,15 +101,27 @@ bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict) fvMeshFunctionObject::read(dict); writeLocalObjects::read(dict); + const momentumTransportModel& mmtm = + lookupObject + ( + momentumTransportModel::typeName + ); + + if (isA(mmtm)) + { + rho_.read(dict); + Cp_.read(dict); + } + const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); patchSet_ = - mesh_.boundaryMesh().patchSet + pbm.patchSet ( wordReList(dict.lookupOrDefault("patches", wordReList())) ); - Info<< type() << " " << name() << ":" << nl; + Info<< type() << ":" << nl; if (patchSet_.empty()) { @@ -173,8 +150,8 @@ bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict) else { WarningInFunction - << "Requested wall heat-transferCoeff on non-wall boundary " - << "type patch: " << pbm[patchi].name() << endl; + << "Requested wall heat-transferCoeff on non-wall boundary" + << " type patch: " << pbm[patchi].name() << nl << endl; } } @@ -183,10 +160,7 @@ bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict) patchSet_ = filteredPatchSet; } - dict.lookup("rho") >> rho_; - dict.lookup("Cp") >> Cp_; - dict.lookup("Prl") >> Prl_; - dict.lookup("Prt") >> Prt_; + coeffModel_->read(dict); return true; } @@ -194,49 +168,41 @@ bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict) bool Foam::functionObjects::wallHeatTransferCoeff::execute() { - word name(type()); - - if - ( - foundObject + tmp thtc; + const momentumTransportModel& mmtm = + lookupObject ( momentumTransportModel::typeName - ) - ) - { - const incompressible::momentumTransportModel& turbModel = - lookupObject - ( - momentumTransportModel::typeName - ); - - return store - ( - name, - calcHeatTransferCoeff(turbModel.nu(), turbModel.nut()) ); - } - else - { - FatalErrorInFunction - << "Unable to find incompressible turbulence model in the " - << "database" << exit(FatalError); - return false; + thtc = coeffModel_->htcByRhoCp(mmtm, patchSet_); + + if (isA(mmtm)) + { + thtc.ref() *= rho_*Cp_; } + else if (isA(mmtm)) + { + const compressible::momentumTransportModel& mtm = + refCast(mmtm); + + thtc.ref() *= mtm.rho()*mtm.thermo().Cp(); + } + + store("wallHeatTransferCoeff", thtc); + + return true; } bool Foam::functionObjects::wallHeatTransferCoeff::write() { - Log << type() << " " << name() << " write:" << nl; + Log << name() << " write:" << nl; writeLocalObjects::write(); - logFiles::write(); - const volScalarField& wallHeatTransferCoeff = - obr_.lookupObject(type()); + const volScalarField& htc = obr_.lookupObject(type()); const fvPatchList& patches = mesh_.boundary(); @@ -248,11 +214,12 @@ bool Foam::functionObjects::wallHeatTransferCoeff::write() label patchi = iter.key(); const fvPatch& pp = patches[patchi]; - const scalarField& hfp = wallHeatTransferCoeff.boundaryField()[patchi]; + const scalarField& hfp = htc.boundaryField()[patchi]; const scalar minHtcp = gMin(hfp); const scalar maxHtcp = gMax(hfp); - const scalar integralHtcp = gSum(magSf[patchi]*hfp); + const scalar averageHtcp = + gSum(magSf[patchi]*hfp)/gSum(magSf[patchi]); if (Pstream::master()) { @@ -261,12 +228,12 @@ bool Foam::functionObjects::wallHeatTransferCoeff::write() << tab << pp.name() << tab << minHtcp << tab << maxHtcp - << tab << integralHtcp + << tab << averageHtcp << endl; } - Log << " min/max/integ(" << pp.name() << ") = " - << minHtcp << ", " << maxHtcp << ", " << integralHtcp << endl; + Log << " min/max/average(" << pp.name() << ") = " + << minHtcp << ", " << maxHtcp << ", " << averageHtcp << endl; } Log << endl; diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.H b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.H index 09e86bfb2b..e8d3eda603 100644 --- a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.H +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeff.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,19 +25,23 @@ Class Foam::functionObjects::wallHeatTransferCoeff Description - Calculates and write the estimated incompressible flow heat transfer - coefficient at wall patches as the volScalarField field - 'wallHeatTransferCoeff'. + Calculates and writes the estimated heat transfer coefficient at wall + patches as the volScalarField field. All wall patches are included by default; to restrict the calculation to certain patches, use the optional 'patches' entry. + The models are selected run time by model entry. For detailed description + look at the header file for specific model under + wallHeatTransferCoeffModels. + Example of function object specification: \verbatim - wallHeatTransferCoeff1 + kappaEff1 { type wallHeatTransferCoeff; libs ("libfieldFunctionObjects.so"); + model kappaEff; ... region fluid; patches (".*Wall"); @@ -48,17 +52,37 @@ Description } \endverbatim -Usage - \table - Property | Description | Required | Default value - type | Type name: wallHeatTransferCoeff | yes | - patches | List of patches to process | no | all wall patches - region | Region to be evaluated | no | default region - rho | Fluid density | yes | - Cp | Fluid heat capacity | yes | - Prl | Fluid laminar Prandtl number | yes | - Prt | Fluid turbulent Prandtl number| yes | - \endtable + \verbatim + kappaEff2 + { + type wallHeatTransferCoeff; + libs ("libfieldFunctionObjects.so"); + model kappaEff; + ... + region fluid; + patches (".*Wall"); + rho 1.225; + Cp 1005; + Prl 0.707; + Prt 0.9; + Lchar 0.001; + } + \endverbatim + + \verbatim + ReynoldsAnalogy1 + { + type wallHeatTransferCoeff; + libs ("libfieldFunctionObjects.so"); + model ReynoldsAnalogy; + ... + region fluid; + patches (".*Wall"); + rho 1.225; + Cp 1005; + Uref 1.0; + } + \endverbatim Note Writing field 'wallHeatTransferCoeff' is done by default, but it can be @@ -83,8 +107,7 @@ SourceFiles #include "fvMeshFunctionObject.H" #include "logFiles.H" #include "writeLocalObjects.H" -#include "HashSet.H" -#include "volFieldsFwd.H" +#include "wallHeatTransferCoeffModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -104,38 +127,39 @@ class wallHeatTransferCoeff public writeLocalObjects { +private: + + // Protected data + + // Pointer to the model + autoPtr coeffModel_; + + // Return wall shear stress + tmp devSigma(); + + + // Private data + + //- Density [kg/m^3] + dimensionedScalar rho_; + + //- Specific capacity [J/K/kg] + dimensionedScalar Cp_; + + protected: // Protected data + //- Reference to Time + const Time& runTime_; + //- Optional list of patches to process labelHashSet patchSet_; - //- Fluid density - scalar rho_; - - //- Fluid heat capacity - scalar Cp_; - - //- Fluid laminar Prandtl number - scalar Prl_; - - //- Fluid turbulent Prandtl number - scalar Prt_; - - - // Protected Member Functions - //- File header information virtual void writeFileHeader(const label i); - //- Calculate the heat transfer coefficient - tmp calcHeatTransferCoeff - ( - const volScalarField& nu, - const volScalarField& nut - ); - public: @@ -145,17 +169,14 @@ public: // Constructors - //- Construct from Time and dictionary + //- Construct from name, mesh and dict wallHeatTransferCoeff ( const word& name, const Time& runTime, - const dictionary& + const dictionary& dict ); - //- Disallow default bitwise copy construction - wallHeatTransferCoeff(const wallHeatTransferCoeff&) = delete; - //- Destructor virtual ~wallHeatTransferCoeff(); @@ -163,7 +184,7 @@ public: // Member Functions - //- Read the wallHeatTransferCoeff data + //- Read the wallHeatTransferCoeffs data virtual bool read(const dictionary&); //- Calculate the wall heat transfer coefficient diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C new file mode 100644 index 0000000000..5aac11cfd1 --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "ReynoldsAnalogy.H" +#include "kinematicMomentumTransportModel.H" +#include "fluidThermoMomentumTransportModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace wallHeatTransferCoeffModels +{ + defineTypeNameAndDebug(ReynoldsAnalogy, 0); + addToRunTimeSelectionTable + ( + wallHeatTransferCoeffModel, + ReynoldsAnalogy, + word + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::wallHeatTransferCoeffModels::ReynoldsAnalogy::ReynoldsAnalogy +( + const word& name, + const fvMesh& mesh, + const dictionary& dict +) +: + wallHeatTransferCoeffModel(name, mesh, dict), + mesh_(mesh), + Uref_("Uref", dimVelocity, dict) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::wallHeatTransferCoeffModels::ReynoldsAnalogy::~ReynoldsAnalogy() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::wallHeatTransferCoeffModels::ReynoldsAnalogy::read +( + const dictionary& dict +) +{ + Uref_.read(dict); + return true; +} + + +Foam::tmp +Foam::wallHeatTransferCoeffModels::ReynoldsAnalogy::htcByRhoCp +( + const momentumTransportModel& mmtm, + const labelHashSet& patches +) const +{ + tmp ttau(this->tau(mmtm, mesh_)); + const volSymmTensorField::Boundary& tauBf = ttau.ref().boundaryField(); + + // Create temporary field for heat transfer coefficient + tmp thtcByRhoCp + ( + volScalarField::New + ( + type(), + mesh_, + dimensionedScalar(dimLength/dimTime, 0) + ) + ); + + volScalarField::Boundary& thtcByRhoCpBf = + thtcByRhoCp.ref().boundaryFieldRef(); + + forAll(thtcByRhoCpBf, patchi) + { + if (!thtcByRhoCpBf[patchi].coupled()) + { + const vectorField nf(tauBf[patchi].patch().nf()); + + // Wall shear stress in [m^2/s^2] + tmp tauwp(-nf&tauBf[patchi]); + + // Non-dimensional skin friction coefficient [-] + const scalarField Cf(2*mag(tauwp)/sqr(Uref_.value())); + + thtcByRhoCpBf[patchi] = 0.5*Uref_.value()*Cf; + } + } + + return thtcByRhoCp; +} + +// ************************************************************************* // diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.H b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.H new file mode 100644 index 0000000000..13b6d8f5b3 --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.H @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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::wallHeatTransferCoeffModels::ReynoldsAnalogy + +Description + Calculates and writes the estimated flow heat transfer coefficient at wall + patches as the volScalarField field 'wallHeatTransferCoeff' using Reynolds + Analogy. + + Reynolds Analogy model, given by: + + \f[ + htc = 0.5 \rho C_p |U_{ref}| C_f + \f] + + where + \vartable + rho | Density [kg/m^3] + Cp | Specific heat capacity [m^2/K/s^2)] + Uref | Far field velocity magnitude [m/s] + Cf | Skin friction coefficient [] + \endvartable + + + All wall patches are included by default; to restrict the calculation to + certain patches, use the optional 'patches' entry. + + Example of function object specification: + \verbatim + ReynoldsAnalogy1 + { + type wallHeatTransferCoeff; + libs ("libfieldFunctionObjects.so"); + model ReynoldsAnalogy; + ... + region fluid; + patches (".*Wall"); + rho 1.225; + Cp 1005; + Uref 1.0; + } + \endverbatim + +Usage + \table + Property | Description | Required | Default value + type | type name: wallHeatTransferCoeff | yes | + model | Type name: ReynoldsAnalogy | no | kappaEff + patches | List of patches to process | no | all wall patches + region | Region to be evaluated | no | default region + rho | Density | yes | + Cp | Specific heat capacity | yes | + Uref | Reference velocity magnitude | yes | no + \endtable + +Note + Cp and rho are required only for incompressible flow calclulations. + +SourceFiles + ReynoldsAnalogy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wallHeatTransferCoeffModels_ReynoldsAnalogy_H +#define wallHeatTransferCoeffModels_ReynoldsAnalogy_H + +#include "wallHeatTransferCoeffModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace wallHeatTransferCoeffModels +{ + +/*---------------------------------------------------------------------------*\ + Class ReynoldsAnalogy Declaration +\*---------------------------------------------------------------------------*/ + +class ReynoldsAnalogy +: + public wallHeatTransferCoeffModel +{ + // Private Data + + //- Reference to mesh + const fvMesh& mesh_; + + //- Reference velocity magnitude [m/s] + dimensionedScalar Uref_; + + + // Private member functions + + //- Calculate the wall shear-stress + tmp calcShearStress + ( + const volSymmTensorField& tau + ); + + +public: + + //- Runtime type information + TypeName("ReynoldsAnalogy"); + + + // Constructors + + //- Construct from name, mesh and dict + ReynoldsAnalogy + ( + const word& name, + const fvMesh& mesh, + const dictionary& dict + ); + + //- Disallow default bitwise copy construction + ReynoldsAnalogy + ( + const ReynoldsAnalogy& + ) = delete; + + + //- Destructor + virtual ~ReynoldsAnalogy(); + + + // Member Functions + + //- Read the ReynoldsAnalogy data + virtual bool read(const dictionary&); + + //- Calculate the heat transfer coefficient + virtual tmp htcByRhoCp + ( + const momentumTransportModel& mmtm, + const labelHashSet& patches + ) const; + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const ReynoldsAnalogy&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace wallHeatTransferCoeffModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.C b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.C new file mode 100644 index 0000000000..b6b0145127 --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.C @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "kappaEff.H" +#include "kinematicMomentumTransportModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace wallHeatTransferCoeffModels +{ + defineTypeNameAndDebug(kappaEff, 0); + addToRunTimeSelectionTable + ( + wallHeatTransferCoeffModel, + kappaEff, + word + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::wallHeatTransferCoeffModels::kappaEff::kappaEff +( + const word& name, + const fvMesh& mesh, + const dictionary& dict +) +: + wallHeatTransferCoeffModel(name, mesh, dict), + mesh_(mesh), + Prl_("Prl", dimless, dict), + Prt_("Prl", dimless, dict), + Lchar_("Lchar", dimLength, dict), + isCharLength_(false) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::wallHeatTransferCoeffModels::kappaEff::~kappaEff() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::wallHeatTransferCoeffModels::kappaEff::read(const dictionary& dict) +{ + Prl_.read(dict); + Prt_.read(dict); + Lchar_.lookupOrDefault("Lchar", dict, dimLength); + isCharLength_ = dict.found("Lchar") ? true : false; + + return true; +} + + +Foam::tmp +Foam::wallHeatTransferCoeffModels::kappaEff::htcByRhoCp +( + const momentumTransportModel& mmtm, + const labelHashSet& patches +) const +{ + tmp thtcByRhoCp + ( + volScalarField::New + ( + type(), + mesh_, + isCharLength_ + ? dimensionedScalar(dimLength/dimTime, 0) + : dimensionedScalar(dimArea/dimTime, 0) + ) + ); + + volScalarField::Boundary& thtcByRhoCpBf = + thtcByRhoCp.ref().boundaryFieldRef(); + + forAllConstIter(labelHashSet, patches, iter) + { + label patchi = iter.key(); + + if (!thtcByRhoCpBf[patchi].coupled()) + { + thtcByRhoCpBf[patchi] = + mmtm.nu(patchi)/Prl_.value() + mmtm.nut(patchi)/Prt_.value(); + + if (isCharLength_) + { + thtcByRhoCpBf[patchi] /= Lchar_.value(); + } + } + } + return thtcByRhoCp; + +} + +// ************************************************************************* // diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.H b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.H new file mode 100644 index 0000000000..6e256fa22b --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/kappaEff/kappaEff.H @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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::wallHeatTransferCoeffModels::kappaEff + +Description + Calculates the estimated flow heat transfer coefficient at wall patches + as the volScalarField field 'kappaEff' using one of equeations bellow. + + kappaEff model, given by: + + \f[ + htc = \rho*C_p*({\frac{\nu}{Prl} + \frac{\nu_t}{Prt}}) + \f] + + kappaEff model with characteristic length, given by: + + \f[ + htc = + \rho*C_p*({\frac{\nu}{Prl} + \frac{\nu_t}{Prt}})\frac{1}{L_{char}}; + \f] + + where + \vartable + rho | Density [kg/m^3] + Cp | Specific heat capacity [m^2/K/s^2)] + Prl | Fluid laminar Prandtl number [] + Prt | Fluid turbulent Prandtl number [] + Lchar | Characteristic length [m] + \endvartable + + Example of function object specification: + \verbatim + kappaEff1 + { + type wallHeatTransferCoeff; + libs ("libfieldFunctionObjects.so"); + model kappaEff; + ... + region fluid; + patches (".*Wall"); + rho 1.225; + Cp 1005; + Prl 0.707; + Prt 0.9; + } + \endverbatim + + \verbatim + kappaEff2 + { + type wallHeatTransferCoeff; + libs ("libfieldFunctionObjects.so"); + model kappaEff; + ... + region fluid; + patches (".*Wall"); + rho 1.225; + Cp 1005; + Prl 0.707; + Prt 0.9; + Lchar 0.001; + } + \endverbatim + +Usage + \table + Property | Description | Required | Default value + type | Type name: wallHeatTransferCoeff | yes | + model | Type name: kappaEff | no | kappaEff + patches | List of patches to process | no | all wall patches + region | Region to be evaluated | no | default region + rho | Fluid density | yes | + Cp | Fluid heat capacity | yes | + Prl | Fluid laminar Prandtl number | yes | + Prt | Fluid turbulent Prandtl number| yes | + Lchar | Characteristic length | no | no + \endtable + +Note + Cp and rho are required only for incompressible flow calclulations. + +SourceFiles + kappaEff.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wallHeatTransferCoeffModels_kappaEff_H +#define wallHeatTransferCoeffModels_kappaEff_H + +#include "wallHeatTransferCoeffModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace wallHeatTransferCoeffModels +{ + +/*---------------------------------------------------------------------------*\ + Class kappaEff Declaration +\*---------------------------------------------------------------------------*/ + +class kappaEff +: + public wallHeatTransferCoeffModel +{ + // Private data + + //- Reference to mesh + const fvMesh& mesh_; + + //- Fluid laminar Prandtl number + dimensionedScalar Prl_; + + //- Fluid turbulent Prandtl number + dimensionedScalar Prt_; + + //- Characteristic length + dimensionedScalar Lchar_; + + //- Is characteristic length used? + bool isCharLength_; + + +public: + + //- Runtime type information + TypeName("kappaEff"); + + + // Constructors + + //- Construct from name, mesh and dict + kappaEff + ( + const word& name, + const fvMesh& mesh, + const dictionary& + ); + + //- Disallow default bitwise copy construction + kappaEff(const kappaEff&) = delete; + + + //- Destructor + virtual ~kappaEff(); + + + // Member Functions + + //- Read the kappaEff data + virtual bool read(const dictionary&); + + //- Calculate the wall heat transfer coefficient + virtual tmp htcByRhoCp + ( + const momentumTransportModel& mmtm, + const labelHashSet& patches + ) const; + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const kappaEff&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace wallHeatTransferCoeffModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.C b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.C new file mode 100644 index 0000000000..8eb6076a50 --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "wallHeatTransferCoeffModel.H" +#include "fluidThermoMomentumTransportModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(wallHeatTransferCoeffModel, 0); + defineRunTimeSelectionTable(wallHeatTransferCoeffModel, word); +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +Foam::autoPtr +Foam::wallHeatTransferCoeffModel::New +( + const word& name, + const fvMesh& mesh, + const dictionary& dict +) +{ + const word model(dict.lookupOrDefault("model", "kappaEff")); + + if (debug) + { + Info<< "Selecting heat transfer coefficient type: " + << model << endl; + } + + wordConstructorTable::iterator cstrIter = + wordConstructorTablePtr_->find(model); + + if (cstrIter == wordConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown heat transfer coefficient type " + << model << nl << nl + << "Valid coefficient types: " << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(name, mesh, dict)); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::tmp Foam::wallHeatTransferCoeffModel::tau +( + const momentumTransportModel& mmtm, + const fvMesh& mesh +) const +{ + if (isA(mmtm)) + { + return + refCast + ( + mmtm + ).devSigma(); + } + else if (isA(mmtm)) + { + return + refCast(mmtm).devTau() + /refCast(mmtm).rho(); + } + else + { + FatalErrorInFunction + << "The type of momentum transport model was not recognised" + << exit(FatalError); + } + + return tmp(); +} + +// ************************************************************************* // diff --git a/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.H b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.H new file mode 100644 index 0000000000..bb981abffc --- /dev/null +++ b/src/functionObjects/field/wallHeatTransferCoeff/wallHeatTransferCoeffModels/wallHeatTransferCoeffModel/wallHeatTransferCoeffModel.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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::wallHeatTransferCoeffModel + +Description + Abstract base class for run time selection of heat transfer coefficient + models. + +SourceFiles + wallHeatTransferCoeffModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wallHeatTransferCoeffModel_H +#define wallHeatTransferCoeffModel_H + +#include "kinematicMomentumTransportModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferCoeffModel Declaration +\*---------------------------------------------------------------------------*/ + +class wallHeatTransferCoeffModel +{ + +public: + + //- Runtime type information + TypeName("wallHeatTransferCoeffModel"); + + + // Declare run-time selection table + + declareRunTimeSelectionTable + ( + autoPtr, + wallHeatTransferCoeffModel, + word, + ( + const word& name, + const fvMesh& mesh, + const dictionary& dict + ), + (name, mesh, dict) + ); + + + // Constructors + + //- Construct from name, mesh and dict + wallHeatTransferCoeffModel + ( + const word& name, + const fvMesh& mesh, + const dictionary& + ) + {} + + //- Disallow default bitwise copy construction + wallHeatTransferCoeffModel(const wallHeatTransferCoeffModel&) = delete; + + //- Clone + autoPtr clone() const + { + NotImplemented; + return autoPtr(nullptr); + } + + + // Selectors + + //- Return a reference to the selected subset + static autoPtr New + ( + const word& name, + const fvMesh& mesh, + const dictionary& + ); + + + //- Destructor + virtual ~wallHeatTransferCoeffModel() + {} + + + // Member Functions + + //- Read the wallHeatTransferCoeffModel data + virtual bool read(const dictionary&) = 0; + + //- Interface for heat transfer coefficient + virtual tmp htcByRhoCp + ( + const momentumTransportModel& mmtm, + const labelHashSet& patches + ) const = 0; + + //- Calculate wall shear stress + tmp tau + ( + const momentumTransportModel& mmtm, + const fvMesh& mesh + ) const; + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const wallHeatTransferCoeffModel&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //