You are on page 1of 4

Flux correction functions to ensure continuity.

Required during start-up, restart, mesh-motion etc. when non-conservative fluxes may adversely
affect the prediction-part of the solution algorithm (the part before the first pressure solution which
would ensure continuity). This is particularly important for VoF and other multi-phase solver in
which non-conservative fluxes cause unboundedness of the phase-fraction.

while (pimple.correctNonOrthogonal())
{
// Solve for pcorr such that the divergence of the corrected flux
// matches the divU provided (from previous iteration, time-step...)

fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
);

pcorrEqn.setReference(0, 0);
pcorrEqn.solve();

if (pimple.finalNonOrthogonalIter())
{
phi -= pcorrEqn.flux();
}
}

After solving the Poisson equation constructed from the continuity equation, the conserved phi
field: is recombined.phi - = pcorrEqn.flux(); This is a numerical consideration and is optional.

I think this is because the grid moved to a new position, and the current phi is no longer divergence
free relative to the current grid, the grid is updated and the phi field also needs to be updated, and
the absolute phi is corrected under the current grid, not the corresponding equation 12.13. Suppose
that the Laplace of a pcorrEqn field is equal to the current phi is not a degree of sporadicity, and
then use phi - = pcorrEqn.flux(); Correct.

Theoretically, to satisfy the compatibility condition of the pressure equation, adjustPhi.H is actually
called. adjustPhi and pRef are aimed at cases where the pressure equation is a full Newmann
boundary, which has two problems:

1. The equation coefficient matrix M is singular, the solution has an infinite number, and the
difference is a constant, so pRef is required.
2. Equation compatibility problems require adjustPhi.
CorrectPhi.H (foamExtend 3.2)

# include "continuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
volScalarField pcorr // Name of the scalar field pcorr
(
IOobject
(
"pcorr", // Name of the field
runTime.timeName(), // Name of the current time i.e. the time folder to read from
mesh, // This is the object which will act as register
IOobject::NO_READ, // Reading options
IOobject::NO_WRITE // Writing options
),
mesh, // Initialises the field to the mesh with default
dimensionedScalar("pcorr", pd.dimensions(), 0.0), // Dimension and default value
pcorrTypes
);
dimensionedScalar rAUf // Scalar dimensioned name
(
"(1|A(U))", // Name
dimTime/rho.dimensions(), // Dimension is time/density
runTime.deltaT().value() // To be accessed for every delta t.
);

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

phi = (fvc::interpolate(U) & mesh.Sf()); // Surface Flux i.e. u.Sf

adjustPhi(phi, U, pcorr); // This is added for the pressure to satisfy continuity.

for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)


{
fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) // Solves the Poisson eq. for pressure.
);

pcorrEqn.setReference(pdRefCell, pdRefValue); // For now don’t know why we need this


pcorrEqn.solve(); // Solves the pcorr eq.

if (nonOrth == nNonOrthCorr) // If
{
phi - = pcorrEqn.flux();
}
}

# include "continuityErrs.H"
# include "CourantNo.H"

// Recalculate rhoPhi from rho


rhoPhi = fvc::interpolate(rho)*phi;
}

This function is to adjust the flux phi to obey continuity (total flux into the domain equals total flux
out from the domain).
This is achieved in the following way:

Total flux = massIn – fixedMassOut – massCorr * adjustableMassOut


where
•massCorr = (massIn – fixedMassOut)/adjustableMassOut
•massIn: Total flux into the domain
•fixedMassOut: Total flux out from the domain through the boundaries on which the
velocity is prescribed
•adjustableMassOut: Total flux from the domain through the boundaries on which
the velocity is NOT fixed
We can make the total flux equal 0 by adjusting the adjustableMassOut by multiplying it by
massCorr.

2)ddtPhiCorr(rUA, U, phi)

You might also like