ENH: Clean-up after latest Foundation integrations

This commit is contained in:
Andrew Heather
2017-03-28 14:21:07 +01:00
parent 45381b1085
commit e6b67f6790
40 changed files with 364 additions and 517 deletions

View File

@ -38,6 +38,9 @@ Description
#include "fvCFD.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
@ -45,7 +48,7 @@ Description
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fixedFluxPressureFvPatchScalarField.H"
#include "fvcSmooth.H"
#include "basicKinematicMPPICCloud.H"
@ -59,16 +62,22 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
#include "createAlphaFluxes.H"
#include "createFvOptions.H"
#include "createTimeControls.H"
#include "correctPhi.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
turbulence->validate();
if (!LTS)
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
@ -76,9 +85,17 @@ int main(int argc, char *argv[])
while (runTime.run())
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
if (LTS)
{
#include "setRDeltaT.H"
}
else
{
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
}
runTime++;
@ -133,6 +150,8 @@ int main(int argc, char *argv[])
#include "alphaControls.H"
#include "alphaEqnSubCycle.H"
mixture.correct();
#include "UEqn.H"
// --- Pressure corrector loop

View File

@ -4,6 +4,7 @@ EXE_INC = \
-I. \
-I./IncompressibleTwoPhaseMixtureTurbulenceModels/lnInclude \
-I$(interFoamPath) \
-I../VoF \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
@ -31,7 +32,7 @@ EXE_LIBS = \
-lmeshTools \
-llagrangian \
-llagrangianIntermediate \
-lthermophysicalFunctions \
-lthermophysicalProperties \
-lspecie \
-lincompressibleTransportModels \
-limmiscibleIncompressibleTwoPhaseMixture \

View File

@ -1,164 +0,0 @@
{
word alphaScheme("div(phi,alpha)");
word alpharScheme("div(phirb,alpha)");
// Standard face-flux compression coefficient
surfaceScalarField phic
(
mixture.cAlpha()*mag(alphaPhic/mesh.magSf())
);
// Add the optional isotropic compression contribution
if (icAlpha > 0)
{
phic *= (1.0 - icAlpha);
phic += (mixture.cAlpha()*icAlpha)*fvc::interpolate(mag(U));
}
// Do not compress interface at non-coupled boundary faces
// (inlets, outlets etc.)
surfaceScalarField::Boundary& phicBf = phic.boundaryFieldRef();
forAll(phic.boundaryField(), patchi)
{
fvsPatchScalarField& phicp = phicBf[patchi];
if (!phicp.coupled())
{
phicp == 0;
}
}
tmp<surfaceScalarField> tphiAlpha;
if (MULESCorr)
{
fvScalarMatrix alpha1Eqn
(
fv::EulerDdtScheme<scalar>(mesh).fvmDdt(alphac, alpha1)
+ fv::gaussConvectionScheme<scalar>
(
mesh,
alphaPhic,
upwind<scalar>(mesh, alphaPhic)
).fvmDiv(alphaPhic, alpha1)
- fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), alpha1)
);
alpha1Eqn.solve();
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
<< " Min(alpha1) = " << min(alpha1).value()
<< " Max(alpha1) = " << max(alpha1).value()
<< endl;
tmp<surfaceScalarField> tphiAlphaUD(alpha1Eqn.flux());
alphaPhi = tphiAlphaUD();
if (alphaApplyPrevCorr && tphiAlphaCorr0.valid())
{
Info<< "Applying the previous iteration compression flux" << endl;
MULES::correct
(
alphac,
alpha1,
alphaPhi,
tphiAlphaCorr0.ref(),
zeroField(), zeroField(),
1, 0
);
alphaPhi += tphiAlphaCorr0();
}
// Cache the upwind-flux
tphiAlphaCorr0 = tphiAlphaUD;
alpha2 = 1.0 - alpha1;
mixture.correct();
}
for (int aCorr=0; aCorr<nAlphaCorr; aCorr++)
{
surfaceScalarField phir(phic*mixture.nHatf());
tmp<surfaceScalarField> tphiAlphaUn
(
fvc::flux
(
alphaPhic,
alpha1,
alphaScheme
)
+ fvc::flux
(
-fvc::flux(-phir, alpha2, alpharScheme),
alpha1,
alpharScheme
)
);
if (MULESCorr)
{
tmp<surfaceScalarField> tphiAlphaCorr(tphiAlphaUn() - alphaPhi);
volScalarField alpha10("alpha10", alpha1);
//MULES::correct(alpha1, tphiAlphaUn(), tphiAlphaCorr(), 1, 0);
MULES::correct
(
alphac,
alpha1,
tphiAlphaUn(),
tphiAlphaCorr.ref(),
zeroField(), zeroField(),
1, 0
);
// Under-relax the correction for all but the 1st corrector
if (aCorr == 0)
{
alphaPhi += tphiAlphaCorr();
}
else
{
alpha1 = 0.5*alpha1 + 0.5*alpha10;
alphaPhi += 0.5*tphiAlphaCorr();
}
}
else
{
alphaPhi = tphiAlphaUn;
MULES::explicitSolve
(
alphac,
alpha1,
alphaPhic,
alphaPhi,
zeroField(), zeroField(),
1, 0
);
}
alpha2 = 1.0 - alpha1;
mixture.correct();
}
rhoPhi = alphaPhi*(rho1 - rho2) + alphaPhic*rho2;
if (alphaApplyPrevCorr && MULESCorr)
{
tphiAlphaCorr0 = alphaPhi - tphiAlphaCorr0;
}
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
<< " Min(alpha1) = " << min(alpha1).value()
<< " Max(alpha1) = " << max(alpha1).value()
<< endl;
}

View File

@ -1,34 +0,0 @@
if (nAlphaSubCycles > 1)
{
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("0", rhoPhi.dimensions(), 0)
);
for
(
subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);
!(++alphaSubCycle).end();
)
{
#include "alphaEqn.H"
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
#include "alphaEqn.H"
}
rho == alpha1*rho1 + alpha2*rho2;
mu = mixture.mu();

View File

@ -1,221 +1,204 @@
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
#include "createRDeltaT.H"
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
Info<< "Reading transportProperties\n" << endl;
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);
volScalarField& alpha1(mixture.alpha1());
volScalarField& alpha2(mixture.alpha2());
const dimensionedScalar& rho1 = mixture.rho1();
const dimensionedScalar& rho2 = mixture.rho2();
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*rho1 + alpha2*rho2
);
rho.oldTime();
// Need to store mu as incompressibleTwoPhaseMixture does not store it
volScalarField mu
(
IOobject
(
"mu",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT
),
mixture.mu(),
calculatedFvPatchScalarField::typeName
);
// Mass flux
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fvc::interpolate(rho)*phi
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rho*gh
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
mesh.solutionDict().subDict("PIMPLE"),
pRefCell,
pRefValue
);
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());
// MULES flux from previous time-step
surfaceScalarField alphaPhi
(
IOobject
(
"alphaPhi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
phi*fvc::interpolate(alpha1)
);
tmp<surfaceScalarField> tphiAlphaCorr0;
// alphac must be constructed before the cloud
// so that the drag-models can find it
volScalarField alphac
(
IOobject
(
"alphac",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
"p_rgh",
runTime.timeName(),
mesh,
dimensionedScalar("0", dimless, 0),
zeroGradientFvPatchScalarField::typeName
);
alphac.oldTime();
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
volScalarField alphacRho(alphac*rho);
alphacRho.oldTime();
Info<< "Constructing kinematicCloud " << endl;
basicKinematicMPPICCloud kinematicCloud
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"kinematicCloud",
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
Info<< "Reading transportProperties\n" << endl;
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);
volScalarField& alpha1(mixture.alpha1());
volScalarField& alpha2(mixture.alpha2());
const dimensionedScalar& rho1 = mixture.rho1();
const dimensionedScalar& rho2 = mixture.rho2();
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*rho1 + alpha2*rho2
);
rho.oldTime();
// Need to store mu as incompressibleTwoPhaseMixture does not store it
volScalarField mu
(
IOobject
(
"mu",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT
),
mixture.mu(),
calculatedFvPatchScalarField::typeName
);
// Mass flux
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fvc::interpolate(rho)*phi
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rho*gh
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
mesh.solutionDict().subDict("PIMPLE"),
pRefCell,
pRefValue
);
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());
// alphac must be constructed before the cloud
// so that the drag-models can find it
volScalarField alphac
(
IOobject
(
"alphac",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("0", dimless, 0),
zeroGradientFvPatchScalarField::typeName
);
alphac.oldTime();
volScalarField alphacRho(alphac*rho);
alphacRho.oldTime();
Info<< "Constructing kinematicCloud " << endl;
basicKinematicMPPICCloud kinematicCloud
(
"kinematicCloud",
rho,
U,
mu,
g
);
// Particle fraction upper limit
scalar alphacMin
(
1.0
- readScalar
(
kinematicCloud.particleProperties().subDict("constantProperties")
.lookup("alphaMax")
)
);
// Update alphac from the particle locations
alphac = max(1.0 - kinematicCloud.theta(), alphacMin);
alphac.correctBoundaryConditions();
surfaceScalarField alphacf("alphacf", fvc::interpolate(alphac));
// Phase mass flux
surfaceScalarField alphaRhoPhic("alphaRhoPhic", alphacf*rhoPhi);
// Volumetric phase flux
surfaceScalarField alphaPhic("alphaPhic", alphacf*phi);
autoPtr
<
PhaseCompressibleTurbulenceModel
<
immiscibleIncompressibleTwoPhaseMixture
>
>turbulence
(
PhaseCompressibleTurbulenceModel
<
immiscibleIncompressibleTwoPhaseMixture
>::New
(
alphac,
rho,
U,
mu,
g
);
alphaRhoPhic,
rhoPhi,
mixture
)
);
// Particle fraction upper limit
scalar alphacMin
(
1.0
- readScalar
(
kinematicCloud.particleProperties().subDict("constantProperties")
.lookup("alphaMax")
)
);
// Update alphac from the particle locations
alphac = max(1.0 - kinematicCloud.theta(), alphacMin);
alphac.correctBoundaryConditions();
surfaceScalarField alphacf("alphacf", fvc::interpolate(alphac));
// Phase mass flux
surfaceScalarField alphaRhoPhic("alphaRhoPhic", alphacf*rhoPhi);
// Volumetric phase flux
surfaceScalarField alphaPhic("alphaPhic", alphacf*phi);
autoPtr
<
PhaseCompressibleTurbulenceModel
<
immiscibleIncompressibleTwoPhaseMixture
>
>turbulence
(
PhaseCompressibleTurbulenceModel
<
immiscibleIncompressibleTwoPhaseMixture
>::New
(
alphac,
rho,
U,
alphaRhoPhic,
rhoPhi,
mixture
)
);
#include "createMRF.H"
#include "createMRF.H"

View File

@ -7,7 +7,7 @@ IOobject alphaPhiHeader
IOobject::AUTO_WRITE
);
const bool alphaRestart = alphaPhiHeader.headerOk();
const bool alphaRestart = alphaPhiHeader.typeHeaderOk<surfaceScalarField>(true);
// MULES flux from previous time-step
surfaceScalarField alphaPhi

View File

@ -124,7 +124,7 @@ int main(int argc, char *argv[])
ghf = (g & mesh.Cf()) - ghRef;
}
if ((mesh.changing() && correctPhi)) || mesh.topoChanging())
if ((mesh.changing() && correctPhi) || mesh.topoChanging())
{
// Calculate absolute flux from the mapped surface velocity
// Note: temporary fix until mapped Uf is assessed