From 071b8ffe89451c5c3f85d86ad00de22b475a3ea3 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 30 Sep 2008 14:26:46 +0100 Subject: [PATCH] adding run-time selectable thermal wall function capability to compressible RAS models --- .../RAS/compressible/LRR/LRR.C | 30 +++- .../RAS/compressible/LRR/LRR.H | 3 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 29 +++- .../LaunderGibsonRSTM/LaunderGibsonRSTM.H | 3 +- .../RAS/compressible/Make/files | 3 + .../RAS/compressible/RASModel/RASModel.C | 29 +++- .../RAS/compressible/RASModel/RASModel.H | 7 + .../compressible/RNGkEpsilon/RNGkEpsilon.C | 24 +++ .../compressible/RNGkEpsilon/RNGkEpsilon.H | 3 +- .../backwardsCompatibilityWallFunctions.C | 71 ++++++++ .../backwardsCompatibilityWallFunctions.H | 7 + .../alphatWallFunctionFvPatchScalarField.C | 132 +++++++++++++++ .../alphatWallFunctionFvPatchScalarField.H | 155 ++++++++++++++++++ .../RAS/compressible/kEpsilon/kEpsilon.C | 24 +++ .../RAS/compressible/kEpsilon/kEpsilon.H | 4 +- .../RAS/compressible/kOmegaSST/kOmegaSST.C | 23 +++ .../RAS/compressible/kOmegaSST/kOmegaSST.H | 3 +- .../compressible/realizableKE/realizableKE.C | 24 +++ .../compressible/realizableKE/realizableKE.H | 3 +- .../RAS/incompressible/RASModel/RASModel.C | 15 +- 20 files changed, 563 insertions(+), 29 deletions(-) create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C index 31ae4ceba9..a22d495249 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C @@ -204,11 +204,20 @@ LRR::LRR IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { - mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); - mut_.correctBoundaryConditions(); - if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { FatalErrorIn @@ -221,6 +230,12 @@ LRR::LRR << exit(FatalError); } + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -312,6 +327,11 @@ void LRR::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -402,6 +422,10 @@ void LRR::correct() mut_ == rho_*Cmu_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.H b/src/turbulenceModels/RAS/compressible/LRR/LRR.H index 553b11be96..0dc2ed2ad8 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.H +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.H @@ -97,6 +97,7 @@ class LRR volScalarField k_; volScalarField epsilon_; volScalarField mut_; + volScalarField alphat_; public: @@ -152,7 +153,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 4943d73613..0181605fb1 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -226,11 +226,20 @@ LaunderGibsonRSTM::LaunderGibsonRSTM IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { - mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); - mut_.correctBoundaryConditions(); - if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { FatalErrorIn @@ -243,6 +252,12 @@ LaunderGibsonRSTM::LaunderGibsonRSTM << exit(FatalError); } + mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -337,6 +352,11 @@ void LaunderGibsonRSTM::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -441,6 +461,9 @@ void LaunderGibsonRSTM::correct() mut_ == Cmu_*rho_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H index 2be69e96b5..4fa0e9315e 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.H @@ -104,6 +104,7 @@ class LaunderGibsonRSTM volScalarField k_; volScalarField epsilon_; volScalarField mut_; + volScalarField alphat_; public: @@ -161,7 +162,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index ff6c31794b..0598d06a00 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -14,6 +14,9 @@ kOmegaSST/kOmegaSST.C /* Wall functions */ wallFunctions = derivedFvPatchFields/wallFunctions +alphatWallFunctions = $(wallFunctions)/alphatWallFunctions +$(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C + mutWallFunctions = $(wallFunctions)/mutWallFunctions $(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C $(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C index a38da49b0e..c1bbdc1684 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C @@ -47,7 +47,8 @@ void RASModel::printCoeffs() { if (printCoeffs_) { - Info<< type() << "Coeffs" << coeffDict_ << endl; + Info<< type() << "Coeffs" << coeffDict_ << nl + << "wallFunctionCoeffs" << wallFunctionDict_ << endl; } } @@ -115,6 +116,15 @@ RASModel::RASModel 0.09 ) ), + Prt_ + ( + dimensioned::lookupOrAddToDict + ( + "Prt", + wallFunctionDict_, + 0.85 + ) + ), yPlusLam_(yPlusLam(kappa_.value(), E_.value())), @@ -148,11 +158,9 @@ tmp RASModel::yPlus(const label patchNo) const tmp tYp(new scalarField(curPatch.size())); scalarField& Yp = tYp(); - if (typeid(curPatch) == typeid(wallFvPatch)) + if (isType(curPatch)) { - scalar Cmu(readScalar(coeffDict_.lookup("Cmu"))); - - Yp = pow(Cmu, 0.25) + Yp = pow(Cmu_.value(), 0.25) *y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /( @@ -165,8 +173,8 @@ tmp RASModel::yPlus(const label patchNo) const WarningIn ( "tmp RASModel::yPlus(const label patchNo) const" - ) << "Patch " << patchNo << " is not a wall. Returning blank field" - << endl; + ) << "Patch " << patchNo << " is not a wall. Returning null field" + << nl << endl; Yp.setSize(0); } @@ -191,8 +199,11 @@ bool RASModel::read() lookup("turbulence") >> turbulence_; coeffDict_ = subDict(type() + "Coeffs"); - kappa_.readIfPresent(subDict("wallFunctionCoeffs")); - E_.readIfPresent(subDict("wallFunctionCoeffs")); + wallFunctionDict_ = subDict("wallFunctionCoeffs"); + kappa_.readIfPresent(wallFunctionDict_); + E_.readIfPresent(wallFunctionDict_); + Cmu_.readIfPresent(wallFunctionDict_); + Prt_.readIfPresent(wallFunctionDict_); yPlusLam_ = yPlusLam(kappa_.value(), E_.value()); diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index 51b4e706da..1be29e6e79 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -95,6 +95,7 @@ protected: dimensionedScalar kappa_; dimensionedScalar E_; dimensionedScalar Cmu_; + dimensionedScalar Prt_; scalar yPlusLam_; @@ -244,6 +245,12 @@ public: return Cmu_; } + //- Return turbulent Prandtl number for use in wall-functions + dimensionedScalar Prt() const + { + return Prt_; + } + //- Return the near wall distances const nearWallDist& y() const { diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C index 8851355ee1..8f6ba82321 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C @@ -174,11 +174,26 @@ RNGkEpsilon::RNGkEpsilon IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -265,6 +280,11 @@ void RNGkEpsilon::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -332,6 +352,10 @@ void RNGkEpsilon::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H index 5063615ccb..98445ced1d 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.H @@ -87,6 +87,7 @@ class RNGkEpsilon volScalarField k_; volScalarField epsilon_; volScalarField mut_; + volScalarField alphat_; public: @@ -142,7 +143,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C index a7c93d4ad6..19df95a3d5 100644 --- a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -27,6 +27,7 @@ License #include "backwardsCompatibilityWallFunctions.H" #include "calculatedFvPatchField.H" +#include "alphatWallFunctionFvPatchScalarField.H" #include "mutWallFunctionFvPatchScalarField.H" #include "epsilonWallFunctionFvPatchScalarField.H" #include "kQRWallFunctionFvPatchField.H" @@ -41,6 +42,76 @@ namespace compressible // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +tmp autoCreateAlphat +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject alphatHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (alphatHeader.headerOk()) + { + return tmp(new volScalarField(alphatHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList alphatBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + alphatBoundaryTypes[patchI] = + RASModels::alphatWallFunctionFvPatchScalarField::typeName; + } + else + { + alphatBoundaryTypes[patchI] = + calculatedFvPatchField::typeName; + } + } + + tmp alphat + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + alphatBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + alphat().write(); + + return alphat; + } +} + + tmp autoCreateMut ( const word& fieldName, diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H index a97b3090cd..bcc812a6b4 100644 --- a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -53,6 +53,13 @@ namespace compressible const fvMesh& mesh ); + //- alphat + tmp autoCreateAlphat + ( + const word& fieldName, + const fvMesh& mesh + ); + //- epsilon tmp autoCreateEpsilon ( diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..a34631cc3c --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "alphatWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& awfpsf +) +: + fixedValueFvPatchScalarField(awfpsf) +{} + + +alphatWallFunctionFvPatchScalarField:: +alphatWallFunctionFvPatchScalarField +( + const alphatWallFunctionFvPatchScalarField& awfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(awfpsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void alphatWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + const scalar Prt = ras.Prt().value(); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + operator==(mutw/Prt); +} + + +void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, alphatWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..d94775a342 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::compressible::RASModels::alphatWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent thermal diffusivity when using wall + functions + - replicates OpenFOAM v1.5 (and earlier) behaviour + +SourceFiles + alphatWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphatWallFunctionFvPatchScalarField_H +#define alphatWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class alphatWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class alphatWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("alphatWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + alphatWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + alphatWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // alphatWallFunctionFvPatchScalarField + // onto a new patch + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new alphatWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphatWallFunctionFvPatchScalarField + ( + const alphatWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new alphatWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C index 6c10f02466..cb0fecc03d 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C @@ -155,11 +155,26 @@ kEpsilon::kEpsilon IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -245,6 +260,11 @@ void kEpsilon::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -305,6 +325,10 @@ void kEpsilon::correct() // Re-calculate viscosity mut_ == rho_*Cmu_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H index d42bc73a66..76d952d40d 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.H @@ -74,7 +74,6 @@ class kEpsilon // Model coefficients -// dimensionedScalar Cmu; dimensionedScalar Cmu_; dimensionedScalar C1_; dimensionedScalar C2_; @@ -88,6 +87,7 @@ class kEpsilon volScalarField k_; volScalarField epsilon_; volScalarField mut_; + volScalarField alphat_; public: @@ -144,7 +144,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C index ec44d17c93..1181169f87 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C @@ -258,11 +258,26 @@ kOmegaSST::kOmegaSST IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); mut_.correctBoundaryConditions(); + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -356,6 +371,10 @@ void kOmegaSST::correct() /max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); mut_.correctBoundaryConditions(); + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -432,6 +451,10 @@ void kOmegaSST::correct() // Re-calculate viscosity mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2)); mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H index 4836d02611..3f9c1486d3 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.H @@ -134,6 +134,7 @@ class kOmegaSST volScalarField k_; volScalarField omega_; volScalarField mut_; + volScalarField alphat_; // Private member functions @@ -238,7 +239,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C index 3806e47ab2..1e762433f3 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C @@ -187,6 +187,18 @@ realizableKE::realizableKE IOobject::AUTO_WRITE ), autoCreateMut("mut", mesh_) + ), + alphat_ + ( + IOobject + ( + "alphat", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateAlphat("alphat", mesh_) ) { bound(k_, k0_); @@ -195,6 +207,9 @@ realizableKE::realizableKE mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); + alphat_ == mut_/Prt_; + alphat_.correctBoundaryConditions(); + printCoeffs(); } @@ -278,6 +293,11 @@ void realizableKE::correct() // Re-calculate viscosity mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); + return; } @@ -344,6 +364,10 @@ void realizableKE::correct() // Re-calculate viscosity mut_ == rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_; mut_.correctBoundaryConditions(); + + // Re-calculate thermal diffusivity + alphat_ = mut_/Prt_; + alphat_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H index 0eb770f083..f997efdd5f 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.H @@ -91,6 +91,7 @@ class realizableKE volScalarField k_; volScalarField epsilon_; volScalarField mut_; + volScalarField alphat_; tmp rCmu ( @@ -157,7 +158,7 @@ public: { return tmp ( - new volScalarField("alphaEff", alphah_*mut_ + alpha()) + new volScalarField("alphaEff", alphah_*alphat_ + alpha()) ); } diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index 628da387da..46236828f2 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -45,7 +45,8 @@ void RASModel::printCoeffs() { if (printCoeffs_) { - Info<< type() << "Coeffs" << coeffDict_ << endl;; + Info<< type() << "Coeffs" << coeffDict_ << nl + << "wallFunctionCoeffs" << wallFunctionDict_ << endl; } } @@ -148,9 +149,10 @@ tmp RASModel::yPlus(const label patchNo) const tmp tYp(new scalarField(curPatch.size())); scalarField& Yp = tYp(); - if (typeid(curPatch) == typeid(wallFvPatch)) + if (isType(curPatch)) { - Yp = pow(Cmu_.value(), 0.25)*y_[patchNo] + Yp = pow(Cmu_.value(), 0.25) + *y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /nu().boundaryField()[patchNo]; } @@ -158,9 +160,8 @@ tmp RASModel::yPlus(const label patchNo) const { WarningIn ( - "tmp RASModel::yPlus(const label patchNo)" - ) << "const : " << nl - << "Patch " << patchNo << " is not a wall. Returning zero field" + "tmp RASModel::yPlus(const label patchNo) const" + ) << "Patch " << patchNo << " is not a wall. Returning null field" << nl << endl; Yp.setSize(0); @@ -185,8 +186,8 @@ bool RASModel::read() { lookup("turbulence") >> turbulence_; coeffDict_ = subDict(type() + "Coeffs"); - wallFunctionDict_ = subDict("wallFunctionCoeffs"); + wallFunctionDict_ = subDict("wallFunctionCoeffs"); kappa_.readIfPresent(wallFunctionDict_); E_.readIfPresent(wallFunctionDict_); Cmu_.readIfPresent(wallFunctionDict_);