Foam::scalar Foam::tabulatedWallFunctions::SpaldingsLaw::Re ( const scalar uPlus ) const { return uPlus*yPlus(uPlus); }
void kOmegaSSTSato<BasicTurbulenceModel>::correctNut() { const PhaseCompressibleTurbulenceModel<transportModel>& gasTurbulence = this->gasTurbulence(); volScalarField yPlus ( pow(this->betaStar_, 0.25)*this->y_*sqrt(this->k_)/this->nu() ); this->nut_ = this->a1_*this->k_ /max ( this->a1_*this->omega_, this->F23()*sqrt(2.0)*mag(symm(fvc::grad(this->U_))) ) + sqr(1 - exp(-yPlus/16.0)) *Cmub_*gasTurbulence.transport().d()*gasTurbulence.alpha() *(mag(this->U_ - gasTurbulence.U())); this->nut_.correctBoundaryConditions(); }
int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "setRootCase.H" # include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; fvMesh::readUpdateState state = mesh.readUpdate(); // Wall distance if (timeI == 0 || state != fvMesh::UNCHANGED) { Info<< "Calculating wall distance\n" << endl; wallDist y(mesh, true); Info<< "Writing wall distance to field " << y.name() << nl << endl; y.write(); } volScalarField yPlus ( IOobject ( "yPlus", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("yPlus", dimless, 0.0) ); Info<< "Reading field U\n" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); # include "createPhi.H" singlePhaseTransportModel laminarTransport(U, phi); autoPtr<incompressible::LESModel> sgsModel ( incompressible::LESModel::New(U, phi, laminarTransport) ); volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); volScalarField nuEff = sgsModel->nuEff(); const fvPatchList& patches = mesh.boundary(); forAll(patches, patchi) { const fvPatch& currPatch = patches[patchi]; if (isA<wallFvPatch>(currPatch)) { yPlus.boundaryField()[patchi] = d[patchi] *sqrt ( nuEff.boundaryField()[patchi] *mag(U.boundaryField()[patchi].snGrad()) ) /sgsModel->nu().boundaryField()[patchi]; const scalarField& Yp = yPlus.boundaryField()[patchi]; Info<< "Patch " << patchi << " named " << currPatch.name() << " y : min: " << min(d) << " max: " << max(d) << " average: " << average(d) << nl << " y+ : min: " << min(Yp) << " max: " << max(Yp) << " average: " << average(Yp) << nl << endl; } } Info<< "Writing yPlus to field " << yPlus.name() << nl << endl; yPlus.write(); }
int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "addRegionOption.H" #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select(runTime, args, "yPlus"); #include "createNamedMesh.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; mesh.readUpdate(); volScalarField yPlus ( IOobject ( "yPlus", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("yPlus", dimless, 0.0) ); IOobject UHeader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ); if (UHeader.headerOk()) { Info<< "Reading field U\n" << endl; volVectorField U(UHeader, mesh); if ( IOobject ( basicThermo::dictName, runTime.constant(), mesh ).headerOk() ) { calcCompressibleYPlus(mesh, runTime, U, yPlus); } else { calcIncompressibleYPlus(mesh, runTime, U, yPlus); } } else { Info<< " no U field" << endl; } Info<< "Writing yPlus to field " << yPlus.name() << nl << endl; yPlus.write(); }
tmp<scalarField> alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::calcAlphat ( const scalarField& prevAlphat ) const { // Lookup the fluid model const phaseSystem& fluid = db().lookupObject<phaseSystem>("phaseProperties"); const phaseModel& phase ( fluid.phases()[internalField().group()] ); const label patchi = patch().index(); // Retrieve turbulence properties from model const phaseCompressibleTurbulenceModel& turbModel = db().lookupObject<phaseCompressibleTurbulenceModel> ( IOobject::groupName(turbulenceModel::propertiesName, phase.name()) ); const scalar Cmu25 = pow025(Cmu_); const scalarField& y = turbModel.y()[patchi]; const tmp<scalarField> tmuw = turbModel.mu(patchi); const scalarField& muw = tmuw(); const tmp<scalarField> talphaw = phase.thermo().alpha(patchi); const scalarField& alphaw = talphaw(); const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); const fvPatchScalarField& kw = k.boundaryField()[patchi]; const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const scalarField magGradUw(mag(Uw.snGrad())); const fvPatchScalarField& rhow = turbModel.rho().boundaryField()[patchi]; const fvPatchScalarField& hew = phase.thermo().he().boundaryField()[patchi]; const fvPatchScalarField& Tw = phase.thermo().T().boundaryField()[patchi]; scalarField Tp(Tw.patchInternalField()); // Heat flux [W/m2] - lagging alphatw const scalarField qDot ( (prevAlphat + alphaw)*hew.snGrad() ); scalarField uTau(Cmu25*sqrt(kw)); scalarField yPlus(uTau*y/(muw/rhow)); scalarField Pr(muw/alphaw); // Molecular-to-turbulent Prandtl number ratio scalarField Prat(Pr/Prt_); // Thermal sublayer thickness scalarField P(this->Psmooth(Prat)); scalarField yPlusTherm(this->yPlusTherm(P, Prat)); tmp<scalarField> talphatConv(new scalarField(this->size())); scalarField& alphatConv = talphatConv.ref(); // Populate boundary values forAll(alphatConv, facei) { // Evaluate new effective thermal diffusivity scalar alphaEff = 0.0; if (yPlus[facei] < yPlusTherm[facei]) { scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei]; scalar B = qDot[facei]*Pr[facei]*yPlus[facei]; scalar C = Pr[facei]*0.5*rhow[facei]*uTau[facei]*sqr(magUp[facei]); alphaEff = A/(B + C + vSmall); } else { scalar A = qDot[facei]*rhow[facei]*uTau[facei]*y[facei]; scalar B = qDot[facei]*Prt_*(1.0/kappa_*log(E_*yPlus[facei]) + P[facei]); scalar magUc = uTau[facei]/kappa_*log(E_*yPlusTherm[facei]) - mag(Uw[facei]); scalar C = 0.5*rhow[facei]*uTau[facei] *(Prt_*sqr(magUp[facei]) + (Pr[facei] - Prt_)*sqr(magUc)); alphaEff = A/(B + C + vSmall); } // Update convective heat transfer turbulent thermal diffusivity alphatConv[facei] = max(0.0, alphaEff - alphaw[facei]); }
int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "addRegionOption.H" argList::addBoolOption ( "compressible", "calculate compressible y+" ); #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createNamedMesh.H" const bool compressible = args.optionFound("compressible"); forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; fvMesh::readUpdateState state = mesh.readUpdate(); // Wall distance if (timeI == 0 || state != fvMesh::UNCHANGED) { Info<< "Calculating wall distance\n" << endl; wallDist y(mesh, true); Info<< "Writing wall distance to field " << y.name() << nl << endl; y.write(); } volScalarField yPlus ( IOobject ( "yPlus", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("yPlus", dimless, 0.0) ); IOobject UHeader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ); if (UHeader.headerOk()) { Info<< "Reading field U\n" << endl; volVectorField U(UHeader, mesh); if (compressible) { calcCompressibleYPlus(mesh, runTime, U, yPlus); } else { calcIncompressibleYPlus(mesh, runTime, U, yPlus); } } else { Info<< " no U field" << endl; } Info<< "Writing yPlus to field " << yPlus.name() << nl << endl; yPlus.write(); }
void alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::updateCoeffs() { if (updated()) { return; } // Lookup the fluid model const ThermalPhaseChangePhaseSystem < MomentumTransferPhaseSystem<twoPhaseSystem> >& fluid = refCast < const ThermalPhaseChangePhaseSystem < MomentumTransferPhaseSystem<twoPhaseSystem> > > ( db().lookupObject<phaseSystem>("phaseProperties") ); const phaseModel& liquid ( fluid.phase1().name() == dimensionedInternalField().group() ? fluid.phase1() : fluid.phase2() ); const label patchi = patch().index(); // Retrieve turbulence properties from model const compressibleTurbulenceModel& turbModel = db().lookupObject<compressibleTurbulenceModel> ( IOobject::groupName ( compressibleTurbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const scalar Cmu25 = pow025(Cmu_); const scalarField& y = turbModel.y()[patchi]; const tmp<scalarField> tmuw = turbModel.mu(patchi); const scalarField& muw = tmuw(); const tmp<scalarField> talphaw = liquid.thermo().alpha(patchi); const scalarField& alphaw = talphaw(); scalarField& alphatw = *this; const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); const fvPatchScalarField& kw = k.boundaryField()[patchi]; const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const scalarField magGradUw(mag(Uw.snGrad())); const fvPatchScalarField& rhow = turbModel.rho().boundaryField()[patchi]; const fvPatchScalarField& hew = liquid.thermo().he().boundaryField()[patchi]; const fvPatchScalarField& Tw = liquid.thermo().T().boundaryField()[patchi]; scalarField Tp(Tw.patchInternalField()); // Heat flux [W/m2] - lagging alphatw const scalarField qDot ( (alphatw + alphaw)*hew.snGrad() ); scalarField uTau(Cmu25*sqrt(kw)); scalarField yPlus(uTau*y/(muw/rhow)); scalarField Pr(muw/alphaw); // Molecular-to-turbulent Prandtl number ratio scalarField Prat(Pr/Prt_); // Thermal sublayer thickness scalarField P(this->Psmooth(Prat)); scalarField yPlusTherm(this->yPlusTherm(P, Prat)); scalarField alphatConv(this->size(), 0.0); // Populate boundary values forAll(alphatw, faceI) { // Evaluate new effective thermal diffusivity scalar alphaEff = 0.0; if (yPlus[faceI] < yPlusTherm[faceI]) { scalar A = qDot[faceI]*rhow[faceI]*uTau[faceI]*y[faceI]; scalar B = qDot[faceI]*Pr[faceI]*yPlus[faceI]; scalar C = Pr[faceI]*0.5*rhow[faceI]*uTau[faceI]*sqr(magUp[faceI]); alphaEff = A/(B + C + VSMALL); } else { scalar A = qDot[faceI]*rhow[faceI]*uTau[faceI]*y[faceI]; scalar B = qDot[faceI]*Prt_*(1.0/kappa_*log(E_*yPlus[faceI]) + P[faceI]); scalar magUc = uTau[faceI]/kappa_*log(E_*yPlusTherm[faceI]) - mag(Uw[faceI]); scalar C = 0.5*rhow[faceI]*uTau[faceI] *(Prt_*sqr(magUp[faceI]) + (Pr[faceI] - Prt_)*sqr(magUc)); alphaEff = A/(B + C + VSMALL); } // Update convective heat transfer turbulent thermal diffusivity alphatConv[faceI] = max(0.0, alphaEff - alphaw[faceI]); }