mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Improved the flux-velocity correspondence for cases where hydrostatic balance is
important e.g. in atmospheric flows.
This commit is contained in:
@ -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()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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"));
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,33 @@
|
|||||||
bool closedVolume = pd.needReference();
|
{
|
||||||
|
bool closedVolume = pd.needReference();
|
||||||
|
|
||||||
rho = thermo->rho();
|
rho = thermo->rho();
|
||||||
|
|
||||||
volScalarField rUA = 1.0/UEqn.A();
|
volScalarField rUA = 1.0/UEqn.A();
|
||||||
U = rUA*UEqn.H();
|
surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA);
|
||||||
|
|
||||||
phi =
|
U = rUA*UEqn.H();
|
||||||
|
|
||||||
|
surfaceScalarField phiU
|
||||||
|
(
|
||||||
fvc::interpolate(rho)
|
fvc::interpolate(rho)
|
||||||
*(
|
*(
|
||||||
(fvc::interpolate(U) & mesh.Sf())
|
(fvc::interpolate(U) & mesh.Sf())
|
||||||
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
|
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
|
||||||
)
|
)
|
||||||
- fvc::interpolate(rho*rUA*gh)*fvc::snGrad(rho)*mesh.magSf();
|
);
|
||||||
|
|
||||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf();
|
||||||
{
|
|
||||||
|
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||||
|
{
|
||||||
fvScalarMatrix pdEqn
|
fvScalarMatrix pdEqn
|
||||||
(
|
(
|
||||||
fvm::ddt(psi, pd)
|
fvm::ddt(psi, pd)
|
||||||
+ fvc::ddt(psi)*pRef
|
+ fvc::ddt(psi)*pRef
|
||||||
+ fvc::ddt(psi, rho)*gh
|
+ fvc::ddt(psi, rho)*gh
|
||||||
+ fvc::div(phi)
|
+ fvc::div(phi)
|
||||||
- fvm::laplacian(rho*rUA, pd)
|
- fvm::laplacian(rhorUAf, pd)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
|
||||||
@ -37,24 +43,25 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
|||||||
{
|
{
|
||||||
phi += pdEqn.flux();
|
phi += pdEqn.flux();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p == pd + rho*gh + pRef;
|
U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
|
||||||
dpdt = fvc::ddt(p);
|
U.correctBoundaryConditions();
|
||||||
|
|
||||||
#include "rhoEqn.H"
|
p == pd + rho*gh + pRef;
|
||||||
#include "compressibleContinuityErrs.H"
|
dpdt = fvc::ddt(p);
|
||||||
|
|
||||||
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
|
#include "rhoEqn.H"
|
||||||
U.correctBoundaryConditions();
|
#include "compressibleContinuityErrs.H"
|
||||||
|
|
||||||
|
// For closed-volume cases adjust the pressure and density levels
|
||||||
// For closed-volume cases adjust the pressure and density levels
|
// to obey overall mass continuity
|
||||||
// to obey overall mass continuity
|
if (closedVolume)
|
||||||
if (closedVolume)
|
{
|
||||||
{
|
|
||||||
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||||
/fvc::domainIntegrate(thermo->psi());
|
/fvc::domainIntegrate(thermo->psi());
|
||||||
pd == p - (rho*gh + pRef);
|
|
||||||
rho = thermo->rho();
|
rho = thermo->rho();
|
||||||
|
}
|
||||||
|
|
||||||
|
pd == p - (rho*gh + pRef);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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"));
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,24 @@
|
|||||||
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++)
|
|
||||||
{
|
{
|
||||||
|
volScalarField rUA = 1.0/UEqn().A();
|
||||||
|
surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
|
||||||
|
|
||||||
|
U = rUA*UEqn().H();
|
||||||
|
UEqn.clear();
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
fvScalarMatrix pdEqn
|
fvScalarMatrix pdEqn
|
||||||
(
|
(
|
||||||
fvm::laplacian(rho*rUA, pd) == fvc::div(phi)
|
fvm::laplacian(rhorUAf, pd) == fvc::div(phi)
|
||||||
);
|
);
|
||||||
|
|
||||||
pdEqn.setReference(pdRefCell, pdRefValue);
|
pdEqn.setReference(pdRefCell, pdRefValue);
|
||||||
|
|
||||||
// retain the residual from the first iteration
|
// retain the residual from the first iteration
|
||||||
if (nonOrth == 0)
|
if (nonOrth == 0)
|
||||||
{
|
{
|
||||||
@ -27,29 +32,34 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
|||||||
|
|
||||||
if (nonOrth == nNonOrthCorr)
|
if (nonOrth == nNonOrthCorr)
|
||||||
{
|
{
|
||||||
|
// Calculate the conservative fluxes
|
||||||
phi -= pdEqn.flux();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#include "continuityErrs.H"
|
#include "continuityErrs.H"
|
||||||
|
|
||||||
// Explicitly relax pressure for momentum corrector
|
p == pd + rho*gh + pRef;
|
||||||
pd.relax();
|
|
||||||
|
|
||||||
p = pd + rho*gh + pRef;
|
// For closed-volume cases adjust the pressure and density levels
|
||||||
|
// to obey overall mass continuity
|
||||||
U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh);
|
if (closedVolume)
|
||||||
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))
|
p += (initialMass - fvc::domainIntegrate(thermo->psi()*p))
|
||||||
/fvc::domainIntegrate(thermo->psi());
|
/fvc::domainIntegrate(thermo->psi());
|
||||||
|
}
|
||||||
|
|
||||||
|
rho = thermo->rho();
|
||||||
|
rho.relax();
|
||||||
|
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|||||||
@ -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 \
|
||||||
|
|||||||
@ -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);
|
|
||||||
|
|
||||||
@ -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"));
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
|
||||||
Reference in New Issue
Block a user