diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C index 0191a90a8c..d9898beda1 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C @@ -55,6 +55,64 @@ scalar epsilonLowReWallFunctionFvPatchScalarField::yPlusLam } +void epsilonLowReWallFunctionFvPatchScalarField::calculate +( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon +) +{ + const label patchI = patch.index(); + + const scalarField& y = turbulence.y()[patchI]; + + const scalar Cmu25 = pow025(Cmu_); + const scalar Cmu75 = pow(Cmu_, 0.75); + + const tmp tk = turbulence.k(); + const volScalarField& k = tk(); + + const tmp tnu = turbulence.nu(); + const scalarField& nuw = tnu().boundaryField()[patchI]; + + const tmp tnut = turbulence.nut(); + const volScalarField& nut = tnut(); + const scalarField& nutw = nut.boundaryField()[patchI]; + + const fvPatchVectorField& Uw = turbulence.U().boundaryField()[patchI]; + + const scalarField magGradUw(mag(Uw.snGrad())); + + // Set epsilon and G + forAll(nutw, faceI) + { + label cellI = patch.faceCells()[faceI]; + + scalar yPlus = Cmu25*sqrt(k[cellI])*y[faceI]/nuw[faceI]; + + scalar w = cornerWeights[faceI]; + + if (yPlus > yPlusLam_) + { + epsilon[cellI] = w*Cmu75*pow(k[cellI], 1.5)/(kappa_*y[faceI]); + } + else + { + epsilon[cellI] = w*2.0*k[cellI]*nuw[faceI]/sqr(y[faceI]); + } + + G[cellI] = + w + *(nutw[faceI] + nuw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[cellI]) + /(kappa_*y[faceI]); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // epsilonLowReWallFunctionFvPatchScalarField:: @@ -119,81 +177,6 @@ epsilonLowReWallFunctionFvPatchScalarField {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void epsilonLowReWallFunctionFvPatchScalarField::updateCoeffs() -{ - if (updated()) - { - return; - } - - const label patchI = patch().index(); - - const turbulenceModel& turbulence = - db().lookupObject("turbulenceModel"); - const scalarField& y = turbulence.y()[patchI]; - - volScalarField& G = - const_cast - ( - db().lookupObject - ( - turbulence.GName() - ) - ); - - DimensionedField& epsilon = - const_cast&> - ( - dimensionedInternalField() - ); - - const tmp tk = turbulence.k(); - const volScalarField& k = tk(); - - const tmp tnu = turbulence.nu(); - const scalarField& nuw = tnu().boundaryField()[patchI]; - - const tmp tnut = turbulence.nut(); - const volScalarField& nut = tnut(); - const scalarField& nutw = nut.boundaryField()[patchI]; - - const fvPatchVectorField& Uw = turbulence.U().boundaryField()[patchI]; - const scalarField magGradUw(mag(Uw.snGrad())); - - const scalar Cmu25 = pow025(Cmu_); - const scalar Cmu75 = pow(Cmu_, 0.75); - - // Set epsilon and G - forAll(nutw, faceI) - { - label faceCellI = patch().faceCells()[faceI]; - - scalar yPlus = Cmu25*sqrt(k[faceCellI])*y[faceI]/nuw[faceI]; - - if (yPlus > yPlusLam_) - { - epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]); - } - else - { - epsilon[faceCellI] = 2.0*k[faceCellI]*nuw[faceI]/sqr(y[faceI]); - } - - G[faceCellI] = - (nutw[faceI] + nuw[faceI]) - *magGradUw[faceI] - *Cmu25*sqrt(k[faceCellI]) - /(kappa_*y[faceI]); - } - - fixedInternalValueFvPatchField::updateCoeffs(); - - // TODO: perform averaging for cells sharing more than one boundary face -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H index b8cf09f0b7..778fffcfd7 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -97,6 +97,16 @@ protected: //- Calculate the Y+ at the edge of the laminar sublayer scalar yPlusLam(const scalar kappa, const scalar E); + //- Calculate the epsilon and G + virtual void calculate + ( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon + ); + public: @@ -166,13 +176,9 @@ public: ); } - - // Member functions - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + //- Destructor + virtual ~epsilonLowReWallFunctionFvPatchScalarField() + {} }; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 9435962e6a..7fb6fcfb96 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -26,11 +26,10 @@ License #include "epsilonWallFunctionFvPatchScalarField.H" #include "incompressible/turbulenceModel/turbulenceModel.H" #include "fvPatchFieldMapper.H" +#include "fvMatrix.H" #include "volFields.H" -#include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" -#include "nutkWallFunctionFvPatchScalarField.H" - +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,7 +38,7 @@ namespace Foam namespace incompressible { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // void epsilonWallFunctionFvPatchScalarField::checkType() { @@ -63,118 +62,160 @@ void epsilonWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedInternalValueFvPatchField(p, iF), - Cmu_(0.09), - kappa_(0.41), - E_(9.8) +void epsilonWallFunctionFvPatchScalarField::setMaster() { - checkType(); -} - - -epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField -( - const epsilonWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedInternalValueFvPatchField(ptf, p, iF, mapper), - Cmu_(ptf.Cmu_), - kappa_(ptf.kappa_), - E_(ptf.E_) -{ - checkType(); -} - - -epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedInternalValueFvPatchField(p, iF, dict), - Cmu_(dict.lookupOrDefault("Cmu", 0.09)), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) -{ - checkType(); -} - - -epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField -( - const epsilonWallFunctionFvPatchScalarField& ewfpsf -) -: - fixedInternalValueFvPatchField(ewfpsf), - Cmu_(ewfpsf.Cmu_), - kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) -{ - checkType(); -} - - -epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField -( - const epsilonWallFunctionFvPatchScalarField& ewfpsf, - const DimensionedField& iF -) -: - fixedInternalValueFvPatchField(ewfpsf, iF), - Cmu_(ewfpsf.Cmu_), - kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) -{ - checkType(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void epsilonWallFunctionFvPatchScalarField::updateCoeffs() -{ - if (updated()) + if (master_ != -1) { return; } - const label patchI = patch().index(); + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + label master = -1; + forAll(bf, patchI) + { + if (isA(bf[patchI])) + { + epsilonWallFunctionFvPatchScalarField& epf = epsilonPatch(patchI); + + if (master == -1) + { + master = patchI; + } + + epf.master() = master; + } + } +} + + +void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() +{ + if (initialised_) + { + return; + } + + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + const fvMesh& mesh = epsilon.mesh(); + + volScalarField weights + ( + IOobject + ( + "weights", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // do not register + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ); + + DynamicList