From 1a1abf3544ac3740fd81b5f060dbf4f73773bbd9 Mon Sep 17 00:00:00 2001
From: andy <a.heather@opencfd.co.uk>
Date: Thu, 23 Jul 2009 12:02:36 +0100
Subject: [PATCH] updated yPlusRAS utility

---
 .../postProcessing/wall/yPlusRAS/Make/options |  13 +-
 .../postProcessing/wall/yPlusRAS/yPlusRAS.C   | 195 ++++++++++++++----
 2 files changed, 163 insertions(+), 45 deletions(-)

diff --git a/applications/utilities/postProcessing/wall/yPlusRAS/Make/options b/applications/utilities/postProcessing/wall/yPlusRAS/Make/options
index cc83637abc1..459989eb9df 100644
--- a/applications/utilities/postProcessing/wall/yPlusRAS/Make/options
+++ b/applications/utilities/postProcessing/wall/yPlusRAS/Make/options
@@ -2,10 +2,17 @@ EXE_INC = \
     -I$(LIB_SRC)/meshTools/lnInclude \
     -I$(LIB_SRC)/transportModels \
     -I$(LIB_SRC)/turbulenceModels \
-    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
+    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \
+    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \
+    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
     -I$(LIB_SRC)/finiteVolume/lnInclude
 
 EXE_LIBS = \
-    -lincompressibleRASModels \
     -lincompressibleTransportModels \
-    -lfiniteVolume
+    -lincompressibleRASModels \
+    -lbasicThermophysicalModels \
+    -lspecie \
+    -lcompressibleRASModels \
+    -lfiniteVolume \
+    -lmeshTools \
+    -lsampling
diff --git a/applications/utilities/postProcessing/wall/yPlusRAS/yPlusRAS.C b/applications/utilities/postProcessing/wall/yPlusRAS/yPlusRAS.C
index 9a5e383cf34..b2f31cb61c0 100644
--- a/applications/utilities/postProcessing/wall/yPlusRAS/yPlusRAS.C
+++ b/applications/utilities/postProcessing/wall/yPlusRAS/yPlusRAS.C
@@ -26,29 +26,156 @@ Application
     yPlusRAS
 
 Description
-    Calculates and reports yPlus for all wall patches, for the specified times.
+    Calculates and reports yPlus for all wall patches, for the specified times
+    when using RAS turbulence models.
+
+    Default behaviour assumes operating in incompressible mode. To apply to
+    compressible RAS cases, use the -compressible option.
 
 \*---------------------------------------------------------------------------*/
 
 #include "fvCFD.H"
+
 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
-#include "RASModel.H"
-#include "wallFvPatch.H"
+#include "incompressible/RAS/RASModel/RASModel.H"
+#include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
+
+#include "basicPsiThermo.H"
+#include "compressible/RAS/RASModel/RASModel.H"
+#include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
+
 #include "wallDist.H"
