diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index b25b812bf60492bbaf666eb49c93e84e105b1090..82d3ff47bcd14b1d081408662373ead305aca10f 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,6 +31,7 @@ License #include "fvMatrix.H" #include "addToRunTimeSelectionTable.H" + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // Foam::scalar Foam::epsilonWallFunctionFvPatchScalarField::tolerance_ = 1e-5; @@ -127,7 +128,10 @@ void Foam::epsilonWallFunctionFvPatchScalarField::createAveragingWeights() Foam::epsilonWallFunctionFvPatchScalarField& -Foam::epsilonWallFunctionFvPatchScalarField::epsilonPatch(const label patchi) +Foam::epsilonWallFunctionFvPatchScalarField::epsilonPatch +( + const label patchi +) { const volScalarField& epsilon = static_cast<const volScalarField&>(this->internalField()); @@ -244,11 +248,11 @@ epsilonWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(p, iF), - G_(), - epsilon_(), lowReCorrection_(false), initialised_(false), master_(-1), + G_(), + epsilon_(), cornerWeights_() {} @@ -263,11 +267,11 @@ epsilonWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(ptf, p, iF, mapper), - G_(), - epsilon_(), lowReCorrection_(ptf.lowReCorrection_), initialised_(false), master_(-1), + G_(), + epsilon_(), cornerWeights_() {} @@ -281,11 +285,11 @@ epsilonWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(p, iF, dict), - G_(), - epsilon_(), - lowReCorrection_(dict.lookupOrDefault("lowReCorrection", false)), + lowReCorrection_(dict.getOrDefault("lowReCorrection", false)), initialised_(false), master_(-1), + G_(), + epsilon_(), cornerWeights_() { // Apply zero-gradient condition on start-up @@ -300,11 +304,11 @@ epsilonWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(ewfpsf), - G_(), - epsilon_(), lowReCorrection_(ewfpsf.lowReCorrection_), initialised_(false), master_(-1), + G_(), + epsilon_(), cornerWeights_() {} @@ -317,18 +321,21 @@ epsilonWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(ewfpsf, iF), - G_(), - epsilon_(), lowReCorrection_(ewfpsf.lowReCorrection_), initialised_(false), master_(-1), + G_(), + epsilon_(), cornerWeights_() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalarField& Foam::epsilonWallFunctionFvPatchScalarField::G(bool init) +Foam::scalarField& Foam::epsilonWallFunctionFvPatchScalarField::G +( + bool init +) { if (patch().index() == master_) { @@ -398,7 +405,7 @@ void Foam::epsilonWallFunctionFvPatchScalarField::updateCoeffs() forAll(*this, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; G[celli] = G0[celli]; epsilon[celli] = epsilon0[celli]; @@ -449,11 +456,11 @@ void Foam::epsilonWallFunctionFvPatchScalarField::updateWeightedCoeffs // Only set the values if the weights are > tolerance forAll(weights, facei) { - scalar w = weights[facei]; + const scalar w = weights[facei]; - if (w > tolerance_) + if (tolerance_ < w) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; G[celli] = (1.0 - w)*G[celli] + w*G0[celli]; epsilon[celli] = (1.0 - w)*epsilon[celli] + w*epsilon0[celli]; @@ -501,7 +508,7 @@ void Foam::epsilonWallFunctionFvPatchScalarField::manipulateMatrix forAll(weights, facei) { // Only set the values if the weights are > tolerance - if (weights[facei] > tolerance_) + if (tolerance_ < weights[facei]) { const label celli = faceCells[facei]; @@ -524,6 +531,16 @@ void Foam::epsilonWallFunctionFvPatchScalarField::manipulateMatrix } +void Foam::epsilonWallFunctionFvPatchScalarField::write +( + Ostream& os +) const +{ + os.writeEntry("lowReCorrection", lowReCorrection_); + fixedValueFvPatchField<scalar>::write(os); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index cab04d5771a27e162c3781c8b1dcf51f1df1d6a8..34d27ee9b5e33c0ddd6e23246afdaeee8f410c1e 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -30,32 +30,31 @@ Group grpWallFunctions Description - This boundary condition provides a turbulence dissipation wall constraint - for low- and high-Reynolds number turbulence models. + This boundary condition provides a wall constraint on turbulent kinetic + energy dissipation rate, i.e. \c epsilon, for low- and high-Reynolds number + turbulence models. The condition can be applied to wall boundaries for which it - calculates \c epsilon and \c G - - specifies the near-wall epsilon value + - specifies the near-wall \c epsilon value where - \vartable - epsilon | turblence dissipation field - G | turblence generation field + epsilon | turbulent kinetic energy dissipation rate field + G | turbulent kinetic energy production field (divergence-free) \endvartable The low-Re correction is activated by setting the entry \c lowReCorrection to 'on'; in this mode the model switches between - laminar and turbulent functions based on the laminar-to-turbulent y+ value - derived from the kappa and E specified in the corresponding nutWallFunction. When the \c lowReCorrection is inactive, the - wall function operates in high-Re mode. + viscous and turbulent functions based on the viscous-to-turbulent + \c y+ value derived from the \c kappa and \c E. + + When the \c lowReCorrection is inactive, the wall function operates + in high-Re mode. Usage \table Property | Description | Required | Default value - Cmu | model coefficient | no | 0.09 - kappa | Von Karman constant | no | 0.41 - E | model coefficient | no | 9.8 lowReCorrection | Low-Re correction active | no | off \endtable @@ -63,13 +62,20 @@ Usage \verbatim <patchName> { + // Mandatory entries type epsilonWallFunction; + + // Optional entries } \endverbatim +Note + The coefficients \c Cmu, \c kappa, and \c E are obtained from + the specified \c nutWallFunction in order to ensure that each patch + possesses the same set of values for these coefficients. + See also Foam::fixedInternalValueFvPatchField - Foam::omegaWallFunctionFvPatchScalarField SourceFiles epsilonWallFunctionFvPatchScalarField.C @@ -98,17 +104,11 @@ class epsilonWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Tolerance used in weighted calculations static scalar tolerance_; - //- Local copy of turbulence G field - scalarField G_; - - //- Local copy of turbulence epsilon field - scalarField epsilon_; - //- Apply low-Re correction term; default = no bool lowReCorrection_; @@ -118,6 +118,12 @@ protected: //- Master patch ID label master_; + //- Local copy of turbulence G field + scalarField G_; + + //- Local copy of turbulence epsilon field + scalarField epsilon_; + //- List of averaging corner weights List<List<scalar>> cornerWeights_; @@ -125,11 +131,11 @@ protected: // Protected Member Functions //- Set the master patch - master is responsible for updating all - // wall function patches + //- wall function patches virtual void setMaster(); //- Create the averaging weights for cells which are bounded by - // multiple wall function faces + //- multiple wall function faces virtual void createAveragingWeights(); //- Helper function to return non-const access to an epsilon patch @@ -187,8 +193,8 @@ public: ); //- Construct by mapping given - // epsilonWallFunctionFvPatchScalarField - // onto a new patch + //- epsilonWallFunctionFvPatchScalarField + //- onto a new patch epsilonWallFunctionFvPatchScalarField ( const epsilonWallFunctionFvPatchScalarField&, @@ -231,6 +237,7 @@ public: ); } + //- Destructor virtual ~epsilonWallFunctionFvPatchScalarField() = default; @@ -263,6 +270,12 @@ public: fvMatrix<scalar>& matrix, const scalarField& weights ); + + + // I-O + + //- Write + virtual void write(Ostream&) const; }; diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C index 9b4d0e71bd091720736fdf5cce38a5e83e165381..a201b7136cbc545ad9bb28d429b5efb4f0c0d67a 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -117,6 +117,9 @@ void fWallFunctionFvPatchScalarField::updateCoeffs() const scalarField& y = turbModel.y()[patchi]; + const tmp<scalarField> tnuw = turbModel.nu(patchi); + const scalarField& nuw = tnuw(); + const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); @@ -126,28 +129,25 @@ void fWallFunctionFvPatchScalarField::updateCoeffs() const tmp<volScalarField> tv2 = v2fModel.v2(); const volScalarField& v2 = tv2(); - const tmp<scalarField> tnuw = turbModel.nu(patchi); - const scalarField& nuw = tnuw(); - const scalar Cmu25 = pow025(nutw.Cmu()); + const scalar N = 6.0; scalarField& f = *this; // Set f wall values forAll(f, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; - scalar uTau = Cmu25*sqrt(k[celli]); + const scalar uTau = Cmu25*sqrt(k[celli]); - scalar yPlus = uTau*y[facei]/nuw[facei]; + const scalar yPlus = uTau*y[facei]/nuw[facei]; - if (yPlus > nutw.yPlusLam()) + if (nutw.yPlusLam() < yPlus) { - scalar N = 6.0; - scalar v2c = v2[celli]; - scalar epsc = epsilon[celli]; - scalar kc = k[celli]; + const scalar v2c = v2[celli]; + const scalar epsc = epsilon[celli]; + const scalar kc = k[celli]; f[facei] = N*v2c*epsc/(sqr(kc) + ROOTVSMALL); f[facei] /= sqr(uTau) + ROOTVSMALL; diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.H index 97c61ad3c20887a89f02d4d34d15e93fb65d6abc..949e12f12d8c46287c2e2ad3264c5e8b50a86f90 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -30,29 +30,44 @@ Group grpWallFunctions Description - This boundary condition provides a turbulence damping function, f, wall - function condition for low- and high Reynolds number, turbulent flow cases - - The model operates in two modes, based on the computed laminar-to-turbulent - switch-over y+ value derived from kappa and E specified in the corresponding - nutWallFunction. + This boundary condition provides a wall constraint on the elliptic + relaxation factor, \c f, which is executed in the \c v2-f eddy viscosity + turbulence model. The condition is applicable for low- and high-Reynolds + number turbulent flow cases. + + For \c f, the viscous sublayer and log-law region blending approaches are + claimed to be inviable (Popovac and Hanjalić (2007), p. 194). Therefore, + the only boundary condition blending mode is the stepwise mode + where the viscous sublayer and log-law region contributions switch over + \c y+ value derived from the \c kappa and \c E. + + Reference: + \verbatim + Remark on the blending approach: + Popovac, M., & Hanjalić, K. (2007). + Compound wall treatment for RANS computation of complex + turbulent flows and heat transfer. + Flow, turbulence and combustion, 78(2), 177-202. + doi:10.1007/s10494-006-9067-x + \endverbatim Usage - \table - Property | Description | Required | Default value - Cmu | model coefficient | no | 0.09 - kappa | Von Karman constant | no | 0.41 - E | model coefficient | no | 9.8 - \endtable - Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type fWallFunction; + + // No optional entry } \endverbatim +Note + The coefficients \c Cmu, \c kappa, and \c E are obtained from + the specified \c nutWallFunction in order to ensure that each patch + possesses the same set of values for these coefficients. + See also Foam::fixedValueFvPatchField @@ -81,7 +96,6 @@ class fWallFunctionFvPatchScalarField : public fixedValueFvPatchField<scalar> { - public: //- Runtime type information @@ -106,7 +120,7 @@ public: ); //- Construct by mapping given fWallFunctionFvPatchScalarField - // onto a new patch + //- onto a new patch fWallFunctionFvPatchScalarField ( const fWallFunctionFvPatchScalarField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C index 9546c41f68750068040098261a7427e186ccc425..1d8a7355d132b0361b4926610ec667370f39ad2f 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -30,25 +30,24 @@ License #include "turbulenceModel.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField +Foam::kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchField<scalar>(p, iF), - Ceps2_(1.9) + Ceps2_(1.9), + Ck_(-0.416), + Bk_(8.366), + C_(11.0) {} -kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField +Foam::kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ( const kLowReWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -57,11 +56,14 @@ kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(ptf, p, iF, mapper), - Ceps2_(ptf.Ceps2_) + Ceps2_(ptf.Ceps2_), + Ck_(ptf.Ck_), + Bk_(ptf.Bk_), + C_(ptf.C_) {} -kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField +Foam::kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -69,34 +71,43 @@ kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(p, iF, dict), - Ceps2_(dict.lookupOrDefault<scalar>("Ceps2", 1.9)) + Ceps2_(dict.getOrDefault<scalar>("Ceps2", 1.9)), + Ck_(dict.getOrDefault<scalar>("Ck", -0.416)), + Bk_(dict.getOrDefault<scalar>("Bk", 8.366)), + C_(dict.getOrDefault<scalar>("C", 11.0)) {} -kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField +Foam::kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ( const kLowReWallFunctionFvPatchScalarField& kwfpsf ) : fixedValueFvPatchField<scalar>(kwfpsf), - Ceps2_(kwfpsf.Ceps2_) + Ceps2_(kwfpsf.Ceps2_), + Ck_(kwfpsf.Ck_), + Bk_(kwfpsf.Bk_), + C_(kwfpsf.C_) {} -kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField +Foam::kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField ( const kLowReWallFunctionFvPatchScalarField& kwfpsf, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchField<scalar>(kwfpsf, iF), - Ceps2_(kwfpsf.Ceps2_) + Ceps2_(kwfpsf.Ceps2_), + Ck_(kwfpsf.Ck_), + Bk_(kwfpsf.Bk_), + C_(kwfpsf.C_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void kLowReWallFunctionFvPatchScalarField::updateCoeffs() +void Foam::kLowReWallFunctionFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -119,12 +130,12 @@ void kLowReWallFunctionFvPatchScalarField::updateCoeffs() const scalarField& y = turbModel.y()[patchi]; - const tmp<volScalarField> tk = turbModel.k(); - const volScalarField& k = tk(); - const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); + const tmp<volScalarField> tk = turbModel.k(); + const volScalarField& k = tk(); + const scalar Cmu25 = pow025(nutw.Cmu()); scalarField& kw = *this; @@ -132,22 +143,20 @@ void kLowReWallFunctionFvPatchScalarField::updateCoeffs() // Set k wall values forAll(kw, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; - scalar uTau = Cmu25*sqrt(k[celli]); + const scalar uTau = Cmu25*sqrt(k[celli]); - scalar yPlus = uTau*y[facei]/nuw[facei]; + const scalar yPlus = uTau*y[facei]/nuw[facei]; - if (yPlus > nutw.yPlusLam()) + if (nutw.yPlusLam() < yPlus) { - scalar Ck = -0.416; - scalar Bk = 8.366; - kw[facei] = Ck/nutw.kappa()*log(yPlus) + Bk; + kw[facei] = Ck_/nutw.kappa()*log(yPlus) + Bk_; } else { - scalar C = 11.0; - scalar Cf = (1.0/sqr(yPlus + C) + 2.0*yPlus/pow3(C) - 1.0/sqr(C)); + const scalar Cf = + 1.0/sqr(yPlus + C_) + 2.0*yPlus/pow3(C_) - 1.0/sqr(C_); kw[facei] = 2400.0/sqr(Ceps2_)*Cf; } @@ -163,23 +172,29 @@ void kLowReWallFunctionFvPatchScalarField::updateCoeffs() } -void kLowReWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::kLowReWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { os.writeEntry("Ceps2", Ceps2_); + os.writeEntry("Ck", Ck_); + os.writeEntry("Bk", Bk_); + os.writeEntry("C", C_); fixedValueFvPatchField<scalar>::write(os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - kLowReWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + kLowReWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.H index 58f016c82140df0ce94134bca7b227ef7bc39926..d073c0d855869192db22ebdd7ad28ec16b5ae748 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -30,30 +30,37 @@ Group grpWallFunctions Description - This boundary condition provides a turbulence kinetic energy wall function - condition for low- and high-Reynolds number turbulent flow cases. + This boundary condition provides a wall constraint on turbulent kinetic + energy, i.e. \c k, for low- and high-Reynolds number turbulence models. - The model operates in two modes, based on the computed laminar-to-turbulent - switch-over y+ value derived from kappa and E specified in the corresponding - nutWallFunction. + The model operates in two modes, based on the computed viscous-to-turbulent + switch-over \c y+ value derived from \c kappa and \c E. Usage \table Property | Description | Required | Default value - Cmu | model coefficient | no | 0.09 - kappa | Von Karman constant | no | 0.41 - E | model coefficient | no | 9.8 - Ceps2 | model coefficient | no | 1.9 + Ceps2 | Model coefficient | no | 1.9 + Ck | Model coefficient | no | -0.416 + Bk | Model coefficient | no | 8.366 + C | Model coefficient | no | 11.0 \endtable Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type kLowReWallFunction; + + // Optional entries } \endverbatim +Note + The coefficients \c Cmu, \c kappa, and \c E are obtained from + the specified \c nutWallFunction in order to ensure that each patch + possesses the same set of values for these coefficients. + See also Foam::fixedValueFvPatchField @@ -82,11 +89,20 @@ class kLowReWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Ceps2 coefficient scalar Ceps2_; + //- Ck coefficient + scalar Ck_; + + //- Bk coefficient + scalar Bk_; + + //- C coefficient + scalar C_; + public: @@ -156,7 +172,7 @@ public: } - // Member functions + // Member Functions // Evaluation functions diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H index e31256153aa55575ae345bcafbb9eebfc44f9bcd..100eec07bb2e2a573ed157a010bc945687a84ebf 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2017, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,17 +30,16 @@ Group grpWallFunctions Description - This boundary condition provides a suitable condition for turbulence - \c k, \c q, and \c R fields for the case of high Reynolds number flow using - wall functions. - - It is a simple wrapper around the zero-gradient condition. + This boundary condition provides a simple wrapper around the zero-gradient + condition, which can be used for \c k, \c q, and \c R fields for + the case of high Reynolds number flow using wall functions. Usage Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type kqRWallFunction; } \endverbatim @@ -72,7 +71,6 @@ class kqRWallFunctionFvPatchField : public zeroGradientFvPatchField<Type> { - public: //- Runtime type information @@ -97,8 +95,8 @@ public: ); //- Construct by mapping given - // kqRWallFunctionFvPatchField - // onto a new patch + //- kqRWallFunctionFvPatchField + //- onto a new patch kqRWallFunctionFvPatchField ( const kqRWallFunctionFvPatchField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C index edd82b2fcea4f43ba271255687dd597fb480ad17..a013e34e07b5ba484e908287ce66b0f8c17f0a50 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -31,14 +31,11 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> Foam::nutLowReWallFunctionFvPatchScalarField:: +calcNut() const { return tmp<scalarField>::New(patch().size(), Zero); } @@ -46,7 +43,8 @@ tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::calcNut() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +Foam::nutLowReWallFunctionFvPatchScalarField:: +nutLowReWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -56,7 +54,8 @@ nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField {} -nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +Foam::nutLowReWallFunctionFvPatchScalarField:: +nutLowReWallFunctionFvPatchScalarField ( const nutLowReWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -68,7 +67,8 @@ nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField {} -nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +Foam::nutLowReWallFunctionFvPatchScalarField:: +nutLowReWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -79,7 +79,8 @@ nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField {} -nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +Foam::nutLowReWallFunctionFvPatchScalarField:: +nutLowReWallFunctionFvPatchScalarField ( const nutLowReWallFunctionFvPatchScalarField& nlrwfpsf ) @@ -88,7 +89,8 @@ nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField {} -nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField +Foam::nutLowReWallFunctionFvPatchScalarField:: +nutLowReWallFunctionFvPatchScalarField ( const nutLowReWallFunctionFvPatchScalarField& nlrwfpsf, const DimensionedField<scalar, volMesh>& iF @@ -100,7 +102,8 @@ nutLowReWallFunctionFvPatchScalarField::nutLowReWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> Foam::nutLowReWallFunctionFvPatchScalarField:: +yPlus() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> @@ -122,14 +125,13 @@ tmp<scalarField> nutLowReWallFunctionFvPatchScalarField::yPlus() const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutLowReWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutLowReWallFunctionFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H index 2cecdbdb5d7e74e56b6cc82bfb73f6c2bbb40010..d17d23e6753b60fd71c6d0c8c87ee99c5e8d7f7e 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.H @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,16 +30,26 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - for use with low Reynolds number models. It sets \c nut to zero, and - provides an access function to calculate y+. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut for use with low Reynolds number models. + It sets \c nut to zero, and provides an access function to calculate \c y+. Usage + \table + Property | Description | Required | Default value + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + \endtable + Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutLowReWallFunction; + + // Optional entries } \endverbatim @@ -101,8 +111,8 @@ public: ); //- Construct by mapping given - // nutLowReWallFunctionFvPatchScalarField - // onto a new patch + //- nutLowReWallFunctionFvPatchScalarField + //- onto a new patch nutLowReWallFunctionFvPatchScalarField ( const nutLowReWallFunctionFvPatchScalarField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C index 1a362ab51a286249e619b3cbc60c74585efafc75..707ef1c1fa5bdfa62fa79a25b6363cdc14d1f6a0 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 201-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,11 +99,12 @@ Foam::nutUBlendedWallFunctionFvPatchScalarField::calcUTau label iter = 0; while (iter++ < 10 && error > 0.001) { - scalar yPlus = y[facei]*ut/nuw[facei]; - scalar uTauVis = magUp[facei]/yPlus; - scalar uTauLog = kappa_*magUp[facei]/log(E_*yPlus); + const scalar yPlus = y[facei]*ut/nuw[facei]; + const scalar uTauVis = magUp[facei]/yPlus; + const scalar uTauLog = kappa_*magUp[facei]/log(E_*yPlus); - scalar utNew = pow(pow(uTauVis, n_) + pow(uTauLog, n_), 1.0/n_); + const scalar utNew = + pow(pow(uTauVis, n_) + pow(uTauLog, n_), 1.0/n_); error = mag(ut - utNew)/(ut + ROOTVSMALL); ut = 0.5*(ut + utNew); } @@ -204,7 +205,10 @@ Foam::nutUBlendedWallFunctionFvPatchScalarField::yPlus() const } -void Foam::nutUBlendedWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutUBlendedWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.H index 35c1625027ac19ad2ccedfe4f262826511b88ddb..99f348a275cc203228b5f5d02ba790c0eaef1b7f 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.H @@ -28,9 +28,9 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions, based on a blending of laminar sub-layer and - log region contributions. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions based on + a blending of laminar sub-layer and log region contributions. \f[ u_\tau = (u_{\tau,v}^n + u_{\tau,l}^n)^{1/n} @@ -43,24 +43,32 @@ Description u_{\tau,l} | friction velocity in the log region \endvartable + Reference: + See the section that describes 'automatic wall treatment' + \verbatim + Menter, F., Ferreira, J. C., Esch, T., Konno, B. (2003). + The SST Turbulence Model with Improved Wall Treatment + for Heat Transfer Predictions in Gas Turbines. + Proceedings of the International Gas Turbine Congress 2003 Tokyo + \endverbatim Usage + \table + Property | Description | Required | Default value + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + \endtable Example of the boundary condition specification: \verbatim - myPatch + <patchName> { + // Mandatory entries type nutUBlendedWallFunction; - } - \endverbatim - Reference: - See the section that describes 'automatic wall treatment' - \verbatim - Menter, F., Carregal Ferreira, J., Esch, T., Konno, B. (2003). - The SST Turbulence Model with Improved Wall Treatment - for Heat Transfer Predictions in Gas Turbines. - Proceedings of the International Gas Turbine Congress 2003 Tokyo + // Optional entries + } \endverbatim Note @@ -100,7 +108,7 @@ class nutUBlendedWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Model coefficient; default = 4 scalar n_; @@ -139,8 +147,8 @@ public: ); //- Construct by mapping given - // nutUBlendedWallFunctionFvPatchScalarField - // onto a new patch + //- nutUBlendedWallFunctionFvPatchScalarField + //- onto a new patch nutUBlendedWallFunctionFvPatchScalarField ( const nutUBlendedWallFunctionFvPatchScalarField&, @@ -184,7 +192,7 @@ public: } - // Member functions + // Member Functions // Evaluation functions diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C index 2e3d5dcad7d0d5fbcfb8cbbd048361d7260a053e..4f5e9901b653759261a0142ff7568c28d77e2d59 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C @@ -31,14 +31,11 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> +Foam::nutURoughWallFunctionFvPatchScalarField::calcNut() const { const label patchi = patch().index(); @@ -66,7 +63,7 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcNut() const forAll(yPlus, facei) { - if (yPlus[facei] > yPlusLam_) + if (yPlusLam_ < yPlus[facei]) { const scalar Re = magUp[facei]*y[facei]/nuw[facei] + ROOTVSMALL; nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1); @@ -77,7 +74,8 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcNut() const } -tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus +Foam::tmp<Foam::scalarField> +Foam::nutURoughWallFunctionFvPatchScalarField::calcYPlus ( const scalarField& magUp ) const @@ -99,7 +97,7 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus tmp<scalarField> tyPlus(new scalarField(patch().size(), Zero)); scalarField& yPlus = tyPlus.ref(); - if (roughnessHeight_ > 0.0) + if (0.0 < roughnessHeight_) { // Rough Walls const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; @@ -207,7 +205,7 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus } -void nutURoughWallFunctionFvPatchScalarField::writeLocalEntries +void Foam::nutURoughWallFunctionFvPatchScalarField::writeLocalEntries ( Ostream& os ) const @@ -223,7 +221,8 @@ void nutURoughWallFunctionFvPatchScalarField::writeLocalEntries // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField +Foam::nutURoughWallFunctionFvPatchScalarField:: +nutURoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -238,7 +237,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField {} -nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField +Foam::nutURoughWallFunctionFvPatchScalarField:: +nutURoughWallFunctionFvPatchScalarField ( const nutURoughWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -255,7 +255,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField {} -nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField +Foam::nutURoughWallFunctionFvPatchScalarField:: +nutURoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -271,7 +272,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField {} -nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField +Foam::nutURoughWallFunctionFvPatchScalarField:: +nutURoughWallFunctionFvPatchScalarField ( const nutURoughWallFunctionFvPatchScalarField& rwfpsf ) @@ -285,7 +287,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField {} -nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField +Foam::nutURoughWallFunctionFvPatchScalarField:: +nutURoughWallFunctionFvPatchScalarField ( const nutURoughWallFunctionFvPatchScalarField& rwfpsf, const DimensionedField<scalar, volMesh>& iF @@ -302,7 +305,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> +Foam::nutURoughWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); @@ -321,7 +325,10 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::yPlus() const } -void nutURoughWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutURoughWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); @@ -331,14 +338,13 @@ void nutURoughWallFunctionFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutURoughWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutURoughWallFunctionFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H index 91c51e21bcc6184c4e8e20bd8eaaaa6ecf68c3f3..93b68c127feb722d9cc718d77b4eb5b289191547 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H @@ -30,16 +30,20 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions for rough walls, based on velocity. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions for rough walls, + based on velocity, \c U. Usage \table Property | Description | Required | Default value - roughnessHeight | roughness height | yes | - roughnessConstant | roughness constanr | yes | - roughnessFactor | scaling factor | yes | - maxIter | Number of N-R iterations | no | 10 + roughnessHeight | Roughness height | yes | + roughnessConstant | Roughness constanr | yes | + roughnessFactor | Scaling factor | yes | + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + maxIter | Number of Newton-Raphson iterations | no | 10 tolerance | Convergence tolerance | no | 0.0001 \endtable @@ -47,10 +51,13 @@ Usage \verbatim <patchName> { + // Mandatory entries type nutURoughWallFunction; - roughnessHeight 1e-5; - roughnessConstant 0.5; - roughnessFactor 1; + roughnessHeight 1e-5; + roughnessConstant 0.5; + roughnessFactor 1; + + // Optional entries } \endverbatim @@ -88,7 +95,7 @@ class nutURoughWallFunctionFvPatchScalarField : public nutWallFunctionFvPatchScalarField { - // Private data + // Private Data // Roughness model parameters @@ -145,8 +152,8 @@ public: ); //- Construct by mapping given - // nutURoughWallFunctionFvPatchScalarField - // onto a new patch + //- nutURoughWallFunctionFvPatchScalarField + //- onto a new patch nutURoughWallFunctionFvPatchScalarField ( const nutURoughWallFunctionFvPatchScalarField&, @@ -190,7 +197,7 @@ public: } - // Member functions + // Member Functions // Access @@ -226,15 +233,13 @@ public: } //- Return reference to the roughness scale factor to allow - // adjustment + //- adjustment scalar& roughnessFactor() { return roughnessFactor_; } - // I-O - // Evaluation functions //- Calculate and return the yPlus at the boundary diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C index 1e2d5d34ef30ab6a3f8adfd6cbdab357bee71d26..fcdb2f93c220969c1dddb90e5cda035da92b7682 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C @@ -31,14 +31,11 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> +Foam::nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const { const label patchi = patch().index(); @@ -91,7 +88,8 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const } -tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau +Foam::tmp<Foam::scalarField> +Foam::nutUSpaldingWallFunctionFvPatchScalarField::calcUTau ( const scalarField& magGradU ) const @@ -101,7 +99,8 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau } -tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau +Foam::tmp<Foam::scalarField> +Foam::nutUSpaldingWallFunctionFvPatchScalarField::calcUTau ( const scalarField& magGradU, const label maxIter, @@ -140,7 +139,7 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau // Note: for exact restart seed with laminar viscosity only: //scalar ut = sqrt(nuw[facei]*magGradU[facei]); - if (ut > ROOTVSMALL) + if (ROOTVSMALL < ut) { int iter = 0; @@ -204,7 +203,7 @@ void Foam::nutUSpaldingWallFunctionFvPatchScalarField::writeLocalEntries // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: nutUSpaldingWallFunctionFvPatchScalarField ( const fvPatch& p, @@ -221,7 +220,7 @@ nutUSpaldingWallFunctionFvPatchScalarField {} -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: nutUSpaldingWallFunctionFvPatchScalarField ( const nutUSpaldingWallFunctionFvPatchScalarField& ptf, @@ -240,7 +239,7 @@ nutUSpaldingWallFunctionFvPatchScalarField {} -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: nutUSpaldingWallFunctionFvPatchScalarField ( const fvPatch& p, @@ -258,7 +257,7 @@ nutUSpaldingWallFunctionFvPatchScalarField {} -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: nutUSpaldingWallFunctionFvPatchScalarField ( const nutUSpaldingWallFunctionFvPatchScalarField& wfpsf @@ -274,7 +273,7 @@ nutUSpaldingWallFunctionFvPatchScalarField {} -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: nutUSpaldingWallFunctionFvPatchScalarField ( const nutUSpaldingWallFunctionFvPatchScalarField& wfpsf, @@ -293,7 +292,7 @@ nutUSpaldingWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -nutUSpaldingWallFunctionFvPatchScalarField:: +Foam::nutUSpaldingWallFunctionFvPatchScalarField:: ~nutUSpaldingWallFunctionFvPatchScalarField() { //if (debug) @@ -314,7 +313,8 @@ nutUSpaldingWallFunctionFvPatchScalarField:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> +Foam::nutUSpaldingWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); @@ -335,7 +335,10 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::yPlus() const } -void nutUSpaldingWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutUSpaldingWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); @@ -345,14 +348,14 @@ void nutUSpaldingWallFunctionFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutUSpaldingWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutUSpaldingWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H index a0e497d7f27fc708956eaf8df1489acac2f7ca33..ecb6c4832e83c9c7381d42929e05732dfed8f089 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H @@ -30,9 +30,10 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions for rough walls, based on velocity, using - Spalding's law to give a continuous nut profile to the wall (y+ = 0) + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions for rough walls, + based on velocity, \c U, using Spalding's law to give a continuous \c nut + profile to the wall (y+ = 0) \f[ y^+ = u^+ + \frac{1}{E} \left[exp(\kappa u^+) - 1 - \kappa u^+\, @@ -46,26 +47,27 @@ Description \kappa | Von Karman constant \endvartable - Usage + \table + Property | Description | Required | Default value + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + maxIter | Number of Newton-Raphson iterations | no | 10 + tolerance | Convergence tolerance | no | 0.0001 + \endtable + Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutUSpaldingWallFunction; - // .. nutWallFunctionFvPatchScalarField entries .. - + // Optional entries } \endverbatim - Additional entries (see below) - \table - Property | Description | Required | Default value - maxIter | Number of N-R iterations | no | 10 - tolerance | Convergence tolerance | no | 0.01 - \endtable - See also Foam::nutWallFunctionFvPatchScalarField @@ -111,7 +113,7 @@ class nutUSpaldingWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Max iterations in calcNut const label maxIter_; @@ -135,7 +137,7 @@ protected: virtual tmp<scalarField> calcUTau(const scalarField& magGradU) const; //- Calculate the friction velocity and number of iterations for - // convergence + //- convergence virtual tmp<scalarField> calcUTau ( const scalarField& magGradU, @@ -171,8 +173,8 @@ public: ); //- Construct by mapping given - // nutUSpaldingWallFunctionFvPatchScalarField - // onto a new patch + //- nutUSpaldingWallFunctionFvPatchScalarField + //- onto a new patch nutUSpaldingWallFunctionFvPatchScalarField ( const nutUSpaldingWallFunctionFvPatchScalarField&, @@ -220,7 +222,7 @@ public: virtual ~nutUSpaldingWallFunctionFvPatchScalarField(); - // Member functions + // Member Functions // Evaluation functions diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C index 90d2bc14745eaf01b0e290c06db848c478d9f494..cf07f1a558dacef22b263a375bdb1d1b4753602c 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -31,14 +31,11 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> +Foam::nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const { const label patchi = patch().index(); @@ -68,7 +65,8 @@ tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const } -tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus +Foam::tmp<Foam::scalarField> +Foam::nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus ( const scalarField& Rey ) const @@ -87,7 +85,7 @@ tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutUTabulatedWallFunctionFvPatchScalarField:: +Foam::nutUTabulatedWallFunctionFvPatchScalarField:: nutUTabulatedWallFunctionFvPatchScalarField ( const fvPatch& p, @@ -112,7 +110,7 @@ nutUTabulatedWallFunctionFvPatchScalarField {} -nutUTabulatedWallFunctionFvPatchScalarField:: +Foam::nutUTabulatedWallFunctionFvPatchScalarField:: nutUTabulatedWallFunctionFvPatchScalarField ( const nutUTabulatedWallFunctionFvPatchScalarField& ptf, @@ -127,7 +125,7 @@ nutUTabulatedWallFunctionFvPatchScalarField {} -nutUTabulatedWallFunctionFvPatchScalarField:: +Foam::nutUTabulatedWallFunctionFvPatchScalarField:: nutUTabulatedWallFunctionFvPatchScalarField ( const fvPatch& p, @@ -153,7 +151,7 @@ nutUTabulatedWallFunctionFvPatchScalarField {} -nutUTabulatedWallFunctionFvPatchScalarField:: +Foam::nutUTabulatedWallFunctionFvPatchScalarField:: nutUTabulatedWallFunctionFvPatchScalarField ( const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf @@ -165,7 +163,7 @@ nutUTabulatedWallFunctionFvPatchScalarField {} -nutUTabulatedWallFunctionFvPatchScalarField:: +Foam::nutUTabulatedWallFunctionFvPatchScalarField:: nutUTabulatedWallFunctionFvPatchScalarField ( const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf, @@ -180,7 +178,8 @@ nutUTabulatedWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> +Foam::nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); @@ -203,7 +202,10 @@ tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const } -void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutUTabulatedWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); os.writeEntry("uPlusTable", uPlusTableName_); @@ -213,14 +215,14 @@ void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutUTabulatedWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutUTabulatedWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H index 8155d21572116715a4b4d955255ef0c5533c944d..00d4d1bdfb7354734313149ee450835d681bd7be 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -30,23 +30,33 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions. As input, the user specifies a look-up table - of U+ as a function of near-wall Reynolds number. The table should be - located in the $FOAM_CASE/constant directory. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions, based on + velocity, i.e. \c U. + + As input, the user specifies a look-up table of \c U+ as a function of + near-wall Reynolds number. + + The table should be located in the $FOAM_CASE/constant directory. Usage \table Property | Description | Required | Default value uPlusTable | U+ as a function of Re table name | yes | + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 \endtable Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutTabulatedWallFunction; uPlusTable myUPlusTable; + + // Optional entries } \endverbatim @@ -83,12 +93,12 @@ class nutUTabulatedWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Name of u+ table word uPlusTableName_; - //- U+ table + //- u+ table uniformInterpolationTable<scalar> uPlusTable_; @@ -125,8 +135,8 @@ public: ); //- Construct by mapping given - // nutUTabulatedWallFunctionFvPatchScalarField - // onto a new patch + //- nutUTabulatedWallFunctionFvPatchScalarField + //- onto a new patch nutUTabulatedWallFunctionFvPatchScalarField ( const nutUTabulatedWallFunctionFvPatchScalarField&, @@ -170,7 +180,7 @@ public: } - // Member functions + // Member Functions // Evaluation functions diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C index 9d9cb2be8de2ec9ce90f532e45ee8b7c369d9db1..93ccdb40f2c1e9ca075d2292b2881a8df35084b5 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -31,14 +31,11 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> +Foam::nutUWallFunctionFvPatchScalarField::calcNut() const { const label patchi = patch().index(); @@ -63,7 +60,7 @@ tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcNut() const forAll(yPlus, facei) { - if (yPlus[facei] > yPlusLam_) + if (yPlusLam_ < yPlus[facei]) { nutw[facei] = nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); @@ -74,7 +71,8 @@ tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcNut() const } -tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcYPlus +Foam::tmp<Foam::scalarField> +Foam::nutUWallFunctionFvPatchScalarField::calcYPlus ( const scalarField& magUp ) const @@ -98,10 +96,10 @@ tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcYPlus forAll(yPlus, facei) { - scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; + const scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; scalar yp = yPlusLam_; - scalar ryPlusLam = 1.0/yp; + const scalar ryPlusLam = 1.0/yp; int iter = 0; scalar yPlusLast = 0.0; @@ -122,7 +120,7 @@ tmp<scalarField> nutUWallFunctionFvPatchScalarField::calcYPlus // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField +Foam::nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -132,7 +130,7 @@ nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField {} -nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField +Foam::nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField ( const nutUWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -144,7 +142,7 @@ nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField {} -nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField +Foam::nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -155,7 +153,7 @@ nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField {} -nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField +Foam::nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField ( const nutUWallFunctionFvPatchScalarField& sawfpsf ) @@ -164,7 +162,7 @@ nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField {} -nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField +Foam::nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField ( const nutUWallFunctionFvPatchScalarField& sawfpsf, const DimensionedField<scalar, volMesh>& iF @@ -176,7 +174,8 @@ nutUWallFunctionFvPatchScalarField::nutUWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutUWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> +Foam::nutUWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> @@ -194,7 +193,10 @@ tmp<scalarField> nutUWallFunctionFvPatchScalarField::yPlus() const } -void nutUWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutUWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); @@ -204,14 +206,14 @@ void nutUWallFunctionFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutUWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutUWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.H index 0efd55081d3db602b0ec09b7bd10a57bfb57a1c4..2e2197a687adc3cef61699209ecdd52a19b28153 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.H @@ -30,15 +30,26 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions, based on velocity. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions, based on + velocity, \c U. Usage + \table + Property | Description | Required | Default value + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + \endtable + Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutUWallFunction; + + // Optional entries } \endverbatim @@ -108,8 +119,8 @@ public: ); //- Construct by mapping given - // nutUWallFunctionFvPatchScalarField - // onto a new patch + //- nutUWallFunctionFvPatchScalarField + //- onto a new patch nutUWallFunctionFvPatchScalarField ( const nutUWallFunctionFvPatchScalarField&, @@ -153,7 +164,7 @@ public: } - // Member functions + // Member Functions // Evaluation functions diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 4f3912ae1f20d2218cd9b7df1698870efeafed78..edbe662950b071a684f43bc3ab5d6b03b89b6a06 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation @@ -133,10 +133,10 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), - UName_(dict.lookupOrDefault<word>("U", word::null)), - Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)), - kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), - E_(dict.lookupOrDefault<scalar>("E", 9.8)), + UName_(dict.getOrDefault<word>("U", word::null)), + Cmu_(dict.getOrDefault<scalar>("Cmu", 0.09)), + kappa_(dict.getOrDefault<scalar>("kappa", 0.41)), + E_(dict.getOrDefault<scalar>("E", 9.8)), yPlusLam_(yPlusLam(kappa_, E_)) { checkType(); @@ -201,7 +201,7 @@ Foam::scalar Foam::nutWallFunctionFvPatchScalarField::yPlusLam { scalar ypl = 11.0; - for (int i=0; i<10; i++) + for (int i = 0; i < 10; ++i) { ypl = log(max(E*ypl, 1))/kappa; } @@ -229,7 +229,10 @@ void Foam::nutWallFunctionFvPatchScalarField::updateCoeffs() } -void Foam::nutWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index d92f0e79ebb5103a913bf31dae9fc1e5cdc8c550..0d00daca51f563874dfbe94237a6b0ec9a4831c1 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation @@ -30,9 +30,19 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions, based on turbulence kinetic energy. - - replicates OpenFOAM v1.5 (and earlier) behaviour + The class \c nutWallFunction is a base class that parents the derived + boundary conditions which provide a wall constraint on various fields, such + as turbulence kinematic viscosity, i.e. \c nut, for low- and high-Reynolds + number turbulence models. + + Reference: + \verbatim + Default model coefficients: + Versteeg, H. K., & Malalasekera, W. (2011). + An introduction to computational fluid dynamics: the finite + volume method. Harlow: Pearson Education. + Subsection "3.5.2 k-epsilon model". + \endverbatim Usage \table @@ -46,16 +56,11 @@ Usage \verbatim <patchName> { + // Mandatory entries type nutWallFunction; - value uniform 0.0; - } - \endverbatim - Reference for the default model coefficients: - \verbatim - H. Versteeg, W. Malalasekera - An Introduction to Computational Fluid Dynamics: The Finite Volume - Method, subsection "3.5.2 k-epsilon model" + // Optional entries + } \endverbatim See also @@ -88,7 +93,7 @@ class nutWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Name of velocity field // Defult is null (not specified) in which case the velocity is @@ -104,7 +109,7 @@ protected: //- E coefficient scalar E_; - //- Y+ at the edge of the laminar sublayer + //- Estimated y+ value at the edge of the viscous sublayer scalar yPlusLam_; @@ -148,8 +153,8 @@ public: ); //- Construct by mapping given - // nutWallFunctionFvPatchScalarField - // onto a new patch + //- nutWallFunctionFvPatchScalarField + //- onto a new patch nutWallFunctionFvPatchScalarField ( const nutWallFunctionFvPatchScalarField&, @@ -199,10 +204,10 @@ public: const label patchi ); - //- Calculate the Y+ at the edge of the laminar sublayer + //- Calculate the y+ at the edge of the viscous sublayer static scalar yPlusLam(const scalar kappa, const scalar E); - //- Return the Y+ at the edge of the laminar sublayer + //- Return the y+ at the edge of the viscous sublayer scalar yPlusLam() const; //- Calculate and return the yPlus at the boundary diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C index 5feb46983fee7ca05cbb240f108ec845fbff2b7a..5238c91a20955c239482ce52cf4ae580f51b0a8c 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.C @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,14 +31,10 @@ License #include "volFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -scalar nutkRoughWallFunctionFvPatchScalarField::fnRough +Foam::scalar Foam::nutkRoughWallFunctionFvPatchScalarField::fnRough ( const scalar KsPlus, const scalar Cs @@ -61,7 +57,8 @@ scalar nutkRoughWallFunctionFvPatchScalarField::fnRough } -tmp<scalarField> nutkRoughWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> Foam::nutkRoughWallFunctionFvPatchScalarField:: +calcNut() const { const label patchi = patch().index(); @@ -86,19 +83,19 @@ tmp<scalarField> nutkRoughWallFunctionFvPatchScalarField::calcNut() const forAll(nutw, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; - scalar uStar = Cmu25*sqrt(k[celli]); - scalar yPlus = uStar*y[facei]/nuw[facei]; - scalar KsPlus = uStar*Ks_[facei]/nuw[facei]; + const scalar uStar = Cmu25*sqrt(k[celli]); + const scalar yPlus = uStar*y[facei]/nuw[facei]; + const scalar KsPlus = uStar*Ks_[facei]/nuw[facei]; scalar Edash = E_; - if (KsPlus > 2.25) + if (2.25 < KsPlus) { Edash /= fnRough(KsPlus, Cs_[facei]); } - scalar limitingNutw = max(nutw[facei], nuw[facei]); + const scalar limitingNutw = max(nutw[facei], nuw[facei]); // To avoid oscillations limit the change in the wall viscosity // which is particularly important if it temporarily becomes zero @@ -129,7 +126,8 @@ tmp<scalarField> nutkRoughWallFunctionFvPatchScalarField::calcNut() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField +Foam::nutkRoughWallFunctionFvPatchScalarField:: +nutkRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -141,7 +139,8 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField {} -nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField +Foam::nutkRoughWallFunctionFvPatchScalarField:: +nutkRoughWallFunctionFvPatchScalarField ( const nutkRoughWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -155,7 +154,8 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField {} -nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField +Foam::nutkRoughWallFunctionFvPatchScalarField:: +nutkRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -168,7 +168,8 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField {} -nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField +Foam::nutkRoughWallFunctionFvPatchScalarField:: +nutkRoughWallFunctionFvPatchScalarField ( const nutkRoughWallFunctionFvPatchScalarField& rwfpsf ) @@ -179,7 +180,8 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField {} -nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField +Foam::nutkRoughWallFunctionFvPatchScalarField:: +nutkRoughWallFunctionFvPatchScalarField ( const nutkRoughWallFunctionFvPatchScalarField& rwfpsf, const DimensionedField<scalar, volMesh>& iF @@ -193,7 +195,7 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void nutkRoughWallFunctionFvPatchScalarField::autoMap +void Foam::nutkRoughWallFunctionFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) @@ -204,7 +206,7 @@ void nutkRoughWallFunctionFvPatchScalarField::autoMap } -void nutkRoughWallFunctionFvPatchScalarField::rmap +void Foam::nutkRoughWallFunctionFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr @@ -220,7 +222,10 @@ void nutkRoughWallFunctionFvPatchScalarField::rmap } -void nutkRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::nutkRoughWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); @@ -232,14 +237,13 @@ void nutkRoughWallFunctionFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutkRoughWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutkRoughWallFunctionFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.H index 4a75cf93120230fece83fa4cde491db969ad44a9..f0ebf8eea707400652b96184976d9b78eb24f5ec 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkRoughWallFunction/nutkRoughWallFunctionFvPatchScalarField.H @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,10 +30,10 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions for rough walls, based on turbulence kinetic - energy. The condition manipulates the E parameter to account for roughness - effects. + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions for rough walls, + based on turbulent kinetic energy, \c k. The condition manipulates the \c E + parameter to account for roughness effects. Parameter ranges - roughness height = sand-grain roughness (0 for smooth walls) @@ -41,18 +41,24 @@ Description Usage \table - Property | Description | Required | Default value - Ks | sand-grain roughness height | yes | - Cs | roughness constant | yes | + Property | Description | Required | Default value + Ks | Sand-grain roughness height | yes | + Cs | Roughness constant | yes | + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 \endtable Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutkRoughWallFunction; Ks uniform 0; Cs uniform 0.5; + + // Optional entries } \endverbatim @@ -84,7 +90,7 @@ class nutkRoughWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Roughness height scalarField Ks_; @@ -126,8 +132,8 @@ public: ); //- Construct by mapping given - // nutkRoughWallFunctionFvPatchScalarField - // onto a new patch + //- nutkRoughWallFunctionFvPatchScalarField + //- onto a new patch nutkRoughWallFunctionFvPatchScalarField ( const nutkRoughWallFunctionFvPatchScalarField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C index aece79fb762a925989d6b663b524970df0175ef1..a19294fb8e2fda0d564165e17a56fab726880018 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,14 +32,11 @@ License #include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -tmp<scalarField> nutkWallFunctionFvPatchScalarField::calcNut() const +Foam::tmp<Foam::scalarField> Foam::nutkWallFunctionFvPatchScalarField:: +calcNut() const { const label patchi = patch().index(); @@ -65,11 +62,11 @@ tmp<scalarField> nutkWallFunctionFvPatchScalarField::calcNut() const forAll(nutw, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; - scalar yPlus = Cmu25*y[facei]*sqrt(k[celli])/nuw[facei]; + const scalar yPlus = Cmu25*y[facei]*sqrt(k[celli])/nuw[facei]; - if (yPlus > yPlusLam_) + if (yPlusLam_ < yPlus) { nutw[facei] = nuw[facei]*(yPlus*kappa_/log(E_*yPlus) - 1.0); } @@ -81,7 +78,7 @@ tmp<scalarField> nutkWallFunctionFvPatchScalarField::calcNut() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField +Foam::nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -91,7 +88,7 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField {} -nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField +Foam::nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField ( const nutkWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -103,7 +100,7 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField {} -nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField +Foam::nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -114,7 +111,7 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField {} -nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField +Foam::nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField ( const nutkWallFunctionFvPatchScalarField& wfpsf ) @@ -123,7 +120,7 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField {} -nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField +Foam::nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField ( const nutkWallFunctionFvPatchScalarField& wfpsf, const DimensionedField<scalar, volMesh>& iF @@ -135,7 +132,8 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp<scalarField> nutkWallFunctionFvPatchScalarField::yPlus() const +Foam::tmp<Foam::scalarField> Foam::nutkWallFunctionFvPatchScalarField:: +yPlus() const { const label patchi = patch().index(); @@ -161,14 +159,14 @@ tmp<scalarField> nutkWallFunctionFvPatchScalarField::yPlus() const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - nutkWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + nutkWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.H index 8b8247009f10a50fd6657dd5ac41bee7eddbfbe2..8b5c3d7c8071c9207ff8a9fd25726ab4457c0a07 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkWallFunction/nutkWallFunctionFvPatchScalarField.H @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,16 +30,26 @@ Group grpWallFunctions Description - This boundary condition provides a turbulent kinematic viscosity condition - when using wall functions, based on turbulence kinetic energy. - - replicates OpenFOAM v1.5 (and earlier) behaviour + This boundary condition provides a wall constraint on the turbulent + kinematic viscosity, i.e. \c nut, when using wall functions, + based on turbulent kinetic energy, \c k. Usage + \table + Property | Description | Required | Default value + Cmu | Model coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | Model coefficient | no | 9.8 + \endtable + Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type nutkWallFunction; + + // Optional entries } \endverbatim @@ -101,8 +111,8 @@ public: ); //- Construct by mapping given - // nutkWallFunctionFvPatchScalarField - // onto a new patch + //- nutkWallFunctionFvPatchScalarField + //- onto a new patch nutkWallFunctionFvPatchScalarField ( const nutkWallFunctionFvPatchScalarField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index d721fcc6775429469ae231f233b2837823798f72..7a8e9de864dd3c0246218e256a30e649d58fc448 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,18 +31,14 @@ License #include "fvMatrix.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -scalar omegaWallFunctionFvPatchScalarField::tolerance_ = 1e-5; +Foam::scalar Foam::omegaWallFunctionFvPatchScalarField::tolerance_ = 1e-5; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void omegaWallFunctionFvPatchScalarField::setMaster() +void Foam::omegaWallFunctionFvPatchScalarField::setMaster() { if (master_ != -1) { @@ -72,7 +68,7 @@ void omegaWallFunctionFvPatchScalarField::setMaster() } -void omegaWallFunctionFvPatchScalarField::createAveragingWeights() +void Foam::omegaWallFunctionFvPatchScalarField::createAveragingWeights() { const volScalarField& omega = static_cast<const volScalarField&>(this->internalField()); @@ -111,7 +107,7 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() const labelUList& faceCells = bf[patchi].patch().faceCells(); forAll(faceCells, i) { - label celli = faceCells[i]; + const label celli = faceCells[i]; weights[celli]++; } } @@ -120,7 +116,7 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() cornerWeights_.setSize(bf.size()); forAll(omegaPatches, i) { - label patchi = omegaPatches[i]; + const label patchi = omegaPatches[i]; const fvPatchScalarField& wf = weights.boundaryField()[patchi]; cornerWeights_[patchi] = 1.0/wf.patchInternalField(); } @@ -132,8 +128,11 @@ void omegaWallFunctionFvPatchScalarField::createAveragingWeights() } -omegaWallFunctionFvPatchScalarField& -omegaWallFunctionFvPatchScalarField::omegaPatch(const label patchi) +Foam::omegaWallFunctionFvPatchScalarField& +Foam::omegaWallFunctionFvPatchScalarField::omegaPatch +( + const label patchi +) { const volScalarField& omega = static_cast<const volScalarField&>(this->internalField()); @@ -147,7 +146,7 @@ omegaWallFunctionFvPatchScalarField::omegaPatch(const label patchi) } -void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields +void Foam::omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields ( const turbulenceModel& turbModel, scalarField& G0, @@ -180,7 +179,7 @@ void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields } -void omegaWallFunctionFvPatchScalarField::calculate +void Foam::omegaWallFunctionFvPatchScalarField::calculate ( const turbulenceModel& turbModel, const List<scalar>& cornerWeights, @@ -196,18 +195,18 @@ void omegaWallFunctionFvPatchScalarField::calculate const scalarField& y = turbModel.y()[patchi]; - const scalar Cmu25 = pow025(nutw.Cmu()); + const tmp<scalarField> tnuw = turbModel.nu(patchi); + const scalarField& nuw = tnuw(); const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); - const tmp<scalarField> tnuw = turbModel.nu(patchi); - const scalarField& nuw = tnuw(); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magGradUw(mag(Uw.snGrad())); + const scalar Cmu25 = pow025(nutw.Cmu()); + // Set omega and G forAll(nutw, facei) { @@ -237,7 +236,7 @@ void omegaWallFunctionFvPatchScalarField::calculate } else { - if (yPlus > nutw.yPlusLam()) + if (nutw.yPlusLam() < yPlus) { omega0[celli] += w*omegaLog; } @@ -263,24 +262,24 @@ void omegaWallFunctionFvPatchScalarField::calculate // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +Foam::omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchField<scalar>(p, iF), - beta1_(0.075), blended_(true), - G_(), - omega_(), initialised_(false), master_(-1), + beta1_(0.075), + G_(), + omega_(), cornerWeights_() {} -omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +Foam::omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ( const omegaWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -289,17 +288,17 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(ptf, p, iF, mapper), - beta1_(ptf.beta1_), blended_(ptf.blended_), - G_(), - omega_(), initialised_(false), master_(-1), + beta1_(ptf.beta1_), + G_(), + omega_(), cornerWeights_() {} -omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +Foam::omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -307,12 +306,12 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedValueFvPatchField<scalar>(p, iF, dict), - beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075)), - blended_(dict.lookupOrDefault<Switch>("blended", true)), - G_(), - omega_(), + blended_(dict.getOrDefault<bool>("blended", true)), initialised_(false), master_(-1), + beta1_(dict.getOrDefault<scalar>("beta1", 0.075)), + G_(), + omega_(), cornerWeights_() { // apply zero-gradient condition on start-up @@ -320,42 +319,45 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField } -omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +Foam::omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ( const omegaWallFunctionFvPatchScalarField& owfpsf ) : fixedValueFvPatchField<scalar>(owfpsf), - beta1_(owfpsf.beta1_), blended_(owfpsf.blended_), - G_(), - omega_(), initialised_(false), master_(-1), + beta1_(owfpsf.beta1_), + G_(), + omega_(), cornerWeights_() {} -omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +Foam::omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ( const omegaWallFunctionFvPatchScalarField& owfpsf, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchField<scalar>(owfpsf, iF), - beta1_(owfpsf.beta1_), blended_(owfpsf.blended_), - G_(), - omega_(), initialised_(false), master_(-1), + beta1_(owfpsf.beta1_), + G_(), + omega_(), cornerWeights_() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -scalarField& omegaWallFunctionFvPatchScalarField::G(bool init) +Foam::scalarField& Foam::omegaWallFunctionFvPatchScalarField::G +( + bool init +) { if (patch().index() == master_) { @@ -371,7 +373,10 @@ scalarField& omegaWallFunctionFvPatchScalarField::G(bool init) } -scalarField& omegaWallFunctionFvPatchScalarField::omega(bool init) +Foam::scalarField& Foam::omegaWallFunctionFvPatchScalarField::omega +( + bool init +) { if (patch().index() == master_) { @@ -387,7 +392,7 @@ scalarField& omegaWallFunctionFvPatchScalarField::omega(bool init) } -void omegaWallFunctionFvPatchScalarField::updateCoeffs() +void Foam::omegaWallFunctionFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -422,7 +427,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() forAll(*this, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; G[celli] = G0[celli]; omega[celli] = omega0[celli]; @@ -432,7 +437,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() } -void omegaWallFunctionFvPatchScalarField::updateWeightedCoeffs +void Foam::omegaWallFunctionFvPatchScalarField::updateWeightedCoeffs ( const scalarField& weights ) @@ -473,11 +478,11 @@ void omegaWallFunctionFvPatchScalarField::updateWeightedCoeffs // only set the values if the weights are > tolerance forAll(weights, facei) { - scalar w = weights[facei]; + const scalar w = weights[facei]; - if (w > tolerance_) + if (tolerance_ < w) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; G[celli] = (1.0 - w)*G[celli] + w*G0[celli]; omega[celli] = (1.0 - w)*omega[celli] + w*omega0[celli]; @@ -489,7 +494,7 @@ void omegaWallFunctionFvPatchScalarField::updateWeightedCoeffs } -void omegaWallFunctionFvPatchScalarField::manipulateMatrix +void Foam::omegaWallFunctionFvPatchScalarField::manipulateMatrix ( fvMatrix<scalar>& matrix ) @@ -505,7 +510,7 @@ void omegaWallFunctionFvPatchScalarField::manipulateMatrix } -void omegaWallFunctionFvPatchScalarField::manipulateMatrix +void Foam::omegaWallFunctionFvPatchScalarField::manipulateMatrix ( fvMatrix<scalar>& matrix, const Field<scalar>& weights @@ -525,7 +530,7 @@ void omegaWallFunctionFvPatchScalarField::manipulateMatrix forAll(weights, facei) { // only set the values if the weights are > tolerance - if (weights[facei] > tolerance_) + if (tolerance_ < weights[facei]) { const label celli = faceCells[facei]; @@ -548,24 +553,27 @@ void omegaWallFunctionFvPatchScalarField::manipulateMatrix } -void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const +void Foam::omegaWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { - os.writeEntry("beta1", beta1_); os.writeEntry("blended", blended_); + os.writeEntry("beta1", beta1_); fixedValueFvPatchField<scalar>::write(os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - omegaWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + omegaWallFunctionFvPatchScalarField + ); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H index a053dafc71b0f5cb485fb79ef85f9db1ca6f9393..90c7cb5a1bc391da5eb57610a1c30221ccb4a5a8 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -2,10 +2,10 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- - | Copyright (C) 2011-2016, 2019 OpenFOAM Foundation + | Copyright (C) 2011-2019 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,8 +30,9 @@ Group grpWallFunctions Description - This boundary condition provides a wall constraint on turbulence specific - dissipation, omega for both low and high Reynolds number turbulence models. + This boundary condition provides a wall constraint on specific turbulent + kinetic energy dissipation rate, i.e. \c omega, for low- and high-Reynolds + number turbulence models. The near-wall omega may be either blended between the viscous region and logarithmic region values using: @@ -55,20 +56,12 @@ Description Nov. 2001 \endverbatim - or switched between these values based on the laminar-to-turbulent y+ value - derived from kappa and E specified in the corresponding nutWallFunction. - Recent tests have shown that the standard switching method provides more - accurate results for 10 < y+ < 30 when used with high Reynolds number - wall-functions and both methods provide accurate results when used with - continuous wall-functions. Based on this the standard switching method is - used by default. + or switched between these values based on the viscous-to-turbulent \c y+ + value derived from \c kappa and \c E. Usage \table Property | Description | Required | Default value - Cmu | Model coefficient | no | 0.09 - kappa | von Karman constant | no | 0.41 - E | Model coefficient | no | 9.8 beta1 | Model coefficient | no | 0.075 blended | Blending switch | no | false \endtable @@ -77,10 +70,25 @@ Usage \verbatim <patchName> { + // Mandatory entries type omegaWallFunction; + + // Optional entries } \endverbatim +Note + The coefficients \c Cmu, \c kappa, and \c E are obtained from + the specified \c nutWallFunction in order to ensure that each patch + possesses the same set of values for these coefficients. + + Some tests have shown that the stepwise switching method provides + more accurate predictions for 10 < y+ < 30 when used with high Reynolds + number wall-functions. + + In addition, the stepwise switching method provides accurate predictions + when used with continuous wall-functions. + See also Foam::fixedInternalValueFvPatchField Foam::epsilonWallFunctionFvPatchScalarField @@ -112,16 +120,22 @@ class omegaWallFunctionFvPatchScalarField { protected: - // Protected data + // Protected Data //- Tolerance used in weighted calculations static scalar tolerance_; - //- beta1 coefficient - scalar beta1_; + //- Blending switch + bool blended_; + + //- Initialised flag + bool initialised_; + + //- Master patch ID + label master_; //- beta1 coefficient - Switch blended_; + scalar beta1_; //- Local copy of turbulence G field scalarField G_; @@ -129,12 +143,6 @@ protected: //- Local copy of turbulence omega field scalarField omega_; - //- Initialised flag - bool initialised_; - - //- Master patch ID - label master_; - //- List of averaging corner weights List<List<scalar>> cornerWeights_; @@ -142,11 +150,11 @@ protected: // Protected Member Functions //- Set the master patch - master is responsible for updating all - // wall function patches + //- wall function patches virtual void setMaster(); //- Create the averaging weights for cells which are bounded by - // multiple wall function faces + //- multiple wall function faces virtual void createAveragingWeights(); //- Helper function to return non-const access to an omega patch @@ -204,8 +212,8 @@ public: ); //- Construct by mapping given - // omegaWallFunctionFvPatchScalarField - // onto a new patch + //- omegaWallFunctionFvPatchScalarField + //- onto a new patch omegaWallFunctionFvPatchScalarField ( const omegaWallFunctionFvPatchScalarField&, diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C index 325609fd2c2f572963e539888466117f8778e8ea..7ec9b0e888086aac3ec1643bba32d1b5c1b7a093 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -45,7 +45,9 @@ v2WallFunctionFvPatchScalarField::v2WallFunctionFvPatchScalarField const DimensionedField<scalar, volMesh>& iF ) : - fixedValueFvPatchField<scalar>(p, iF) + fixedValueFvPatchField<scalar>(p, iF), + Cv2_(0.193), + Bv2_(-0.94) {} @@ -57,7 +59,9 @@ v2WallFunctionFvPatchScalarField::v2WallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField<scalar>(ptf, p, iF, mapper) + fixedValueFvPatchField<scalar>(ptf, p, iF, mapper), + Cv2_(ptf.Cv2_), + Bv2_(ptf.Bv2_) {} @@ -68,7 +72,9 @@ v2WallFunctionFvPatchScalarField::v2WallFunctionFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField<scalar>(p, iF, dict) + fixedValueFvPatchField<scalar>(p, iF, dict), + Cv2_(dict.getOrDefault<scalar>("Cv2", 0.193)), + Bv2_(dict.getOrDefault<scalar>("Bv2", -0.94)) {} @@ -77,7 +83,9 @@ v2WallFunctionFvPatchScalarField::v2WallFunctionFvPatchScalarField const v2WallFunctionFvPatchScalarField& v2wfpsf ) : - fixedValueFvPatchField<scalar>(v2wfpsf) + fixedValueFvPatchField<scalar>(v2wfpsf), + Cv2_(v2wfpsf.Cv2_), + Bv2_(v2wfpsf.Bv2_) {} @@ -87,7 +95,9 @@ v2WallFunctionFvPatchScalarField::v2WallFunctionFvPatchScalarField const DimensionedField<scalar, volMesh>& iF ) : - fixedValueFvPatchField<scalar>(v2wfpsf, iF) + fixedValueFvPatchField<scalar>(v2wfpsf, iF), + Cv2_(v2wfpsf.Cv2_), + Bv2_(v2wfpsf.Bv2_) {} @@ -116,12 +126,12 @@ void v2WallFunctionFvPatchScalarField::updateCoeffs() const scalarField& y = turbModel.y()[patchi]; - const tmp<volScalarField> tk = turbModel.k(); - const volScalarField& k = tk(); - const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); + const tmp<volScalarField> tk = turbModel.k(); + const volScalarField& k = tk(); + const scalar Cmu25 = pow025(nutw.Cmu()); scalarField& v2 = *this; @@ -129,22 +139,19 @@ void v2WallFunctionFvPatchScalarField::updateCoeffs() // Set v2 wall values forAll(v2, facei) { - label celli = patch().faceCells()[facei]; + const label celli = patch().faceCells()[facei]; - scalar uTau = Cmu25*sqrt(k[celli]); + const scalar uTau = Cmu25*sqrt(k[celli]); - scalar yPlus = uTau*y[facei]/nuw[facei]; + const scalar yPlus = uTau*y[facei]/nuw[facei]; - if (yPlus > nutw.yPlusLam()) + if (nutw.yPlusLam() < yPlus) { - scalar Cv2 = 0.193; - scalar Bv2 = -0.94; - v2[facei] = Cv2/nutw.kappa()*log(yPlus) + Bv2; + v2[facei] = Cv2_/nutw.kappa()*log(yPlus) + Bv2_; } else { - scalar Cv2 = 0.193; - v2[facei] = Cv2*pow4(yPlus); + v2[facei] = Cv2_*pow4(yPlus); } v2[facei] *= sqr(uTau); @@ -156,6 +163,17 @@ void v2WallFunctionFvPatchScalarField::updateCoeffs() } +void v2WallFunctionFvPatchScalarField::write +( + Ostream& os +) const +{ + os.writeEntry("Cv2", Cv2_); + os.writeEntry("Bv2", Bv2_); + fixedValueFvPatchField<scalar>::write(os); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.H index ae7d35ee275e114a28846d897821b89d78accf4a..9300094622d37d1fc0c6cf796163aac69b1c9750 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016, 2019 OpenFOAM Foundation @@ -30,31 +30,35 @@ Group grpWallFunctions Description - This boundary condition provides a turbulence stress normal to streamlines - wall function condition for low- and high-Reynolds number, turbulent flow - cases. - - The model operates in two modes, based on the computed laminar-to-turbulent - switch-over y+ value derived from kappa and E specified in the corresponding - nutWallFunction. + This boundary condition provides a wall constraint on wall-normal velocity + scale, i.e. \c v2, for low- and high-Reynolds number turbulence models. + The model operates in two modes, based on the computed viscous-to-turbulent + switch-over \c y+ value derived from \c kappa and \c E. Usage \table Property | Description | Required | Default value - Cmu | model coefficient | no | 0.09 - kappa | Von Karman constant | no | 0.41 - E | model coefficient | no | 9.8 + Cv2 | model coefficient | no | 0.193 + Bv2 | model coefficient | no | -0.94 \endtable Example of the boundary condition specification: \verbatim <patchName> { + // Mandatory entries type v2WallFunction; + + // Optional entries } \endverbatim +Note + The coefficients \c Cmu, \c kappa, and \c E are obtained from + the specified \c nutWallFunction in order to ensure that each patch + possesses the same set of values for these coefficients. + See also Foam::fixedValueFvPatchField @@ -83,6 +87,16 @@ class v2WallFunctionFvPatchScalarField : public fixedValueFvPatchField<scalar> { +protected: + + // Protected Data + + //- Cv2 coefficient + scalar Cv2_; + + //- Bv2 coefficient + scalar Bv2_; + public: @@ -108,7 +122,7 @@ public: ); //- Construct by mapping given v2WallFunctionFvPatchScalarField - // onto a new patch + //- onto a new patch v2WallFunctionFvPatchScalarField ( const v2WallFunctionFvPatchScalarField&, @@ -158,6 +172,12 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; };