From 299c4a109e442ce3d0d1581c8db1d7d9da7d77e5 Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Fri, 4 Apr 2014 17:02:51 +0100
Subject: [PATCH] ENH: wall function updates for ACMI

---
 .../epsilonWallFunctionFvPatchScalarField.C   | 20 ++++++-----
 .../epsilonWallFunctionFvPatchScalarField.H   |  5 ++-
 .../omegaWallFunctionFvPatchScalarField.C     | 36 ++++++++++---------
 .../omegaWallFunctionFvPatchScalarField.H     |  5 ++-
 .../epsilonWallFunctionFvPatchScalarField.C   | 20 ++++++-----
 .../epsilonWallFunctionFvPatchScalarField.H   |  5 ++-
 .../omegaWallFunctionFvPatchScalarField.C     | 36 ++++++++++---------
 .../omegaWallFunctionFvPatchScalarField.H     |  5 ++-
 8 files changed, 80 insertions(+), 52 deletions(-)

diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
index 8e2fc1156ca..b0899d12f6e 100644
--- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
@@ -38,6 +38,10 @@ namespace Foam
 namespace compressible
 {
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+scalar epsilonWallFunctionFvPatchScalarField::tolerance_ = 1e-5;
+
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void epsilonWallFunctionFvPatchScalarField::checkType()
@@ -469,17 +473,17 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs
 
     scalarField& epsilonf = *this;
 
-    // only set the values if the weights are < 1 - tolerance
+    // only set the values if the weights are > tolerance
     forAll(weights, faceI)
     {
         scalar w = weights[faceI];
 
-        if (w < 1.0 - 1e-6)
+        if (w > tolerance_)
         {
             label cellI = patch().faceCells()[faceI];
 
-            G[cellI] = w*G[cellI] + (1.0 - w)*G0[cellI];
-            epsilon[cellI] = w*epsilon[cellI] + (1.0 - w)*epsilon0[cellI];
+            G[cellI] = (1.0 - w)*G[cellI] + w*G0[cellI];
+            epsilon[cellI] = (1.0 - w)*epsilon[cellI] + w*epsilon0[cellI];
             epsilonf[faceI] = epsilon[cellI];
         }
     }
@@ -521,16 +525,16 @@ void epsilonWallFunctionFvPatchScalarField::manipulateMatrix
     DynamicList<scalar> constraintEpsilon(weights.size());
     const labelUList& faceCells = patch().faceCells();
 
-    const DimensionedField<scalar, volMesh>& epsilon
-        = dimensionedInternalField();
+    const DimensionedField<scalar, volMesh>& epsilon =
+        dimensionedInternalField();
 
     label nConstrainedCells = 0;
 
 
     forAll(weights, faceI)
     {
-        // only set the values if the weights are < 1 - tolerance
-        if (weights[faceI] < (1.0 - 1e-6))
+        // only set the values if the weights are > tolerance
+        if (weights[faceI] > tolerance_)
         {
             nConstrainedCells++;
 
diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
index 9eefc78620e..b024313213d 100644
--- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -94,6 +94,9 @@ protected:
 
     // Protected data
 
+        //- Tolerance used in weighted calculations
+        static scalar tolerance_;
+
         //- Cmu coefficient
         scalar Cmu_;
 
diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
index 506b652a1d7..4fa243302b1 100644
--- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
@@ -39,6 +39,10 @@ namespace Foam
 namespace compressible
 {
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+scalar omegaWallFunctionFvPatchScalarField::tolerance_ = 1e-5;
+
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
 void omegaWallFunctionFvPatchScalarField::checkType()
@@ -81,14 +85,14 @@ void omegaWallFunctionFvPatchScalarField::setMaster()
     {
         if (isA<omegaWallFunctionFvPatchScalarField>(bf[patchI]))
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
             if (master == -1)
             {
                 master = patchI;
             }
 
-            epf.master() = master;
+            opf.master() = master;
         }
     }
 }
@@ -162,10 +166,10 @@ omegaWallFunctionFvPatchScalarField::omegaPatch(const label patchI)
 
     const volScalarField::GeometricBoundaryField& bf = omega.boundaryField();
 
-    const omegaWallFunctionFvPatchScalarField& epf =
+    const omegaWallFunctionFvPatchScalarField& opf =
         refCast<const omegaWallFunctionFvPatchScalarField>(bf[patchI]);
 
-    return const_cast<omegaWallFunctionFvPatchScalarField&>(epf);
+    return const_cast<omegaWallFunctionFvPatchScalarField&>(opf);
 }
 
 
@@ -181,11 +185,11 @@ void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields
     {
         if (!cornerWeights_[patchI].empty())
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
             const List<scalar>& w = cornerWeights_[patchI];
 
-            epf.calculate(turbulence, w, epf.patch(), G0, omega0);
+            opf.calculate(turbulence, w, opf.patch(), G0, omega0);
         }
     }
 
@@ -194,9 +198,9 @@ void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields
     {
         if (!cornerWeights_[patchI].empty())
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
-            epf == scalarField(omega0, epf.patch().faceCells());
+            opf == scalarField(omega0, opf.patch().faceCells());
         }
     }
 }
@@ -486,17 +490,17 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs
 
     scalarField& omegaf = *this;
 
-    // only set the values if the weights are < 1 - tolerance
+    // only set the values if the weights are > tolerance_
     forAll(weights, faceI)
     {
         scalar w = weights[faceI];
 
-        if (w < 1.0 - 1e-6)
+        if (w > tolerance_)
         {
             label cellI = patch().faceCells()[faceI];
 
-            G[cellI] = w*G[cellI] + (1.0 - w)*G0[cellI];
-            omega[cellI] = w*omega[cellI] + (1.0 - w)*omega0[cellI];
+            G[cellI] = (1.0 - w)*G[cellI] + w*G0[cellI];
+            omega[cellI] = (1.0 - w)*omega[cellI] + w*omega0[cellI];
             omegaf[faceI] = omega[cellI];
         }
     }
@@ -538,16 +542,16 @@ void omegaWallFunctionFvPatchScalarField::manipulateMatrix
     DynamicList<scalar> constraintomega(weights.size());
     const labelUList& faceCells = patch().faceCells();
 
