58static const scalar Cmu(0.09);
59static const scalar
kappa(0.41);
63void correctProcessorPatches(GeometricField<Type, fvPatchField, volMesh>&
fld)
65 if (UPstream::parRun())
67 fld.boundaryFieldRef().template evaluateCoupled<processorFvPatch>();
74 const word& fieldName,
76 const scalarField& mask,
77 const scalarField& boundaryLayerField
83 mesh.time().timeName(),
90 if (fieldHeader.typeHeaderOk<volScalarField>(
true))
94 pf = (1 - mask)*pf + mask*boundaryLayerField;
101 correctProcessorPatches(
fld);
112 const scalarField& mask,
113 const scalarField& kBL,
114 const scalarField& epsilonBL
121 mesh.time().timeName(),
125 IOobject::NO_REGISTER
128 if (omegaHeader.typeHeaderOk<volScalarField>(
true))
133 pf = (1 - mask)*pf + mask*epsilonBL/(Cmu*kBL + SMALL);
140 correctProcessorPatches(omega);
151 const word& fieldName,
152 const volScalarField& value
158 mesh.time().timeName(),
162 IOobject::NO_REGISTER
165 if (fldHeader.typeHeaderOk<volScalarField>(
true))
174 correctProcessorPatches(
fld);
182tmp<volScalarField> calcNut
185 const volVectorField&
U
194 basicThermo::dictName,
197 ).typeHeaderOk<IOdictionary>(
true)
201 autoPtr<fluidThermo>
pThermo(fluidThermo::New(
mesh));
209 autoPtr<compressible::turbulenceModel>
turbulence
211 compressible::turbulenceModel::New
223 return tmp<volScalarField>::New(
turbulence->nut());
230 #include "createPhi.H"
235 autoPtr<incompressible::turbulenceModel>
turbulence
243 return tmp<volScalarField>::New(
turbulence->nut());
248int main(
int argc,
char *argv[])
252 "Apply a simplified boundary-layer model to the velocity and"
253 " turbulence fields based on the 1/7th power-law."
262 "Specify the boundary-layer thickness"
268 "Boundary-layer thickness as Cbl * mean distance to wall"
270 argList::addBoolOption
272 "writeTurbulenceFields",
273 "Write the turbulence fields"
275 argList::addOptionCompat
277 "writeTurbulenceFields", {
"write-nut", 1906}
282 if (!
args.found(
"ybl") && !
args.found(
"Cbl"))
285 <<
"Neither option 'ybl' or 'Cbl' have been provided to calculate "
286 <<
"the boundary-layer thickness.\n"
287 <<
"Please choose either 'ybl' OR 'Cbl'."
290 else if (
args.found(
"ybl") &&
args.found(
"Cbl"))
293 <<
"Both 'ybl' and 'Cbl' have been provided to calculate "
294 <<
"the boundary-layer thickness.\n"
295 <<
"Please choose either 'ybl' OR 'Cbl'."
299 const bool writeTurbulenceFields =
args.found(
"writeTurbulenceFields");
310 Info<<
"Setting boundary layer velocity" <<
nl <<
endl;
311 const scalar yblv = ybl.value();
314 if ((
y[celli] > 0) && (
y[celli] <= yblv))
317 U[celli] *= ::pow(
y[celli]/yblv, (1.0/7.0));
320 mask.correctBoundaryConditions();
321 correctProcessorPatches(
U);
323 if (writeTurbulenceFields)
330 nut = (1 - mask)*
nut + mask*
sqr(kappa*
min(
y, ybl))*::sqrt(2)*S;
334 correctProcessorPatches(
nut);
344 scalar ce0 = ::pow(Cmu, 0.75)/
kappa;
348 blendField(
"k",
mesh, mask, kBL);
349 blendField(
"epsilon",
mesh, mask, epsilonBL);
350 calcOmegaField(
mesh, mask, kBL, epsilonBL);
359 runTime.printExecutionTime(Info);
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))
void clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place).
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Creates and initialises the face-flux field phi.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
compressible::turbulenceModel & turbulence
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
dimensionedSymmTensor sqr(const dimensionedVector &dv)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
SymmTensor< Cmpt > devSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of the symmetric part of a SymmTensor.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar pow025(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a).
surfacesMesh setField(triSurfaceToAgglom)
Foam::argList args(argc, argv)
Info<< "Reading thermophysical properties\n"<< endl;autoPtr< psiReactionThermo > pThermo(psiReactionThermo::New(mesh))
singlePhaseTransportModel laminarTransport(U, phi)
#define forAll(list, i)
Loop across all elements in list.