/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "yPlusLES.H" #include "volFields.H" #include "incompressible/LES/LESModel/LESModel.H" #include "compressible/LES/LESModel/LESModel.H" #include "wallFvPatch.H" #include "nearWallDist.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::yPlusLES, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::yPlusLES::writeFileHeader(const label i) { file() << "# y+ (LES)" << nl << "# time " << token::TAB << "patch" << token::TAB << "min" << token::TAB << "max" << token::TAB << "average" << endl; } void Foam::yPlusLES::calcIncompressibleYPlus ( const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus ) { const incompressible::LESModel& model = mesh.lookupObject("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(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 = min(Yp); scalar maxYp = max(Yp); scalar avgYp = average(Yp); if (log_) { Info<< " patch " << currPatch.name() << " y+ : min = " << min(Yp) << ", max = " << max(Yp) << ", average = " << average(Yp) << 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; } } void Foam::yPlusLES::calcCompressibleYPlus ( const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus ) { const compressible::LESModel& model = mesh.lookupObject("LESProperties"); volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); volScalarField muEff(model.muEff()); const fvPatchList& patches = mesh.boundary(); const volScalarField muLam(model.mu()); Info<< type() << " output:" << nl; bool foundPatch = false; forAll(patches, patchI) { const fvPatch& currPatch = patches[patchI]; if (isA(currPatch)) { foundPatch = true; yPlus.boundaryField()[patchI] = d[patchI] *sqrt ( muEff.boundaryField()[patchI] *mag(U.boundaryField()[patchI].snGrad()) ) /muLam.boundaryField()[patchI]; const scalarField& Yp = yPlus.boundaryField()[patchI]; scalar minYp = min(Yp); scalar maxYp = max(Yp); scalar avgYp = average(Yp); if (log_) { Info<< " patch " << currPatch.name() << " y+ : min = " << min(Yp) << ", max = " << max(Yp) << ", average = " << average(Yp) << 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; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::yPlusLES::yPlusLES ( const word& name, const objectRegistry& obr, const dictionary& dict, const bool loadFromFiles ) : functionObjectFile(obr, name, typeName), name_(name), obr_(obr), active_(true), log_(false), phiName_("phi"), UName_("U") { // Check if the available mesh is an fvMesh, otherwise deactivate if (!isA(obr_)) { active_ = false; WarningIn ( "yPlusLES::yPlusLES" "(" "const word&, " "const objectRegistry&, " "const dictionary&, " "const bool" ")" ) << "No fvMesh available, deactivating." << nl << endl; } } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::yPlusLES::~yPlusLES() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::yPlusLES::read(const dictionary& dict) { if (active_) { log_ = dict.lookupOrDefault("log", false); phiName_ = dict.lookupOrDefault("phiName", "phi"); } } void Foam::yPlusLES::execute() { // Do nothing - only valid on write } void Foam::yPlusLES::end() { // Do nothing - only valid on write } void Foam::yPlusLES::write() { if (active_) { functionObjectFile::write(); const surfaceScalarField& phi = obr_.lookupObject(phiName_); const volVectorField& U = obr_.lookupObject(UName_); const fvMesh& mesh = refCast(obr_); volScalarField yPlusLES ( IOobject ( "yPlusLES", mesh.time().timeName(), mesh, IOobject::NO_READ ), mesh, dimensionedScalar("0", dimless, 0.0) ); if (log_) { Info<< type() << " output:" << nl; } if (phi.dimensions() == dimMass/dimTime) { calcCompressibleYPlus(mesh, U, yPlusLES); } else { calcIncompressibleYPlus(mesh, U, yPlusLES); } if (log_) { Info<< endl; } yPlusLES.write(); } } // ************************************************************************* //