From e9b6c5f293624e0510d8996c1e692d283307652e Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Wed, 11 Sep 2013 22:59:00 +0100
Subject: [PATCH] Rationalise all correctPhi implementations

---
 .../rhoPimpleDyMFoam/correctPhi.H             | 38 +++++++++----------
 .../pimpleFoam/pimpleDyMFoam/correctPhi.H     |  8 ++--
 .../cavitatingDyMFoam/correctPhi.H            | 23 +++++++++++
 .../compressibleInterDyMFoam/correctPhi.H     | 38 +++++++++----------
 .../multiphaseEulerFoam/correctPhi.H          | 18 +--------
 .../multiphaseEulerFoam/multiphaseEulerFoam.C |  1 +
 6 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H
index 24316a16854..e916b7a56aa 100644
--- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H
+++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/correctPhi.H
@@ -1,30 +1,30 @@
+if (mesh.changing())
 {
-    if (mesh.changing())
+    forAll(U.boundaryField(), patchi)
     {
-        forAll(U.boundaryField(), patchi)
+        if (U.boundaryField()[patchi].fixesValue())
         {
-            if (U.boundaryField()[patchi].fixesValue())
-            {
-                U.boundaryField()[patchi].initEvaluate();
-            }
+            U.boundaryField()[patchi].initEvaluate();
         }
+    }
 
-        forAll(U.boundaryField(), patchi)
+    forAll(U.boundaryField(), patchi)
+    {
+        if (U.boundaryField()[patchi].fixesValue())
         {
-            if (U.boundaryField()[patchi].fixesValue())
-            {
-                U.boundaryField()[patchi].evaluate();
+            U.boundaryField()[patchi].evaluate();
 
-                phi.boundaryField()[patchi] =
-                    rho.boundaryField()[patchi]
-                   *(
-                       U.boundaryField()[patchi]
-                     & mesh.Sf().boundaryField()[patchi]
-                    );
-            }
+            phi.boundaryField()[patchi] =
+                rho.boundaryField()[patchi]
+               *(
+                   U.boundaryField()[patchi]
+                 & mesh.Sf().boundaryField()[patchi]
+               );
         }
     }
+}
 
+{
     volScalarField pcorr
     (
         IOobject
@@ -40,13 +40,13 @@
         pcorrTypes
     );
 
-    dimensionedScalar Dp("Dp", dimTime, 1.0);
+    dimensionedScalar rAUf("rAUf", dimTime, 1.0);
 
     while (pimple.correctNonOrthogonal())
     {
         fvScalarMatrix pcorrEqn
         (
-            fvm::laplacian(Dp, pcorr) == fvc::div(phi) - divrhoU
+            fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divrhoU
         );
 
         pcorrEqn.solve();
diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H
index ebc62e7e592..b693bb78607 100644
--- a/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H
+++ b/applications/solvers/incompressible/pimpleFoam/pimpleDyMFoam/correctPhi.H
@@ -37,13 +37,13 @@ if (mesh.changing())
         pcorrTypes
     );
 
-    dimensionedScalar Dp("Dp", dimTime, 1.0);
+    dimensionedScalar rAUf("rAUf", dimTime, 1.0);
 
     while (pimple.correctNonOrthogonal())
     {
         fvScalarMatrix pcorrEqn
         (
-            fvm::laplacian(Dp, pcorr) == fvc::div(phi)
+            fvm::laplacian(rAUf, pcorr) == fvc::div(phi)
         );
 
         pcorrEqn.setReference(pRefCell, pRefValue);
@@ -54,6 +54,6 @@ if (mesh.changing())
             phi -= pcorrEqn.flux();
         }
     }
-}
 
-#include "continuityErrs.H"
+    #include "continuityErrs.H"
+}
diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H
index 52e73a6f404..c05d664838b 100644
--- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H
+++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H
@@ -1,3 +1,26 @@
+if (mesh.changing())
+{
+    forAll(U.boundaryField(), patchI)
+    {
+        if (U.boundaryField()[patchI].fixesValue())
+        {
+            U.boundaryField()[patchI].initEvaluate();
+        }
+    }
+
+    forAll(U.boundaryField(), patchI)
+    {
+        if (U.boundaryField()[patchI].fixesValue())
+        {
+            U.boundaryField()[patchI].evaluate();
+
+            phiv.boundaryField()[patchI] =
+                U.boundaryField()[patchI]
+              & mesh.Sf().boundaryField()[patchI];
+        }
+    }
+}
+
 {
     volScalarField pcorr
     (
diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H
index 76e9217b650..97c63e6a3ee 100644
--- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H
+++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/correctPhi.H
@@ -1,28 +1,26 @@
+if (mesh.changing())
 {
-    if (mesh.changing())
+    forAll(U.boundaryField(), patchi)
     {
-        forAll(U.boundaryField(), patchi)
+        if (U.boundaryField()[patchi].fixesValue())
         {
-            if (U.boundaryField()[patchi].fixesValue())
-            {
-                U.boundaryField()[patchi].initEvaluate();
-            }
+            U.boundaryField()[patchi].initEvaluate();
         }
+    }
 
-        forAll(U.boundaryField(), patchi)
+    forAll(U.boundaryField(), patchi)
+    {
+        if (U.boundaryField()[patchi].fixesValue())
         {
-            if (U.boundaryField()[patchi].fixesValue())
-            {
-                U.boundaryField()[patchi].evaluate();
+            U.boundaryField()[patchi].evaluate();
 
-                phi.boundaryField()[patchi] =
-                U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi];
-            }
+            phi.boundaryField()[patchi] =
+            U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi];
         }
     }
+}
 
-    #include "continuityErrs.H"
-
+{
     volScalarField pcorr
     (
         IOobject
@@ -38,13 +36,13 @@
         pcorrTypes
     );
 
-    dimensionedScalar Dp("Dp", dimTime/rho.dimensions(), 1.0);
+    dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
 
     while (pimple.correctNonOrthogonal())
     {
         fvScalarMatrix pcorrEqn
         (
-            fvm::laplacian(Dp, pcorr) == fvc::div(phi) - divU
+            fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
         );
 
         pcorrEqn.solve();
@@ -54,8 +52,8 @@
             phi -= pcorrEqn.flux();
         }
     }
-}
 
-phi.oldTime() = phi;
+    phi.oldTime() = phi;
 
-#include "continuityErrs.H"
+    #include "continuityErrs.H"
+}
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H
index 57a79b6091c..e291b7dbcd2 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H
@@ -1,20 +1,6 @@
 {
     #include "continuityErrs.H"
 
-    wordList pcorrTypes
-    (
-        p.boundaryField().size(),
-        zeroGradientFvPatchScalarField::typeName
-    );
-
-    forAll (p.boundaryField(), i)
-    {
-        if (p.boundaryField()[i].fixesValue())
-        {
-            pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
-        }
-    }
-
     volScalarField pcorr
     (
         IOobject
@@ -30,9 +16,7 @@
         pcorrTypes
     );
 
-    dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0);
-
-    //adjustPhi(phi, U, pcorr);
+    dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
 
     while (pimple.correctNonOrthogonal())
     {
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseEulerFoam.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseEulerFoam.C
index 0c5c8a2a864..aacc4b6d498 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseEulerFoam.C
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseEulerFoam.C
@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
     #include "createMRFZones.H"
     #include "initContinuityErrs.H"
     #include "readTimeControls.H"
+    #include "createPcorrTypes.H"
     #include "correctPhi.H"
     #include "CourantNo.H"
     #include "setInitialDeltaT.H"
-- 
GitLab