{ volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh)); surfaceScalarField phiHbyA ( "phiHbyA", fvc::flux(HbyA) + fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi) ); surfaceScalarField phig ( ( mixture.surfaceTensionForce() - ghf*fvc::snGrad(rho) )*rAUf*mesh.magSf() ); phiHbyA += phig; // Update the pressure BCs to ensure flux consistency constrainPressure(p_rgh, U, phiHbyA, rAUf); PtrList p_rghEqnComps(mixture.phases().size()); label phasei = 0; forAllConstIters(mixture.phases(), phase) { const rhoThermo& thermo = phase().thermo(); const volScalarField& rho = thermo.rho()(); p_rghEqnComps.set ( phasei, ( fvc::ddt(rho) + thermo.psi()*correction(fvm::ddt(p_rgh)) + fvc::div(phi, rho) - fvc::Sp(fvc::div(phi), rho) ).ptr() ); ++phasei; } // Cache p_rgh prior to solve for density update volScalarField p_rgh_0(p_rgh); while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqnIncomp ( fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) ); tmp p_rghEqnComp; phasei = 0; forAllConstIters(mixture.phases(), phase) { tmp hmm ( (max(phase(), scalar(0))/phase().thermo().rho()) *p_rghEqnComps[phasei] ); if (phasei == 0) { p_rghEqnComp = hmm; } else { p_rghEqnComp.ref() += hmm; } ++phasei; } solve ( p_rghEqnComp + p_rghEqnIncomp, mesh.solver(p_rgh.select(pimple.finalInnerIter())) ); if (pimple.finalNonOrthogonalIter()) { phasei = 0; for (phaseModel& phase : mixture.phases()) { phase.dgdt() = pos0(phase) *(p_rghEqnComps[phasei] & p_rgh)/phase.thermo().rho(); ++phasei; } phi = phiHbyA + p_rghEqnIncomp.flux(); U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf); U.correctBoundaryConditions(); } } p = max(p_rgh + mixture.rho()*gh, pMin); // Update densities from change in p_rgh mixture.correctRho(p_rgh - p_rgh_0); rho = mixture.rho(); // Correct p_rgh for consistency with p and the updated densities p_rgh = p - rho*gh; p_rgh.correctBoundaryConditions(); K = 0.5*magSqr(U); Info<< "max(U) " << max(mag(U)).value() << endl; Info<< "min(p_rgh) " << min(p_rgh).value() << endl; }