Improved the flux-velocity correspondence for cases where hydrostatic balance is

important e.g. in atmospheric flows.
This commit is contained in:
henry
2009-02-03 16:51:07 +00:00
parent 6c36054c43
commit 338b72b1eb
11 changed files with 151 additions and 180 deletions

View File

@ -9,4 +9,18 @@
UEqn.relax(); UEqn.relax();
solve(UEqn == -fvc::grad(pd) - fvc::grad(rho)*gh); if (momentumPredictor)
{
solve
(
UEqn
==
-fvc::reconstruct
(
(
fvc::snGrad(pd)
+ ghf*fvc::snGrad(rho)
) * mesh.magSf()
)
);
}

View File

@ -41,13 +41,12 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "setRootCase.H"
# include "setRootCase.H" #include "createTime.H"
# include "createTime.H" #include "createMesh.H"
# include "createMesh.H" #include "readEnvironmentalProperties.H"
# include "readEnvironmentalProperties.H" #include "createFields.H"
# include "createFields.H" #include "initContinuityErrs.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,23 +54,24 @@ int main(int argc, char *argv[])
while (runTime.run()) while (runTime.run())
{ {
# include "readPISOControls.H" #include "readTimeControls.H"
# include "compressibleCourantNo.H" #include "readPISOControls.H"
//# include "setDeltaT.H" #include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++; runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "rhoEqn.H" #include "rhoEqn.H"
# include "UEqn.H" #include "UEqn.H"
// --- PISO loop // --- PISO loop
for (int corr=0; corr<nCorr; corr++) for (int corr=0; corr<nCorr; corr++)
{ {
# include "hEqn.H" #include "hEqn.H"
# include "pEqn.H" #include "pEqn.H"
} }
turbulence->correct(); turbulence->correct();

View File

@ -57,6 +57,7 @@
Info<< "Calculating field g.h\n" << endl; Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C()); volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));

View File

@ -1,60 +1,67 @@
bool closedVolume = pd.needReference();
rho = thermo->rho();
volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
phi =
fvc::interpolate(rho)
*(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
)
- fvc::interpolate(rho*rUA*gh)*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {
fvScalarMatrix pdEqn bool closedVolume = pd.needReference();
rho = thermo->rho();
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA);
U = rUA*UEqn.H();
surfaceScalarField phiU
( (
fvm::ddt(psi, pd) fvc::interpolate(rho)
+ fvc::ddt(psi)*pRef *(
+ fvc::ddt(psi, rho)*gh (fvc::interpolate(U) & mesh.Sf())
+ fvc::div(phi) + fvc::ddtPhiCorr(rUA, rho, U, phi)
- fvm::laplacian(rho*rUA, pd) )
); );
if (corr == nCorr-1 && nonOrth == nNonOrthCorr) phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {
pdEqn.solve(mesh.solver(pd.name() + "Final")); fvScalarMatrix pdEqn
} (
else fvm::ddt(psi, pd)
{ + fvc::ddt(psi)*pRef
pdEqn.solve(mesh.solver(pd.name())); + fvc::ddt(psi, rho)*gh
+ fvc::div(phi)
- fvm::laplacian(rhorUAf, pd)
);
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
{
pdEqn.solve(mesh.solver(pd.name() + "Final"));
}
else
{
pdEqn.solve(mesh.solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
{
phi += pdEqn.flux();
}
} }
if (nonOrth == nNonOrthCorr) U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
U.correctBoundaryConditions();
p == pd + rho*gh + pRef;
dpdt = fvc::ddt(p);
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{ {
phi += pdEqn.flux(); p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
rho = thermo->rho();
} }
}
p == pd + rho*gh + pRef;
dpdt = fvc::ddt(p);
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
U.correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
pd == p - (rho*gh + pRef); pd == p - (rho*gh + pRef);
rho = thermo->rho();
} }

View File

@ -11,7 +11,15 @@
eqnResidual = solve eqnResidual = solve
( (
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh UEqn()
==
-fvc::reconstruct
(
(
fvc::snGrad(pd)
+ ghf*fvc::snGrad(rho)
) * mesh.magSf()
)
).initialResidual(); ).initialResidual();
maxResidual = max(eqnResidual, maxResidual); maxResidual = max(eqnResidual, maxResidual);

View File

@ -53,6 +53,7 @@
Info<< "Calculating field g.h\n" << endl; Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C()); volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));

View File

@ -1,55 +1,65 @@
volScalarField rUA = 1.0/UEqn().A();
U = rUA*UEqn().H();
UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p);
phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {
fvScalarMatrix pdEqn volScalarField rUA = 1.0/UEqn().A();
( surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
);
pdEqn.setReference(pdRefCell, pdRefValue); U = rUA*UEqn().H();
// retain the residual from the first iteration UEqn.clear();
if (nonOrth == 0)
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p);
surfaceScalarField buoyancyPhi = ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
phi -= buoyancyPhi;
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {
eqnResidual = pdEqn.solve().initialResidual(); fvScalarMatrix pdEqn
maxResidual = max(eqnResidual, maxResidual); (
} fvm::laplacian(rhorUAf, pd) == fvc::div(phi)
else );
{
pdEqn.solve(); pdEqn.setReference(pdRefCell, pdRefValue);
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pdEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pdEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
// Calculate the conservative fluxes
phi -= pdEqn.flux();
// Explicitly relax pressure for momentum corrector
pd.relax();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U -= rUA*fvc::reconstruct((buoyancyPhi + pdEqn.flux())/rhorUAf);
U.correctBoundaryConditions();
}
} }
if (nonOrth == nNonOrthCorr) #include "continuityErrs.H"
p == pd + rho*gh + pRef;
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{ {
phi -= pdEqn.flux(); p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
} }
}
#include "continuityErrs.H" rho = thermo->rho();
rho.relax();
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
// Explicitly relax pressure for momentum corrector
pd.relax();
p = pd + rho*gh + pRef;
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
U.correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
pd == p - (rho*gh + pRef); pd == p - (rho*gh + pRef);
} }
rho = thermo->rho();
rho.relax();
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
-I../buoyantSimpleFoam \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels \

View File

@ -1,18 +0,0 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
- fvm::Sp(fvc::div(phi), U)
+ turbulence->divDevRhoReff(U)
);
UEqn().relax();
eqnResidual = solve
(
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

View File

@ -54,6 +54,7 @@
Info<< "Calculating field g.h\n" << endl; Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C()); volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("gh", g & mesh.Cf());
dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef"));

View File

@ -1,54 +0,0 @@
volScalarField rUA = 1.0/UEqn().A();
U = rUA*UEqn().H();
UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p);
phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf();
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pdEqn
(
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
);
pdEqn.setReference(pdRefCell, pdRefValue);
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pdEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pdEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= pdEqn.flux();
}
}
#include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
pd.relax();
p = pd + rho*gh + pRef;
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
U.correctBoundaryConditions();
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
/fvc::domainIntegrate(thermo->psi());
pd == p - (rho*gh + pRef);
}
rho = thermo->rho();
rho.relax();
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;