From 4734b1af5bd96515945d68331d287224b5eaba62 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Thu, 9 Jun 2016 16:05:13 +0100
Subject: [PATCH] wallShearStress: utility replaced by functionObject used with
 the '-postProcess' option

---
 .../wall/wallShearStress/Make/files           |   3 -
 .../wall/wallShearStress/Make/options         |  23 --
 .../wall/wallShearStress/wallShearStress.C    | 211 ------------------
 bin/wallShearStress                           |   1 +
 .../postProcessing/fields/wallShearStress     |  18 ++
 src/functionObjects/field/Make/files          |   1 +
 .../wallShearStress/wallShearStress.C         |  52 +++--
 .../wallShearStress/wallShearStress.H         |   0
 src/functionObjects/forces/Make/files         |   1 -
 9 files changed, 48 insertions(+), 262 deletions(-)
 delete mode 100644 applications/utilities/postProcessing/wall/wallShearStress/Make/files
 delete mode 100644 applications/utilities/postProcessing/wall/wallShearStress/Make/options
 delete mode 100644 applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C
 create mode 120000 bin/wallShearStress
 create mode 100644 etc/caseDicts/postProcessing/fields/wallShearStress
 rename src/functionObjects/{forces => field}/wallShearStress/wallShearStress.C (94%)
 rename src/functionObjects/{forces => field}/wallShearStress/wallShearStress.H (100%)

