Skip to content
Snippets Groups Projects
Commit c530e1cd authored by Henry's avatar Henry
Browse files

twoPhaseEulerFoam: transform to solve for p_rgh

to avoid excessive pressure/buoyancy balance errors on non-orthogonal meshes
Resolves bug-report http://openfoam.org/mantisbt/view.php?id=1379
parent e588d618
Branches
Tags
No related merge requests found
Showing
with 286 additions and 84 deletions
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
Info<< "Creating twoPhaseSystem\n" << endl; Info<< "Creating twoPhaseSystem\n" << endl;
twoPhaseSystem fluid(mesh, g); twoPhaseSystem fluid(mesh, g);
...@@ -27,6 +30,13 @@ ...@@ -27,6 +30,13 @@
fluid.lookup("pMin") fluid.lookup("pMin")
); );
Info<< "Calculating field g.h\n" << endl;
dimensionedScalar ghRef(g & (cmptMag(g.value())/mag(g.value()))*hRef);
volScalarField gh("gh", (g & mesh.C()) - ghRef);
surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef);
rhoThermo& thermo1 = phase1.thermo(); rhoThermo& thermo1 = phase1.thermo();
rhoThermo& thermo2 = phase2.thermo(); rhoThermo& thermo2 = phase2.thermo();
...@@ -38,6 +48,20 @@ ...@@ -38,6 +48,20 @@
volScalarField& rho2 = thermo2.rho(); volScalarField& rho2 = thermo2.rho();
const volScalarField& psi2 = thermo2.psi(); const volScalarField& psi2 = thermo2.psi();
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
volVectorField U volVectorField U
( (
IOobject IOobject
...@@ -99,7 +123,14 @@ ...@@ -99,7 +123,14 @@
label pRefCell = 0; label pRefCell = 0;
scalar pRefValue = 0.0; scalar pRefValue = 0.0;
setRefCell(p, pimple.dict(), pRefCell, pRefValue); setRefCell
(
p,
p_rgh,
pimple.dict(),
pRefCell,
pRefValue
);
Info<< "Creating field dpdt\n" << endl; Info<< "Creating field dpdt\n" << endl;
volScalarField dpdt volScalarField dpdt
......
...@@ -28,49 +28,60 @@ ...@@ -28,49 +28,60 @@
mrfZones.makeAbsolute(phi2); mrfZones.makeAbsolute(phi2);
// Phase-1 pressure flux (e.g. due to particle-particle pressure) // Phase-1 pressure flux (e.g. due to particle-particle pressure)
surfaceScalarField phiP1 surfaceScalarField phiF1
( (
"phiP1", "phiF1",
fvc::interpolate(rAU1*phase1.turbulence().pPrime()) fvc::interpolate(rAU1*phase1.turbulence().pPrime())
*fvc::snGrad(alpha1)*mesh.magSf() *fvc::snGrad(alpha1)*mesh.magSf()
); );
phiP1.boundaryField() == 0; phiF1.boundaryField() == 0;
// Phase-2 pressure flux (e.g. due to particle-particle pressure) // Phase-2 pressure flux (e.g. due to particle-particle pressure)
surfaceScalarField phiP2 surfaceScalarField phiF2
( (
"phiP2", "phiF2",
fvc::interpolate(rAU2*phase2.turbulence().pPrime()) fvc::interpolate(rAU2*phase2.turbulence().pPrime())
*fvc::snGrad(alpha2)*mesh.magSf() *fvc::snGrad(alpha2)*mesh.magSf()
); );
phiP2.boundaryField() == 0; phiF2.boundaryField() == 0;
volScalarField rho("rho", fluid.rho());
surfaceScalarField ghSnGradRho(ghf*fvc::snGrad(rho)*mesh.magSf());
// Add the phase-1 buoyancy force
phiF1 +=
rAlphaAU1f
*(
ghSnGradRho
- alpha2f*fvc::interpolate(rho1 - rho2)*(g & mesh.Sf())
)/fvc::interpolate(rho1);
// Add the phase-2 buoyancy force
phiF2 +=
rAlphaAU2f
*(
ghSnGradRho
- alpha1f*fvc::interpolate(rho2 - rho1)*(g & mesh.Sf())
)/fvc::interpolate(rho2);
// Phase-1 predicted flux
surfaceScalarField phiHbyA1 surfaceScalarField phiHbyA1
( (
IOobject::groupName("phiHbyA", phase1.name()), IOobject::groupName("phiHbyA", phase1.name()),
(fvc::interpolate(HbyA1) & mesh.Sf()) (fvc::interpolate(HbyA1) & mesh.Sf())
+ rAlphaAU1f*fvc::ddtCorr(U1, phi1) + rAlphaAU1f*fvc::ddtCorr(U1, phi1)
+ fvc::interpolate(rAU1*dragCoeff)*phi2
- phiF1
); );
// Phase-2 predicted flux
surfaceScalarField phiHbyA2 surfaceScalarField phiHbyA2
( (
IOobject::groupName("phiHbyA", phase2.name()), IOobject::groupName("phiHbyA", phase2.name()),
(fvc::interpolate(HbyA2) & mesh.Sf()) (fvc::interpolate(HbyA2) & mesh.Sf())
+ rAlphaAU2f*fvc::ddtCorr(U2, phi2) + rAlphaAU2f*fvc::ddtCorr(U2, phi2)
); + fvc::interpolate(rAU2*dragCoeff)*phi1
- phiF2
phiHbyA1 +=
(
fvc::interpolate(rAU1*dragCoeff)*phi2
- phiP1
+ rAlphaAU1f*(g & mesh.Sf())
);
phiHbyA2 +=
(
fvc::interpolate(rAU2*dragCoeff)*phi1
- phiP2
+ rAlphaAU2f*(g & mesh.Sf())
); );
mrfZones.makeRelative(phiHbyA1); mrfZones.makeRelative(phiHbyA1);
...@@ -98,7 +109,7 @@ ...@@ -98,7 +109,7 @@
// Update the fixedFluxPressure BCs to ensure flux consistency // Update the fixedFluxPressure BCs to ensure flux consistency
setSnGrad<fixedFluxPressureFvPatchScalarField> setSnGrad<fixedFluxPressureFvPatchScalarField>
( (
p.boundaryField(), p_rgh.boundaryField(),
( (
phiHbyA.boundaryField() phiHbyA.boundaryField()
- mrfZones.relative - mrfZones.relative
...@@ -134,8 +145,8 @@ ...@@ -134,8 +145,8 @@
)/rho1 )/rho1
+ (alpha1/rho1)*correction + (alpha1/rho1)*correction
( (
psi1*fvm::ddt(p) psi1*fvm::ddt(p_rgh)
+ fvm::div(phid1, p) - fvm::Sp(fvc::div(phid1), p) + fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
); );
deleteDemandDrivenData(pEqnComp1().faceFluxCorrectionPtr()); deleteDemandDrivenData(pEqnComp1().faceFluxCorrectionPtr());
pEqnComp1().relax(); pEqnComp1().relax();
...@@ -147,8 +158,8 @@ ...@@ -147,8 +158,8 @@
)/rho2 )/rho2
+ (alpha2/rho2)*correction + (alpha2/rho2)*correction
( (
psi2*fvm::ddt(p) psi2*fvm::ddt(p_rgh)
+ fvm::div(phid2, p) - fvm::Sp(fvc::div(phid2), p) + fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
); );
deleteDemandDrivenData(pEqnComp2().faceFluxCorrectionPtr()); deleteDemandDrivenData(pEqnComp2().faceFluxCorrectionPtr());
pEqnComp2().relax(); pEqnComp2().relax();
...@@ -160,31 +171,31 @@ ...@@ -160,31 +171,31 @@
contErr1 contErr1
- fvc::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), rho1) - fvc::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), rho1)
)/rho1 )/rho1
+ (alpha1*psi1/rho1)*correction(fvm::ddt(p)); + (alpha1*psi1/rho1)*correction(fvm::ddt(p_rgh));
pEqnComp2 = pEqnComp2 =
( (
contErr2 contErr2
- fvc::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), rho2) - fvc::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), rho2)
)/rho2 )/rho2
+ (alpha2*psi2/rho2)*correction(fvm::ddt(p)); + (alpha2*psi2/rho2)*correction(fvm::ddt(p_rgh));
} }
// Cache p prior to solve for density update // Cache p prior to solve for density update
volScalarField p_0(p); volScalarField p_rgh_0(p_rgh);
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqnIncomp fvScalarMatrix pEqnIncomp
( (
fvc::div(phiHbyA) fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p) - fvm::laplacian(rAUf, p_rgh)
); );
solve solve
( (
pEqnComp1() + pEqnComp2() + pEqnIncomp, pEqnComp1() + pEqnComp2() + pEqnIncomp,
mesh.solver(p.select(pimple.finalInnerIter())) mesh.solver(p_rgh.select(pimple.finalInnerIter()))
); );
if (pimple.finalNonOrthogonalIter()) if (pimple.finalNonOrthogonalIter())
...@@ -209,22 +220,22 @@ ...@@ -209,22 +220,22 @@
fluid.dgdt() = fluid.dgdt() =
( (
alpha1*(pEqnComp2 & p) alpha1*(pEqnComp2 & p_rgh)
- alpha2*(pEqnComp1 & p) - alpha2*(pEqnComp1 & p_rgh)
); );
p.relax(); p_rgh.relax();
p = max(p_rgh + rho*gh, pMin);
p_rgh = p - rho*gh;
mSfGradp = pEqnIncomp.flux()/rAUf; mSfGradp = pEqnIncomp.flux()/rAUf;
U1 = HbyA1 U1 = HbyA1
+ fvc::reconstruct + fvc::reconstruct
( (
rAlphaAU1f rAlphaAU1f*mSfGradp/fvc::interpolate(rho1)
*( - phiF1
(g & mesh.Sf())
+ mSfGradp/fvc::interpolate(rho1)
)
- phiP1
); );
U1.correctBoundaryConditions(); U1.correctBoundaryConditions();
fvOptions.correct(U1); fvOptions.correct(U1);
...@@ -232,12 +243,8 @@ ...@@ -232,12 +243,8 @@
U2 = HbyA2 U2 = HbyA2
+ fvc::reconstruct + fvc::reconstruct
( (
rAlphaAU2f rAlphaAU2f*mSfGradp/fvc::interpolate(rho2)
*( - phiF2
(g & mesh.Sf())
+ mSfGradp/fvc::interpolate(rho2)
)
- phiP2
); );
U2.correctBoundaryConditions(); U2.correctBoundaryConditions();
fvOptions.correct(U2); fvOptions.correct(U2);
...@@ -246,11 +253,9 @@ ...@@ -246,11 +253,9 @@
} }
} }
p = max(p, pMin);
// Update densities from change in p // Update densities from change in p
rho1 += psi1*(p - p_0); rho1 += psi1*(p_rgh - p_rgh_0);
rho2 += psi2*(p - p_0); rho2 += psi2*(p_rgh - p_rgh_0);
K1 = 0.5*magSqr(U1); K1 = 0.5*magSqr(U1);
K2 = 0.5*magSqr(U2); K2 = 0.5*magSqr(U2);
......
...@@ -49,7 +49,6 @@ int main(int argc, char *argv[]) ...@@ -49,7 +49,6 @@ int main(int argc, char *argv[])
pimpleControl pimple(mesh); pimpleControl pimple(mesh);
#include "readGravitationalAcceleration.H"
#include "createFields.H" #include "createFields.H"
#include "createMRFZones.H" #include "createMRFZones.H"
#include "createFvOptions.H" #include "createFvOptions.H"
......
...@@ -22,17 +22,17 @@ boundaryField ...@@ -22,17 +22,17 @@ boundaryField
{ {
inlet inlet
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
outlet outlet
{ {
type fixedValue; type calculated;
value $internalField; value $internalField;
} }
walls walls
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
} }
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 1e5;
boundaryField
{
inlet
{
type fixedFluxPressure;
value $internalField;
}
outlet
{
type fixedValue;
value $internalField;
}
walls
{
type fixedFluxPressure;
value $internalField;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -61,7 +61,7 @@ snGradSchemes ...@@ -61,7 +61,7 @@ snGradSchemes
fluxRequired fluxRequired
{ {
default no; default no;
p ; p_rgh;
} }
......
...@@ -23,7 +23,7 @@ solvers ...@@ -23,7 +23,7 @@ solvers
nAlphaSubCycles 2; nAlphaSubCycles 2;
} }
p p_rgh
{ {
solver GAMG; solver GAMG;
smoother DIC; smoother DIC;
...@@ -38,9 +38,9 @@ solvers ...@@ -38,9 +38,9 @@ solvers
relTol 0.01; relTol 0.01;
} }
pFinal p_rghFinal
{ {
$p; $p_rgh;
relTol 0; relTol 0;
} }
......
...@@ -22,17 +22,17 @@ boundaryField ...@@ -22,17 +22,17 @@ boundaryField
{ {
inlet inlet
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
outlet outlet
{ {
type fixedValue; type calculated;
value $internalField; value $internalField;
} }
walls walls
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
} }
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 1e5;
boundaryField
{
inlet
{
type fixedFluxPressure;
value $internalField;
}
outlet
{
type fixedValue;
value $internalField;
}
walls
{
type fixedFluxPressure;
value $internalField;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -63,7 +63,7 @@ snGradSchemes ...@@ -63,7 +63,7 @@ snGradSchemes
fluxRequired fluxRequired
{ {
default no; default no;
p ; p_rgh;
} }
......
...@@ -23,7 +23,7 @@ solvers ...@@ -23,7 +23,7 @@ solvers
nAlphaSubCycles 2; nAlphaSubCycles 2;
} }
p p_rgh
{ {
solver GAMG; solver GAMG;
smoother DIC; smoother DIC;
...@@ -38,9 +38,9 @@ solvers ...@@ -38,9 +38,9 @@ solvers
relTol 0.01; relTol 0.01;
} }
pFinal p_rghFinal
{ {
$p; $p_rgh;
relTol 0; relTol 0;
} }
......
...@@ -14,7 +14,7 @@ FoamFile ...@@ -14,7 +14,7 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 -1 -2 0 0 0 0 ]; dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5; internalField uniform 1e5;
...@@ -22,19 +22,19 @@ boundaryField ...@@ -22,19 +22,19 @@ boundaryField
{ {
inlet inlet
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
outlet outlet
{ {
type fixedValue; type calculated;
value $internalField; value $internalField;
} }
walls walls
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
inlet
{
type fixedFluxPressure;
value $internalField;
}
outlet
{
type fixedValue;
value $internalField;
}
walls
{
type fixedFluxPressure;
value $internalField;
}
frontAndBackPlanes
{
type empty;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -68,7 +68,7 @@ snGradSchemes ...@@ -68,7 +68,7 @@ snGradSchemes
fluxRequired fluxRequired
{ {
default no; default no;
p ; p_rgh;
alpha.particles; alpha.particles;
} }
......
...@@ -30,7 +30,7 @@ solvers ...@@ -30,7 +30,7 @@ solvers
minIter 1; minIter 1;
} }
p p_rgh
{ {
solver GAMG; solver GAMG;
smoother DIC; smoother DIC;
...@@ -45,9 +45,9 @@ solvers ...@@ -45,9 +45,9 @@ solvers
relTol 0.01; relTol 0.01;
} }
pFinal p_rghFinal
{ {
$p; $p_rgh;
relTol 0; relTol 0;
} }
......
...@@ -22,17 +22,17 @@ boundaryField ...@@ -22,17 +22,17 @@ boundaryField
{ {
inlet inlet
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
outlet outlet
{ {
type fixedValue; type calculated;
value $internalField; value $internalField;
} }
walls walls
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
} }
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 1e5;
boundaryField
{
inlet
{
type fixedFluxPressure;
value $internalField;
}
outlet
{
type fixedValue;
value $internalField;
}
walls
{
type fixedFluxPressure;
value $internalField;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -60,7 +60,7 @@ snGradSchemes ...@@ -60,7 +60,7 @@ snGradSchemes
fluxRequired fluxRequired
{ {
default no; default no;
p ; p_rgh;
} }
......
...@@ -23,7 +23,7 @@ solvers ...@@ -23,7 +23,7 @@ solvers
nAlphaSubCycles 2; nAlphaSubCycles 2;
} }
p p_rgh
{ {
solver GAMG; solver GAMG;
smoother DIC; smoother DIC;
...@@ -38,9 +38,9 @@ solvers ...@@ -38,9 +38,9 @@ solvers
relTol 0.01; relTol 0.01;
} }
pFinal p_rghFinal
{ {
$p; $p_rgh;
relTol 0; relTol 0;
} }
......
...@@ -22,17 +22,17 @@ boundaryField ...@@ -22,17 +22,17 @@ boundaryField
{ {
inlet inlet
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
outlet outlet
{ {
type fixedValue; type calculated;
value $internalField; value $internalField;
} }
walls walls
{ {
type fixedFluxPressure; type calculated;
value $internalField; value $internalField;
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment