From e5168727995e4e4080e39250960a3478c52d32f8 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Mon, 23 Nov 2015 13:49:03 +0000
Subject: [PATCH] TurbulenceModels: Correct nut during construction for
 single-phase solvers only. For multiphase solvers the phase construction is
 not complete at this point.

---
 .../RAS/LamBremhorstKE/LamBremhorstKE.C              |  9 ++++++++-
 .../RAS/LienCubicKE/LienCubicKE.C                    |  9 ++++++++-
 .../RAS/LienLeschziner/LienLeschziner.C              |  9 ++++++++-
 .../RAS/ShihQuadraticKE/ShihQuadraticKE.C            |  9 ++++++++-
 .../turbulentTransportModels/RAS/qZeta/qZeta.C       |  9 ++++++++-
 .../RAS/LaheyKEpsilon/LaheyKEpsilon.C                |  4 ++--
 .../LES/DeardorffDiffStress/DeardorffDiffStress.C    | 11 +++++++++--
 .../turbulenceModels/LES/Smagorinsky/Smagorinsky.C   |  9 ++++++++-
 .../LES/SpalartAllmarasDES/SpalartAllmarasDES.C      |  9 ++++++++-
 .../turbulenceModels/LES/WALE/WALE.C                 |  9 ++++++++-
 .../turbulenceModels/LES/dynamicKEqn/dynamicKEqn.C   |  9 ++++++++-
 .../LES/dynamicLagrangian/dynamicLagrangian.C        |  9 ++++++++-
 .../turbulenceModels/LES/kEqn/kEqn.C                 |  9 ++++++++-
 src/TurbulenceModels/turbulenceModels/RAS/LRR/LRR.C  | 12 ++++++++++--
 .../RAS/LaunderSharmaKE/LaunderSharmaKE.C            |  9 ++++++++-
 .../turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C   |  9 ++++++++-
 src/TurbulenceModels/turbulenceModels/RAS/SSG/SSG.C  | 12 ++++++++++--
 .../RAS/SpalartAllmaras/SpalartAllmaras.C            |  9 ++++++++-
 .../turbulenceModels/RAS/kEpsilon/kEpsilon.C         |  9 ++++++++-
 .../turbulenceModels/RAS/kOmega/kOmega.C             |  9 ++++++++-
 .../turbulenceModels/RAS/kOmegaSST/kOmegaSST.C       |  9 ++++++++-
 .../turbulenceModels/RAS/realizableKE/realizableKE.C |  9 ++++++++-
 src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C  |  9 ++++++++-
 23 files changed, 183 insertions(+), 27 deletions(-)

diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.C
index 1364f2cea28..d2417a85307 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.C
@@ -180,8 +180,15 @@ LamBremhorstKE::LamBremhorstKE
 
     if (type == typeName)
     {
-        correctNut();
         printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.C
index 4183371298f..440517134f0 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.C
@@ -330,8 +330,15 @@ LienCubicKE::LienCubicKE
 
     if (type == typeName)
     {
-        correctNut();
         printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.C
index 40f50293125..29b5aa0114f 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.C
@@ -224,8 +224,15 @@ LienLeschziner::LienLeschziner
 
     if (type == typeName)
     {
-        correctNut();
         printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.C
index 7c764f47470..38dc7ab62b4 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.C
@@ -222,8 +222,15 @@ ShihQuadraticKE::ShihQuadraticKE
 
     if (type == typeName)
     {
-        correctNut();
         printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.C
index a12b61f1a64..bc57fd4200e 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.C
@@ -207,8 +207,15 @@ qZeta::qZeta
 
     if (type == typeName)
     {
-        correctNut();
         printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/phaseCompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C b/src/TurbulenceModels/phaseCompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C
index f523fce5a0b..c7d0d22e442 100644
--- a/src/TurbulenceModels/phaseCompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C
+++ b/src/TurbulenceModels/phaseCompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C
@@ -106,10 +106,10 @@ LaheyKEpsilon<BasicTurbulenceModel>::LaheyKEpsilon
 {
     if (type == typeName)
     {
+        this->printCoeffs(type);
+
         // Cannot correct nut yet: construction of the phases is not complete
         // correctNut();
-
-        this->printCoeffs(type);
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/DeardorffDiffStress/DeardorffDiffStress.C b/src/TurbulenceModels/turbulenceModels/LES/DeardorffDiffStress/DeardorffDiffStress.C
index 31526fbf0c1..5a00433a347 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/DeardorffDiffStress/DeardorffDiffStress.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/DeardorffDiffStress/DeardorffDiffStress.C
@@ -110,9 +110,16 @@ DeardorffDiffStress<BasicTurbulenceModel>::DeardorffDiffStress
 {
     if (type == typeName)
     {
-        this->boundNormalStress(this->R_);
-        correctNut();
         this->printCoeffs(type);
+        this->boundNormalStress(this->R_);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/Smagorinsky/Smagorinsky.C b/src/TurbulenceModels/turbulenceModels/LES/Smagorinsky/Smagorinsky.C
index c3549fdd885..7de1f91f1ed 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/Smagorinsky/Smagorinsky.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/Smagorinsky/Smagorinsky.C
@@ -113,8 +113,15 @@ Smagorinsky<BasicTurbulenceModel>::Smagorinsky
 {
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/SpalartAllmarasDES/SpalartAllmarasDES.C b/src/TurbulenceModels/turbulenceModels/LES/SpalartAllmarasDES/SpalartAllmarasDES.C
index 53e22dd3847..fa6ddc86e3e 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/SpalartAllmarasDES/SpalartAllmarasDES.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/SpalartAllmarasDES/SpalartAllmarasDES.C
@@ -318,8 +318,15 @@ SpalartAllmarasDES<BasicTurbulenceModel>::SpalartAllmarasDES
 {
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/WALE/WALE.C b/src/TurbulenceModels/turbulenceModels/LES/WALE/WALE.C
index 674c889b1c4..3879d5fffe1 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/WALE/WALE.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/WALE/WALE.C
@@ -143,8 +143,15 @@ WALE<BasicTurbulenceModel>::WALE
 {
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/dynamicKEqn/dynamicKEqn.C b/src/TurbulenceModels/turbulenceModels/LES/dynamicKEqn/dynamicKEqn.C
index 9f98bea0247..7fd40001837 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/dynamicKEqn/dynamicKEqn.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/dynamicKEqn/dynamicKEqn.C
@@ -185,8 +185,15 @@ dynamicKEqn<BasicTurbulenceModel>::dynamicKEqn
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/dynamicLagrangian/dynamicLagrangian.C b/src/TurbulenceModels/turbulenceModels/LES/dynamicLagrangian/dynamicLagrangian.C
index 15908a4ffee..7c5c403fcc8 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/dynamicLagrangian/dynamicLagrangian.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/dynamicLagrangian/dynamicLagrangian.C
@@ -122,8 +122,15 @@ dynamicLagrangian<BasicTurbulenceModel>::dynamicLagrangian
 {
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C
index eda73f69294..c02556ea037 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C
+++ b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C
@@ -113,8 +113,15 @@ kEqn<BasicTurbulenceModel>::kEqn
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/LRR/LRR.C b/src/TurbulenceModels/turbulenceModels/RAS/LRR/LRR.C
index 7dfa45a031a..fe33923d197 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/LRR/LRR.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/LRR/LRR.C
@@ -200,11 +200,19 @@ LRR<BasicTurbulenceModel>::LRR
 {
     if (type == typeName)
     {
+        this->printCoeffs(type);
+
         this->boundNormalStress(this->R_);
         bound(epsilon_, this->epsilonMin_);
         k_ = 0.5*tr(this->R_);
-        correctNut();
-        this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C
index ef6809fcfc7..e5ef40222a7 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C
@@ -204,8 +204,15 @@ LaunderSharmaKE<BasicTurbulenceModel>::LaunderSharmaKE
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C
index 5406367db63..18d22249274 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C
@@ -205,8 +205,15 @@ RNGkEpsilon<BasicTurbulenceModel>::RNGkEpsilon
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/SSG/SSG.C b/src/TurbulenceModels/turbulenceModels/RAS/SSG/SSG.C
index 4d61b3db653..34798924b69 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/SSG/SSG.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/SSG/SSG.C
@@ -209,11 +209,19 @@ SSG<BasicTurbulenceModel>::SSG
 {
     if (type == typeName)
     {
+        this->printCoeffs(type);
+
         this->boundNormalStress(this->R_);
         bound(epsilon_, this->epsilonMin_);
         k_ = 0.5*tr(this->R_);
-        correctNut();
-        this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C
index 8c5e5b2da53..50f9a989f0b 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.C
@@ -255,8 +255,15 @@ SpalartAllmaras<BasicTurbulenceModel>::SpalartAllmaras
 {
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C
index e4a45b01fb8..7cf2b1fc10d 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C
@@ -188,7 +188,14 @@ kEpsilon<BasicTurbulenceModel>::kEpsilon
     if (type == typeName)
     {
         this->printCoeffs(type);
-        correctNut();
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmega/kOmega.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmega/kOmega.C
index 412a6b3e6b4..4578b5811f7 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/kOmega/kOmega.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmega/kOmega.C
@@ -147,8 +147,15 @@ kOmega<BasicTurbulenceModel>::kOmega
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C
index 76fd9cf0c35..f634aa65beb 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C
@@ -350,8 +350,15 @@ kOmegaSST<BasicTurbulenceModel>::kOmegaSST
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C
index 597d21f1ebb..c3428a64c97 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C
@@ -226,8 +226,15 @@ realizableKE<BasicTurbulenceModel>::realizableKE
 
     if (type == typeName)
     {
-        correctNut();
         this->printCoeffs(type);
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C
index 1ccad744858..95cb209a45d 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C
@@ -239,7 +239,14 @@ v2f<BasicTurbulenceModel>::v2f
     if (type == typeName)
     {
         this->printCoeffs(type);
-        correctNut();
+
+        // Correct nut for single-phase solvers only.
+        // For multiphase solvers the phase construction is not complete
+        // at this point.
+        if (isType<geometricOneField>(alpha))
+        {
+            correctNut();
+        }
     }
 }
 
-- 
GitLab