diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/cavitatingFoam/createFields.H index 49c7de1473..dbacf1dbd3 100644 --- a/applications/solvers/multiphase/cavitatingFoam/createFields.H +++ b/applications/solvers/multiphase/cavitatingFoam/createFields.H @@ -25,38 +25,6 @@ mesh ); - volScalarField gamma - ( - IOobject - ( - "gamma", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)) - ); - gamma.oldTime(); - - Info<< "Creating compressibilityModel\n" << endl; - autoPtr psiModel = - barotropicCompressibilityModel::New - ( - thermodynamicProperties, - gamma - ); - - const volScalarField& psi = psiModel->psi(); - - rho == max - ( - psi*p - + (1.0 - gamma)*rhol0 - + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, - rhoMin - ); - Info<< "Reading field U\n" << endl; volVectorField U ( @@ -78,6 +46,27 @@ twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); + volScalarField& gamma(twoPhaseProperties.alpha1()); + gamma.oldTime(); + + Info<< "Creating compressibilityModel\n" << endl; + autoPtr psiModel = + barotropicCompressibilityModel::New + ( + thermodynamicProperties, + gamma + ); + + const volScalarField& psi = psiModel->psi(); + + rho == max + ( + psi*p + + (1.0 - gamma)*rhol0 + + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, + rhoMin + ); + // Create incompressible turbulence model autoPtr turbulence ( diff --git a/applications/solvers/multiphase/interFoam/createFields.H b/applications/solvers/multiphase/interFoam/createFields.H index 34dea334e8..68765262db 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 73af502ce2..0d01b9a9e5 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 43f1ca8733..392704b940 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 (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 5e5eaaf10b..025d95f701 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 {