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

multiphase: Changed phiU to phiHbyA and cache HbyA rather than store the velocity predictor in U

parent a6fac2d8
Branches
Tags
No related merge requests found
Showing
with 204 additions and 133 deletions
......@@ -2,8 +2,8 @@
rho1 = eos1->rho(p, T);
rho2 = eos2->rho(p, T);
volScalarField rAU = 1.0/UEqn.A();
surfaceScalarField rAUf = fvc::interpolate(rAU);
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
......@@ -27,20 +27,25 @@
- fvc::Sp(fvc::div(phid2), p_rgh);
}
U = rAU*UEqn.H();
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiU
surfaceScalarField phiHbyA
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
phi = phiU +
surfaceScalarField phig
(
(
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Thermodynamic density needs to be updated by psi*d(p) after the
// pressure solution - done in 2 parts. Part 1:
......@@ -50,7 +55,7 @@
{
fvScalarMatrix p_rghEqnIncomp
(
fvc::div(phi)
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
......@@ -74,13 +79,15 @@
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
phi += p_rghEqnIncomp.flux();
phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
U.correctBoundaryConditions();
}
}
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
rho1 = eos1->rho(p, T);
......
{
volScalarField rAU("Dp", 1.0/UEqn.A());
surfaceScalarField rAUf("Dpf", fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
......@@ -11,7 +11,6 @@
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
mrfZones.relativeFlux(phiHbyA);
adjustPhi(phiHbyA, U, p_rgh);
......
{
volScalarField rAU("Dp", 1.0/UEqn.A());
surfaceScalarField rAUf("Dpf", fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
......
{
volScalarField rAU("Dp", 1.0/UEqn.A());
surfaceScalarField rAUf("Dpf", fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
......
{
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rAUf(fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
U = rAU*UEqn.H();
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiU
surfaceScalarField phiHbyA
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
adjustPhi(phiU, U, p_rgh);
adjustPhi(phiHbyA, U, p_rgh);
phi =
phiU
+ (
surfaceScalarField phig
(
(
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
Pair<tmp<volScalarField> > vDotP = twoPhaseProperties->vDotP();
const volScalarField& vDotcP = vDotP[0]();
......@@ -28,7 +32,7 @@
{
fvScalarMatrix p_rghEqn
(
fvc::div(phi) - fvm::laplacian(rAUf, p_rgh)
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
- (vDotvP - vDotcP)*(pSat - rho*gh) + fvm::Sp(vDotvP - vDotcP, p_rgh)
);
......@@ -38,13 +42,13 @@
if (pimple.finalNonOrthogonalIter())
{
phi += p_rghEqn.flux();
phi = phiHbyA + p_rghEqn.flux();
U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
p == p_rgh + rho*gh;
......
{
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rAUf(fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
U = rAU*UEqn.H();
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiU
surfaceScalarField phiHbyA
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
//+ fvc::ddtPhiCorr(rAU, rho, U, phi)
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
mrfZones.relativeFlux(phiU);
mrfZones.relativeFlux(phiHbyA);
adjustPhi(phiU, U, p_rgh);
adjustPhi(phiHbyA, U, p_rgh);
phi =
phiU
+ (
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
surfaceScalarField phig
(
- ghf*fvc::snGrad(rho)*rAUf*mesh.magSf()
);
phiHbyA += phig;
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phi)
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
......@@ -34,13 +35,13 @@
if (pimple.finalNonOrthogonalIter())
{
phi -= p_rghEqn.flux();
phi = phiHbyA - p_rghEqn.flux();
U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
p == p_rgh + rho*gh;
......
{
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rAUf(fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
U = rAU*UEqn.H();
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiU
surfaceScalarField phiHbyA
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
adjustPhi(phiU, U, p_rgh);
adjustPhi(phiHbyA, U, p_rgh);
phi = phiU +
surfaceScalarField phig
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phi)
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
......@@ -32,13 +37,13 @@
if (pimple.finalNonOrthogonalIter())
{
phi -= p_rghEqn.flux();
phi = phiHbyA - p_rghEqn.flux();
U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
p == p_rgh + rho*gh;
......
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rAUf
(
"(rho*(1|A(U)))",
fvc::interpolate(rho)*fvc::interpolate(rAU)
);
U = rAU*UEqn.H();
phi =
fvc::interpolate(rho)
*(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
{
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField phiU("phiU", phi);
phi -= ghf*fvc::snGrad(rho)*rAUf*mesh.magSf();
surfaceScalarField rAUf("Dp", fvc::interpolate(rho*rAU));
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiHbyA
(
fvm::laplacian(rAUf, p_rgh) == fvc::ddt(rho) + fvc::div(phi)
fvc::interpolate(rho)
*(
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
)
);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
surfaceScalarField phig
(
- ghf*fvc::snGrad(rho)*rAUf*mesh.magSf()
);
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
phiHbyA += phig;
if (pimple.finalNonOrthogonalIter())
while (pimple.correctNonOrthogonal())
{
phi -= p_rghEqn.flux();
}
}
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::ddt(rho) + fvc::div(phiHbyA)
);
p == p_rgh + rho*gh;
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA - p_rghEqn.flux();
U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
p == p_rgh + rho*gh;
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
}
{
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rAUf(fvc::interpolate(rAU));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("Dp", fvc::interpolate(rAU));
U = rAU*UEqn.H();
surfaceScalarField phiU
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiHbyA
(
"phiU",
(fvc::interpolate(U) & mesh.Sf())
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rAU, rho, U, phi)
);
adjustPhi(phiU, U, p_rgh);
adjustPhi(phiHbyA, U, p_rgh);
surfaceScalarField phig
(
- ghf*fvc::snGrad(rho)*rAUf*mesh.magSf()
);
phi = phiU - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf();
phiHbyA += phig;
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phi)
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
......@@ -27,13 +34,13 @@
if (pimple.finalNonOrthogonalIter())
{
phi -= p_rghEqn.flux();
phi = phiHbyA - p_rghEqn.flux();
U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
p == p_rgh + rho*gh;
......
......@@ -41,6 +41,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
phiHbyAName_("phiHbyA"),
phiName_("phi"),
rhoName_("rho"),
DpName_("Dp"),
adjoint_(false)
{}
......@@ -57,6 +58,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
phiHbyAName_(ptf.phiHbyAName_),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
DpName_(ptf.rhoName_),
adjoint_(ptf.adjoint_)
{}
......@@ -72,6 +74,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
phiHbyAName_(dict.lookupOrDefault<word>("phiHbyA", "phiHbyA")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
DpName_(dict.lookupOrDefault<word>("Dp", "Dp")),
adjoint_(dict.lookupOrDefault<Switch>("adjoint", false))
{
if (dict.found("gradient"))
......@@ -97,6 +100,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
phiHbyAName_(wbppsf.phiHbyAName_),
phiName_(wbppsf.phiName_),
rhoName_(wbppsf.rhoName_),
DpName_(wbppsf.DpName_),
adjoint_(wbppsf.adjoint_)
{}
......@@ -111,6 +115,7 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
phiHbyAName_(wbppsf.phiHbyAName_),
phiName_(wbppsf.phiName_),
rhoName_(wbppsf.rhoName_),
DpName_(wbppsf.DpName_),
adjoint_(wbppsf.adjoint_)
{}
......@@ -136,6 +141,7 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
fvsPatchField<scalar> phip =
patch().patchField<surfaceScalarField, scalar>(phi);
/*
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{
const fvPatchField<scalar>& rhop =
......@@ -144,16 +150,38 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
phip /= rhop;
}
const fvPatchField<scalar>& Dpp =
patch().lookupPatchField<volScalarField, scalar>("Dp");
if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
phiHbyAp /= rhop;
}
*/
const scalarField *DppPtr = NULL;
if (db().foundObject<volScalarField>(DpName_))
{
DppPtr =
&patch().lookupPatchField<volScalarField, scalar>(DpName_);
}
else if (db().foundObject<surfaceScalarField>(DpName_))
{
const surfaceScalarField& Dp =
db().lookupObject<surfaceScalarField>(DpName_);
DppPtr =
&patch().patchField<surfaceScalarField, scalar>(Dp);
}
if (adjoint_)
{
gradient() = (phip - phiHbyAp)/patch().magSf()/Dpp;
gradient() = (phip - phiHbyAp)/patch().magSf()/(*DppPtr);
}
else
{
gradient() = (phiHbyAp - phip)/patch().magSf()/Dpp;
gradient() = (phiHbyAp - phip)/patch().magSf()/(*DppPtr);
}
fixedGradientFvPatchScalarField::updateCoeffs();
......@@ -166,6 +194,7 @@ 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;
gradient().writeEntry("gradient", os);
}
......
......@@ -71,6 +71,9 @@ class fixedFluxPressureFvPatchScalarField
// if neccessary
word rhoName_;
//- Name of the pressure diffusivity field
word DpName_;
//- Is the pressure adjoint, i.e. has the opposite sign
Switch adjoint_;
......
......@@ -136,6 +136,7 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs()
fvsPatchField<scalar> phip =
patch().patchField<surfaceScalarField, scalar>(phi);
/*
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{
const fvPatchField<scalar>& rhop =
......@@ -144,6 +145,15 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs()
phip /= rhop;
}
if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
phiHbyAp /= rhop;
}
*/
const fvsPatchField<scalar>& Dpp =
patch().lookupPatchField<surfaceScalarField, scalar>("Dp");
......
......@@ -39,7 +39,7 @@ laplacianSchemes
{
default none;
laplacian(muEff,U) Gauss linear corrected;
laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected;
laplacian(Dp,p_rgh) Gauss linear corrected;
laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
laplacian(mut,Alpha) Gauss linear corrected;
......
......@@ -39,7 +39,7 @@ laplacianSchemes
{
default none;
laplacian(muEff,U) Gauss linear corrected;
laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected;
laplacian(Dp,p_rgh) Gauss linear corrected;
laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
laplacian(mut,Alpha) Gauss linear corrected;
......
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