diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/Allwclean b/Allwclean deleted file mode 100755 index fe919e6..0000000 --- a/Allwclean +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -#---script to clean all of the point dumping utilities and misc utilities - -cd yPlusCFD -wclean - -#-----end script---#!/bin/bash - - diff --git a/Allwmake b/Allwmake deleted file mode 100755 index f01676c..0000000 --- a/Allwmake +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -#---script to compile all of the point dumping utilities and misc utilities - -cd yPlusCFD -wmake - -#-----end script--- diff --git a/yPlusCFD/Make/files b/Make/files similarity index 100% rename from yPlusCFD/Make/files rename to Make/files diff --git a/yPlusCFD/Make/options b/Make/options similarity index 53% rename from yPlusCFD/Make/options rename to Make/options index 35c5fb7..cd158b6 100755 --- a/yPlusCFD/Make/options +++ b/Make/options @@ -1,14 +1,18 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/turbulenceModels \ - -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ - -I$(LIB_SRC)/turbulenceModels/incompressible/LES/LESModel \ - -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \ -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ + -lcompressibleTurbulenceModel \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -lincompressibleTurbulenceModel \ + -lincompressibleTransportModels \ -lincompressibleRASModels \ -lincompressibleLESModels \ - -lincompressibleTransportModels \ - -lfiniteVolume + -lfiniteVolume \ + -lgenericPatchFields + diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ee2b1fe --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +yPlus +===== + +A utility for computing yPlus in OpenFOAM. + +## Compiling/installing + +Run `wmake` in this directory. diff --git a/yPlus.C b/yPlus.C new file mode 100644 index 0000000..727aaa8 --- /dev/null +++ b/yPlus.C @@ -0,0 +1,386 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Application + yPlus + +Description + Calculates and reports yPlus for all wall patches, for the specified times. + + Default behaviour assumes operating in incompressible mode. + Use the -compressible option for compressible RAS cases. + + Copyright 2013 Daniel Wei + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" +#include "incompressible/turbulenceModel/turbulenceModel.H" +#include "fluidThermo.H" +#include "compressible/turbulenceModel/turbulenceModel.H" +#include "compressible/RAS/RASModel/RASModel.H" +#include "wallDist.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + timeSelector::addOptions(); + + argList::addBoolOption + ( + "compressible", + "calculate compressible y+" + ); + + argList::addBoolOption + ( + "writeY", + "write wall distance files" + ); + + argList::addBoolOption + ( + "writeYPlus", + "write yPlus files" + ); + + argList::addBoolOption + ( + "uTauInfo", + "Show uTau infor, used in channelFlow post-process" + ); + +# include "setRootCase.H" +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createMesh.H" + + const bool compressible = args.optionFound("compressible"); + const bool writeY = args.optionFound("writeY"); + const bool writeYPlus = args.optionFound("writeYPlus"); + const bool uTauInfo = args.optionFound("uTauInfo"); + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); + Info<< "Time = " << runTime.timeName() << endl; + + //-Wall distance + //-y has values on all mesh cells + if (writeY) + { + fvMesh::readUpdateState state = mesh.readUpdate(); + 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(); + } + } + + //-wallDistanceOnPatch only has values on wall patch cells + // volScalarField wallDistanceOnPatch + // ( + // IOobject + // ( + // "wallDistanceOnPatch", + // runTime.timeName(), + // mesh, + // IOobject::NO_READ, + // IOobject::NO_WRITE + // ), + // mesh, + // dimensionedScalar("wallDistanceOnPatch", dimLength, 0.0) + // ); + + //-yPlus only has values on wall patch cells + volScalarField yPlus + ( + IOobject + ( + "yPlus", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("yPlus", dimless, 0.0) + ); + + //-uTau only has values on wall patch cells + volScalarField uTau + ( + IOobject + ( + "uTau", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("uTau", dimVelocity, 0.0) + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + + volScalarField muEff + ( + IOobject + ( + "muEff", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("muEff", dimensionSet(1,-1,-1,0,0,0,0), 0.0) + ); + volScalarField muLam + ( + IOobject + ( + "muLam", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("muLam", dimensionSet(1,-1,-1,0,0,0,0), 0.0) + ); + volScalarField nuEff + ( + IOobject + ( + "nuEff", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("nuEff", dimensionSet(0,2,-1,0,0,0,0), 0.0) + ); + volScalarField nuLam + ( + IOobject + ( + "nuLam", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("nuLam", dimensionSet(0,2,-1,0,0,0,0), 0.0) + ); + + if (compressible) + { + autoPtr pThermo + ( + fluidThermo::New(mesh) + ); + fluidThermo& thermo = pThermo(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + thermo.rho() + ); + + #include "compressibleCreatePhi.H" + + autoPtr comModel + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + muEff=comModel->muEff(); + muLam=comModel->mu(); + } + else + { +# include "createPhi.H" + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr incModel + ( + incompressible::turbulenceModel::New(U, phi, laminarTransport) + ); + + nuEff=incModel->nuEff(); + nuLam=incModel->nu(); + } + + volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); + + const fvPatchList& patches = mesh.boundary(); + + dimensionedScalar uTauAvg("uTauAvg", dimVelocity, 0); + scalar nPatch = 0; + + forAll(patches, patchi) + { + const fvPatch& currPatch = patches[patchi]; + + if (isA(currPatch)) + { + if (compressible) + { + autoPtr pThermo + ( + basicThermo::New(mesh) + ); + basicThermo& thermo = pThermo(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + thermo.rho() + ); + + // wallDistanceOnPatch.boundaryField()[patchi] = d[patchi]; + yPlus.boundaryField()[patchi] = + d[patchi] + *sqrt + ( + rho.boundaryField()[patchi] + *muEff.boundaryField()[patchi] + *mag(U.boundaryField()[patchi].snGrad()) + ) + /muLam.boundaryField()[patchi]; + + uTau.boundaryField()[patchi] = + sqrt + ( + rho.boundaryField()[patchi] + *muEff.boundaryField()[patchi] + *mag(U.boundaryField()[patchi].snGrad()) + ); + } + else + { + // wallDistanceOnPatch.boundaryField()[patchi] = d[patchi]; + yPlus.boundaryField()[patchi] = + d[patchi] + *sqrt + ( + nuEff.boundaryField()[patchi] + *mag(U.boundaryField()[patchi].snGrad()) + ) + /nuLam.boundaryField()[patchi]; + + uTau.boundaryField()[patchi] = + sqrt + ( + nuEff.boundaryField()[patchi] + *mag(U.boundaryField()[patchi].snGrad()) + ); + } + + const scalarField& Yp = yPlus.boundaryField()[patchi]; + + // Mean uTau estimation + uTauAvg.value() += average(uTau.boundaryField()[patchi]); + nPatch ++; + + Info<< "Patch " << patchi + << " named " << currPatch.name() << nl + << " d : min: " << min(d[patchi]) + << " max: " << max(d[patchi]) + << " average: " << average(d[patchi]) << nl + << " uTau: min: " << min(uTau.boundaryField()[patchi]) + << " max: " << max(uTau.boundaryField()[patchi]) + << " average: " << average(uTau.boundaryField()[patchi])< RASModel - ( - incompressible::RASModel::New(U, phi, laminarTransport) - ); - - volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y(); diff --git a/yPlusCFD/yPlus.C b/yPlusCFD/yPlus.C deleted file mode 100755 index b08120b..0000000 --- a/yPlusCFD/yPlus.C +++ /dev/null @@ -1,213 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Application - plusPostRANS - -Description - - calculates y+ and u+ fields for wall-bounded flows computed with - one of the available low-Re RANS (no wall function!) turbulence - models. More specifically it - - :: calculates and outputs y+ (avg., min., max.) based on the - velocity gradient at the wall - - :: calculates and outputs the wall averaged friction velocity - - :: writes fields of y+ and U+ to the corresponding time directory - -\*---------------------------------------------------------------------------*/ -#include "fvCFD.H" -#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" -#include "RASModel.H" -#include "LESModel.H" -#include "nearWallDist.H" -#include "wallDist.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -int main(int argc, char *argv[]) -{ - timeSelector::addOptions(); - - Foam::argList::addOption - ( - "tolerance", - "matchTolerance", - "specify a matching tolerance fraction of cell-to-face distance and y (default 0.001)" - ); - - argList::addBoolOption - ( - "noWrite", - "do not write the y+, u+, and uTau fields and only calculate the min, max, and average. " - ); - - #include "setRootCase.H" - - scalar matchTolerance = 0; - scalar matchTol = 1; - - bool noWrite = args.optionFound("noWrite"); - - if (args.optionReadIfPresent("tolerance", matchTolerance)) - { - matchTol = matchTolerance; - Info<< "Using cell distance to y match tolerance fraction of " << matchTol << nl << endl; - }else{ - matchTol = 0.001; - Info<< "Using default cell-to-face distance to y match tolerance fraction of " << matchTol << nl << endl; - } - - - - #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(); - - wallDist y(mesh, true); - - if (timeI == 0 || state != fvMesh::UNCHANGED) - { - Info<< "Calculating wall distance\n" <(currPatch)) - { - yPlusTemp.boundaryField()[patchi] = - d[patchi] - *sqrt - ( - RASModel->nu()().boundaryField()[patchi] - *mag(U.boundaryField()[patchi].snGrad()) - ) - /RASModel->nu()().boundaryField()[patchi]; - - const scalarField& YpTemp = yPlusTemp.boundaryField()[patchi]; - - uTau.boundaryField()[patchi] = - sqrt - ( - RASModel->nu()() - *mag(U.boundaryField()[patchi].snGrad()) - ); - - const scalarField& uTauTemp = uTau.boundaryField()[patchi]; - - Info<< " y+ for Patch " << patchi - << " named " << currPatch.name() << ":" - << " min: " << min(YpTemp) << " max: " << max(YpTemp) - << " average: " << average(YpTemp) - << nl << endl; - Info<< " uTau for Patch " << patchi - << " named " << currPatch.name() << ":" - << " min: " << min(uTauTemp) << " max: " << max(uTauTemp) - << " average: " << average(uTauTemp) - << nl << endl; - } - } - - -const volVectorField& centers = mesh.C(); -const surfaceVectorField& faceCenters = mesh.Cf(); - - //go through all the cells in the mesh - forAll(uTau, cellI){ - - //loop over all the patches - forAll(patches, patchi){ - const fvPatch& currPatch = patches[patchi]; - - //loop through all the faces on that patch - label nFaces = mesh.boundaryMesh()[patchi].size(); - - //if this patch is a wall... - if(isA(currPatch)){ - for(int facei = 0; faceinu(); - - //dummy variable holding velocity units - dimensionedScalar UUnits ( "UUnits", dimensionSet(0,1,-1,0,0), 1.0 ); - - //true uPlus over arbitrary geometry - uPlus = U / stabilise(uTau, SMALL*UUnits);//used to fix divide by zero error if uTau is zero - - if(noWrite){ - Info << " noWrite option selected, nothing written." << nl <