diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C index 5ac329fe31a371fcb357c7b288ef43b56df873c7..526ee9563942db8faa264ef3930a138e50f5c93f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C @@ -62,7 +62,7 @@ directMappedVelocityFluxFixedValueFvPatchField fixedValueFvPatchVectorField(ptf, p, iF, mapper), phiName_(ptf.phiName_) { - if (!isType<directMappedPatchBase>(this->patch().patch())) + if (!isA<directMappedPatchBase>(this->patch().patch())) { FatalErrorIn ( @@ -95,7 +95,7 @@ directMappedVelocityFluxFixedValueFvPatchField fixedValueFvPatchVectorField(p, iF, dict), phiName_(dict.lookup("phi")) { - if (!isType<directMappedPatchBase>(this->patch().patch())) + if (!isA<directMappedPatchBase>(this->patch().patch())) { FatalErrorIn ( @@ -207,7 +207,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs() allUValues ); newUValues = patch().patchSlice(newUValues); - + mapDistribute::distribute ( Pstream::defaultCommsType, diff --git a/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C index e847acda6e829d24076b3262783887d79c997811..eb9a3c783eae6666d7eac8f66b8baeaf60c28b77 100644 --- a/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C +++ b/src/turbulenceModels/compressible/LES/DeardorffDiffStress/DeardorffDiffStress.C @@ -48,6 +48,9 @@ void DeardorffDiffStress::updateSubGridScaleFields(const volScalarField& K) { muSgs_ = ck_*rho()*sqrt(K)*delta(); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C index 61907f0c5b985251f0256f2879146d13b2393d59..d1e3591e9d89642c01ce9f545d61d7d134c89687 100644 --- a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.C @@ -84,6 +84,19 @@ GenEddyVisc::GenEddyVisc IOobject::AUTO_WRITE ), mesh_ + ), + + alphaSgs_ + ( + IOobject + ( + "alphaSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ ) {} diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H index 5690b26a489be8d7bd520d032268b7fd7b136a08..5a9504dbd1477a3e9a9c2c1084778a7fbd211cd8 100644 --- a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H @@ -72,6 +72,7 @@ protected: volScalarField k_; volScalarField muSgs_; + volScalarField alphaSgs_; public: @@ -113,12 +114,18 @@ public: return muSgs_; } - //- Return thermal conductivity + //- Return thermal diffusivity + virtual tmp<volScalarField> alphaSgs() const + { + return alphaSgs_; + } + + //- Return thermal diffusivity virtual tmp<volScalarField> alphaEff() const { return tmp<volScalarField> ( - new volScalarField("alphaEff", muSgs_ + alpha()) + new volScalarField("alphaEff", alphaSgs_ + alpha()) ); } diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C index 4c8089851a8cd0e4823d0e18e33a12a70d85a1e4..a1400f67b327c553f2393d4cd6bf30480eeda58d 100644 --- a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.C @@ -88,6 +88,19 @@ GenSGSStress::GenSGSStress IOobject::AUTO_WRITE ), mesh_ + ), + + alphaSgs_ + ( + IOobject + ( + "alphaSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ ) {} diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H index 6425d86b4982dbc6e300f9aa3feda7737b85f8e6..131db3bc16de9faeee5fd2371c430a37ff4c4436 100644 --- a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H @@ -73,6 +73,7 @@ protected: volSymmTensorField B_; volScalarField muSgs_; + volScalarField alphaSgs_; public: @@ -96,35 +97,41 @@ public: // Member Functions - //- Return the SGS turbulent kinetic energy. + //- Return the SGS turbulent kinetic energy virtual tmp<volScalarField> k() const { return 0.5*tr(B_); } - //- Return the SGS turbulent dissipation. + //- Return the SGS turbulent dissipation virtual tmp<volScalarField> epsilon() const { volScalarField K = k(); return ce_*K*sqrt(K)/delta(); } - //- Return the SGS viscosity. + //- Return the SGS viscosity virtual tmp<volScalarField> muSgs() const { return muSgs_; } + //- Return the SGS thermal diffusivity + virtual tmp<volScalarField> alphaSgs() const + { + return alphaSgs_; + } + //- Return thermal conductivity virtual tmp<volScalarField> alphaEff() const { return tmp<volScalarField> ( - new volScalarField("alphaEff", muSgs_ + alpha()) + new volScalarField("alphaEff", alphaSgs_ + alpha()) ); } - //- Return the sub-grid stress tensor. + //- Return the sub-grid stress tensor virtual tmp<volSymmTensorField> B() const { return B_; @@ -135,7 +142,7 @@ public: virtual tmp<volSymmTensorField> devRhoBeff() const; //- Returns divergence of B : i.e. the additional term in the - // filtered NSE. + // filtered NSE virtual tmp<fvVectorMatrix> divDevRhoBeff(volVectorField& U) const; //- Correct Eddy-Viscosity and related properties diff --git a/src/turbulenceModels/compressible/LES/LESModel/LESModel.C b/src/turbulenceModels/compressible/LES/LESModel/LESModel.C index 3e7b3eabf44b16b7ad09f694b2b887bf40b4ce73..267de51f6049490b4fe09b3c9677cea6cd56bade 100644 --- a/src/turbulenceModels/compressible/LES/LESModel/LESModel.C +++ b/src/turbulenceModels/compressible/LES/LESModel/LESModel.C @@ -81,7 +81,45 @@ LESModel::LESModel k0_("k0", dimVelocity*dimVelocity, SMALL), - delta_(LESdelta::New("delta", U.mesh(), *this)) + delta_(LESdelta::New("delta", U.mesh(), *this)), + + wallFunctionDict_(subDict("wallFunctionCoeffs")), + kappa_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "kappa", + wallFunctionDict_, + 0.4187 + ) + ), + E_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "E", + wallFunctionDict_, + 9.0 + ) + ), + Cmu_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "Cmu", + wallFunctionDict_, + 0.07 + ) + ), + Prt_ + ( + dimensioned<scalar>::lookupOrAddToDict + ( + "Prt", + wallFunctionDict_, + 0.85 + ) + ) { readIfPresent("k0", k0_); } @@ -107,9 +145,15 @@ bool LESModel::read() { coeffDict_ = subDict(type() + "Coeffs"); + readIfPresent("k0", k0_); + delta_().read(*this); - readIfPresent("k0", k0_); + wallFunctionDict_ = subDict("wallFunctionCoeffs"); + kappa_.readIfPresent(wallFunctionDict_); + E_.readIfPresent(wallFunctionDict_); + Cmu_.readIfPresent(wallFunctionDict_); + Prt_.readIfPresent(wallFunctionDict_); return true; } diff --git a/src/turbulenceModels/compressible/LES/LESModel/LESModel.H b/src/turbulenceModels/compressible/LES/LESModel/LESModel.H index dec3e88c0ff25fc25ec04d6461d398e195e3cf9f..58ca05ce927378d8b92c1e20998ce0ad64d87a1a 100644 --- a/src/turbulenceModels/compressible/LES/LESModel/LESModel.H +++ b/src/turbulenceModels/compressible/LES/LESModel/LESModel.H @@ -87,6 +87,19 @@ protected: autoPtr<LESdelta> delta_; + // Wall function properties + + //- Wall function dictionary + dictionary wallFunctionDict_; + + dimensionedScalar kappa_; + + dimensionedScalar E_; + + dimensionedScalar Cmu_; + + dimensionedScalar Prt_; + // Protected Member Functions @@ -167,12 +180,6 @@ public: return coeffDict_; } - //- Access function to filter width - inline const volScalarField& delta() const - { - return delta_(); - } - //- Return the value of k0 which k is not allowed to be less than const dimensionedScalar& k0() const { @@ -185,6 +192,35 @@ public: return k0_; } + //- Access function to filter width + inline const volScalarField& delta() const + { + return delta_(); + } + + //- Return kappa for use in wall-functions + dimensionedScalar kappa() const + { + return kappa_; + } + + //- Return E for use in wall-functions + dimensionedScalar E() const + { + return E_; + } + + //- Return Cmu for use in wall-functions + dimensionedScalar Cmu() const + { + return Cmu_; + } + + //- Return turbulent Prandtl number for use in wall-functions + dimensionedScalar Prt() const + { + return Prt_; + } //- Return the SGS turbulent kinetic energy. virtual tmp<volScalarField> k() const = 0; @@ -192,7 +228,7 @@ public: //- Return the SGS turbulent dissipation. virtual tmp<volScalarField> epsilon() const = 0; - //- Return the effective viscosity + //- Return the SGS turbulent viscosity virtual tmp<volScalarField> muSgs() const = 0; //- Return the effective viscosity @@ -204,6 +240,9 @@ public: ); } + //- Return the SGS turbulent thermal diffusivity + virtual tmp<volScalarField> alphaSgs() const = 0; + //- Return the SGS thermal conductivity. virtual tmp<volScalarField> alphaEff() const = 0; @@ -227,6 +266,12 @@ public: return muSgs(); } + //- Return the turbulence thermal diffusivity + virtual tmp<volScalarField> alphat() const + { + return alphaSgs(); + } + //- Return the Reynolds stress tensor virtual tmp<volSymmTensorField> R() const { @@ -254,7 +299,7 @@ public: //- Correct Eddy-Viscosity and related properties virtual void correct(const tmp<volTensorField>& gradU); - //- Read turbulenceProperties dictionary + //- Read LESProperties dictionary virtual bool read() = 0; }; diff --git a/src/turbulenceModels/compressible/LES/Make/files b/src/turbulenceModels/compressible/LES/Make/files index 06e7b76d4512f94bb16c8c2fca3ca50270fd4ebe..3609694e5916e89412564d137c1a7e78651efce2 100644 --- a/src/turbulenceModels/compressible/LES/Make/files +++ b/src/turbulenceModels/compressible/LES/Make/files @@ -16,4 +16,8 @@ wallFunctions=derivedFvPatchFields/wallFunctions muSgsWallFunctions=$(wallFunctions)/muSgsWallFunctions $(muSgsWallFunctions)/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C +alphaSgsWallFunctions=$(wallFunctions)/alphaSgsWallFunctions +$(alphaSgsWallFunctions)/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.C +$(alphaSgsWallFunctions)/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C + LIB = $(FOAM_LIBBIN)/libcompressibleLESModels diff --git a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C index c89b2aeecf7c988a7140ab782e6a382ac992ad58..0698b5aa27cdf5a4078050aa43b039b178e4fb33 100644 --- a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C +++ b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C @@ -56,6 +56,9 @@ void Smagorinsky::updateSubGridScaleFields(const volTensorField& gradU) muSgs_ = ck_*rho()*delta()*sqrt(k_); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C index 65a6a69bde2ab2ed3a3fb98c1a9bc270a0de07d0..dc05459d3d814e2089a937b4ce512781cf368eb8 100644 --- a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C @@ -49,6 +49,9 @@ void SpalartAllmaras::updateSubGridScaleFields() { muSgs_.internalField() = rho()*fv1()*nuTilda_.internalField(); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } @@ -227,8 +230,20 @@ SpalartAllmaras::SpalartAllmaras IOobject::AUTO_WRITE ), mesh_ - ) + ), + alphaSgs_ + ( + IOobject + ( + "alphaSgs", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { updateSubGridScaleFields(); diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H index e119768537c319c3205661c9ef842ab5bbfe3c7f..847badd27723fb2402bb3d5d7797bd453432dc49 100644 --- a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H @@ -89,6 +89,7 @@ class SpalartAllmaras volScalarField nuTilda_; volScalarField dTilda_; volScalarField muSgs_; + volScalarField alphaSgs_; public: @@ -136,12 +137,18 @@ public: return muSgs_; } + //- Return SGS thermal diffusivity + virtual tmp<volScalarField> alphaSgs() const + { + return alphaSgs_; + } + //- Return thermal conductivity virtual tmp<volScalarField> alphaEff() const { return tmp<volScalarField> ( - new volScalarField("alphaEff", muSgs_ + alpha()) + new volScalarField("alphaEff", alphaSgs_ + alpha()) ); } diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..becc932047a5e95150872731a09dc9e43d732549 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.C @@ -0,0 +1,317 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 "alphaSgsJayatillekeWallFunctionFvPatchScalarField.H" +#include "LESModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxExp_ = 50.0; +scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01; +label alphaSgsJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10; + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType() +{ + if (!isA<wallFvPatch>(patch())) + { + FatalErrorIn + ( + "alphaSgsJayatillekeWallFunctionFvPatchScalarField::checkType()" + ) + << "Patch type for patch " << patch().name() << " must be wall\n" + << "Current patch type is " << patch().type() << nl + << exit(FatalError); + } +} + + +scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::Psmooth +( + const scalar Prat +) const +{ + return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat)); +} + + +scalar alphaSgsJayatillekeWallFunctionFvPatchScalarField::yPlusTherm +( + const scalar P, + const scalar Prat, + const scalar E, + const scalar kappa +) const +{ + scalar ypt = 11.0; + + for (int i=0; i<maxIters_; i++) + { + scalar f = ypt - (log(E*ypt)/kappa + P)/Prat; + scalar df = 1.0 - 1.0/(ypt*kappa*Prat); + scalar yptNew = ypt - f/df; + + if (yptNew < VSMALL) + { + return 0; + } + else if (mag(yptNew - ypt) < tolerance_) + { + return yptNew; + } + else + { + ypt = yptNew; + } + } + + return ypt; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +alphaSgsJayatillekeWallFunctionFvPatchScalarField:: +alphaSgsJayatillekeWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{ + checkType(); +} + + +alphaSgsJayatillekeWallFunctionFvPatchScalarField:: +alphaSgsJayatillekeWallFunctionFvPatchScalarField +( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +alphaSgsJayatillekeWallFunctionFvPatchScalarField:: +alphaSgsJayatillekeWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{ + checkType(); +} + + +alphaSgsJayatillekeWallFunctionFvPatchScalarField:: +alphaSgsJayatillekeWallFunctionFvPatchScalarField +( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{ + checkType(); +} + + +alphaSgsJayatillekeWallFunctionFvPatchScalarField:: +alphaSgsJayatillekeWallFunctionFvPatchScalarField +( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField& tppsf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void alphaSgsJayatillekeWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + // Get info from the SGS model + const LESModel& sgs = db().lookupObject<LESModel>("LESProperties"); + + // Wall function constants + const scalar E = sgs.E().value(); + const scalar kappa = sgs.kappa().value(); + const scalar Prt = sgs.Prt().value(); + + // Field data + const label patchI = patch().index(); + + const scalarField& muw = sgs.mu().boundaryField()[patchI]; + const scalarField& muSgsw = sgs.muSgs()().boundaryField()[patchI]; + + const scalarField& alphaw = sgs.alpha().boundaryField()[patchI]; + scalarField& alphaSgsw = *this; + + const fvPatchVectorField& Uw = sgs.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField magGradUw = mag(Uw.snGrad()); + + const scalarField& rhow = sgs.rho().boundaryField()[patchI]; + const fvPatchScalarField& hw = + patch().lookupPatchField<volScalarField, scalar>("h"); + + const scalarField& ry = patch().deltaCoeffs(); + + // Heat flux [W/m2] - lagging alphaSgsw + const scalarField qDot = (alphaw + alphaSgsw)*hw.snGrad(); + + // Populate boundary values + forAll(alphaSgsw, faceI) + { + // Calculate uTau using Newton-Raphson iteration + scalar uTau = + sqrt((muSgsw[faceI] + muw[faceI])/rhow[faceI]*magGradUw[faceI]); + + if (uTau > ROOTVSMALL) + { + label iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = min(kappa*magUp[faceI]/uTau, maxExp_); + scalar fkUu = exp(kUu) - 1.0 - kUu*(1.0 + 0.5*kUu); + + scalar f = + - uTau/(ry[faceI]*muw[faceI]/rhow[faceI]) + + magUp[faceI]/uTau + + 1.0/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + - 1.0/(ry[faceI]*muw[faceI]/rhow[faceI]) + - magUp[faceI]/sqr(uTau) + - 1.0/E*kUu*fkUu/uTau; + + scalar uTauNew = uTau - f/df; + err = mag((uTau - uTauNew)/uTau); + uTau = uTauNew; + + } while (uTau>VSMALL && err>tolerance_ && ++iter<maxIters_); + + scalar yPlus = uTau/ry[faceI]/(muw[faceI]/rhow[faceI]); + + // Molecular Prandtl number + scalar Pr = muw[faceI]/alphaw[faceI]; + + // Molecular-to-turbulenbt Prandtl number ratio + scalar Prat = Pr/Prt; + + // Thermal sublayer thickness + scalar P = Psmooth(Prat); + scalar yPlusTherm = this->yPlusTherm(P, Prat, E, kappa); + + // Evaluate new effective thermal diffusivity + scalar alphaEff = 0.0; + if (yPlus < yPlusTherm) + { + scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI]; + scalar B = qDot[faceI]*Pr*yPlus; + scalar C = Pr*0.5*rhow[faceI]*uTau*sqr(magUp[faceI]); + alphaEff = A/(B + C + VSMALL); + } + else + { + scalar A = qDot[faceI]*rhow[faceI]*uTau/ry[faceI]; + scalar B = qDot[faceI]*Prt*(1.0/kappa*log(E*yPlus) + P); + scalar magUc = uTau/kappa*log(E*yPlusTherm) - mag(Uw[faceI]); + scalar C = + 0.5*rhow[faceI]*uTau + *(Prt*sqr(magUp[faceI]) + (Pr - Prt)*sqr(magUc)); + alphaEff = A/(B + C + VSMALL); + } + + // Update turbulent thermal diffusivity + alphaSgsw[faceI] = max(0.0, alphaEff - alphaw[faceI]); + + if (debug) + { + Info<< " uTau = " << uTau << nl + << " Pr = " << Pr << nl + << " Prt = " << Prt << nl + << " qDot = " << qDot[faceI] << nl + << " yPlus = " << yPlus << nl + << " yPlusTherm = " << yPlusTherm << nl + << " alphaEff = " << alphaEff << nl + << " alphaw = " << alphaw[faceI] << nl + << " alphaSgsw = " << alphaSgsw[faceI] << nl + << endl; + } + } + else + { + alphaSgsw[faceI] = 0.0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + alphaSgsJayatillekeWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..09bb27059e1b57f9d215aa4eae76771edda2b90e --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsJayatillekeWallFunction/alphaSgsJayatillekeWallFunctionFvPatchScalarField.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + alphaSgsJayatillekeWallFunctionFvPatchScalarField + +Description + Thermal wall function for turbulent thermal diffusivity based on the + Jayatilleke thermal wall function + +SourceFiles + alphaSgsJayatillekeWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphaSgsJayatillekeWallFunctionFvPatchScalarField_H +#define alphaSgsJayatillekeWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class alphaSgsJayatillekeWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class alphaSgsJayatillekeWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + static scalar maxExp_; + static scalar tolerance_; + static label maxIters_; + + + // Private member functions + + //- Check the type of the patch + void checkType(); + + //- `P' function + scalar Psmooth(const scalar Prat) const; + + //- Calculate y+ at the edge of the thermal laminar sublayer + scalar yPlusTherm + ( + const scalar P, + const scalar Prat, + const scalar E, + const scalar kappa + ) const; + + +public: + + //- Runtime type information + TypeName("alphaSgsJayatillekeWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given an + // alphaSgsJayatillekeWallFunctionFvPatchScalarField + // onto a new patch + alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new alphaSgsJayatillekeWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + const alphaSgsJayatillekeWallFunctionFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new alphaSgsJayatillekeWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..9a8d890bdeebde15b2d5e7fb17c1abb90eb6f5fb --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.C @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 "alphaSgsWallFunctionFvPatchScalarField.H" +#include "LESModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void alphaSgsWallFunctionFvPatchScalarField::checkType() +{ + if (!isA<wallFvPatch>(patch())) + { + FatalErrorIn + ( + "alphaSgsWallFunctionFvPatchScalarField::checkType()" + ) + << "Patch type for patch " << patch().name() << " must be wall\n" + << "Current patch type is " << patch().type() << nl + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +alphaSgsWallFunctionFvPatchScalarField:: +alphaSgsWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{ + checkType(); +} + + +alphaSgsWallFunctionFvPatchScalarField:: +alphaSgsWallFunctionFvPatchScalarField +( + const alphaSgsWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +alphaSgsWallFunctionFvPatchScalarField:: +alphaSgsWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{ + checkType(); +} + + +alphaSgsWallFunctionFvPatchScalarField:: +alphaSgsWallFunctionFvPatchScalarField +( + const alphaSgsWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{ + checkType(); +} + + +alphaSgsWallFunctionFvPatchScalarField:: +alphaSgsWallFunctionFvPatchScalarField +( + const alphaSgsWallFunctionFvPatchScalarField& tppsf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void alphaSgsWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + // Get reference to the SGS model + const LESModel& sgs = db().lookupObject<LESModel>("LESProperties"); + + // Turbulent Prandtl number + const scalar Prt = sgs.Prt().value(); + + // Get the turbulent viscosity at the wall + const scalarField& muSgsw = sgs.muSgs()().boundaryField()[patch().index()]; + + operator==(muSgsw/Prt); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + alphaSgsWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..e5e200d2b51d2e80807e526fbef648550323edf3 --- /dev/null +++ b/src/turbulenceModels/compressible/LES/derivedFvPatchFields/wallFunctions/alphaSgsWallFunctions/alphaSgsWallFunction/alphaSgsWallFunctionFvPatchScalarField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + alphaSgsWallFunctionFvPatchScalarField + +Description + Boundary condition for thermal diffusivity when using wall functions + - replicates OpenFOAM v1.5 (and earlier) behaviour + +SourceFiles + alphaSgsWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef alphaSgsWallFunctionFvPatchScalarField_H +#define alphaSgsWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class alphaSgsWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class alphaSgsWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("alphaSgsWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + alphaSgsWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + alphaSgsWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given alphaSgsWallFunctionFvPatchScalarField + // onto a new patch + alphaSgsWallFunctionFvPatchScalarField + ( + const alphaSgsWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + alphaSgsWallFunctionFvPatchScalarField + ( + const alphaSgsWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new alphaSgsWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + alphaSgsWallFunctionFvPatchScalarField + ( + const alphaSgsWallFunctionFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new alphaSgsWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C index 7e9b3d9b7ba2844b6c90fb69cf91007e743f3a5a..4736499b4f70ac73c6e5ba1cbee7d575383b8820 100644 --- a/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C +++ b/src/turbulenceModels/compressible/LES/dynOneEqEddy/dynOneEqEddy.C @@ -47,6 +47,9 @@ void dynOneEqEddy::updateSubGridScaleFields(const volSymmTensorField& D) { muSgs_ = ck_(D)*rho()*sqrt(k_)*delta(); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C index b5670ad2451aa1e9d6b2379925341f0829826a40..67c230608fc568425238883870e1b355fb0af059 100644 --- a/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C +++ b/src/turbulenceModels/compressible/LES/lowReOneEqEddy/lowReOneEqEddy.C @@ -51,6 +51,9 @@ void lowReOneEqEddy::updateSubGridScaleFields() // low Re no corrected eddy viscosity muSgs_ -= (mu()/beta_)*(scalar(1) - exp(-beta_*muSgs_/mu())); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C index 414aba5b0322630f5497275c856118fce3387823..fbcf333d4f4969660c1246b2b9040f313c145c9f 100644 --- a/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C +++ b/src/turbulenceModels/compressible/LES/oneEqEddy/oneEqEddy.C @@ -47,6 +47,9 @@ void oneEqEddy::updateSubGridScaleFields() { muSgs_ = ck_*rho()*sqrt(k_)*delta(); muSgs_.correctBoundaryConditions(); + + alphaSgs_ = muSgs_/Prt(); + alphaSgs_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H index 7479eb4c553c9667138c29d9c0c5a0656174ee17..7c787d8ceb6406a3cc67b6eb112830f97d423077 100644 --- a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H +++ b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.H @@ -351,7 +351,7 @@ public: //- Solve the turbulence equations and correct the turbulence viscosity virtual void correct() = 0; - //- Read turbulenceProperties dictionary + //- Read RASProperties dictionary virtual bool read() = 0; }; diff --git a/tutorials/combustion/dieselFoam/aachenBomb/system/fvSchemes b/tutorials/combustion/dieselFoam/aachenBomb/system/fvSchemes index 5ed3bb30fa8c7dc529bb44900d8f2dbd2c181f0c..fa4f6b47e33e5109a3844c5430f6094a7b84de2f 100644 --- a/tutorials/combustion/dieselFoam/aachenBomb/system/fvSchemes +++ b/tutorials/combustion/dieselFoam/aachenBomb/system/fvSchemes @@ -35,7 +35,12 @@ divSchemes div(phi,k) Gauss limitedLinear 1; div(phi,epsilon) Gauss limitedLinear 1; div(phi,Yi_h) Gauss upwind; - div(phi,fu_ft_h) Gauss multivariateSelection { fu limitedLinear 1 ; ft limitedLinear 1 ; h limitedLinear 1 ; }; + div(phi,fu_ft_h) Gauss multivariateSelection + { + fu limitedLinear 1; + ft limitedLinear 1; + h limitedLinear 1; + }; div((muEff*dev2(grad(U).T()))) Gauss linear; } @@ -64,7 +69,8 @@ snGradSchemes fluxRequired { - p ; + default no; + p; }