예제 #1
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    p, e, psi, rho, U, phi, turbulence, thermo = _createFields(runTime, mesh)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.loop():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum, velMag = compressibleCourantNo(
            mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        UEqn = _UEqn(U, rho, phi, turbulence, p)

        _eEqn(rho, e, phi, turbulence, p, thermo)

        # --- PISO loop

        for corr in range(nCorr):
            cumulativeContErr = _pEqn(rho, thermo, UEqn, nNonOrthCorr, psi, U,
                                      mesh, phi, p, cumulativeContErr)
            pass

        turbulence.correct()

        rho.ext_assign(thermo.rho())

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #2
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )

    p, e, psi, rho, U, phi, turbulence, thermo = _createFields( runTime, mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl
    
    while runTime.loop() :
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum, velMag = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn( rho, phi )

        UEqn = _UEqn( U, rho, phi, turbulence, p )

        _eEqn( rho, e, phi, turbulence, p, thermo )

        # --- PISO loop

        for corr in range( nCorr ) :
            cumulativeContErr = _pEqn( rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p, cumulativeContErr )
            pass

        turbulence.correct();

        rho.ext_assign( thermo.rho() )

        runTime.write();

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #3
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    thermo, turbulence, p, h, psi, rho, U, phi, pMin, DpDt, mrfZones, pZones, pressureImplicitPorosity = create_fields(
        runTime, mesh)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.run():

        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

        from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

        runTime.increment()

        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        if nOuterCorr != 1:
            p.storePrevIter()
            rho.storePrevIter()
            pass

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        for oCorr in range(nOuterCorr):
            UEqn = fun_UEqn(mesh, pZones, rho, U, phi, turbulence, mrfZones, p,
                            momentumPredictor, oCorr, nOuterCorr)
            hEqn = fun_hEqn(mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr,
                            nOuterCorr)

            for corr in range(nCorr):
                fun_pEqn(mesh, thermo, p, rho, psi, U, phi, DpDt, pMin, UEqn,
                         mrfZones, nNonOrthCorr, nCorr, oCorr, nOuterCorr,
                         corr, transonic, cumulativeContErr)
                pass
            turbulence.correct()
            pass

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime(
        ) << " s" << "  ClockTime = " << runTime.elapsedClockTime(
        ) << " s" << nl << nl

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #4
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase

    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime

    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh

    mesh = createMesh(runTime)

    p, h, psi, rho, U, phi, turbulence, thermo, pMin, DpDt = _createFields(runTime, mesh)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs

    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl

    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.run():

        from Foam.finiteVolume.cfdTools.general.include import readTimeControls

        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

        from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls

        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls(mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo

        CoNum, meanCoNum, velMag = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.general.include import setDeltaT

        runTime = setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        if nOuterCorr != 1:
            p.storePrevIter()
            rho.storePrevIter()
            pass

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn

        rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            UEqn = _UEqn(mesh, U, rho, phi, turbulence, p, oCorr, nOuterCorr, momentumPredictor)

            hEqn = _hEqn(mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr, nOuterCorr)

            # --- PISO loop

            for corr in range(nCorr):
                cumulativeContErr = _pEqn(
                    rho,
                    thermo,
                    UEqn,
                    nNonOrthCorr,
                    psi,
                    U,
                    mesh,
                    phi,
                    p,
                    DpDt,
                    pMin,
                    corr,
                    cumulativeContErr,
                    nCorr,
                    oCorr,
                    nOuterCorr,
                    transonic,
                )
                pass

            turbulence.correct()
            pass

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        pass

    ext_Info() << "End\n"

    import os

    return os.EX_OK
예제 #5
0
def main_standalone(argc, argv):
    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    thermo, p, h, psi, rho, U, phi, turbulence, DpDt = createFields(
        runTime, mesh)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    runTime.increment()
    while not runTime.end():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, ddtPhiCorr = readPISOControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        UEqn = _UEqn(U, rho, phi, turbulence, p)

        _hEqn(rho, h, phi, turbulence, DpDt, thermo)

        # -------PISO loop
        for corr in range(nCorr):
            cumulativeContErr = _pEqn(rho, thermo, UEqn, nNonOrthCorr, psi, U,
                                      mesh, phi, p, cumulativeContErr)
            pass
        from Foam import fvc
        from Foam.finiteVolume import surfaceScalarField
        from Foam.OpenFOAM import word
        DpDt = fvc.DDt(
            surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)), p)

        turbulence.correct()

        rho.ext_assign(psi * p)

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
                      "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        runTime.increment()

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #6
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt = create_fields( runTime, mesh, g )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info()<< "\nStarting time loop\n" << nl
    
    while runTime.run() :
        
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
        from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls( mesh )
        
        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn  
        rhoEqn( rho, phi )
        
        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range( nOuterCorr ):
            finalIter = oCorr == ( nOuterCorr-1 )

            if nOuterCorr != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_UEqn( mesh, rho, phi, U, p_rgh, ghf, turbulence, finalIter, momentumPredictor )
            fun_hEqn( mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter )

            # --- PISO loop
            for corr in range( nCorr ):
                cumulativeContErr = fun_pEqn( mesh, p, rho, psi, p_rgh, U, phi, ghf, gh, DpDt, UEqn, \
                                              thermo, nNonOrthCorr, corr, nCorr, finalIter, cumulativeContErr )
                pass

            turbulence.correct()

            rho.ext_assign( thermo.rho() )
            pass

        runTime.write()
        
        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        pass
    
    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #7
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration(runTime, mesh)

    thermo, p, h, psi, phi, rho, U, turbulence, DpDt, initialMass, totalVolume = _createFields(
        runTime, mesh, g)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                               CoNum)

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.run():
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        UEqn = _Ueqn(U, phi, turbulence, p, rho, g, mesh, momentumPredictor)

        hEqn = _hEqn(rho, h, phi, turbulence, thermo, DpDt)

        # --- PISO loop
        for corr in range(nCorr):
            cumulativeContErr = _pEqn( runTime, mesh, UEqn, thermo, p, psi, U, rho, phi, DpDt, g,\
                                       initialMass, totalVolume, corr, nCorr, nNonOrthCorr, cumulativeContErr )
            pass

        turbulence.correct()

        rho.ext_assign(thermo.rho())

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        pass

    ext_Info() << "End\n" << nl

    import os
    return os.EX_OK
예제 #8
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    thermodynamicProperties, rho0, p0, psi, rhoO = readThermodynamicProperties(
        runTime, mesh)

    transportProperties, mu = readTransportProperties(runTime, mesh)

    p, U, rho, phi = _createFields(runTime, mesh, rhoO, psi)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.loop():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum, velMag = compressibleCourantNo(
            mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        from Foam import fvm, fvc
        from Foam.finiteVolume import solve
        UEqn = fvm.ddt(rho, U) + fvm.div(phi, U) - fvm.laplacian(mu, U)

        solve(UEqn == -fvc.grad(p))

        for corr in range(nCorr):
            rUA = 1.0 / UEqn.A()
            U.ext_assign(rUA * UEqn.H())

            from Foam.OpenFOAM import word
            from Foam.finiteVolume import surfaceScalarField

            phid = surfaceScalarField(
                word("phid"),
                psi * ((fvc.interpolate(U) & mesh.Sf()) +
                       fvc.ddtPhiCorr(rUA, rho, U, phi)))

            phi.ext_assign((rhoO / psi) * phid)

            pEqn = fvm.ddt(psi, p) + fvc.div(phi) + fvm.div(
                phid, p) - fvm.laplacian(rho * rUA, p)

            pEqn.solve()

            phi.ext_assign(phi + pEqn.flux())

            cumulativeContErr = compressibleContinuityErrs(
                rho, phi, psi, rho0, p, p0, cumulativeContErr)

            U.ext_assign(U - rUA * fvc.grad(p))
            U.correctBoundaryConditions()
            pass
        rho.ext_assign(rhoO + psi * p)

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #9
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    thermodynamicProperties, rho0, p0, psi, rhoO = readThermodynamicProperties( runTime, mesh )
    
    transportProperties, mu = readTransportProperties( runTime, mesh )

    p, U, rho, phi = _createFields( runTime, mesh, rhoO, psi )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl
    
    while runTime.loop() :
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn( rho, phi )
        
        from Foam import fvm, fvc
        from Foam.finiteVolume import solve
        UEqn = fvm.ddt(rho, U) + fvm.div(phi, U) - fvm.laplacian(mu, U)

        solve( UEqn == -fvc.grad( p ) )
        
        for corr in range( nCorr ): 
            rUA = 1.0 / UEqn.A()
            U.ext_assign( rUA * UEqn.H() )
            
            from Foam.OpenFOAM import word
            from Foam.finiteVolume import surfaceScalarField

            phid = surfaceScalarField( word( "phid" ), 
                                       psi * ( ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) ) )
            
            phi.ext_assign( ( rhoO / psi ) * phid )

            pEqn = fvm.ddt( psi, p ) + fvc.div( phi ) + fvm.div( phid, p ) - fvm.laplacian( rho * rUA, p ) 
            
            pEqn.solve()

            phi.ext_assign( phi + pEqn.flux() )
            
            cumulativeContErr = compressibleContinuityErrs( rho, phi, psi, rho0, p, p0, cumulativeContErr )
            
            U.ext_assign( U - rUA * fvc.grad( p ) )
            U.correctBoundaryConditions()
            pass
        rho.ext_assign( rhoO + psi*p )
        
        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #10
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    thermodynamicProperties, R, Cv = readThermodynamicProperties(runTime, mesh)

    transportProperties, mu = readingTransportProperties(runTime, mesh)

    p, T, e, U, psi, rho, phi = _createFields(runTime, mesh, R, Cv)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    runTime.increment()
    while not runTime.end():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transSonic, nOuterCorr = readPISOControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        from Foam import fvm
        UEqn = fvm.ddt(rho, U) + fvm.div(phi, U) - fvm.laplacian(mu, U)

        from Foam import fvc
        from Foam.finiteVolume import solve
        solve(UEqn == -fvc.grad(p))

        solve( fvm.ddt( rho, e ) + fvm.div( phi, e ) - fvm.laplacian( mu, e ) == \
               - p * fvc.div( phi / fvc.interpolate( rho ) ) + mu * fvc.grad( U ).symm().magSqr() )

        T.ext_assign(e / Cv)

        psi.ext_assign(1.0 / (R * T))

        # --- PISO loop
        for corr in range(nCorr):
            rUA = 1.0 / UEqn.A()
            U.ext_assign(rUA * UEqn.H())

            from Foam.OpenFOAM import word
            phid = ((fvc.interpolate(rho * U) & mesh.Sf()) +
                    fvc.ddtPhiCorr(rUA, rho, U, phi)) / fvc.interpolate(p)
            print "111111111111"
            for nonOrth in range(nNonOrthCorr + 1):
                pEqn = fvm.ddt(psi, p) + fvm.div(
                    phid, p, word("div(phid,p)")) - fvm.laplacian(
                        rho * rUA, p)

                pEqn.solve()
                phi = pEqn.flux()
                pass

            cumulativeContErr = compressibleContinuityErrs(
                p, rho, phi, psi, cumulativeContErr)

            U.ext_assign(U - rUA * fvc.grad(p))
            U.correctBoundaryConditions()

            pass

        rho.ext_assign(psi * p)

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl

        runTime.increment()
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #11
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)
    
    thermo, p, h, psi, phi, rho, U, turbulence, DpDt, initialMass, totalVolume = _createFields( runTime, mesh, g )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum, velMag = compressibleCourantNo( mesh, phi, rho, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" <<nl
    
    while runTime.run():
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
        
        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum, velMag = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn  
        rhoEqn( rho, phi )
        
        UEqn = _Ueqn(  U, phi, turbulence, p, rho, g, mesh, momentumPredictor )
        
        hEqn = _hEqn( rho, h, phi, turbulence, thermo, DpDt )
        
        # --- PISO loop
        for corr in range( nCorr ):
            cumulativeContErr = _pEqn( runTime, mesh, UEqn, thermo, p, psi, U, rho, phi, DpDt, g,\
                                       initialMass, totalVolume, corr, nCorr, nNonOrthCorr, cumulativeContErr )
            pass

        turbulence.correct()

        rho.ext_assign( thermo.rho() )
        
        runTime.write()
        
        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        pass
        
    ext_Info() << "End\n" << nl 

    import os
    return os.EX_OK
예제 #12
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime
    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh(runTime)

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration(runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt = create_fields(
        runTime, mesh, g)

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                               CoNum)

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl

    while runTime.run():

        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

        from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls(
            mesh)

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            finalIter = oCorr == (nOuterCorr - 1)

            if nOuterCorr != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_UEqn(mesh, rho, phi, U, p_rgh, ghf, turbulence,
                            finalIter, momentumPredictor)
            fun_hEqn(mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter)

            # --- PISO loop
            for corr in range(nCorr):
                cumulativeContErr = fun_pEqn( mesh, p, rho, psi, p_rgh, U, phi, ghf, gh, DpDt, UEqn, \
                                              thermo, nNonOrthCorr, corr, nCorr, finalIter, cumulativeContErr )
                pass

            turbulence.correct()

            rho.ext_assign(thermo.rho())
            pass

        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime(
        ) << " s" << "  ClockTime = " << runTime.elapsedClockTime(
        ) << " s" << nl << nl

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #13
0
def main_standalone( argc, argv ):
    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )
    
    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )

    thermo, p, h, psi, rho, U, phi, turbulence, DpDt = createFields( runTime, mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() <<  "\nStarting time loop\n" << nl

    runTime.increment()
    while not runTime.end() :
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, ddtPhiCorr = readPISOControls( mesh )

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn( rho, phi )
        
        UEqn = _UEqn( U, rho, phi, turbulence, p )
        
        _hEqn( rho, h, phi, turbulence, DpDt,thermo )
        

        # -------PISO loop
        for corr in range( nCorr ):
            cumulativeContErr = _pEqn( rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p, cumulativeContErr )          
            pass
        from Foam import fvc
        from Foam.finiteVolume import surfaceScalarField
        from Foam.OpenFOAM import word
        DpDt = fvc.DDt( surfaceScalarField( word("phiU"), phi / fvc.interpolate( rho ) ), p )

        
        turbulence.correct()

        rho.ext_assign( psi * p )
                
        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
                      "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        runTime.increment()
        
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #14
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )

    thermodynamicProperties, R, Cv = readThermodynamicProperties( runTime, mesh )
    
    transportProperties, mu = readingTransportProperties( runTime, mesh )
    
    p, T, e, U, psi, rho, phi = _createFields( runTime, mesh, R, Cv )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl
    
    runTime.increment()
    while not runTime.end() :
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transSonic, nOuterCorr = readPISOControls( mesh )

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn( rho, phi )
        
        from Foam import fvm
        UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) - fvm.laplacian( mu, U )
        
        from Foam import fvc
        from Foam.finiteVolume import solve
        solve( UEqn == -fvc.grad( p ) )

        solve( fvm.ddt( rho, e ) + fvm.div( phi, e ) - fvm.laplacian( mu, e ) == \
               - p * fvc.div( phi / fvc.interpolate( rho ) ) + mu * fvc.grad( U ).symm().magSqr() )
        
        T.ext_assign( e / Cv )
        
        psi.ext_assign( 1.0 / ( R * T ) )
        
        # --- PISO loop
        for corr in range( nCorr ):
            rUA = 1.0/UEqn.A()
            U.ext_assign( rUA * UEqn.H() )
            
            
            from Foam.OpenFOAM import word
            phid = ( ( fvc.interpolate( rho * U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) )  / fvc.interpolate( p )
            print "111111111111"
            for nonOrth in range( nNonOrthCorr + 1 ):
                pEqn = fvm.ddt( psi, p ) + fvm.div( phid, p, word( "div(phid,p)" ) ) - fvm.laplacian( rho * rUA, p ) 
                
                pEqn.solve()
                phi = pEqn.flux()
                pass
            
            cumulativeContErr = compressibleContinuityErrs( p, rho, phi, psi, cumulativeContErr )
            
            U.ext_assign( U - rUA * fvc.grad( p ) )
            U.correctBoundaryConditions()
            
            pass
            
        rho.ext_assign( psi * p )
        
        runTime.write()

        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        runTime.increment()
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK