105 epsilonPatches.append(patchi);
115 cornerWeights_.setSize(bf.size());
117 for (
const auto& patchi : epsilonPatches)
120 cornerWeights_[patchi] = 1.0/wf.patchInternalField();
123 G_.setSize(internalField().size(),
Zero);
156 forAll(cornerWeights_, patchi)
158 if (!cornerWeights_[patchi].empty())
169 forAll(cornerWeights_, patchi)
171 if (!cornerWeights_[patchi].empty())
175 epf ==
scalarField(epsilon0, epf.patch().faceCells());
190 const label patchi =
patch.index();
192 const scalar Cmu25 =
pow025(wallCoeffs_.Cmu());
193 const scalar Cmu75 =
pow(wallCoeffs_.Cmu(), 0.75);
194 const scalar
kappa = wallCoeffs_.kappa();
195 const scalar yPlusLam = wallCoeffs_.yPlusLam();
208 const auto yPlus = [&](
const label facei) -> scalar
217 const auto epsilonVis = [&](
const label facei) -> scalar
227 const auto epsilonLog = [&](
const label facei) -> scalar
238 case blenderType::STEPWISE:
242 if (lowReCorrection_ &&
yPlus(facei) < yPlusLam)
258 case blenderType::BINOMIAL:
267 pow(epsilonVis(facei), n_) +
pow(epsilonLog(facei), n_),
274 case blenderType::MAX:
281 *
max(epsilonVis(facei), epsilonLog(facei));
286 case blenderType::EXPONENTIAL:
291 const scalar yPlusFace =
yPlus(facei);
293 0.001*
pow4(yPlusFace)/(scalar(1) + yPlusFace);
294 const scalar invGamma = scalar(1)/(Gamma + ROOTVSMALL);
299 epsilonVis(facei)*
exp(-Gamma)
300 + epsilonLog(facei)*
exp(-invGamma)
306 case blenderType::TANH:
311 const scalar epsilonVisFace = epsilonVis(facei);
312 const scalar epsilonLogFace = epsilonLog(facei);
313 const scalar b1 = epsilonVisFace + epsilonLogFace;
317 pow(epsilonVisFace, 1.2) +
pow(epsilonLogFace, 1.2),
324 * (phiTanh*b1 + (1 - phiTanh)*b2);
338 if (!lowReCorrection_ || (
yPlus(facei) > yPlusLam))
342 *(nutw[facei] + nuw[facei])
373 lowReCorrection_(false),
394 lowReCorrection_(ptf.lowReCorrection_),
414 lowReCorrection_(
dict.getOrDefault(
"lowReCorrection", false)),
435 lowReCorrection_(ewfpsf.lowReCorrection_),
454 lowReCorrection_(ewfpsf.lowReCorrection_),
457 wallCoeffs_(ewfpsf.wallCoeffs_),
471 if (patch().index() == master_)
481 return epsilonPatch(master_).G();
490 if (patch().index() == master_)
500 return epsilonPatch(master_).epsilon(init);
516 internalField().
group()
522 if (
patch().index() == master_)
524 createAveragingWeights();
525 calculateTurbulenceFields(turbModel,
G(
true),
epsilon(
true));
533 FieldType&
G = db().lookupObjectRef<FieldType>(turbModel.GName());
535 FieldType&
epsilon =
const_cast<FieldType&
>(internalField());
539 const label celli =
patch().faceCells()[facei];
541 G[celli] =
G0[celli];
564 internalField().
group()
570 if (
patch().index() == master_)
572 createAveragingWeights();
573 calculateTurbulenceFields(turbModel,
G(
true),
epsilon(
true));
581 FieldType&
G = db().lookupObjectRef<FieldType>(turbModel.GName());
583 FieldType&
epsilon =
const_cast<FieldType&
>(internalField());
590 const scalar w = weights[facei];
594 const label celli =
patch().faceCells()[facei];
596 G[celli] = (1.0 - w)*G[celli] + w*G0[celli];
598 epsilonf[facei] =
epsilon[celli];
611 if (manipulatedMatrix())
628 if (manipulatedMatrix())
642 if (weights[facei] > tolerance_)
646 constraintCells.append(celli);
647 constraintValues.append(
fld[celli]);
654 <<
": number of constrained cells = " << constraintCells.size()
655 <<
" out of " <<
patch().size()
659 matrix.setValues(constraintCells, constraintValues);
671 writeLocalEntries(
os);
683 epsilonWallFunctionFvPatchScalarField
Macros for easy insertion into run-time selection tables.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool empty() const noexcept
label size() const noexcept
The number of entries in the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
This boundary condition provides wall functions for the turbulent kinetic energy dissipation rate (i....
scalarField G_
Local copy of turbulence G field.
List< List< scalar > > cornerWeights_
List of averaging corner weights.
epsilonWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
scalarField epsilon_
Local copy of turbulence epsilon field.
void writeLocalEntries(Ostream &) const
Write local wall function variables.
virtual void manipulateMatrix(fvMatrix< scalar > &matrix)
Manipulate matrix.
bool initialised_
Initialised flag.
static scalar tolerance_
Tolerance used in weighted calculations.
const bool lowReCorrection_
Apply low-Re correction term (default = no).
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void createAveragingWeights()
Create the averaging weights for cells which are bounded by multiple wall function faces.
wallFunctionCoefficients wallCoeffs_
Wall-function coefficients.
virtual void calculate(const turbulenceModel &turbulence, const List< scalar > &cornerWeights, const fvPatch &patch, scalarField &G, scalarField &epsilon)
Calculate the epsilon and G.
virtual label & master()
Return non-const access to the master patch ID.
label master_
Master patch ID.
scalarField & G(bool init=false)
Return non-const access to the master's G field.
virtual void updateWeightedCoeffs(const scalarField &weights)
Update the coefficients associated with the patch field.
virtual epsilonWallFunctionFvPatchScalarField & epsilonPatch(const label patchi)
Helper function to return non-const access to an epsilon patch.
virtual void calculateTurbulenceFields(const turbulenceModel &turbulence, scalarField &G0, scalarField &epsilon0)
Main driver to calculate the turbulence fields.
scalarField & epsilon(bool init=false)
Return non-const access to the master's epsilon field.
virtual void setMaster()
Set the master patch - master is responsible for updating all wall function patches.
Smooth ATC in cells next to a set of patches supplied by type.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
fixedValueFvPatchField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
A special matrix type and solver, designed for finite volume solutions of scalar equations....
void setValues(const labelUList &cellLabels, const Type &value)
Set solution in given cells to the specified value and eliminate the corresponding equations from the...
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
const objectRegistry & db() const
The associated objectRegistry.
const fvPatch & patch() const noexcept
Return the patch.
bool manipulatedMatrix() const noexcept
True if the matrix has already been manipulated.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-volume patch fields.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
const DimensionedField< scalar, volMesh > & internalField() const noexcept
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
void extrapolateInternal()
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual const labelUList & faceCells() const
Return faceCells.
bool changing() const noexcept
Is mesh changing (topology changing and/or moving).
A class for managing temporary objects.
Abstract base class for turbulence models (RAS, LES and laminar).
const volVectorField & U() const
Access function to velocity field.
static const word propertiesName
Default name of the turbulence properties dictionary.
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
virtual tmp< volScalarField > nu() const =0
Return the laminar viscosity.
virtual tmp< volScalarField > nut() const =0
Return the turbulence viscosity.
const nearWallDist & y() const
Return the near wall distances.
The class wallFunctionBlenders is a base class that hosts common entries for various derived wall-fun...
void writeEntries(Ostream &) const
Write wall-function blending data as dictionary entries.
wallFunctionBlenders()
Default construct with default coefficients.
blenderType
Options for the blending treatment of viscous and inertial sublayers.
@ STEPWISE
"Stepwise switch (discontinuous)"
enum blenderType blender_
Blending treatment.
scalar n_
Binomial blending exponent being used when blenderType is blenderType::BINOMIAL.
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
constexpr const char *const group
Group name for atomic constants.
const dimensionedScalar G0
Conductance quantum: default SI units: [S].
const dimensionedScalar epsilon0
Electric constant: default SI units: [F/m].
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionedScalar G
Newtonian constant of gravitation.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedScalar exp(const dimensionedScalar &ds)
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedScalar tanh(const dimensionedScalar &ds)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensionedScalar pow4(const dimensionedScalar &ds)
static constexpr const zero Zero
Global zero (0).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
UList< label > labelUList
A UList of labels.
fvPatchField< vector > fvPatchVectorField
fvPatchField< scalar > fvPatchScalarField
dimensionedScalar pow025(const dimensionedScalar &ds)
static bool initialised_(false)
#define forAll(list, i)
Loop across all elements in list.