def alphaEqnSubCycle(runTime, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface): nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr"))) nAlphaSubCycles = ref.readLabel(pimple.dict().lookup( ref.word("nAlphaSubCycles"))) if (nAlphaSubCycles > 1): totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi alphaSubCycle = ref.subCycle_volScalarField(alpha1, nAlphaSubCycles) for item in alphaSubCycle: alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr) 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 << 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, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface): nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr"))) nAlphaSubCycles = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaSubCycles"))) if nAlphaSubCycles > 1: totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi alphaSubCycle = ref.subCycle_volScalarField(alpha1, nAlphaSubCycles) for item in alphaSubCycle: alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr) rhoPhiSum << 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 << rhoPhiSum else: alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr) pass interface.correct() rho == alpha1 * rho1 + (1.0 - alpha1) * rho2 pass
def read_controls( args, runTime, pimple ): adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime ) nAlphaCorr = ref.readLabel( pimple.dict().lookup( ref.word( "nAlphaCorr" ) ) ) nAlphaSubCycles = ref.readLabel( pimple.dict().lookup( ref.word( "nAlphaSubCycles" ) ) ) if nAlphaSubCycles > 1 and nCorrPIMPLE != 1: from Foam.OpenFOAM import ext_Info, nl ref.ext_Info() << args.executable() << "FATAL ERROR: Sub-cycling alpha is only allowed for PISO operations, i.e. when the number of outer-correctors = 1" << ref.nl; import os; os_exit( 1 ) pass return adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles
def read_controls(args, runTime, pimple): adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime) nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr"))) nAlphaSubCycles = ref.readLabel(pimple.dict().lookup( ref.word("nAlphaSubCycles"))) if nAlphaSubCycles > 1 and nOuterCorr != 1: from Foam.OpenFOAM import ext_Info, nl ref.ext_Info() << args.executable( ) << "FATAL ERROR: Sub-cycling alpha is only allowed for PISO, i.e. when the number of outer-correctors = 1" << ref.nl import os os_exit(1) pass return adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles
def alphaEqnsSubCycle(runTime, pimple, mesh, phi, alpha1, alpha2, rho, rho1, rho2, rhoPhi, dgdt, interface): nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr"))) nAlphaSubCycles = ref.readLabel(pimple.dict().lookup( ref.word("nAlphaSubCycles"))) phic = (phi() / mesh.magSf()).mag() # mixed calculations phic << (interface.cAlpha() * phic).ext_min(phic.ext_max()) divU = ref.fvc.div(phi) if nAlphaSubCycles > 1: totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi alphaSubCycle = ref.subCycle_volScalarField(alpha1, nAlphaSubCycles) for item in alphaSubCycle: alphaEqns(runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr) 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 << rhoPhiSum pass else: alphaEqns(runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr) pass if pimple.corr() == 0: interface.correct() pass pass
def alphaEqnsSubCycle( runTime, pimple, mesh, phi, alpha1, alpha2, rho, rho1, rho2, rhoPhi, dgdt, interface ): nAlphaCorr = ref.readLabel( pimple.dict().lookup( ref.word( "nAlphaCorr" ) ) ) nAlphaSubCycles = ref.readLabel( pimple.dict().lookup( ref.word( "nAlphaSubCycles" ) ) ) phic = ( phi() / mesh.magSf() ).mag() # mixed calculations phic << ( interface.cAlpha() * phic ).ext_min( phic.ext_max() ) divU = ref.fvc.div( phi ) if nAlphaSubCycles > 1: totalDeltaT = runTime.deltaT() rhoPhiSum = 0.0 * rhoPhi alphaSubCycle = ref.subCycle_volScalarField( alpha1, nAlphaSubCycles ) for item in alphaSubCycle: alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ) 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 << rhoPhiSum pass else: alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ) pass if pimple.corr() == 1: interface.correct() pass pass