From 23ad7a11feb848f06348e9f0343f22a1988e81d4 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Mon, 25 Jun 2012 11:34:46 +0100
Subject: [PATCH] multiphaseEulerFoam: Completed support for surface tension
 and contact angle.

Also improved the efficiency of the handling of the models by evaluating only those specified.
---
 .../alphaContactAngleFvPatchScalarField.H     |   2 +-
 .../multiphaseSystem/multiphaseSystem.C       | 124 +++++++-----------
 .../multiphaseSystem/multiphaseSystem.H       |  42 +++---
 .../fixedFluxPressureFvPatchScalarField.C     |   9 +-
 .../bubbleColumn/constant/transportProperties |   2 -
 .../constant/transportProperties              |  12 --
 .../constant/transportProperties              |  12 --
 7 files changed, 82 insertions(+), 121 deletions(-)

diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.H
index 8f980046e2e..668c9bb9ba0 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.H
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.H
@@ -118,7 +118,7 @@ public:
     <
         interfaceThetaProps,
         multiphaseSystem::interfacePair,
-        multiphaseSystem::interfacePair::hash
+        multiphaseSystem::interfacePair::symmHash
     > thetaPropsTable;
 
 
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C
index b55ffed9f7f..4dd5c2ef51b 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C
@@ -92,18 +92,23 @@ void Foam::multiphaseSystem::solveAlphas()
 
             if (&phase2 == &phase1) continue;
 
-            surfaceScalarField phic
-            (
-                (mag(phi_) + mag(phase1.phi() - phase2.phi()))/mesh_.magSf()
-            );
+            surfaceScalarField phir(phase1.phi() - phase2.phi());
 
-            surfaceScalarField phir
+            scalarCoeffSymmTable::const_iterator cAlpha
             (
-                (phase1.phi() - phase2.phi())
-              + min(cAlpha(phase1, phase2)*phic, max(phic))
-               *nHatf(phase1, phase2)
+                cAlphas_.find(interfacePair(phase1, phase2))
             );
 
+            if (cAlpha != cAlphas_.end())
+            {
+                surfaceScalarField phic
+                (
+                    (mag(phi_) + mag(phase1.phi() - phase2.phi()))/mesh_.magSf()
+                );
+
+                phir += min(cAlpha()*phic, max(phic))*nHatf(phase1, phase2);
+            }
+
             word phirScheme
             (
                 "div(phir," + alpha2.name() + ',' + alpha1.name() + ')'
@@ -189,67 +194,6 @@ void Foam::multiphaseSystem::solveAlphas()
 }
 
 
-Foam::scalar Foam::multiphaseSystem::cAlpha
-(
-    const phaseModel& phase1,
-    const phaseModel& phase2
-) const
-{
-    scalarCoeffTable::const_iterator cAlpha
-    (
-        cAlphas_.find(interfacePair(phase1, phase2))
-    );
-
-    if (cAlpha == cAlphas_.end())
-    {
-        FatalErrorIn
-        (
-            "multiphaseSystem::cAlpha"
-            "(const phaseModel& phase1, const phaseModel& phase2) const"
-        )   << "Cannot find interface " << interfacePair(phase1, phase2)
-            << " in list of cAlpha values"
-            << exit(FatalError);
-    }
-
-    return cAlpha();
-}
-
-
-Foam::dimensionedScalar Foam::multiphaseSystem::Cvm
-(
-    const phaseModel& phase1,
-    const phaseModel& phase2
-) const
-{
-    scalarCoeffTable::const_iterator Cvm
-    (
-        Cvms_.find(interfacePair(phase1, phase2))
-    );
-
-    if (Cvm != Cvms_.end())
-    {
-        return Cvm()*phase2.rho();
-    }
-
-    Cvm = Cvms_.find(interfacePair(phase2, phase1));
-
-    if (Cvm != Cvms_.end())
-    {
-        return Cvm()*phase1.rho();
-    }
-
-    FatalErrorIn
-    (
-        "multiphaseSystem::Cvm"
-        "(const phaseModel& phase1, const phaseModel& phase2) const"
-    )   << "Cannot find interface " << interfacePair(phase1, phase2)
-        << " in list of Cvm values"
-        << exit(FatalError);
-
-    return Cvm()*phase2.rho();
-}
-
-
 Foam::tmp<Foam::surfaceVectorField> Foam::multiphaseSystem::nHatfv
 (
     const volScalarField& alpha1,
@@ -545,7 +489,24 @@ Foam::tmp<Foam::volScalarField> Foam::multiphaseSystem::Cvm
 
         if (&phase2 != &phase)
         {
-            tCvm() += Cvm(phase, phase2)*phase2;
+            scalarCoeffTable::const_iterator Cvm
+            (
+                Cvms_.find(interfacePair(phase, phase2))
+            );
+
+            if (Cvm != Cvms_.end())
+            {
+                tCvm() += Cvm()*phase2.rho()*phase2;
+            }
+            else
+            {
+                Cvm = Cvms_.find(interfacePair(phase2, phase));
+
+                if (Cvm != Cvms_.end())
+                {
+                    tCvm() += Cvm()*phase.rho()*phase2;
+                }
+            }
         }
     }
 
@@ -584,11 +545,28 @@ Foam::tmp<Foam::volVectorField> Foam::multiphaseSystem::Svm
 
         if (&phase2 != &phase)
         {
-            tSvm() += Cvm(phase, phase2)*phase2*phase2.DDtU();
+            scalarCoeffTable::const_iterator Cvm
+            (
+                Cvms_.find(interfacePair(phase, phase2))
+            );
+
+            if (Cvm != Cvms_.end())
+            {
+                tSvm() += Cvm()*phase2.rho()*phase2*phase2.DDtU();
+            }
+            else
+            {
+                Cvm = Cvms_.find(interfacePair(phase2, phase));
+
+                if (Cvm != Cvms_.end())
+                {
+                    tSvm() += Cvm()*phase.rho()*phase2*phase2.DDtU();
+                }
+            }
         }
     }
 
-    // Remove lift at fixed-flux boundaries
+    // Remove virtual mass at fixed-flux boundaries
     forAll(phase.phi().boundaryField(), patchi)
     {
         if
@@ -737,7 +715,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
 
         if (&phase2 != &phase1)
         {
-            scalarCoeffTable::const_iterator sigma
+            scalarCoeffSymmTable::const_iterator sigma
             (
                 sigmas_.find(interfacePair(phase1, phase2))
             );
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H
index 79d1d72ab4d..33ba3d76e92 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H
@@ -72,6 +72,21 @@ public:
     {
     public:
 
+        class symmHash
+        :
+            public Hash<interfacePair>
+        {
+        public:
+
+            symmHash()
+            {}
+
+            label operator()(const interfacePair& key) const
+            {
+                return word::hash()(key.first()) + word::hash()(key.second());
+            }
+        };
+
         class hash
         :
             public Hash<interfacePair>
@@ -83,7 +98,7 @@ public:
 
             label operator()(const interfacePair& key) const
             {
-                return word::hash()(key.first()) + word::hash()(key.second());
+                return word::hash()(key.first(), word::hash()(key.second()));
             }
         };
 
@@ -130,10 +145,10 @@ public:
     };
 
 
-    typedef HashPtrTable<dragModel, interfacePair, interfacePair::hash>
+    typedef HashPtrTable<dragModel, interfacePair, interfacePair::symmHash>
         dragModelTable;
 
-    typedef HashPtrTable<volScalarField, interfacePair, interfacePair::hash>
+    typedef HashPtrTable<volScalarField, interfacePair, interfacePair::symmHash>
         dragCoeffFields;
 
 
@@ -168,17 +183,20 @@ private:
 
         volScalarField alphas_;
 
+        typedef HashTable<scalar, interfacePair, interfacePair::symmHash>
+            scalarCoeffSymmTable;
+
         typedef HashTable<scalar, interfacePair, interfacePair::hash>
             scalarCoeffTable;
 
-        scalarCoeffTable sigmas_;
+        scalarCoeffSymmTable sigmas_;
         dimensionSet dimSigma_;
 
-        scalarCoeffTable cAlphas_;
+        scalarCoeffSymmTable cAlphas_;
 
         scalarCoeffTable Cvms_;
 
-        typedef HashTable<dictionary, interfacePair, interfacePair::hash>
+        typedef HashTable<dictionary, interfacePair, interfacePair::symmHash>
             interfaceDictTable;
 
         dragModelTable dragModels_;
@@ -196,18 +214,6 @@ private:
 
         void solveAlphas();
 
-        scalar cAlpha
-        (
-            const phaseModel& phase1,
-            const phaseModel& phase2
-        ) const;
-
-        dimensionedScalar Cvm
-        (
-            const phaseModel& phase1,
-            const phaseModel& phase2
-        ) const;
-
         tmp<surfaceVectorField> nHatfv
         (
             const volScalarField& alpha1,
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
index ebfc0a83862..893dc030dc3 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
@@ -58,7 +58,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
     phiHbyAName_(ptf.phiHbyAName_),
     phiName_(ptf.phiName_),
     rhoName_(ptf.rhoName_),
-    DpName_(ptf.rhoName_),
+    DpName_(ptf.DpName_),
     adjoint_(ptf.adjoint_)
 {}
 
@@ -194,8 +194,11 @@ void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
     writeEntryIfDifferent<word>(os, "phiHbyA", "phiHbyA", phiHbyAName_);
     writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "Dp", "Dp", rhoName_);
-    os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
+    writeEntryIfDifferent<word>(os, "Dp", "Dp", DpName_);
+    if (adjoint_)
+    {
+        os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
+    }
     gradient().writeEntry("gradient", os);
 }
 
