39 Foam::nutURoughWallFunctionFvPatchScalarField::calcNut()
const 41 const label patchi =
patch().index();
48 internalField().
group()
56 const tmp<scalarField> tnuw = turbModel.nu(patchi);
64 tmp<scalarField> tyPlus = calcYPlus(
magUp);
68 auto&
nutw = tnutw.ref();
72 if (yPlusLam <
yPlus[facei])
74 const scalar
Re =
magUp[facei]*
y[facei]/nuw[facei] + ROOTVSMALL;
84 Foam::nutURoughWallFunctionFvPatchScalarField::calcYPlus
89 const label patchi =
patch().index();
96 internalField().
group()
102 const tmp<scalarField> tnuw = turbModel.nu(patchi);
105 const scalar
kappa = wallCoeffs_.kappa();
106 const scalar E = wallCoeffs_.E();
107 const scalar yPlusLam = wallCoeffs_.yPlusLam();
110 auto&
yPlus = tyPlus.ref();
112 if (roughnessHeight_ > 0.0)
115 const scalar c_1 = 1.0/(90.0 - 2.25) + roughnessConstant_;
116 static const scalar c_2 = 2.25/(90.0 - 2.25);
117 static const scalar c_3 = 2.0*
atan(1.0)/
log(90.0/2.25);
118 static const scalar c_4 = c_3*
log(2.25);
125 const scalar magUpara =
magUp[facei];
126 const scalar
Re = magUpara*
y[facei]/nuw[facei];
127 const scalar kappaRe =
kappa*
Re;
129 scalar yp = yPlusLam;
130 const scalar ryPlusLam = 1.0/yp;
133 scalar yPlusLast = 0.0;
134 scalar dKsPlusdYPlus = roughnessHeight_/
y[facei];
137 dKsPlusdYPlus *= roughnessFactor_;
144 const scalar KsPlus = yp*dKsPlusdYPlus;
149 scalar yPlusGPrime = 0;
153 const scalar t_1 = 1 + roughnessConstant_*KsPlus;
155 yPlusGPrime = roughnessConstant_*KsPlus/t_1;
157 else if (KsPlus > 2.25)
159 const scalar t_1 = c_1*KsPlus - c_2;
160 const scalar t_2 = c_3*
log(KsPlus) - c_4;
161 const scalar sint_2 =
sin(t_2);
162 const scalar logt_1 =
log(t_1);
165 (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*
cos(t_2));
168 const scalar denom = 1.0 +
log(E*yp) -
G - yPlusGPrime;
169 if (
mag(denom) > VSMALL)
171 yp = (kappaRe + yp*(1 - yPlusGPrime))/denom;
175 mag(ryPlusLam*(yp - yPlusLast)) > tolerance_
189 const scalar magUpara =
magUp[facei];
190 const scalar
Re = magUpara*
y[facei]/nuw[facei];
191 const scalar kappaRe =
kappa*
Re;
193 scalar yp = yPlusLam;
194 const scalar ryPlusLam = 1.0/yp;
197 scalar yPlusLast = 0;
202 yp = (kappaRe + yp)/(1.0 +
log(E*yp));
207 mag(ryPlusLam*(yp - yPlusLast)) > tolerance_
219 void Foam::nutURoughWallFunctionFvPatchScalarField::writeLocalEntries
242 roughnessHeight_(
Zero),
243 roughnessConstant_(
Zero),
244 roughnessFactor_(
Zero),
260 roughnessHeight_(ptf.roughnessHeight_),
261 roughnessConstant_(ptf.roughnessConstant_),
262 roughnessFactor_(ptf.roughnessFactor_),
263 maxIter_(ptf.maxIter_),
264 tolerance_(ptf.tolerance_)
277 roughnessHeight_(
dict.
get<scalar>(
"roughnessHeight")),
278 roughnessConstant_(
dict.
get<scalar>(
"roughnessConstant")),
279 roughnessFactor_(
dict.
get<scalar>(
"roughnessFactor")),
280 maxIter_(
dict.getOrDefault<label>(
"maxIter", 10)),
281 tolerance_(
dict.getOrDefault<scalar>(
"tolerance", 0.0001))
292 roughnessHeight_(rwfpsf.roughnessHeight_),
293 roughnessConstant_(rwfpsf.roughnessConstant_),
294 roughnessFactor_(rwfpsf.roughnessFactor_),
295 maxIter_(rwfpsf.maxIter_),
296 tolerance_(rwfpsf.tolerance_)
308 roughnessHeight_(rwfpsf.roughnessHeight_),
309 roughnessConstant_(rwfpsf.roughnessConstant_),
310 roughnessFactor_(rwfpsf.roughnessFactor_),
311 maxIter_(rwfpsf.maxIter_),
312 tolerance_(rwfpsf.tolerance_)
321 const label patchi =
patch().index();
328 internalField().
group()
335 return calcYPlus(
magUp());
345 writeLocalEntries(
os);
357 nutURoughWallFunctionFvPatchScalarField
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
scalar yPlusLam() const noexcept
Return the object: yPlusLam.
virtual const volVectorField & U(const turbulenceModel &turb) const
Helper to return the velocity field either from the turbulence model (default) or the mesh database...
fvPatchField< vector > fvPatchVectorField
This boundary condition provides a wall function on the turbulent viscosity (i.e. nut) based on veloc...
dimensionedScalar log(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const dimensionedScalar G
Newtonian constant of gravitation.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Abstract base class for turbulence models (RAS, LES and laminar).
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
constexpr const char *const group
Group name for atomic constants.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
The class nutWallFunction is an abstract base class that hosts calculation methods and common functi...
dimensionedScalar cos(const dimensionedScalar &ds)
fvPatchField< scalar > fvPatchScalarField
static const word propertiesName
Default name of the turbulence properties dictionary.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
dimensionedScalar sin(const dimensionedScalar &ds)
virtual void write(Ostream &) const
Write.
OBJstream os(runTime.globalPath()/outputName)
virtual void write(Ostream &os) const
Write.
scalarField Re(const UList< complex > &cmplx)
Extract real component.
nutURoughWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
dimensionedScalar atan(const dimensionedScalar &ds)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
wallFunctionCoefficients wallCoeffs_
Wall-function coefficients.
A class for managing temporary objects.
static const nutWallFunctionFvPatchScalarField & nutw(const turbulenceModel &turbModel, const label patchi)
Return the nut patchField for the given wall patch.
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
static constexpr const zero Zero
Global zero (0)