From f5bb944965116ba6d87c88872242ffbf9e8d0599 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Sun, 12 Apr 2015 09:57:56 +0100
Subject: [PATCH] twoPhaseEulerFoam: Improved handling of velocity/flux
 boundary conditions Updated tutorials to converge pressure during PIMPLE loop
 to avoid phase-fraction unboundedness which limits thermodynamics
 convergence.

---
 .../multiphase/twoPhaseEulerFoam/UEqns.H      |  2 ++
 .../multiphase/twoPhaseEulerFoam/pEqn.H       | 19 +++++---------
 .../twoPhaseEulerFoam/twoPhaseEulerFoam.C     |  1 +
 .../BlendedInterfacialModel.C                 | 24 +++++++++++++----
 .../BlendedInterfacialModel.H                 |  6 ++++-
 .../twoPhaseSystem/twoPhaseSystem.C           |  3 ++-
 .../LES/bubbleColumn/0/T.water                |  2 +-
 .../LES/bubbleColumn/system/fvSolution        |  2 +-
 .../RAS/bubbleColumn/0/T.water                |  2 +-
 .../RAS/bubbleColumn/system/fvSolution        |  2 +-
 .../RAS/fluidisedBed/system/fvSolution        |  2 +-
 .../laminar/bubbleColumn/0/T.water            |  2 +-
 .../laminar/bubbleColumn/system/fvSolution    |  2 +-
 .../laminar/bubbleColumnIATE/0/T.water        |  2 +-
 .../bubbleColumnIATE/system/fvSolution        |  2 +-
 .../laminar/fluidisedBed/system/fvSolution    |  2 +-
 .../laminar/injection/constant/fvOptions      |  2 +-
 .../laminar/injection/system/fvSolution       |  2 +-
 .../laminar/mixerVessel2D/system/fvSolution   | 26 +++++++++++--------
 19 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H
index 1cee6d04813..6c765ec66b9 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H
@@ -30,6 +30,7 @@ volScalarField dragCoeff(fluid.dragCoeff());
         U1Eqn.relax();
         U1Eqn += fvm::Sp(dragCoeff, U1);
         fvOptions.constrain(U1Eqn);
+        U1.correctBoundaryConditions();
     }
 
     {
@@ -52,5 +53,6 @@ volScalarField dragCoeff(fluid.dragCoeff());
         U2Eqn.relax();
         U2Eqn += fvm::Sp(dragCoeff, U2);
         fvOptions.constrain(U2Eqn);
+        U2.correctBoundaryConditions();
     }
 }
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H
index 0924c5d178c..b0a5ae9e7ce 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/pEqn.H
@@ -13,6 +13,12 @@ while (pimple.correct())
     // Update continuity errors due to temperature changes
     #include "correctContErrs.H"
 
+    // Correct flux BCs to be consistent with the velocity BCs
+    phi1.boundaryField() ==
+        mrfZones.relative(mesh.Sf().boundaryField() & U1.boundaryField());
+    phi2.boundaryField() ==
+        mrfZones.relative(mesh.Sf().boundaryField() & U2.boundaryField());
+
     volVectorField HbyA1
     (
         IOobject::groupName("HbyA", phase1.name()),
@@ -92,9 +98,9 @@ while (pimple.correct())
     surfaceScalarField phiCorrCoeff1(pos(alpha1fBar - 0.99));
     surfaceScalarField phiCorrCoeff2(pos(0.01 - alpha1fBar));
 
-    // Set ddtPhiCorr to 0 on non-coupled boundaries
     forAll(mesh.boundary(), patchi)
     {
+        // Set ddtPhiCorr to 0 on non-coupled boundaries
         if
         (
             !mesh.boundary()[patchi].coupled()
@@ -272,18 +278,7 @@ while (pimple.correct())
                     ((phi1s + D1f*phi2s) - (phi2s + D2f*phi1s))/(1 - D1f*D2f)
                 );
 
-                phi1.boundaryField() ==
-                    mrfZones.relative
-                    (
-                        mesh.Sf().boundaryField() & U1.boundaryField()
-                    );
                 phi1 = phi + alpha2f*phir;
-
-                phi2.boundaryField() ==
-                    mrfZones.relative
-                    (
-                        mesh.Sf().boundaryField() & U2.boundaryField()
-                    );
                 phi2 = phi - alpha1f*phir;
             }
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C
index f9effa437ba..f518de61778 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C
@@ -37,6 +37,7 @@ Description
 #include "IOMRFZoneList.H"
 #include "fvIOoptionList.H"
 #include "fixedFluxPressureFvPatchScalarField.H"
+#include "fixedValueFvsPatchFields.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C
index a41165d8ee9..93d9bb4c78b 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.C
@@ -60,13 +60,15 @@ Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
     const blendingMethod& blending,
     const phasePair& pair,
     const orderedPhasePair& pair1In2,
-    const orderedPhasePair& pair2In1
+    const orderedPhasePair& pair2In1,
+    const bool correctFixedFluxBCs
 )
 :
     pair_(pair),
     pair1In2_(pair1In2),
     pair2In1_(pair2In1),
-    blending_(blending)
+    blending_(blending),
+    correctFixedFluxBCs_(correctFixedFluxBCs)
 {
     if (modelTable.found(pair_))
     {
@@ -161,7 +163,11 @@ Foam::BlendedInterfacialModel<modelType>::K() const
         x() += model2In1_->K()*f2;
     }
 
-    if (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    if
+    (
+        correctFixedFluxBCs_
+     && (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    )
     {
         correctFixedFluxBCs(x());
     }
@@ -217,7 +223,11 @@ Foam::BlendedInterfacialModel<modelType>::F() const
         x() -= model2In1_->F()*f2; // note : subtraction
     }
 
-    if (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    if
+    (
+        correctFixedFluxBCs_
+     && (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    )
     {
         correctFixedFluxBCs(x());
     }
@@ -272,7 +282,11 @@ Foam::BlendedInterfacialModel<modelType>::D() const
         x() += model2In1_->D()*f2;
     }
 
-    if (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    if
+    (
+        correctFixedFluxBCs_
+     && (model_.valid() || model1In2_.valid() || model2In1_.valid())
+    )
     {
         correctFixedFluxBCs(x());
     }
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H
index aa3bb3df2e0..f56ab025b66 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H
@@ -75,6 +75,9 @@ class BlendedInterfacialModel
         //- Blending model
         const blendingMethod& blending_;
 
+        //- If true set coefficients and forces to 0 at fixed-flux BCs
+        bool correctFixedFluxBCs_;
+
 
     // Private Member Functions
 
@@ -103,7 +106,8 @@ public:
             const blendingMethod& blending,
             const phasePair& pair,
             const orderedPhasePair& pair1In2,
-            const orderedPhasePair& pair2In1
+            const orderedPhasePair& pair2In1,
+            const bool correctFixedFluxBCs = true
         );
 
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C
index d7a58a38096..32ca0ace850 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/twoPhaseSystem.C
@@ -184,7 +184,8 @@ Foam::twoPhaseSystem::twoPhaseSystem
             ),
             pair_,
             pair1In2_,
-            pair2In1_
+            pair2In1_,
+            false // Do not zero drag coefficent at fixed-flux BCs
         )
     );
 
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/0/T.water b/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/0/T.water
index d19f29f191e..3c62df75d0c 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/0/T.water
+++ b/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/0/T.water
@@ -28,7 +28,7 @@ boundaryField
     {
         type               inletOutlet;
         phi                phi.water;
-        inletValue         uniform 300;
+        inletValue         $internalField;
         value              $internalField;
     }
     inlet
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/system/fvSolution
index 1e0e5d0f07b..de1aecacf93 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/LES/bubbleColumn/system/fvSolution
@@ -35,7 +35,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/0/T.water b/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/0/T.water
index d19f29f191e..3c62df75d0c 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/0/T.water
+++ b/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/0/T.water
@@ -28,7 +28,7 @@ boundaryField
     {
         type               inletOutlet;
         phi                phi.water;
-        inletValue         uniform 300;
+        inletValue         $internalField;
         value              $internalField;
     }
     inlet
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/system/fvSolution
index 9868241ad99..f6f72076f0b 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/RAS/bubbleColumn/system/fvSolution
@@ -35,7 +35,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/system/fvSolution
index 0328d987376..49d9bfea716 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/system/fvSolution
@@ -42,7 +42,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/0/T.water b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/0/T.water
index 1cfd38f9265..e592c501d54 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/0/T.water
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/0/T.water
@@ -28,7 +28,7 @@ boundaryField
     {
         type               inletOutlet;
         phi                phi.water;
-        inletValue         uniform 300;
+        inletValue         $internalField;
         value              $internalField;
     }
     inlet
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/system/fvSolution
index 6487d35276d..350b0c0c1fe 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumn/system/fvSolution
@@ -35,7 +35,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/0/T.water b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/0/T.water
index d19f29f191e..3c62df75d0c 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/0/T.water
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/0/T.water
@@ -28,7 +28,7 @@ boundaryField
     {
         type               inletOutlet;
         phi                phi.water;
-        inletValue         uniform 300;
+        inletValue         $internalField;
         value              $internalField;
     }
     inlet
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/system/fvSolution
index 171537ad317..28572b1e0ae 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/bubbleColumnIATE/system/fvSolution
@@ -35,7 +35,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/fluidisedBed/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/laminar/fluidisedBed/system/fvSolution
index 5ca69b0fcd9..d5d97565bd2 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/fluidisedBed/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/fluidisedBed/system/fvSolution
@@ -42,7 +42,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions
index 5bcb5c0dbb1..f231c3d6054 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/constant/fvOptions
@@ -23,7 +23,7 @@ injector1
     selectionMode   points;
     points
     (
-        (0.075 0.1 0.05)
+        (0.075 0.2 0.05)
     );
 }
 
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/system/fvSolution
index 6487d35276d..350b0c0c1fe 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/injection/system/fvSolution
@@ -35,7 +35,7 @@ solvers
         agglomerator    faceAreaPair;
         mergeLevels     1;
         tolerance       1e-8;
-        relTol          0.01;
+        relTol          0;
     }
 
     p_rghFinal
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/fvSolution b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/fvSolution
index 59c0cbf3ab2..a95a952401d 100644
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/fvSolution
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/system/fvSolution
@@ -25,17 +25,21 @@ solvers
 
     p_rgh
     {
-        solver          GAMG;
-        smoother        DIC;
-        nPreSweeps      0;
-        nPostSweeps     2;
-        nFinestSweeps   2;
-        cacheAgglomeration true;
-        nCellsInCoarsestLevel 10;
-        agglomerator    faceAreaPair;
-        mergeLevels     1;
-        tolerance       1e-7;
-        relTol          0.01;
+        solver          PCG;
+        preconditioner
+        {
+            preconditioner  GAMG;
+            smoother        GaussSeidel;
+            nPreSweeps      0;
+            nPostSweeps     2;
+            nFinestSweeps   2;
+            cacheAgglomeration true;
+            nCellsInCoarsestLevel 10;
+            agglomerator    faceAreaPair;
+            mergeLevels     1;
+        }
+        tolerance       1e-6;
+        relTol          0;
     }
 
     p_rghFinal
-- 
GitLab