From f57bfe7c0529372a07d0062fd8f0fb35e503f55f Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Jul 2009 14:22:05 +0100 Subject: [PATCH 1/4] adding yPlus calcs for incompressible S-A models --- ...ndardRoughWallFunctionFvPatchScalarField.C | 263 ++++++++++-------- ...ndardRoughWallFunctionFvPatchScalarField.H | 3 + ...asStandardWallFunctionFvPatchScalarField.C | 82 ++++-- ...asStandardWallFunctionFvPatchScalarField.H | 3 + ...rtAllmarasWallFunctionFvPatchScalarField.C | 4 - 5 files changed, 202 insertions(+), 153 deletions(-) diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index 7359e6f081..d6b96ed5b4 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -39,6 +39,134 @@ namespace incompressible namespace RASModels { +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +tmp +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus +( + const scalarField& magUp +) const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + tmp tyPlus(new scalarField(patch().size(), 0.0)); + scalarField& yPlus = tyPlus(); + + if (roughnessHeight_ > 0.0) + { + // Rough Walls + const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; + static const scalar c_2 = 2.25/(90 - 2.25); + static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); + static const scalar c_4 = c_3*log(2.25); + + //if (KsPlusBasedOnYPlus_) + { + // If KsPlus is based on YPlus the extra term added to the law + // of the wall will depend on yPlus + forAll(yPlus, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = magUpara*y[facei]/nuw[facei]; + const scalar kappaRe = kappa_*Re; + + scalar yp = yPlusLam; + const scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; + + // Enforce the roughnessHeight to be less than the distance to + // the first cell centre + if (dKsPlusdYPlus > 1) + { + dKsPlusdYPlus = 1; + } + + // Additional tuning parameter (fudge factor) - nominally = 1 + dKsPlusdYPlus *= roughnessFudgeFactor_; + + do + { + yPlusLast = yp; + + // The non-dimensional roughness height + scalar KsPlus = yp*dKsPlusdYPlus; + + // The extra term in the law-of-the-wall + scalar G = 0.0; + + scalar yPlusGPrime = 0.0; + + if (KsPlus >= 90) + { + const scalar t_1 = 1 + roughnessConstant_*KsPlus; + G = log(t_1); + yPlusGPrime = roughnessConstant_*KsPlus/t_1; + } + else if (KsPlus > 2.25) + { + const scalar t_1 = c_1*KsPlus - c_2; + const scalar t_2 = c_3*log(KsPlus) - c_4; + const scalar sint_2 = sin(t_2); + const scalar logt_1 = log(t_1); + G = logt_1*sint_2; + yPlusGPrime = + (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); + } + + scalar denom = 1.0 + log(E_*yp) - G - yPlusGPrime; + if (mag(denom) > VSMALL) + { + yp = (kappaRe + yp*(1 - yPlusGPrime))/denom; + } + } while + ( + mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 + && ++iter < 10 + && yp > VSMALL + ); + + yPlus[facei] = yp; + } + } + } + else + { + // Smooth Walls + forAll(yPlus, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = magUpara*y[facei]/nuw[facei]; + const scalar kappaRe = kappa_*Re; + + scalar yp = yPlusLam; + const scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yp; + yPlus = (kappaRe + yp)/(1.0 + log(E_*yp)); + + } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10); + + yPlus[facei] = yp; + } + } + + return tyPlus; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: @@ -123,131 +251,24 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; // The flow velocity at the adjacent cell centre - scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); tmp tnutw(new scalarField(patch().size(), 0.0)); scalarField& nutw = tnutw(); - if (roughnessHeight_ > 0.0) + forAll(yPlus, facei) { - // Rough Walls - const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; - static const scalar c_2 = 2.25/(90 - 2.25); - static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); - static const scalar c_4 = c_3*log(2.25); - - //if (KsPlusBasedOnYPlus_) + if (yPlus[facei] > yPlusLam) { - // If KsPlus is based on YPlus the extra term added to the law - // of the wall will depend on yPlus. - forAll(nutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = magUpara*y[facei]/nuw[facei]; - const scalar kappaRe = kappa_*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; - - // Enforce the roughnessHeight to be less than the distance to - // the first cell centre - if (dKsPlusdYPlus > 1) - { - dKsPlusdYPlus = 1; - } - - // Additional tuning parameter (fudge factor) - nominally = 1 - dKsPlusdYPlus *= roughnessFudgeFactor_; - - do - { - yPlusLast = yPlus; - - // The non-dimensional roughness height. - scalar KsPlus = yPlus*dKsPlusdYPlus; - - // The extra term in the law-of-the-wall. - scalar G = 0.0; - - scalar yPlusGPrime = 0.0; - - if (KsPlus >= 90) - { - const scalar t_1 = 1 + roughnessConstant_*KsPlus; - G = log(t_1); - yPlusGPrime = roughnessConstant_*KsPlus/t_1; - } - else if (KsPlus > 2.25) - { - const scalar t_1 = c_1*KsPlus - c_2; - const scalar t_2 = c_3*log(KsPlus) - c_4; - const scalar sint_2 = sin(t_2); - const scalar logt_1 = log(t_1); - G = logt_1*sint_2; - yPlusGPrime = - (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); - } - - scalar denom = 1.0 + log(E_*yPlus) - G - yPlusGPrime; - if (mag(denom) > VSMALL) - { - yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom; - } - else - { - // Ensure immediate end and nutw = 0. - yPlus = 0; - } - - } while - ( - mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 - && ++iter < 10 - && yPlus > VSMALL - ); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); - } - } - } - } - else - { - // Smooth Walls. - forAll(nutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = magUpara*y[facei]/nuw[facei]; - const scalar kappaRe = kappa_*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do - { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); - - } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 && ++iter < 10); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); - } + const scalar Re = magUp[facei]*y[facei]/nuw[facei]; + nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1); } } @@ -258,13 +279,13 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const tmp nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const { - notImplemented - ( - "nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus()" - "const" - ); + const label patchI = patch().index(); - return tmp(NULL); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + + return calcYPlus(magUp); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H index 5e819756db..8d72e5ad13 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -72,6 +72,9 @@ class nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField // Protected member functions + //- Calculate yPLus + virtual tmp calcYPlus(const scalarField& magUp) const; + //- Calculate the turbulence viscosity virtual tmp calcNut() const; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index aef85e9b38..25c9b87d98 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -39,6 +39,48 @@ namespace incompressible namespace RASModels { +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +tmp +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus +( + const scalarField& magUp +) const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + tmp tyPlus(new scalarField(patch().size(), 0.0)); + scalarField& yPlus = tyPlus(); + + forAll(yPlus, facei) + { + scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; + + scalar yp = yPlusLam; + scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yp; + yPlus = (kappaRe + yp)/(1.0 + log(E_*yp)); + + } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 ); + + yPlus[facei] = yp; + } + + return tyPlus; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: @@ -107,37 +149,22 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + tmp tnutw(new scalarField(patch().size(), 0.0)); scalarField& nutw = tnutw(); - forAll(nutw, facei) + forAll(yPlus, facei) { - scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; - - scalar yPlus = yPlusLam; - scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do + if (yPlus[facei] > yPlusLam) { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); - - } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*kappa_/log(E_*yPlus) - 1.0); + nutw[facei] = + nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); } } @@ -148,13 +175,12 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const tmp nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const { - notImplemented - ( - "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() " - "const" - ); + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); - return tmp(NULL); + return calcYPlus(magUp); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H index 80e525569a..f54bb57c8a 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -60,6 +60,9 @@ protected: // Protected member functions + //- Calculate yPLus + virtual tmp calcYPlus(const scalarField& magUp) const; + //- Calculate the turbulence viscosity virtual tmp calcNut() const; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C index 80aa3e3199..ff02c3043b 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -167,9 +167,7 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magGradU = mag(Uw.snGrad()); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; return max(0.0, sqr(calcUTau(magGradU))/magGradU - nuw); @@ -183,9 +181,7 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; return y*calcUTau(mag(Uw.snGrad()))/nuw; From 01903e5e8f5e9397467b4f6693fefb772e730a61 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Jul 2009 15:18:00 +0100 Subject: [PATCH 2/4] further updates to wall function calcs --- ...ndardRoughWallFunctionFvPatchScalarField.C | 275 ++++++++++-------- ...ndardRoughWallFunctionFvPatchScalarField.H | 3 + ...asStandardWallFunctionFvPatchScalarField.C | 86 ++++-- ...asStandardWallFunctionFvPatchScalarField.H | 3 + ...ndardRoughWallFunctionFvPatchScalarField.C | 2 +- ...asStandardWallFunctionFvPatchScalarField.C | 6 +- 6 files changed, 212 insertions(+), 163 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index 172cfb0db5..351f4ca80d 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -39,6 +39,137 @@ namespace compressible namespace RASModels { +tmp +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus +( + const scalarField& magUp +) const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; + + tmp tyPlus(new scalarField(patch().size(), 0.0)); + scalarField& yPlus = tyPlus(); + + if (roughnessHeight_ > 0.0) + { + // Rough Walls + const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; + static const scalar c_2 = 2.25/(90 - 2.25); + static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); + static const scalar c_4 = c_3*log(2.25); + + //if (KsPlusBasedOnYPlus_) + { + // If KsPlus is based on YPlus the extra term added to the law + // of the wall will depend on yPlus + forAll(yPlus, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; + const scalar kappaRe = kappa_*Re; + + scalar yp = yPlusLam; + const scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; + + // Enforce the roughnessHeight to be less than the distance to + // the first cell centre. + if (dKsPlusdYPlus > 1) + { + dKsPlusdYPlus = 1; + } + + // Additional tuning parameter (fudge factor) - nominally = 1 + dKsPlusdYPlus *= roughnessFudgeFactor_; + + do + { + yPlusLast = yp; + + // The non-dimensional roughness height + scalar KsPlus = yp*dKsPlusdYPlus; + + // The extra term in the law-of-the-wall + scalar G = 0.0; + + scalar yPlusGPrime = 0.0; + + if (KsPlus >= 90) + { + const scalar t_1 = 1 + roughnessConstant_*KsPlus; + G = log(t_1); + yPlusGPrime = roughnessConstant_*KsPlus/t_1; + } + else if (KsPlus > 2.25) + { + const scalar t_1 = c_1*KsPlus - c_2; + const scalar t_2 = c_3*log(KsPlus) - c_4; + const scalar sint_2 = sin(t_2); + const scalar logt_1 = log(t_1); + G = logt_1*sint_2; + yPlusGPrime = + (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); + } + + scalar denom = 1.0 + log(E_*yp) - G - yPlusGPrime; + if (mag(denom) > VSMALL) + { + yp = kappaRe + yp*(1 - yPlusGPrime))/denom; + } + + } while + ( + mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 + && ++iter < 10 + && yp > VSMALL + ); + + yPlus[facei] = max(0.0, yp); + } + } + } + else + { + // Smooth Walls + forAll(yPlus, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; + const scalar kappaRe = kappa_*Re; + + scalar yp = yPlusLam; + const scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yp; + yp = (kappaRe + yp)/(1.0 + log(E_*yp)); + + } while + ( + mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 + && ++iter < 10 + ); + + yPlus[facei] = max(0.0, yp); + } + } + + return tyPlus; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: @@ -123,140 +254,24 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; scalarField magUp = mag(Uw.patchInternalField() - Uw); - const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); tmp tmutw(new scalarField(patch().size(), 0.0)); scalarField& mutw = tmutw(); - if (roughnessHeight_ > 0.0) + forAll(yPlus, facei) { - // Rough Walls. - const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; - static const scalar c_2 = 2.25/(90 - 2.25); - static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); - static const scalar c_4 = c_3*log(2.25); - - //if (KsPlusBasedOnYPlus_) + if (yPlus[facei] > yPlusLam) { - // If KsPlus is based on YPlus the extra term added to the law - // of the wall will depend on yPlus. - forAll(mutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; - const scalar kappaRe = kappa_*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; - - // Enforce the roughnessHeight to be less than the distance to - // the first cell centre. - if (dKsPlusdYPlus > 1) - { - dKsPlusdYPlus = 1; - } - - // Additional tuning parameter (fudge factor) - nominally = 1 - dKsPlusdYPlus *= roughnessFudgeFactor_; - - do - { - yPlusLast = yPlus; - - // The non-dimensional roughness height - scalar KsPlus = yPlus*dKsPlusdYPlus; - - // The extra term in the law-of-the-wall - scalar G = 0.0; - - scalar yPlusGPrime = 0.0; - - if (KsPlus >= 90) - { - const scalar t_1 = 1 + roughnessConstant_*KsPlus; - G = log(t_1); - yPlusGPrime = roughnessConstant_*KsPlus/t_1; - } - else if (KsPlus > 2.25) - { - const scalar t_1 = c_1*KsPlus - c_2; - const scalar t_2 = c_3*log(KsPlus) - c_4; - const scalar sint_2 = sin(t_2); - const scalar logt_1 = log(t_1); - G = logt_1*sint_2; - yPlusGPrime = - (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); - } - - scalar denom = 1.0 + log(E_*yPlus) - G - yPlusGPrime; - if (mag(denom) > VSMALL) - { - yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom; - if( yPlus < 0 ) - { - yPlus = 0; - } - } - else - { - // Ensure immediate end and mutw = 0 - yPlus = 0; - } - - } while - ( - mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 - && ++iter < 10 - && yPlus > VSMALL - ); - - if (yPlus > yPlusLam) - { - mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); - } - } - } - } - else - { - // Smooth Walls - forAll(mutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; - const scalar kappaRe = kappa_*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do - { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); - - } while - ( - mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 - && ++iter < 10 - ); - - if (yPlus > yPlusLam) - { - mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); - } + const scalar Re = rho[facei]*magUp[facei]*y[facei]/muw[facei]; + mutw[facei] = muw[facei]*(sqr(yPlus[facei])/Re - 1); } } @@ -267,13 +282,13 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const tmp mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const { - notImplemented - ( - "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus()" - "const" - ); + const label patchI = patch().index(); - return tmp(NULL); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + + return calcYPlus(magUp); } @@ -283,6 +298,8 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write ) const { fixedValueFvPatchScalarField::write(os); + os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessHeight") << roughnessHeight_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessConstant") diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H index e2434c8183..2414825d21 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -74,6 +74,9 @@ protected: // Protected member functions + //- Calculate yPLus + virtual tmp calcYPlus(const scalarField& magUp) const; + //- Calculate the turbulence viscosity virtual tmp calcMut() const; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index f2337dab47..493cf1598d 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -39,6 +39,50 @@ namespace compressible namespace RASModels { +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus +( + const scalarField& magUp +) const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; + const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; + + tmp tyPlus(new scalarField(patch().size(), 0.0)); + scalarField& yPlus = tyPlus(); + + forAll(yPlus, faceI) + { + scalar kappaRe = kappa_*magUp[facei]*y[faceI]/(muw[faceI]/rhow[faceI]); + + scalar yp = yPlusLam; + scalar ryPlusLam = 1.0/yp; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yp; + yp = (kappaRe + yp)/(1.0 + log(E_*yp)); + + } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10); + + yPlus[facei] = max(0.0, yp); + } + + return tyPlus; + +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: @@ -108,40 +152,23 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + tmp tmutw(new scalarField(patch().size(), 0.0)); scalarField& mutw = tmutw(); - forAll(mutw, faceI) + forAll(yPlus, faceI) { - scalar magUpara = magUp[faceI]; - - scalar kappaRe = kappa_*magUpara*y[faceI]/(muw[faceI]/rhow[faceI]); - - scalar yPlus = yPlusLam; - scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do + if (yPlus[facei] > yPlusLam) { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); - - } while (mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10); - - if (yPlus > yPlusLam) - { - mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0); + mutw[faceI] = + muw[faceI]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); } } @@ -152,13 +179,12 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const tmp mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const { - notImplemented - ( - "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() " - "const" - ); + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); - return tmp(NULL); + return calcYPlus(magUp); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H index 6813e59667..09ba112ce4 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -60,6 +60,9 @@ protected: // Protected member functions + //- Calculate yPLus + virtual tmp calcYPlus(const scalarField& magUp) const; + //- Calculate the turbulence viscosity virtual tmp calcMut() const; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index d6b96ed5b4..f44da462b9 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -155,7 +155,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus do { yPlusLast = yp; - yPlus = (kappaRe + yp)/(1.0 + log(E_*yp)); + yp = (kappaRe + yp)/(1.0 + log(E_*yp)); } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index 25c9b87d98..450c857a75 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -39,7 +39,7 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus @@ -70,11 +70,11 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus do { yPlusLast = yp; - yPlus = (kappaRe + yp)/(1.0 + log(E_*yp)); + yp = (kappaRe + yp)/(1.0 + log(E_*yp)); } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 ); - yPlus[facei] = yp; + yPlus[facei] = max(0.0, yp); } return tyPlus; From 85b9b3e38a2711df36ff16168b5bb10ef8460449 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Jul 2009 16:40:50 +0100 Subject: [PATCH 3/4] adding yPlus calcs for compressible S-A models + other small fixes --- .../mutRoughWallFunctionFvPatchScalarField.C | 16 ++++++---------- ...StandardRoughWallFunctionFvPatchScalarField.C | 6 +++--- ...marasStandardWallFunctionFvPatchScalarField.C | 16 ++++++---------- ...alartAllmarasWallFunctionFvPatchScalarField.C | 11 ++--------- .../mutWallFunctionFvPatchScalarField.C | 8 +++++++- .../mutWallFunctionFvPatchScalarField.H | 3 +++ .../nutRoughWallFunctionFvPatchScalarField.C | 4 +--- ...StandardRoughWallFunctionFvPatchScalarField.C | 6 +++--- ...marasStandardWallFunctionFvPatchScalarField.C | 6 +++--- ...alartAllmarasWallFunctionFvPatchScalarField.C | 9 ++++----- .../nutWallFunctionFvPatchScalarField.C | 11 ++++++++--- .../nutWallFunctionFvPatchScalarField.H | 3 +++ 12 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C index 4fe171f2fd..ed4acb4da0 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C @@ -67,8 +67,7 @@ scalar mutRoughWallFunctionFvPatchScalarField::fnRough // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -mutRoughWallFunctionFvPatchScalarField:: -mutRoughWallFunctionFvPatchScalarField +mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF @@ -80,8 +79,7 @@ mutRoughWallFunctionFvPatchScalarField {} -mutRoughWallFunctionFvPatchScalarField:: -mutRoughWallFunctionFvPatchScalarField +mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField ( const mutRoughWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -95,8 +93,7 @@ mutRoughWallFunctionFvPatchScalarField {} -mutRoughWallFunctionFvPatchScalarField:: -mutRoughWallFunctionFvPatchScalarField +mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -109,8 +106,7 @@ mutRoughWallFunctionFvPatchScalarField {} -mutRoughWallFunctionFvPatchScalarField:: -mutRoughWallFunctionFvPatchScalarField +mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField ( const mutRoughWallFunctionFvPatchScalarField& rwfpsf ) @@ -121,8 +117,7 @@ mutRoughWallFunctionFvPatchScalarField {} -mutRoughWallFunctionFvPatchScalarField:: -mutRoughWallFunctionFvPatchScalarField +mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField ( const mutRoughWallFunctionFvPatchScalarField& rwfpsf, const DimensionedField& iF @@ -221,6 +216,7 @@ tmp mutRoughWallFunctionFvPatchScalarField::calcMut() const void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); + writeLocalEntries(os); Cs_.writeEntry("Cs", os); Ks_.writeEntry("Ks", os); writeEntry("value", os); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index 351f4ca80d..c187661095 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -48,6 +48,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const scalarField& muw = rasModel.mu().boundaryField()[patchI]; const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; @@ -122,7 +123,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus scalar denom = 1.0 + log(E_*yp) - G - yPlusGPrime; if (mag(denom) > VSMALL) { - yp = kappaRe + yp*(1 - yPlusGPrime))/denom; + yp = (kappaRe + yp*(1 - yPlusGPrime))/denom; } } while @@ -298,8 +299,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write ) const { fixedValueFvPatchScalarField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + writeLocalEntries(os); os.writeKeyword("roughnessHeight") << roughnessHeight_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessConstant") diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index 493cf1598d..052b22664b 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -42,7 +42,7 @@ namespace RASModels // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp -nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus ( const scalarField& magUp ) const @@ -60,7 +60,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus forAll(yPlus, faceI) { - scalar kappaRe = kappa_*magUp[facei]*y[faceI]/(muw[faceI]/rhow[faceI]); + scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]); scalar yp = yPlusLam; scalar ryPlusLam = 1.0/yp; @@ -75,11 +75,10 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10); - yPlus[facei] = max(0.0, yp); + yPlus[faceI] = max(0.0, yp); } return tyPlus; - } @@ -151,10 +150,8 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI]; const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; tmp tyPlus = calcYPlus(magUp); @@ -165,10 +162,10 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const forAll(yPlus, faceI) { - if (yPlus[facei] > yPlusLam) + if (yPlus[faceI] > yPlusLam) { mutw[faceI] = - muw[faceI]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); + muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0); } } @@ -194,8 +191,7 @@ void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write ) const { fvPatchField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + writeLocalEntries(os); writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C index c8454c4c7f..23874146ea 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -39,7 +39,7 @@ namespace compressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau ( @@ -173,11 +173,8 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const const RASModel& rasModel = db().lookupObject("RASProperties"); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magGradU = mag(Uw.snGrad()); - const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = rasModel.mu().boundaryField()[patchI]; return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw); @@ -191,11 +188,8 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const const RASModel& rasModel = db().lookupObject("RASProperties"); const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = rasModel.mu().boundaryField()[patchI]; return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow); @@ -208,8 +202,7 @@ void mutSpalartAllmarasWallFunctionFvPatchScalarField::write ) const { fvPatchField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + writeLocalEntries(os); writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C index e7cdea1dea..dcd52cc4e1 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C @@ -189,10 +189,16 @@ tmp mutWallFunctionFvPatchScalarField::yPlus() const void mutWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); + writeLocalEntries(os); + writeEntry("value", os); +} + + +void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; - writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H index 962790c510..3945c345e9 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H @@ -79,6 +79,9 @@ protected: //- Calculate the turbulence viscosity virtual tmp calcMut() const; + //- Write local wall function variables + virtual void writeLocalEntries(Ostream&) const; + public: diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C index 49980bde53..e26e652a1a 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C @@ -223,9 +223,7 @@ tmp nutRoughWallFunctionFvPatchScalarField::calcNut() const void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + writeLocalEntries(os); Cs_.writeEntry("Cs", os); Ks_.writeEntry("Ks", os); writeEntry("value", os); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index f44da462b9..e2de2dae71 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -294,15 +294,15 @@ void nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write Ostream& os ) const { - fixedValueFvPatchScalarField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + fvPatchField::write(os); + writeLocalEntries(os); os.writeKeyword("roughnessHeight") << roughnessHeight_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessConstant") << roughnessConstant_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessFudgeFactor") << roughnessFudgeFactor_ << token::END_STATEMENT << nl; + writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index 450c857a75..7bea1742fb 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -189,9 +189,9 @@ void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write Ostream& os ) const { - fixedValueFvPatchScalarField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + fvPatchField::write(os); + writeLocalEntries(os); + writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C index ff02c3043b..99187abb64 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -51,8 +51,7 @@ tmp nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patch().index()]; - - scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField magUp = mag(Uw.patchInternalField() - Uw); const scalarField& nuw = rasModel.nu().boundaryField()[patch().index()]; const scalarField& nutw = *this; @@ -193,9 +192,9 @@ void nutSpalartAllmarasWallFunctionFvPatchScalarField::write Ostream& os ) const { - fixedValueFvPatchScalarField::write(os); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; + fvPatchField::write(os); + writeLocalEntries(os); + writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 7a975c7326..0fdefb2b51 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -40,7 +40,7 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void nutWallFunctionFvPatchScalarField::checkType() { @@ -158,7 +158,6 @@ tmp nutWallFunctionFvPatchScalarField::calcNut() const const scalar Cmu25 = pow(Cmu_, 0.25); - tmp tnutw(new scalarField(patch().size(), 0.0)); scalarField& nutw = tnutw(); @@ -197,10 +196,16 @@ tmp nutWallFunctionFvPatchScalarField::yPlus() const void nutWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); + writeLocalEntries(os); + writeEntry("value", os); +} + + +void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; - writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index d37d63f53b..cb68c36f1f 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -79,6 +79,9 @@ protected: //- Calculate the turbulence viscosity virtual tmp calcNut() const; + //- Write local wall function variables + virtual void writeLocalEntries(Ostream&) const; + public: From 1ce132fb2a6f739150ddd64a450628208d45559b Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Jul 2009 17:07:42 +0100 Subject: [PATCH 4/4] code clean-up --- .../pdfs/RosinRammler/RosinRammler.C | 46 ++++++-------- .../pdfs/RosinRammler/RosinRammler.H | 17 +++--- .../pdfs/exponential/exponential.C | 46 ++++++-------- .../pdfs/exponential/exponential.H | 18 +++--- .../pdfs/general/general.C | 60 ++++++++----------- .../pdfs/general/general.H | 20 +++---- src/thermophysicalModels/pdfs/normal/normal.C | 51 ++++++---------- src/thermophysicalModels/pdfs/normal/normal.H | 21 ++++--- src/thermophysicalModels/pdfs/pdf/newPdf.C | 12 ++-- src/thermophysicalModels/pdfs/pdf/pdf.C | 22 ++----- src/thermophysicalModels/pdfs/pdf/pdf.H | 54 +++++++---------- .../pdfs/uniform/uniform.C | 35 ++++------- .../pdfs/uniform/uniform.H | 21 ++++--- 13 files changed, 173 insertions(+), 250 deletions(-) diff --git a/src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.C b/src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.C index 1adf2d1352..36b84679ed 100644 --- a/src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.C +++ b/src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.C @@ -24,33 +24,21 @@ License \*---------------------------------------------------------------------------*/ - #include "RosinRammler.H" #include "addToRunTimeSelectionTable.H" -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(RosinRammler, 0); +namespace Foam +{ + defineTypeNameAndDebug(RosinRammler, 0); -addToRunTimeSelectionTable -( - pdf, - RosinRammler, - dictionary -); + addToRunTimeSelectionTable(pdf, RosinRammler, dictionary); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -RosinRammler::RosinRammler -( - const dictionary& dict, - Random& rndGen -) +Foam::RosinRammler::RosinRammler(const dictionary& dict, Random& rndGen) : pdf(dict, rndGen), pdfDict_(dict.subDict(typeName + "PDF")), @@ -80,10 +68,10 @@ RosinRammler::RosinRammler // find max value so that it can be normalized to 1.0 scalar sMax = 0; label n = d_.size(); - for(label i=0; ixy_[i][0]) && (x xy_; label nEntries_; + //- min and max values of the distribution scalar minValue_; scalar maxValue_; scalar range_; + public: //- Runtime type information - TypeName("general"); + TypeName("general"); // Constructors @@ -85,17 +87,19 @@ public: // Destructor - - ~general(); + virtual ~general(); // Member Functions - scalar sample() const; + //- Sample the pdf + virtual scalar sample() const; - scalar minValue() const; - scalar maxValue() const; + //- Return the minimum value + virtual scalar minValue() const; + //- Return the maximum value + virtual scalar maxValue() const; }; @@ -105,10 +109,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//#include "generalI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/thermophysicalModels/pdfs/normal/normal.C b/src/thermophysicalModels/pdfs/normal/normal.C index a4b26f7517..f8633c270b 100644 --- a/src/thermophysicalModels/pdfs/normal/normal.C +++ b/src/thermophysicalModels/pdfs/normal/normal.C @@ -24,33 +24,20 @@ License \*---------------------------------------------------------------------------*/ - #include "normal.H" #include "addToRunTimeSelectionTable.H" -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(normal, 0); - -addToRunTimeSelectionTable -( - pdf, - normal, - dictionary -); +namespace Foam +{ + defineTypeNameAndDebug(normal, 0); + addToRunTimeSelectionTable(pdf, normal, dictionary); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -normal::normal -( - const dictionary& dict, - Random& rndGen -) +Foam::normal::normal(const dictionary& dict, Random& rndGen) : pdf(dict, rndGen), pdfDict_(dict.subDict(typeName + "PDF")), @@ -63,11 +50,11 @@ normal::normal { scalar sMax = 0; label n = strength_.size(); - for(label i=0; i Foam::pdf::New +Foam::autoPtr Foam::pdf::New ( const dictionary& dict, Random& rndGen @@ -47,8 +44,8 @@ autoPtr Foam::pdf::New if (cstrIter == dictionaryConstructorTablePtr_->end()) { FatalErrorIn("pdf::New(const dictionary&, Random&)") - << "unknown pdf type " << pdfType << endl << endl - << "Valid pdf types are :" << endl + << "unknown pdf type " << pdfType << nl << nl + << "Valid pdf types are:" << nl << dictionaryConstructorTablePtr_->toc() << exit(FatalError); } @@ -56,6 +53,5 @@ autoPtr Foam::pdf::New return autoPtr(cstrIter()(dict, rndGen)); } -// ************************************************************************* // -} +// ************************************************************************* // diff --git a/src/thermophysicalModels/pdfs/pdf/pdf.C b/src/thermophysicalModels/pdfs/pdf/pdf.C index f1b9ebb76f..21945ca786 100644 --- a/src/thermophysicalModels/pdfs/pdf/pdf.C +++ b/src/thermophysicalModels/pdfs/pdf/pdf.C @@ -27,24 +27,16 @@ License #include "pdf.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + namespace Foam { - -defineTypeNameAndDebug(pdf, 0); - -defineRunTimeSelectionTable(pdf, dictionary); - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - + defineTypeNameAndDebug(pdf, 0); + defineRunTimeSelectionTable(pdf, dictionary); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components -pdf::pdf -( - const dictionary& dict, - Random& rndGen -) +Foam::pdf::pdf(const dictionary& dict, Random& rndGen) : dict_(dict), rndGen_(rndGen) @@ -53,10 +45,8 @@ pdf::pdf // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -pdf::~pdf() +Foam::pdf::~pdf() {} // ************************************************************************* // - -} // end namespace Foam diff --git a/src/thermophysicalModels/pdfs/pdf/pdf.H b/src/thermophysicalModels/pdfs/pdf/pdf.H index 1e4f0f417d..ef1fa11b92 100644 --- a/src/thermophysicalModels/pdfs/pdf/pdf.H +++ b/src/thermophysicalModels/pdfs/pdf/pdf.H @@ -91,44 +91,35 @@ protected: public: //-Runtime type information - TypeName("pdf"); + TypeName("pdf"); - // Declare runtime constructor selection table - declareRunTimeSelectionTable + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + pdf, + dictionary, ( - autoPtr, - pdf, - dictionary, - ( - const dictionary& dict, - Random& rndGen - ), - (dict, rndGen) - ); + const dictionary& dict, + Random& rndGen + ), + (dict, rndGen) + ); // Constructors - + //- Construct from dictionary - pdf - ( - const dictionary& dict, - Random& rndGen - ); - - // Selectors - - static autoPtr New - ( - const dictionary& dict, - Random& rndGen - ); + pdf(const dictionary& dict, Random& rndGen); - // Destructor + //- Selector + static autoPtr New(const dictionary& dict, Random& rndGen); - virtual ~pdf(); + + //- Destructor + virtual ~pdf(); // Member Functions @@ -136,7 +127,10 @@ public: //- Sample the pdf virtual scalar sample() const = 0; + //- Return the minimum value virtual scalar minValue() const = 0; + + //- Return the maximum value virtual scalar maxValue() const = 0; }; @@ -147,10 +141,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//#include "pdfI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/thermophysicalModels/pdfs/uniform/uniform.C b/src/thermophysicalModels/pdfs/uniform/uniform.C index 31fcac6195..988c337071 100644 --- a/src/thermophysicalModels/pdfs/uniform/uniform.C +++ b/src/thermophysicalModels/pdfs/uniform/uniform.C @@ -27,29 +27,17 @@ License #include "uniform.H" #include "addToRunTimeSelectionTable.H" -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(uniform, 0); - -addToRunTimeSelectionTable -( - pdf, - uniform, - dictionary -); +namespace Foam +{ + defineTypeNameAndDebug(uniform, 0); + addToRunTimeSelectionTable(pdf, uniform, dictionary); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -uniform::uniform -( - const dictionary& dict, - Random& rndGen -) +Foam::uniform::uniform(const dictionary& dict, Random& rndGen) : pdf(dict, rndGen), pdfDict_(dict.subDict(typeName + "PDF")), @@ -67,21 +55,22 @@ Foam::uniform::~uniform() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -scalar uniform::sample() const +Foam::scalar Foam::uniform::sample() const { return (minValue_ + rndGen_.scalar01()*range_); } -scalar uniform::minValue() const + +Foam::scalar Foam::uniform::minValue() const { return minValue_; } -scalar uniform::maxValue() const + +Foam::scalar Foam::uniform::maxValue() const { return maxValue_; } -// ************************************************************************* // -} +// ************************************************************************* // diff --git a/src/thermophysicalModels/pdfs/uniform/uniform.H b/src/thermophysicalModels/pdfs/uniform/uniform.H index 96764ed351..86b7542f34 100644 --- a/src/thermophysicalModels/pdfs/uniform/uniform.H +++ b/src/thermophysicalModels/pdfs/uniform/uniform.H @@ -56,6 +56,7 @@ class uniform // Private data dictionary pdfDict_; + //- min and max values of the distribution scalar minValue_; scalar maxValue_; @@ -67,7 +68,7 @@ class uniform public: //- Runtime type information - TypeName("uniform"); + TypeName("uniform"); // Constructors @@ -80,18 +81,20 @@ public: ); - // Destructor - - ~uniform(); + //- Destructor + virtual ~uniform(); // Member Functions - scalar sample() const; + //- Sample the pdf + virtual scalar sample() const; - scalar minValue() const; - scalar maxValue() const; + //- Return the minimum value + virtual scalar minValue() const; + //- Return the maximum value + virtual scalar maxValue() const; }; @@ -101,10 +104,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//#include "uniformI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* //