def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, mrfZones, turbulence, UEqn, dpdt, K, cumulativeContErr, rhoMax, rhoMin ): rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() rAU = 1.0 / UEqn.A() U << rAU() * UEqn.H() if pimple.transonic(): phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \ + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) ); mrfZones.relativeFlux( ref.fvc.interpolate( psi ), phid ) while pimple.correctNonOrthogonal(): pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter() ) ) ) if pimple.finalNonOrthogonalIter(): phi == pEqn.flux() pass pass pass else: phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) mrfZones.relativeFlux( ref.fvc.interpolate( rho ), phi ) while pimple.correctNonOrthogonal(): pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter() ) ) ) if pimple.finalNonOrthogonalIter(): phi += pEqn.flux() pass pass pass ref.rhoEqn( rho, phi ) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations # Explicitly relax pressure for momentum corrector p.relax() # Recalculate density from the relaxed pressure rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() ref.ext_Info()<< "rho max/min : " << rho.ext_max().value() << " " << rho.ext_min().value() << ref.nl U -= rAU * ref.fvc.grad( p ) U.correctBoundaryConditions() K << 0.5 * U.magSqr() dpdt << ref.fvc.ddt( p ) return cumulativeContErr
def fun_pEqn( mesh, runTime, thermo, rho, p, psi, U, phi, turbulence, UEqn, cumulativeContErr, nNonOrthCorr ): rho<<thermo.rho() rAU = 1.0 / UEqn.A() U<< rAU * UEqn.H() phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) ) for nonOrth in range( nNonOrthCorr + 1 ): pEqn = ref.fvm.ddt( psi, p ) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho * rAU, p ) pEqn.solve() pass if nonOrth == nNonOrthCorr: phi<< pEqn.flux() pass ref.rhoEqn( rho, phi ) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) #it is necessary to force "mixed calculations" implementation U -= rAU * ref.fvc.grad( p ) U.correctBoundaryConditions() return cumulativeContErr
def fun_pEqn(mesh, runTime, thermo, rho, p, psi, U, phi, turbulence, UEqn, cumulativeContErr, nNonOrthCorr): rho << thermo.rho() rAU = 1.0 / UEqn.A() U << rAU * UEqn.H() phid = ref.surfaceScalarField( ref.word("phid"), ref.fvc.interpolate(psi) * ((ref.fvc.interpolate(U) & mesh.Sf()) + ref.fvc.ddtPhiCorr(rAU, rho, U, phi))) for nonOrth in range(nNonOrthCorr + 1): pEqn = ref.fvm.ddt(psi, p) + ref.fvm.div(phid, p) - ref.fvm.laplacian( rho * rAU, p) pEqn.solve() pass if nonOrth == nNonOrthCorr: phi << pEqn.flux() pass ref.rhoEqn(rho, phi) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) #it is necessary to force "mixed calculations" implementation U -= rAU * ref.fvc.grad(p) U.correctBoundaryConditions() return cumulativeContErr
def fun_pEqn(mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, UEqn, DpDt, cumulativeContErr, corr): rho << thermo.rho() # Thermodynamic density needs to be updated by psi*d(p) after the # pressure solution - done in 2 parts. Part 1: thermo.rho() << thermo.rho() - psi() * p_rgh() # mixed calculations rAU = 1.0 / UEqn.A() rhorAUf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"), ref.fvc.interpolate(rho * rAU)) U << rAU * UEqn.H() phi << ref.fvc.interpolate(rho) * ((ref.fvc.interpolate(U) & mesh.Sf()) + ref.fvc.ddtPhiCorr(rAU, rho, U, phi)) buoyancyPhi = -rhorAUf * ghf * ref.fvc.snGrad(rho) * mesh.magSf() phi += buoyancyPhi p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction( ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi) for nonOrth in range(pimple.nNonOrthCorr() + 1): p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorAUf, p_rgh) p_rghEqn.solve( mesh.solver(p_rgh.select(pimple.finalInnerIter(corr, nonOrth)))) if nonOrth == pimple.nNonOrthCorr(): # Calculate the conservative fluxes phi += p_rghEqn.flux() # Explicitly relax pressure for momentum corrector p_rgh.relax() # Correct the momentum source with the pressure gradient flux # calculated from the relaxed pressure U += rAU * ref.fvc.reconstruct( (buoyancyPhi + p_rghEqn.flux()) / rhorAUf) U.correctBoundaryConditions() pass pass p << p_rgh + rho * gh # Second part of thermodynamic density update thermo.rho() << thermo.rho() + psi() * p_rgh # mixed calculations DpDt << ref.fvc.DDt( ref.surfaceScalarField(ref.word("phiU"), phi() / ref.fvc.interpolate(rho)), p) # mixed calculations ref.rhoEqn(rho, phi) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr) #mixed calculations return cumulativeContErr
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, mrfZones, turbulence, UEqn, DpDt, cumulativeContErr, corr, rhoMax, rhoMin ): rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() rAU = 1.0 / UEqn.A() U << rAU() * UEqn.H() if pimple.transonic(): phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \ + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) ); mrfZones.relativeFlux( ref.fvc.interpolate( psi ), phid ) for nonOrth in range( pimple.nNonOrthCorr() + 1 ): pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) ) if nonOrth == pimple.nNonOrthCorr(): phi == pEqn.flux() pass pass pass else: phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) mrfZones.relativeFlux( ref.fvc.interpolate( rho ), phi ) for nonOrth in range( pimple.nNonOrthCorr() + 1 ): pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) ) if nonOrth == pimple.nNonOrthCorr(): phi += pEqn.flux() pass pass pass ref.rhoEqn( rho, phi ) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations # Explicitly relax pressure for momentum corrector p.relax() # Recalculate density from the relaxed pressure rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() ref.ext_Info()<< "rho max/min : " << rho.ext_max().value() << " " << rho.ext_min().value() << ref.nl U -= rAU * ref.fvc.grad( p ) U.correctBoundaryConditions() DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations return cumulativeContErr
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence, UEqn, rAU, DpDt, cumulativeContErr, corr, rhoMax, rhoMin ): rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() U << rAU() * UEqn.H() if pimple.transonic(): phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \ + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) ); for nonOrth in range( pimple.nNonOrthCorr() + 1 ): pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) ) if nonOrth == pimple.nNonOrthCorr(): phi == pEqn.flux() pass pass pass else: phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) for nonOrth in range( pimple.nNonOrthCorr() + 1 ): pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p ) # mixed calculations pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) ) if nonOrth == pimple.nNonOrthCorr(): phi += pEqn.flux() pass pass pass ref.rhoEqn( rho, phi ) cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations # Explicitly relax pressure for momentum corrector p.relax() # Recalculate density from the relaxed pressure rho << thermo.rho() rho << rho().ext_max( rhoMin ) rho << rho().ext_min( rhoMax ) rho.relax() ref.ext_Info()<< "rho max/min : " << rho.ext_max().value() << " " << rho.ext_min().value() << ref.nl U -= rAU * ref.fvc.grad( p ) U.correctBoundaryConditions() DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations return cumulativeContErr
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, UEqn, dpdt, K, cumulativeContErr ): rho << thermo.rho() # Thermodynamic density needs to be updated by psi*d(p) after the # pressure solution - done in 2 parts. Part 1: thermo.rho() << thermo.rho() - psi() * p_rgh() # mixed calculations rAU = 1.0 / UEqn.A() rhorAUf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"), ref.fvc.interpolate(rho * rAU)) U << rAU * UEqn.H() phi << ref.fvc.interpolate(rho) * ((ref.fvc.interpolate(U) & mesh.Sf()) + ref.fvc.ddtPhiCorr(rAU, rho, U, phi)) buoyancyPhi = -rhorAUf * ghf * ref.fvc.snGrad(rho) * mesh.magSf() phi += buoyancyPhi p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction(ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi) while pimple.correctNonOrthogonal(): p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorAUf, p_rgh) p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter()))) if pimple.finalNonOrthogonalIter(): # Calculate the conservative fluxes phi += p_rghEqn.flux() # Explicitly relax pressure for momentum corrector p_rgh.relax() # Correct the momentum source with the pressure gradient flux # calculated from the relaxed pressure U += rAU * ref.fvc.reconstruct((buoyancyPhi + p_rghEqn.flux()) / rhorAUf) U.correctBoundaryConditions() K << 0.5 * U.magSqr() pass pass p << p_rgh + rho * gh # Second part of thermodynamic density update thermo.rho() << thermo.rho() + psi() * p_rgh # mixed calculations dpdt << ref.fvc.ddt(p) # mixed calculations ref.rhoEqn(rho, phi) cumulativeContErr = ref.compressibleContinuityErrs(rho(), thermo, cumulativeContErr) # mixed calculations return cumulativeContErr