diff --git a/applications/utilities/postProcessing/wall/wallShearStress/Make/files b/applications/utilities/postProcessing/wall/wallShearStress/Make/files
deleted file mode 100644
index 2af0d8c60f7..00000000000
--- a/applications/utilities/postProcessing/wall/wallShearStress/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-wallShearStress.C
-
-EXE = $(FOAM_APPBIN)/wallShearStress
diff --git a/applications/utilities/postProcessing/wall/wallShearStress/Make/options b/applications/utilities/postProcessing/wall/wallShearStress/Make/options
deleted file mode 100644
index 0128cf8401e..00000000000
--- a/applications/utilities/postProcessing/wall/wallShearStress/Make/options
+++ /dev/null
@@ -1,23 +0,0 @@
-EXE_INC = \
-    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-    -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-    -I$(LIB_SRC)/transportModels \
-    -I$(LIB_SRC)/turbulenceModels \
-    -I$(LIB_SRC)/transportModels/compressible/lnInclude \
-    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-    -I$(LIB_SRC)/finiteVolume/lnInclude \
-    -I$(LIB_SRC)/meshTools/lnInclude
-
-EXE_LIBS = \
-    -lturbulenceModels \
-    -lincompressibleTurbulenceModels \
-    -lcompressibleTurbulenceModels \
-    -lincompressibleTransportModels \
-    -lcompressibleTransportModels \
-    -lfluidThermophysicalModels \
-    -lspecie \
-    -lgenericPatchFields \
-    -lfiniteVolume \
-    -lfvOptions \
-    -lmeshTools
diff --git a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C b/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C
deleted file mode 100644
index 1406016e96a..00000000000
--- a/applications/utilities/postProcessing/wall/wallShearStress/wallShearStress.C
+++ /dev/null
@@ -1,211 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
-
-Application
-    wallShearStress
-
-Description
-    Calculates and reports the turbulent wall shear stress for all patches,
-    for the specified times.
-
-    Compressible modes is automatically selected based on the existence of the
-    "thermophysicalProperties" dictionary required to construct the
-    thermodynamics package.
-
-\*---------------------------------------------------------------------------*/
-
-#include "fvCFD.H"
-#include "turbulentTransportModel.H"
-#include "turbulentFluidThermoModel.H"
-#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-void calcIncompressible
-(
-    const fvMesh& mesh,
-    const Time& runTime,
-    const volVectorField& U,
-    volVectorField& wallShearStress
-)
-{
-    #include "createPhi.H"
-
-    singlePhaseTransportModel laminarTransport(U, phi);
-
-    autoPtr<incompressible::turbulenceModel> model
-    (
-        incompressible::turbulenceModel::New(U, phi, laminarTransport)
-    );
-
-    const volSymmTensorField Reff(model->devReff());
-
-    volVectorField::Boundary& wallShearStressBf =
-        wallShearStress.boundaryFieldRef();
-
-    forAll(wallShearStressBf, patchi)
-    {
-        wallShearStressBf[patchi] =
-        (
-           -mesh.Sf().boundaryField()[patchi]
-           /mesh.magSf().boundaryField()[patchi]
-        ) & Reff.boundaryField()[patchi];
-    }
-}
-
-
-void calcCompressible
-(
-    const fvMesh& mesh,
-    const Time& runTime,
-    const volVectorField& U,
-    volVectorField& wallShearStress
-)
-{
-    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<fluidThermo> pThermo(fluidThermo::New(mesh));
-    fluidThermo& thermo = pThermo();
-
-    autoPtr<compressible::turbulenceModel> model
-    (
-        compressible::turbulenceModel::New(rho, U, phi, thermo)
-    );
-
-    const volSymmTensorField Reff(model->devRhoReff());
-
-    volVectorField::Boundary& wallShearStressBf =
-        wallShearStress.boundaryFieldRef();
-
-    forAll(wallShearStressBf, patchi)
-    {
-        wallShearStressBf[patchi] =
-        (
-           -mesh.Sf().boundaryField()[patchi]
-           /mesh.magSf().boundaryField()[patchi]
-        ) & Reff.boundaryField()[patchi];
-    }
-}
-
-
-int main(int argc, char *argv[])
-{
-    timeSelector::addOptions();
-    #include "addRegionOption.H"
-    #include "setRootCase.H"
-    #include "createTime.H"
-    instantList timeDirs = timeSelector::select0(runTime, args);
-    #include "createNamedMesh.H"
-
-    forAll(timeDirs, timeI)
-    {
-        runTime.setTime(timeDirs[timeI], timeI);
-        Info<< "Time = " << runTime.timeName() << endl;
-        mesh.readUpdate();
-
-        volVectorField wallShearStress
-        (
-            IOobject
-            (
-                "wallShearStress",
-                runTime.timeName(),
-                mesh,
-                IOobject::NO_READ,
-                IOobject::AUTO_WRITE
-            ),
-            mesh,
-            dimensionedVector
-            (
-                "wallShearStress",
-                sqr(dimLength)/sqr(dimTime),
-                Zero
-            )
-        );
-
-        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()
-            )
-            {
-                calcCompressible(mesh, runTime, U, wallShearStress);
-            }
-            else
-            {
-                calcIncompressible(mesh, runTime, U, wallShearStress);
-            }
-        }
-        else
-        {
-            Info<< "    no U field" << endl;
-        }
-
-        Info<< "Writing wall shear stress to field " << wallShearStress.name()
-            << nl << endl;
-
-        wallShearStress.write();
-    }
-
-    Info<< "End" << endl;
-
-    return 0;
-}
-
-
-// ************************************************************************* //
diff --git a/bin/wallShearStress b/bin/wallShearStress
new file mode 120000
index 00000000000..ff6b4704c67
--- /dev/null
+++ b/bin/wallShearStress
@@ -0,0 +1 @@
+supercededByPostProcessOption
\ No newline at end of file
diff --git a/etc/caseDicts/postProcessing/fields/wallShearStress b/etc/caseDicts/postProcessing/fields/wallShearStress
new file mode 100644
index 00000000000..c4f5b96e89c
--- /dev/null
+++ b/etc/caseDicts/postProcessing/fields/wallShearStress
@@ -0,0 +1,18 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+
+wallShearStress
+{
+    type            wallShearStress;
+    libs            ("libfieldFunctionObjects.so");
+
+    executeControl  writeTime;
+    writeControl    writeTime;
+}
+
+// ************************************************************************* //
diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files
index 50ffce51de6..3b447f03120 100644
--- a/src/functionObjects/field/Make/files
+++ b/src/functionObjects/field/Make/files
@@ -52,5 +52,6 @@ MachNo/MachNo.C
 
 turbulenceFields/turbulenceFields.C
 yPlus/yPlus.C
+wallShearStress/wallShearStress.C
 
 LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
