mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
compressibleInterFoam: Improved mass conservation
using the continuity error correction formulation developed for twoPhaseEulerFoam and reactingEulerFoam.
This commit is contained in:
committed by
Andrew Heather
parent
092d4f4f0b
commit
3df71d18d0
@ -113,6 +113,8 @@
|
||||
phiCN,
|
||||
upwind<scalar>(mesh, phiCN)
|
||||
).fvmDiv(phiCN, alpha1)
|
||||
// - fvm::Sp(fvc::ddt(dimensionedScalar("1", dimless, 1), mesh)
|
||||
// + fvc::div(phiCN), alpha1)
|
||||
==
|
||||
Su + fvm::Sp(Sp + divU, alpha1)
|
||||
);
|
||||
@ -125,19 +127,19 @@
|
||||
<< " Max(" << alpha1.name() << ") = " << max(alpha1).value()
|
||||
<< endl;
|
||||
|
||||
tmp<surfaceScalarField> talphaPhiUD(alpha1Eqn.flux());
|
||||
alphaPhi = talphaPhiUD();
|
||||
tmp<surfaceScalarField> talphaPhi1UD(alpha1Eqn.flux());
|
||||
alphaPhi10 = talphaPhi1UD();
|
||||
|
||||
if (alphaApplyPrevCorr && talphaPhiCorr0.valid())
|
||||
if (alphaApplyPrevCorr && talphaPhi1Corr0.valid())
|
||||
{
|
||||
Info<< "Applying the previous iteration compression flux" << endl;
|
||||
MULES::correct(alpha1, alphaPhi, talphaPhiCorr0.ref(), 1, 0);
|
||||
MULES::correct(alpha1, alphaPhi10, talphaPhi1Corr0.ref(), 1, 0);
|
||||
|
||||
alphaPhi += talphaPhiCorr0();
|
||||
alphaPhi10 += talphaPhi1Corr0();
|
||||
}
|
||||
|
||||
// Cache the upwind-flux
|
||||
talphaPhiCorr0 = talphaPhiUD;
|
||||
talphaPhi1Corr0 = talphaPhi1UD;
|
||||
|
||||
alpha2 = 1.0 - alpha1;
|
||||
|
||||
@ -151,7 +153,7 @@
|
||||
|
||||
surfaceScalarField phir(phic*mixture.nHatf());
|
||||
|
||||
tmp<surfaceScalarField> talphaPhiUn
|
||||
tmp<surfaceScalarField> talphaPhi1Un
|
||||
(
|
||||
fvc::flux
|
||||
(
|
||||
@ -169,15 +171,15 @@
|
||||
|
||||
if (MULESCorr)
|
||||
{
|
||||
tmp<surfaceScalarField> talphaPhiCorr(talphaPhiUn() - alphaPhi);
|
||||
tmp<surfaceScalarField> talphaPhi1Corr(talphaPhi1Un() - alphaPhi10);
|
||||
volScalarField alpha10("alpha10", alpha1);
|
||||
|
||||
MULES::correct
|
||||
(
|
||||
geometricOneField(),
|
||||
alpha1,
|
||||
talphaPhiUn(),
|
||||
talphaPhiCorr.ref(),
|
||||
talphaPhi1Un(),
|
||||
talphaPhi1Corr.ref(),
|
||||
Sp,
|
||||
(-Sp*alpha1)(),
|
||||
1,
|
||||
@ -187,24 +189,24 @@
|
||||
// Under-relax the correction for all but the 1st corrector
|
||||
if (aCorr == 0)
|
||||
{
|
||||
alphaPhi += talphaPhiCorr();
|
||||
alphaPhi10 += talphaPhi1Corr();
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha1 = 0.5*alpha1 + 0.5*alpha10;
|
||||
alphaPhi += 0.5*talphaPhiCorr();
|
||||
alphaPhi10 += 0.5*talphaPhi1Corr();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alphaPhi = talphaPhiUn;
|
||||
alphaPhi10 = talphaPhi1Un;
|
||||
|
||||
MULES::explicitSolve
|
||||
(
|
||||
geometricOneField(),
|
||||
alpha1,
|
||||
phiCN,
|
||||
alphaPhi,
|
||||
alphaPhi10,
|
||||
Sp,
|
||||
(Su + divU*min(alpha1(), scalar(1)))(),
|
||||
1,
|
||||
@ -219,34 +221,37 @@
|
||||
|
||||
if (alphaApplyPrevCorr && MULESCorr)
|
||||
{
|
||||
talphaPhiCorr0 = alphaPhi - talphaPhiCorr0;
|
||||
talphaPhiCorr0.ref().rename("alphaPhiCorr0");
|
||||
talphaPhi1Corr0 = alphaPhi10 - talphaPhi1Corr0;
|
||||
talphaPhi1Corr0.ref().rename("alphaPhi1Corr0");
|
||||
}
|
||||
else
|
||||
{
|
||||
talphaPhiCorr0.clear();
|
||||
talphaPhi1Corr0.clear();
|
||||
}
|
||||
|
||||
#include "rhofs.H"
|
||||
|
||||
if
|
||||
(
|
||||
word(mesh.ddtScheme("ddt(rho,U)"))
|
||||
== fv::EulerDdtScheme<vector>::typeName
|
||||
|| word(mesh.ddtScheme("ddt(rho,U)"))
|
||||
== fv::localEulerDdtScheme<vector>::typeName
|
||||
)
|
||||
{
|
||||
#include "rhofs.H"
|
||||
rhoPhi = alphaPhi*(rho1f - rho2f) + phiCN*rho2f;
|
||||
rhoPhi = alphaPhi10*(rho1f - rho2f) + phiCN*rho2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ocCoeff > 0)
|
||||
{
|
||||
// Calculate the end-of-time-step alpha flux
|
||||
alphaPhi = (alphaPhi - (1.0 - cnCoeff)*alphaPhi.oldTime())/cnCoeff;
|
||||
alphaPhi10 =
|
||||
(alphaPhi10 - (1.0 - cnCoeff)*alphaPhi10.oldTime())/cnCoeff;
|
||||
}
|
||||
|
||||
// Calculate the end-of-time-step mass flux
|
||||
#include "rhofs.H"
|
||||
rhoPhi = alphaPhi*(rho1f - rho2f) + phi*rho2f;
|
||||
rhoPhi = alphaPhi10*(rho1f - rho2f) + phi*rho2f;
|
||||
}
|
||||
|
||||
Info<< "Phase-1 volume fraction = "
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
IOobject alphaPhiHeader
|
||||
IOobject alphaPhi10Header
|
||||
(
|
||||
"alphaPhi",
|
||||
"alphaPhi10",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
);
|
||||
|
||||
const bool alphaRestart = alphaPhiHeader.typeHeaderOk<surfaceScalarField>(true);
|
||||
const bool alphaRestart =
|
||||
alphaPhi10Header.typeHeaderOk<surfaceScalarField>(true);
|
||||
|
||||
// MULES flux from previous time-step
|
||||
surfaceScalarField alphaPhi
|
||||
surfaceScalarField alphaPhi10
|
||||
(
|
||||
alphaPhiHeader,
|
||||
alphaPhi10Header,
|
||||
phi*fvc::interpolate(alpha1)
|
||||
);
|
||||
|
||||
// MULES Correction
|
||||
tmp<surfaceScalarField> talphaPhiCorr0;
|
||||
tmp<surfaceScalarField> talphaPhi1Corr0;
|
||||
|
||||
Reference in New Issue
Block a user