From aa7c66a3ffad756e57f3eaa3dd8de2411a6f6c57 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Mon, 16 Apr 2012 11:46:35 +0100
Subject: [PATCH] twoPhaseMixture: Added support for named phases e.g. in
 transportProperties

phases (air water);
---
 .../multiphase/cavitatingFoam/createFields.H  | 39 +++++++------------
 .../multiphase/interFoam/createFields.H       | 16 +-------
 .../twoLiquidMixingFoam/createFields.H        | 16 +-------
 .../twoPhaseMixture.C                         | 19 +++++++--
 .../twoPhaseMixture.H                         | 16 +++++++-
 5 files changed, 47 insertions(+), 59 deletions(-)

diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/cavitatingFoam/createFields.H
index 49c7de14733..dbacf1dbd3f 100644
--- a/applications/solvers/multiphase/cavitatingFoam/createFields.H
+++ b/applications/solvers/multiphase/cavitatingFoam/createFields.H
@@ -25,18 +25,28 @@
         mesh
     );
 
-    volScalarField gamma
+    Info<< "Reading field U\n" << endl;
+    volVectorField U
     (
         IOobject
         (
-            "gamma",
+            "U",
             runTime.timeName(),
             mesh,
-            IOobject::NO_READ,
+            IOobject::MUST_READ,
             IOobject::AUTO_WRITE
         ),
-        max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0))
+        mesh
     );
+
+    #include "createPhiv.H"
+    #include "compressibleCreatePhi.H"
+
+    Info<< "Reading transportProperties\n" << endl;
+
+    twoPhaseMixture twoPhaseProperties(U, phiv, "gamma");
+
+    volScalarField& gamma(twoPhaseProperties.alpha1());
     gamma.oldTime();
 
     Info<< "Creating compressibilityModel\n" << endl;
@@ -57,27 +67,6 @@
         rhoMin
     );
 
-    Info<< "Reading field U\n" << endl;
-    volVectorField U
-    (
-        IOobject
-        (
-            "U",
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
-        ),
-        mesh
-    );
-
-    #include "createPhiv.H"
-    #include "compressibleCreatePhi.H"
-
-    Info<< "Reading transportProperties\n" << endl;
-
-    twoPhaseMixture twoPhaseProperties(U, phiv, "gamma");
-
     // Create incompressible turbulence model
     autoPtr<incompressible::turbulenceModel> turbulence
     (
diff --git a/applications/solvers/multiphase/interFoam/createFields.H b/applications/solvers/multiphase/interFoam/createFields.H
index 34dea334e8f..68765262dba 100644
--- a/applications/solvers/multiphase/interFoam/createFields.H
+++ b/applications/solvers/multiphase/interFoam/createFields.H
@@ -12,20 +12,6 @@
         mesh
     );
 
-    Info<< "Reading field alpha1\n" << endl;
-    volScalarField alpha1
-    (
-        IOobject
-        (
-            "alpha1",
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
-        ),
-        mesh
-    );
-
     Info<< "Reading field U\n" << endl;
     volVectorField U
     (
@@ -46,6 +32,8 @@
     Info<< "Reading transportProperties\n" << endl;
     twoPhaseMixture twoPhaseProperties(U, phi);
 
+    volScalarField& alpha1(twoPhaseProperties.alpha1());
+
     const dimensionedScalar& rho1 = twoPhaseProperties.rho1();
     const dimensionedScalar& rho2 = twoPhaseProperties.rho2();
 
diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H
index 73af502ce2b..0d01b9a9e5e 100644
--- a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H
+++ b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H
@@ -12,20 +12,6 @@
         mesh
     );
 
-    Info<< "Reading field alpha1\n" << endl;
-    volScalarField alpha1
-    (
-        IOobject
-        (
-            "alpha1",
-            runTime.timeName(),
-            mesh,
-            IOobject::MUST_READ,
-            IOobject::AUTO_WRITE
-        ),
-        mesh
-    );
-
     Info<< "Reading field U\n" << endl;
     volVectorField U
     (
@@ -45,6 +31,8 @@
     Info<< "Reading transportProperties\n" << endl;
     twoPhaseMixture twoPhaseProperties(U, phi);
 
+    volScalarField& alpha1(twoPhaseProperties.alpha1());
+
     const dimensionedScalar& rho1 = twoPhaseProperties.rho1();
     const dimensionedScalar& rho2 = twoPhaseProperties.rho2();
 
diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C
index 43f1ca87338..392704b940c 100644
--- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C
+++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -59,8 +59,8 @@ Foam::twoPhaseMixture::twoPhaseMixture
 :
     transportModel(U, phi),
 
-    phase1Name_("phase1"),
-    phase2Name_("phase2"),
+    phase1Name_(found("phases") ? wordList(lookup("phases"))[0] : "phase1"),
+    phase2Name_(found("phases") ? wordList(lookup("phases"))[1] : "phase2"),
 
     nuModel1_
     (
@@ -89,7 +89,18 @@ Foam::twoPhaseMixture::twoPhaseMixture
     U_(U),
     phi_(phi),
 
-    alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
+    alpha1_
+    (
+        IOobject
+        (
+            found("phases") ? word("alpha" + phase1Name_) : alpha1Name,
+            U_.time().timeName(),
+            U_.db(),
+            IOobject::MUST_READ,
+            IOobject::AUTO_WRITE
+        ),
+        U_.mesh()
+    ),
 
     nu_
     (
diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H
index 5e5eaaf10b1..025d95f7011 100644
--- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H
+++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -69,7 +69,7 @@ protected:
         const volVectorField& U_;
         const surfaceScalarField& phi_;
 
-        const volScalarField& alpha1_;
+        volScalarField alpha1_;
 
         volScalarField nu_;
 
@@ -110,6 +110,18 @@ public:
             return phase2Name_;
         }
 
+        //- Return the phase-fraction of phase 1
+        const volScalarField& alpha1() const
+        {
+            return alpha1_;
+        }
+
+        //- Return the phase-fraction of phase 1
+        volScalarField& alpha1()
+        {
+            return alpha1_;
+        }
+
         //- Return const-access to phase1 viscosityModel
         const viscosityModel& nuModel1() const
         {
-- 
GitLab