icoFlux

Here is a pythonFlu version of referenced icoFoam C++ solver

args = ref.setRootCase( argc, argv )
 
runTime = man.createTime( args )
 
mesh = man.createMesh( runTime )
 
transportProperties, nu, p, U, phi, pRefCell, pRefValue = createFields( runTime, mesh )
 
cumulativeContErr = ref.initContinuityErrs()
 
ref.ext_Info() << "\nStarting time loop\n"
 
while runTime.loop() :
    ref.ext_Info() << "Time = " <<  runTime.timeName() << ref.nl << ref.nl
 
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh )
 
    CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
 
    UEqn = man.fvm.ddt( U ) + man.fvm.div( phi, U ) - man.fvm.laplacian( nu, U )
 
    ref.solve( UEqn == -man.fvc.grad( p ) )
 
    # --- PISO loop
 
    for corr in range( nCorr ) :
        rUA = 1.0 / UEqn.A()
 
        U << rUA * UEqn.H()
        phi << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rUA, U, phi )
 
        ref.adjustPhi( phi, U, p )
 
        for nonOrth in range( nNonOrthCorr + 1 ) :
            pEqn = ( ref.fvm.laplacian( rUA, p ) == ref.fvc.div( phi ) )
 
            pEqn.setReference( pRefCell, pRefValue ) 
            pEqn.solve()                             
 
            if nonOrth == nNonOrthCorr:
                phi -= pEqn.flux()
                pass
 
            pass
 
        cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
 
        U -= rUA * ref.fvc.grad( p )
        U.correctBoundaryConditions()    
 
        pass
 
    runTime.write()    
 
    ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
                  "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
 
    pass
 
ref.ext_Info() << "End\n"
 
import os
return os.EX_OK