53 for (
int iter = 0; iter < 10; ++iter)
56 ypl = (
log(
max(E*ypl, scalar(1)))/
kappa + Pc)*Sct/Sc;
65 tmp<scalarField> sorptionWallFunctionFvPatchScalarField::yPlus()
const 68 const label patchi =
patch().index();
71 tmp<scalarField> tkwc =
k.boundaryField()[patchi].patchInternalField();
75 tmp<scalarField> tnuwc =
nu.boundaryField()[patchi].patchInternalField();
79 tmp<scalarField> tywc =
y.boundaryField()[patchi].patchInternalField();
85 9.24*(
pow(Sc_/Sct_, 0.75) - 1)*(1 + 0.28*
exp(-0.007*Sc_/Sct_));
86 const scalar Cmu25 =
pow025(wallCoeffs_.
Cmu());
88 const scalar E = wallCoeffs_.
E();
91 auto& yPlus = tyPlus.ref();
96 const scalar yStar = Cmu25*
sqrt(kwc[facei])*ywc[facei]/nuwc[facei];
99 const scalar yPlusVis = Sc_*yStar;
102 const scalar yPlusLog = Sct_*(
log(
max(E*yStar, 1 + 1
e-4))/
kappa + Pc);
106 case blenderType::EXPONENTIAL:
110 0.01*
pow4(Sc_*yStar)/(1 + 5*
pow3(Sc_)*yStar);
111 const scalar invGamma = scalar(1)/
max(Gamma, ROOTVSMALL);
114 yPlus[facei] = yPlusVis*
exp(-Gamma) + yPlusLog*
exp(-invGamma);
118 case blenderType::STEPWISE:
120 static const scalar yStarLam =
124 if (yStar < yStarLam)
126 yPlus[facei] = yPlusVis;
130 yPlus[facei] = yPlusLog;
135 case blenderType::BINOMIAL:
146 case blenderType::MAX:
148 yPlus[facei] =
max(yPlusVis, yPlusLog);
152 case blenderType::TANH:
154 const scalar phiTanh =
tanh(
pow4(0.1*yStar));
155 const scalar b1 = yPlusVis + yPlusLog;
157 pow(
pow(yPlusVis, 1.2) +
pow(yPlusLog, 1.2), 1.0/1.2);
159 yPlus[facei] = phiTanh*b1 + (1 - phiTanh)*b2;
169 tmp<scalarField> sorptionWallFunctionFvPatchScalarField::flux()
const 172 const label patchi =
patch().index();
175 tmp<scalarField> tkwc =
k.boundaryField()[patchi].patchInternalField();
178 tmp<scalarField> tywc =
y.boundaryField()[patchi].patchInternalField();
182 tmp<scalarField> ta =
189 const auto& Csurf = *
this;
192 const scalar t = db().time().timeOutputValue();
193 tmp<scalarField> tkAbs = kAbsPtr_->value(t);
194 tmp<scalarField> tCstar = Csurf/tkAbs;
197 const word& fldName = internalField().name();
199 tmp<scalarField> tCwc =
C.boundaryField()[patchi].patchInternalField();
203 return (tCstar - tCwc)/ta;
207 void sorptionWallFunctionFvPatchScalarField::writeLocalEntries
213 os.writeEntryIfDifferent<
bool>(
"laminar",
false, laminar_);
214 os.writeEntry(
"Sc", Sc_);
215 os.writeEntry(
"Sct", Sct_);
216 os.writeEntryIfDifferent<scalar>(
"D", -1, D_);
218 os.writeEntryIfDifferent<word>(
"k",
"k", kName_);
219 os.writeEntryIfDifferent<word>(
"nu",
"nu", nuName_);
223 kAbsPtr_->writeData(
os);
236 fixedGradientFvPatchScalarField(
p, iF),
257 fixedGradientFvPatchScalarField(ptf,
p, iF, mapper),
259 laminar_(ptf.laminar_),
260 kAbsPtr_(ptf.kAbsPtr_.clone(
patch().
patch())),
265 nuName_(ptf.nuName_),
266 wallCoeffs_(ptf.wallCoeffs_)
277 fixedGradientFvPatchScalarField(
p, iF),
279 laminar_(
dict.getOrDefault<bool>(
"laminar", false)),
283 D_(
dict.getOrDefault<scalar>(
"D", -1)),
284 kName_(
dict.getOrDefault<
word>(
"k",
"k")),
285 nuName_(
dict.getOrDefault<
word>(
"nu",
"nu")),
293 <<
"Molecular diffusion coefficient cannot be non-positive. " 302 <<
"Adsorption or absorption coefficient is not set." 306 if (!this->readGradientEntry(
dict) || !this->readValueEntry(
dict))
308 extrapolateInternal();
316 const sorptionWallFunctionFvPatchScalarField& swfpsf
319 fixedGradientFvPatchScalarField(swfpsf),
320 wallFunctionBlenders(swfpsf),
321 laminar_(swfpsf.laminar_),
322 kAbsPtr_(swfpsf.kAbsPtr_.clone(
patch().
patch())),
326 kName_(swfpsf.kName_),
327 nuName_(swfpsf.nuName_),
328 wallCoeffs_(swfpsf.wallCoeffs_)
338 fixedGradientFvPatchScalarField(swfpsf, iF),
340 laminar_(swfpsf.laminar_),
341 kAbsPtr_(swfpsf.kAbsPtr_.clone(
patch().
patch())),
345 kName_(swfpsf.kName_),
346 nuName_(swfpsf.nuName_),
347 wallCoeffs_(swfpsf.wallCoeffs_)
358 fixedGradientFvPatchScalarField::autoMap(mapper);
362 kAbsPtr_->autoMap(mapper);
373 fixedGradientFvPatchScalarField::rmap(ptf, addr);
376 refCast<const sorptionWallFunctionFvPatchScalarField>(ptf);
380 kAbsPtr_->rmap(swfptf.kAbsPtr_(), addr);
392 gradient() = flux()/
patch().deltaCoeffs();
394 fixedGradientFvPatchScalarField::updateCoeffs();
402 writeLocalEntries(
os);
413 sorptionWallFunctionFvPatchScalarField
scalar n_
Binomial blending exponent being used when blenderType is blenderType::BINOMIAL.
dimensionedScalar tanh(const dimensionedScalar &ds)
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
static const wallDist & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
sorptionWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
dimensionedScalar sqrt(const dimensionedScalar &ds)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
dimensionedScalar pow025(const dimensionedScalar &ds)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
label k
Boltzmann constant.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
The sorptionWallFunction is a wall boundary condition to specify scalar/concentration gradient for tu...
The class wallFunctionBlenders is a base class that hosts common entries for various derived wall-fun...
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
virtual void write(Ostream &) const
Write.
const dimensionedScalar e
Elementary charge.
dimensionedScalar exp(const dimensionedScalar &ds)
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
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.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
const volScalarField & y() const noexcept
Return reference to cached distance-to-wall field.
static scalar calcYStarLam(const scalar kappa, const scalar E, const scalar Sc, const scalar Sct, const scalar Pc)
Estimate the y* at the intersection of the two sublayers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
void writeEntries(Ostream &) const
Write wall-function coefficients as dictionary entries.
OBJstream os(runTime.globalPath()/outputName)
virtual void write(Ostream &) const
Write.
scalar Cmu() const noexcept
Return the object: Cmu.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar pow3(const dimensionedScalar &ds)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void writeEntries(Ostream &) const
Write wall-function blending data as dictionary entries.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensionedScalar pow4(const dimensionedScalar &ds)
const std::string patch
OpenFOAM patch number as a std::string.
scalar E() const noexcept
Return the object: E.
enum blenderType blender_
Blending treatment.
List< label > labelList
A List of labels.
scalar kappa() const noexcept
Return the object: kappa.
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)