def alphaEqnSubCycle( runTime, piso, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface ): from Foam.OpenFOAM import word,readLabel nAlphaCorr = readLabel( piso.lookup( word( "nAlphaCorr" ) ) ) nAlphaSubCycles = readLabel( piso.lookup( word( "nAlphaSubCycles" ) ) ) if (nAlphaSubCycles > 1): totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi from Foam.finiteVolume import subCycle_volScalarField alphaSubCycle = subCycle_volScalarField(alpha1, nAlphaSubCycles) for item in alphaSubCycle: alphaEqn( mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr ) rhoPhiSum.ext_assign( rhoPhiSum + ( runTime.deltaT() / totalDeltaT ) * rhoPhi ) pass # To make sure that variable in the local scope will be destroyed # - during destruction of this variable it performs some important actions # - there is a difference between C++ and Python memory management, namely # if C++ automatically destroys stack variables when they exit the scope, # Python relay its memory management of some "garbage collection" algorithm # that do not provide predictable behavior on the "exit of scope" del alphaSubCycle rhoPhi.ext_assign( rhoPhiSum ) else: alphaEqn( mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr ) pass interface.correct() rho == alpha1 * rho1 + ( 1.0 - alpha1 ) * rho2 pass
def alphaEqnSubCycle(runTime, piso, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface): from Foam.OpenFOAM import word, readLabel nAlphaCorr = readLabel(piso.lookup(word("nAlphaCorr"))) nAlphaSubCycles = readLabel(piso.lookup(word("nAlphaSubCycles"))) if (nAlphaSubCycles > 1): totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi from Foam.finiteVolume import subCycle_volScalarField alphaSubCycle = subCycle_volScalarField(alpha1, nAlphaSubCycles) for item in alphaSubCycle: alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr) rhoPhiSum.ext_assign(rhoPhiSum + (runTime.deltaT() / totalDeltaT) * rhoPhi) pass # To make sure that variable in the local scope will be destroyed # - during destruction of this variable it performs some important actions # - there is a difference between C++ and Python memory management, namely # if C++ automatically destroys stack variables when they exit the scope, # Python relay its memory management of some "garbage collection" algorithm # that do not provide predictable behavior on the "exit of scope" del alphaSubCycle rhoPhi.ext_assign(rhoPhiSum) else: alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr) pass interface.correct() rho == alpha1 * rho1 + (1.0 - alpha1) * rho2 pass
def alphaEqnsSubCycle( runTime, piso, mesh, phi, alpha1, alpha2, rho, rho1, rho2, rhoPhi, dgdt, interface, oCorr ): from Foam.OpenFOAM import word,readLabel nAlphaCorr = readLabel( piso.lookup( word( "nAlphaCorr" ) ) ) nAlphaSubCycles = readLabel( piso.lookup( word( "nAlphaSubCycles" ) ) ) from Foam.finiteVolume import surfaceScalarField phic = ( phi / mesh.magSf() ).mag() phic.ext_assign( ( interface.cAlpha() * phic ).ext_min( phic.ext_max() ) ) from Foam import fvc divU = fvc.div( phi ) if nAlphaSubCycles > 1: totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi from Foam.finiteVolume import subCycle_volScalarField alphaSubCycle = subCycle_volScalarField( alpha1, nAlphaSubCycles ) for item in alphaSubCycle: alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ) rhoPhiSum.ext_assign( rhoPhiSum + ( runTime.deltaT() / totalDeltaT ) * rhoPhi ) pass # To make sure that variable in the local scope will be destroyed # - during destruction of this variable it performs some important actions # - there is a difference between C++ and Python memory management, namely # if C++ automatically destroys stack variables when they exit the scope, # Python relay its memory management of some "garbage collection" algorithm # that do not provide predictable behavior on the "exit of scope" del alphaSubCycle rhoPhi.ext_assign( rhoPhiSum ) pass else: alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ) pass if oCorr == 0: interface.correct() pass pass