-    const DimensionedField<scalar, volMesh>& omega
-        = dimensionedInternalField();
+    const DimensionedField<scalar, volMesh>& omega =
+        dimensionedInternalField();
 
     label nConstrainedCells = 0;
 
 
     forAll(weights, faceI)
     {
-        // only set the values if the weights are < 1 - tolerance
-        if (weights[faceI] < (1.0 - 1e-6))
+        // only set the values if the weights are > tolerance
+        if (weights[faceI] > tolerance_)
         {
             nConstrainedCells++;
 
diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
index 9db8e32a8d6..a17c65ef4a2 100644
--- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -99,6 +99,9 @@ protected:
 
     // Protected data
 
+        //- Tolerance used in weighted calculations
+        static scalar tolerance_;
+
         //- Cmu coefficient
         scalar Cmu_;
 
diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
index 0520f7267e0..9a8841f7849 100644
--- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
@@ -38,6 +38,10 @@ namespace Foam
 namespace incompressible
 {
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+scalar epsilonWallFunctionFvPatchScalarField::tolerance_ = 1e-5;
+
 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
 
 void epsilonWallFunctionFvPatchScalarField::checkType()
@@ -469,17 +473,17 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs
 
     scalarField& epsilonf = *this;
 
-    // only set the values if the weights are < 1 - tolerance
+    // only set the values if the weights are > tolerance
     forAll(weights, faceI)
     {
         scalar w = weights[faceI];
 
-        if (w < 1.0 - 1e-6)
+        if (w > tolerance_)
         {
             label cellI = patch().faceCells()[faceI];
 
-            G[cellI] = w*G[cellI] + (1.0 - w)*G0[cellI];
-            epsilon[cellI] = w*epsilon[cellI] + (1.0 - w)*epsilon0[cellI];
+            G[cellI] = (1.0 - w)*G[cellI] + w*G0[cellI];
+            epsilon[cellI] = (1.0 - w)*epsilon[cellI] + w*epsilon0[cellI];
             epsilonf[faceI] = epsilon[cellI];
         }
     }
@@ -521,16 +525,16 @@ void epsilonWallFunctionFvPatchScalarField::manipulateMatrix
     DynamicList<scalar> constraintEpsilon(weights.size());
     const labelUList& faceCells = patch().faceCells();
 
-    const DimensionedField<scalar, volMesh>& epsilon
-        = dimensionedInternalField();
+    const DimensionedField<scalar, volMesh>& epsilon =
+        dimensionedInternalField();
 
     label nConstrainedCells = 0;
 
 
     forAll(weights, faceI)
     {
-        // only set the values if the weights are < 1 - tolerance
-        if (weights[faceI] < (1.0 - 1e-6))
+        // only set the values if the weights are > tolerance
+        if (weights[faceI] > tolerance_)
         {
             nConstrainedCells++;
 
diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
index 61de72a385f..ef2eeeb831d 100644
--- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -94,6 +94,9 @@ protected:
 
     // Protected data
 
+        //- Tolerance used in weighted calculations
+        static scalar tolerance_;
+
         //- Cmu coefficient
         scalar Cmu_;
 
diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
index 3cc0370ac69..066f03a0b7c 100644
--- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
+++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
@@ -39,6 +39,10 @@ namespace Foam
 namespace incompressible
 {
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+scalar omegaWallFunctionFvPatchScalarField::tolerance_ = 1e-5;
+
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
 void omegaWallFunctionFvPatchScalarField::checkType()
@@ -81,14 +85,14 @@ void omegaWallFunctionFvPatchScalarField::setMaster()
     {
         if (isA<omegaWallFunctionFvPatchScalarField>(bf[patchI]))
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
             if (master == -1)
             {
                 master = patchI;
             }
 
-            epf.master() = master;
+            opf.master() = master;
         }
     }
 }
@@ -162,10 +166,10 @@ omegaWallFunctionFvPatchScalarField::omegaPatch(const label patchI)
 
     const volScalarField::GeometricBoundaryField& bf = omega.boundaryField();
 
-    const omegaWallFunctionFvPatchScalarField& epf =
+    const omegaWallFunctionFvPatchScalarField& opf =
         refCast<const omegaWallFunctionFvPatchScalarField>(bf[patchI]);
 
-    return const_cast<omegaWallFunctionFvPatchScalarField&>(epf);
+    return const_cast<omegaWallFunctionFvPatchScalarField&>(opf);
 }
 
 
@@ -181,11 +185,11 @@ void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields
     {
         if (!cornerWeights_[patchI].empty())
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
             const List<scalar>& w = cornerWeights_[patchI];
 
-            epf.calculate(turbulence, w, epf.patch(), G0, omega0);
+            opf.calculate(turbulence, w, opf.patch(), G0, omega0);
         }
     }
 
@@ -194,9 +198,9 @@ void omegaWallFunctionFvPatchScalarField::calculateTurbulenceFields
     {
         if (!cornerWeights_[patchI].empty())
         {
-            omegaWallFunctionFvPatchScalarField& epf = omegaPatch(patchI);
+            omegaWallFunctionFvPatchScalarField& opf = omegaPatch(patchI);
 
-            epf == scalarField(omega0, epf.patch().faceCells());
+            opf == scalarField(omega0, opf.patch().faceCells());
         }
     }
 }
@@ -484,17 +488,17 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs
 
     scalarField& omegaf = *this;
 
-    // only set the values if the weights are < 1 - tolerance
+    // only set the values if the weights are > tolerance
     forAll(weights, faceI)
     {
         scalar w = weights[faceI];
 
-        if (w < 1.0 - 1e-6)
+        if (w > tolerance_)
         {
             label cellI = patch().faceCells()[faceI];
 
-            G[cellI] = w*G[cellI] + (1.0 - w)*G0[cellI];
-            omega[cellI] = w*omega[cellI] + (1.0 - w)*omega0[cellI];
+            G[cellI] = (1.0 - w)*G[cellI] + w*G0[cellI];
+            omega[cellI] = (1.0 - w)*omega[cellI] + w*omega0[cellI];
             omegaf[faceI] = omega[cellI];
         }
     }
@@ -536,16 +540,16 @@ void omegaWallFunctionFvPatchScalarField::manipulateMatrix
     DynamicList<scalar> constraintomega(weights.size());
     const labelUList& faceCells = patch().faceCells();
 
-    const DimensionedField<scalar, volMesh>& omega
-        = dimensionedInternalField();
+    const DimensionedField<scalar, volMesh>& omega =
+        dimensionedInternalField();
 
     label nConstrainedCells = 0;
 
 
     forAll(weights, faceI)
     {
-        // only set the values if the weights are < 1 - tolerance
-        if (weights[faceI] < (1.0 - 1e-6))
+        // only set the values if the weights are > tolerance
+        if (weights[faceI] > tolerance_)
         {
             nConstrainedCells++;
 
diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
index 957d0f945ee..496062792eb 100644
--- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
+++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -99,6 +99,9 @@ protected:
 
     // Protected data
 
+        //- Tolerance used in weighted calculations
+        static scalar tolerance_;
+
         //- Cmu coefficient
         scalar Cmu_;
 
-- 
GitLab