void calcYPlus ( const TurbulenceModel& turbulenceModel, const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus ) { volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); const volScalarField::GeometricBoundaryField nutBf = turbulenceModel->nut()().boundaryField(); const volScalarField::GeometricBoundaryField nuEffBf = turbulenceModel->nuEff()().boundaryField(); const volScalarField::GeometricBoundaryField nuBf = turbulenceModel->nu()().boundaryField(); const fvPatchList& patches = mesh.boundary(); forAll(patches, patchi) { const fvPatch& patch = patches[patchi]; if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi])) { const nutWallFunctionFvPatchScalarField& nutPf = dynamic_cast<const nutWallFunctionFvPatchScalarField&> ( nutBf[patchi] ); yPlus.boundaryField()[patchi] = nutPf.yPlus(); const scalarField& Yp = yPlus.boundaryField()[patchi]; Info<< "Patch " << patchi << " named " << nutPf.patch().name() << ", wall-function " << nutPf.type() << ", y+ : min: " << gMin(Yp) << " max: " << gMax(Yp) << " average: " << gAverage(Yp) << nl << endl; } else if (isA<wallFvPatch>(patch)) { yPlus.boundaryField()[patchi] = d[patchi] *sqrt ( nuEffBf[patchi] *mag(U.boundaryField()[patchi].snGrad()) )/nuBf[patchi]; const scalarField& Yp = yPlus.boundaryField()[patchi]; Info<< "Patch " << patchi << " named " << patch.name() << " y+ : min: " << gMin(Yp) << " max: " << gMax(Yp) << " average: " << gAverage(Yp) << nl << endl; } } }
void Foam::functionObjects::yPlus::calcYPlus ( const turbulenceModel& turbModel, const fvMesh& mesh, volScalarField& yPlus ) { volScalarField::Boundary d = nearWallDist(mesh).y(); const volScalarField::Boundary nutBf = turbModel.nut()().boundaryField(); const volScalarField::Boundary nuEffBf = turbModel.nuEff()().boundaryField(); const volScalarField::Boundary nuBf = turbModel.nu()().boundaryField(); const fvPatchList& patches = mesh.boundary(); volScalarField::Boundary& yPlusBf = yPlus.boundaryFieldRef(); forAll(patches, patchi) { const fvPatch& patch = patches[patchi]; if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi])) { const nutWallFunctionFvPatchScalarField& nutPf = dynamic_cast<const nutWallFunctionFvPatchScalarField&> ( nutBf[patchi] ); yPlusBf[patchi] = nutPf.yPlus(); } else if (isA<wallFvPatch>(patch)) { yPlusBf[patchi] = d[patchi] *sqrt ( nuEffBf[patchi] *mag(turbModel.U().boundaryField()[patchi].snGrad()) )/nuBf[patchi]; } } }
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(); }
void Foam::yPlus::calcYPlus ( const TurbulenceModel& turbulenceModel, const fvMesh& mesh, volScalarField& yPlus ) { volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); const volScalarField::GeometricBoundaryField nutBf = turbulenceModel.nut()().boundaryField(); const volScalarField::GeometricBoundaryField nuEffBf = turbulenceModel.nuEff()().boundaryField(); const volScalarField::GeometricBoundaryField nuBf = turbulenceModel.nu()().boundaryField(); const fvPatchList& patches = mesh.boundary(); forAll(patches, patchi) { const fvPatch& patch = patches[patchi]; if (isA<nutWallFunctionFvPatchScalarField>(nutBf[patchi])) { const nutWallFunctionFvPatchScalarField& nutPf = dynamic_cast<const nutWallFunctionFvPatchScalarField&> ( nutBf[patchi] ); yPlus.boundaryField()[patchi] = nutPf.yPlus(); const scalarField& yPlusp = yPlus.boundaryField()[patchi]; const scalar minYplus = gMin(yPlusp); const scalar maxYplus = gMax(yPlusp); const scalar avgYplus = gAverage(yPlusp); if (Pstream::master()) { if (log_) Info << " patch " << patch.name() << " y+ : min = " << minYplus << ", max = " << maxYplus << ", average = " << avgYplus << nl; file() << obr_.time().value() << token::TAB << patch.name() << token::TAB << minYplus << token::TAB << maxYplus << token::TAB << avgYplus << endl; } } else if (isA<wallFvPatch>(patch)) { yPlus.boundaryField()[patchi] = d[patchi] *sqrt ( nuEffBf[patchi] *mag(turbulenceModel.U().boundaryField()[patchi].snGrad()) )/nuBf[patchi]; const scalarField& yPlusp = yPlus.boundaryField()[patchi]; const scalar minYplus = gMin(yPlusp); const scalar maxYplus = gMax(yPlusp); const scalar avgYplus = gAverage(yPlusp); if (Pstream::master()) { if (log_) Info << " patch " << patch.name() << " y+ : min = " << minYplus << ", max = " << maxYplus << ", average = " << avgYplus << nl; file() << obr_.time().value() << token::TAB << patch.name() << token::TAB << minYplus << token::TAB << maxYplus << token::TAB << avgYplus << endl; } } } }
void Foam::yPlusLES::calcIncompressibleYPlus ( const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus ) { const incompressible::LESModel& model = mesh.lookupObject<incompressible::LESModel>("LESProperties"); volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); volScalarField nuEff(model.nuEff()); const fvPatchList& patches = mesh.boundary(); const volScalarField nuLam(model.nu()); bool foundPatch = false; forAll(patches, patchI) { const fvPatch& currPatch = patches[patchI]; if (isA<wallFvPatch>(currPatch)) { foundPatch = true; yPlus.boundaryField()[patchI] = d[patchI] *sqrt ( nuEff.boundaryField()[patchI] *mag(U.boundaryField()[patchI].snGrad()) ) /nuLam.boundaryField()[patchI]; const scalarField& Yp = yPlus.boundaryField()[patchI]; scalar minYp = gMin(Yp); scalar maxYp = gMax(Yp); scalar avgYp = gAverage(Yp); if (log_) { Info<< " patch " << currPatch.name() << " y+ : min = " << minYp << ", max = " << maxYp << ", average = " << avgYp << nl; } if (Pstream::master()) { file() << obr_.time().value() << token::TAB << currPatch.name() << token::TAB << minYp << token::TAB << maxYp << token::TAB << avgYp << endl; } } } if (log_ && !foundPatch) { Info<< " no " << wallFvPatch::typeName << " patches" << endl; } }