diff --git a/src/functionObjects/forces/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C
similarity index 94%
rename from src/functionObjects/forces/wallShearStress/wallShearStress.C
rename to src/functionObjects/field/wallShearStress/wallShearStress.C
index 0fbc1003cb1..9d56c7be3bd 100644
--- a/src/functionObjects/forces/wallShearStress/wallShearStress.C
+++ b/src/functionObjects/field/wallShearStress/wallShearStress.C
@@ -67,7 +67,6 @@ void Foam::functionObjects::wallShearStress::calcShearStress
     forAllConstIter(labelHashSet, patchSet_, iter)
     {
         label patchi = iter.key();
-        const polyPatch& pp = mesh.boundaryMesh()[patchi];
 
         vectorField& ssp = shearStress.boundaryFieldRef()[patchi];
         const vectorField& Sfp = mesh.Sf().boundaryField()[patchi];
@@ -75,21 +74,6 @@ void Foam::functionObjects::wallShearStress::calcShearStress
         const symmTensorField& Reffp = Reff.boundaryField()[patchi];
 
         ssp = (-Sfp/magSfp) & Reffp;
-
-        vector minSsp = gMin(ssp);
-        vector maxSsp = gMax(ssp);
-
-        if (Pstream::master())
-        {
-            file() << mesh.time().value()
-                << token::TAB << pp.name()
-                << token::TAB << minSsp
-                << token::TAB << maxSsp
-                << endl;
-        }
-
-        Log << "    min/max(" << pp.name() << ") = "
-            << minSsp << ", " << maxSsp << endl;
     }
 }
 
@@ -212,8 +196,6 @@ bool Foam::functionObjects::wallShearStress::execute(const bool postProcess)
     typedef compressible::turbulenceModel cmpModel;
     typedef incompressible::turbulenceModel icoModel;
 
-    writeFiles::write();
-
     const fvMesh& mesh = refCast<const fvMesh>(obr_);
 
     volVectorField& wallShearStress =
@@ -222,9 +204,6 @@ bool Foam::functionObjects::wallShearStress::execute(const bool postProcess)
             mesh.lookupObject<volVectorField>(type())
         );
 
-    Log << type() << " " << name() << " output:" << nl;
-
-
     tmp<volSymmTensorField> Reff;
     if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName))
     {
@@ -260,12 +239,37 @@ bool Foam::functionObjects::wallShearStress::write(const bool postProcess)
     const volVectorField& wallShearStress =
         obr_.lookupObject<volVectorField>(type());
 
-    Log << type() << " " << name() << " output:" << nl
-        << "    writing field " << wallShearStress.name() << nl
-        << endl;
+    Log << type() << " " << name() << " write:" << nl
+        << "    writing field " << wallShearStress.name() << endl;
 
     wallShearStress.write();
 
+    const fvMesh& mesh = refCast<const fvMesh>(obr_);
+    const fvPatchList& patches = mesh.boundary();
+
+    forAllConstIter(labelHashSet, patchSet_, iter)
+    {
+        label patchi = iter.key();
+        const fvPatch& pp = patches[patchi];
+
+        const vectorField& ssp = wallShearStress.boundaryField()[patchi];
+
+        vector minSsp = gMin(ssp);
+        vector maxSsp = gMax(ssp);
+
+        if (Pstream::master())
+        {
+            file() << mesh.time().value()
+                << token::TAB << pp.name()
+                << token::TAB << minSsp
+                << token::TAB << maxSsp
+                << endl;
+        }
+
+        Log << "    min/max(" << pp.name() << ") = "
+            << minSsp << ", " << maxSsp << endl;
+    }
+
     return true;
 }
 
diff --git a/src/functionObjects/forces/wallShearStress/wallShearStress.H b/src/functionObjects/field/wallShearStress/wallShearStress.H
similarity index 100%
rename from src/functionObjects/forces/wallShearStress/wallShearStress.H
rename to src/functionObjects/field/wallShearStress/wallShearStress.H
diff --git a/src/functionObjects/forces/Make/files b/src/functionObjects/forces/Make/files
index f4bde58606e..310f1d60ba5 100644
--- a/src/functionObjects/forces/Make/files
+++ b/src/functionObjects/forces/Make/files
@@ -1,4 +1,3 @@
-wallShearStress/wallShearStress.C
 forces/forces.C
 forceCoeffs/forceCoeffs.C
 
-- 
GitLab