diff --git a/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/constant/transportProperties b/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/constant/transportProperties
index 22545b07217..bb819c4d0aa 100644
--- a/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/constant/transportProperties
+++ b/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/constant/transportProperties
@@ -49,12 +49,10 @@ phases
 
 sigmas
 (
-    (air water)     0.07
 );
 
 interfaceCompression
 (
-    (air water)     0
 );
 
 virtualMass
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/constant/transportProperties b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/constant/transportProperties
index fad0a7a482e..9ee595eb134 100644
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/constant/transportProperties
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/constant/transportProperties
@@ -79,9 +79,6 @@ sigmas
     (air water)     0.07
     (air oil)       0.07
     (air mercury)   0.07
-    (water oil)     0
-    (water mercury) 0
-    (oil mercury)   0
 );
 
 interfaceCompression
@@ -89,19 +86,10 @@ interfaceCompression
     (air water)     1
     (air oil)       1
     (air mercury)   1
-    (water oil)     0
-    (water mercury) 0
-    (oil mercury)   0
 );
 
 virtualMass
 (
-    (air water)     0
-    (air oil)       0
-    (air mercury)   0
-    (water oil)     0.5
-    (water mercury) 0.5
-    (oil mercury)   0.5
 );
 
 drag
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/constant/transportProperties b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/constant/transportProperties
index fad0a7a482e..9ee595eb134 100644
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/constant/transportProperties
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/constant/transportProperties
@@ -79,9 +79,6 @@ sigmas
     (air water)     0.07
     (air oil)       0.07
     (air mercury)   0.07
-    (water oil)     0
-    (water mercury) 0
-    (oil mercury)   0
 );
 
 interfaceCompression
@@ -89,19 +86,10 @@ interfaceCompression
     (air water)     1
     (air oil)       1
     (air mercury)   1
-    (water oil)     0
-    (water mercury) 0
-    (oil mercury)   0
 );
 
 virtualMass
 (
-    (air water)     0
-    (air oil)       0
-    (air mercury)   0
-    (water oil)     0.5
-    (water mercury) 0.5
-    (oil mercury)   0.5
 );
 
 drag
-- 
GitLab