-#include "nutWallFunctionFvPatchScalarField.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-int main(int argc, char *argv[])
+void calcIncompressibleYPlus
+(
+    const fvMesh& mesh,
+    const Time& runTime,
+    const volVectorField& U,
+    volScalarField& yPlus
+)
 {
     typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
         wallFunctionPatchField;
 
+    #include "createPhi.H"
+
+    singlePhaseTransportModel laminarTransport(U, phi);
+
+    autoPtr<incompressible::RASModel> RASModel
+    (
+        incompressible::RASModel::New(U, phi, laminarTransport)
+    );
+
+    const volScalarField::GeometricBoundaryField nutPatches =
+        RASModel->nut()().boundaryField();
+
+    forAll(nutPatches, patchi)
+    {
+        if (isA<wallFunctionPatchField>(nutPatches[patchi]))
+        {
+            const wallFunctionPatchField& nutPw =
+                dynamic_cast<const wallFunctionPatchField&>
+                    (nutPatches[patchi]);
+
+            yPlus.boundaryField()[patchi] = nutPw.yPlus();
+            const scalarField& Yp = yPlus.boundaryField()[patchi];
+
+            Info<< "Patch " << patchi
+                << " named " << nutPw.patch().name()
+                << " y+ : min: " << min(Yp) << " max: " << max(Yp)
+                << " average: " << average(Yp) << nl << endl;
+        }
+    }
+}
+
+
+void calcCompressibleYPlus
+(
+    const fvMesh& mesh,
+    const Time& runTime,
+    const volVectorField& U,
+    volScalarField& yPlus
+)
+{
+    typedef compressible::RASModels::mutWallFunctionFvPatchScalarField
+        wallFunctionPatchField;
+
+    IOobject rhoHeader
+    (
+        "rho",
+        runTime.timeName(),
+        mesh,
+        IOobject::MUST_READ,
+        IOobject::NO_WRITE
+    );
+
+    if (!rhoHeader.headerOk())
+    {
+        Info<< "    no rho field" << endl;
+        return;
+    }
+
+    Info << "Reading field rho\n" << endl;
+    volScalarField rho(rhoHeader, mesh);
+
+    #include "compressibleCreatePhi.H"
+
+    autoPtr<basicPsiThermo> pThermo
+    (
+        basicPsiThermo::New(mesh)
+    );
+    basicPsiThermo& thermo = pThermo();
+
+    autoPtr<compressible::RASModel> RASModel
+    (
+        compressible::RASModel::New
+        (
+            rho,
+            U,
+            phi,
+            thermo
+        )
+    );
+
+    const volScalarField::GeometricBoundaryField mutPatches =
+        RASModel->mut()().boundaryField();
+
+    forAll(mutPatches, patchi)
+    {
+        if (isA<wallFunctionPatchField>(mutPatches[patchi]))
+        {
+            const wallFunctionPatchField& mutPw =
+                dynamic_cast<const wallFunctionPatchField&>
+                    (mutPatches[patchi]);
+
+            yPlus.boundaryField()[patchi] = mutPw.yPlus();
+            const scalarField& Yp = yPlus.boundaryField()[patchi];
+
+            Info<< "Patch " << patchi
+                << " named " << mutPw.patch().name()
+                << " y+ : min: " << min(Yp) << " max: " << max(Yp)
+                << " average: " << average(Yp) << nl << endl;
+        }
+    }
+}
+
+
+int main(int argc, char *argv[])
+{
     timeSelector::addOptions();
+
+    #include "addRegionOption.H"
+
+    argList::validOptions.insert("compressible","");
+
     #include "setRootCase.H"
     #include "createTime.H"
     instantList timeDirs = timeSelector::select0(runTime, args);
-    #include "createMesh.H"
+    #include "createNamedMesh.H"
+
+    bool compressible = args.optionFound("compressible");
 
     forAll(timeDirs, timeI)
     {
@@ -80,48 +207,32 @@ int main(int argc, char *argv[])
             dimensionedScalar("yPlus", dimless, 0.0)
         );
 
-        Info << "Reading field U\n" << endl;
-        volVectorField U
-        (
-            IOobject
-            (
-                "U",
-                runTime.timeName(),
-                mesh,
-                IOobject::MUST_READ,
-                IOobject::AUTO_WRITE
-            ),
-            mesh
-        );
-
-        #include "createPhi.H"
-
-        singlePhaseTransportModel laminarTransport(U, phi);
-
-        autoPtr<incompressible::RASModel> RASModel
+        IOobject UHeader
         (
-            incompressible::RASModel::New(U, phi, laminarTransport)
+            "U",
+            runTime.timeName(),
+            mesh,
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
         );
 
-        const volScalarField::GeometricBoundaryField nutPatches =
-            RASModel->nut()().boundaryField();
-
-        forAll(nutPatches, patchi)
+        if (UHeader.headerOk())
         {
-            if (isA<wallFunctionPatchField>(nutPatches[patchi]))
-            {
-                const wallFunctionPatchField& nutPw =
-                    dynamic_cast<const wallFunctionPatchField&>
-                        (nutPatches[patchi]);
+            Info << "Reading field U\n" << endl;
+            volVectorField U(UHeader, mesh);
 
-                yPlus.boundaryField()[patchi] = nutPw.yPlus();
-                const scalarField& Yp = yPlus.boundaryField()[patchi];
-
-                Info<< "Patch " << patchi
-                    << " named " << nutPw.patch().name()
-                    << " y+ : min: " << min(Yp) << " max: " << max(Yp)
-                    << " average: " << average(Yp) << nl << endl;
+            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;
-- 
GitLab