def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    T, U, transportProperties, DT, phi = _createFields(runTime, mesh)

    simple = man.simpleControl(mesh)

    ref.ext_Info() << "\nCalculating scalar transport\n" << ref.nl

    CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

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

        while simple.correctNonOrthogonal():
            ref.solve(
                ref.fvm.ddt(T) + ref.fvm.div(phi, T) -
                ref.fvm.laplacian(DT, T))
            pass

        runTime.write()
        pass

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

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

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport, sources = _createFields(
        runTime, mesh)

    cumulativeContErr = ref.initContinuityErrs()

    pimple = man.pimpleControl(mesh)

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

    while runTime.run():
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

        CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

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

        runTime.increment()

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

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UEqn, rAU = Ueqn(mesh, pimple, phi, U, p, turbulence, sources)

            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = pEqn(runTime, mesh, pimple, U, rAU, UEqn,
                                         phi, p, pRefCell, pRefValue,
                                         cumulativeContErr, sources)
                pass

            if pimple.turbCorr():
                turbulence.correct()
                pass
            pass

        runTime.write()

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

        pass

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

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

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pimple = man.pimpleControl(mesh)

    cumulativeContErr = ref.initContinuityErrs()

    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh )

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    cumulativeContErr = correctPhi(runTime, mesh, phi, p, p_rgh, rho, U,
                                   cumulativeContErr, pimple, pRefCell,
                                   pRefValue)

    CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

    runTime = ref.setInitialDeltaT(runTime, adjustTimeStep, maxCo, CoNum)

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)
        maxAlphaCo, alphaCoNum, meanAlphaCoNum = alphaCourantNo(
            runTime, mesh, alpha1, phi)
        runTime = setDeltaT(runTime, adjustTimeStep, maxCo, CoNum, maxAlphaCo,
                            alphaCoNum, maxDeltaT)

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

        twoPhaseProperties.correct()

        alphaEqnSubCycle(runTime, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1,
                         rho2, interface)

        while pimple.loop():
            UEqn = _UEqn(mesh, alpha1, U, p, p_rgh, ghf, rho, rhoPhi,
                         turbulence, g, twoPhaseProperties, interface, pimple)

            # --- PISO loop
            while pimple.correct():
                cumulativeContErr = _pEqn(runTime, mesh, UEqn, U, p, p_rgh, gh,
                                          ghf, phi, alpha1, rho, g, interface,
                                          pimple, pRefCell, pRefValue,
                                          cumulativeContErr)
                pass

            if pimple.turbCorr():
                turbulence.correct()
                pass

            pass

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = man.readGravitationalAcceleration(runTime, mesh)

    pimple = ref.pimpleControl(mesh)

    adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles = read_controls(
        args, runTime, pimple)

    cumulativeContErr = ref.initContinuityErrs()

    p_rgh, alpha1, alpha2, U, phi, twoPhaseProperties, rho10, rho20, psi1, psi2, pMin, \
                      gh, ghf, p, rho1, rho2, rho, rhoPhi, dgdt, interface, turbulence = _createFields( runTime, mesh, g )

    CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

    runTime = ref.setInitialDeltaT(runTime, adjustTimeStep, maxCo, CoNum)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.run():
        adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles = read_controls(
            args, runTime, pimple)

        CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

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

        runTime.increment()

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

        # --- Outer-corrector loop
        pimple.start()
        while pimple.loop():
            alphaEqnsSubCycle(runTime, pimple, mesh, phi, alpha1, alpha2, rho,
                              rho1, rho2, rhoPhi, dgdt, interface)

            ref.solve(ref.fvm.ddt(rho) + ref.fvc.div(rhoPhi))

            UEqn = fun_UEqn(mesh, alpha1, U, p, p_rgh, ghf, rho, rhoPhi,
                            turbulence, g, twoPhaseProperties, interface,
                            pimple)

            # --- PISO loop
            for corr in range(pimple.nCorr()):
                fun_pEqn( runTime, mesh, pimple, UEqn, p, p_rgh, phi, U, rho, rho1, rho2, rho10, rho20, gh, ghf, dgdt, pMin, \
                          psi1, psi2, alpha1, alpha2, interface, corr )
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass

            pimple.increment()
            pass
        rho << alpha1 * rho1 + alpha2 * rho2

        runTime.write()

        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime(
        ) << " s\n\n" << ref.nl
        pass

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

    import os
    return os.EX_OK
Example #5
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createDynamicFvMesh(runTime)

    cumulativeContErr = ref.initContinuityErrs()

    p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue, sources = _createFields(
        runTime, mesh)

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    pimple = man.pimpleControl(mesh)

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT, pimpleDic, correctPhi, checkMeshCourantNo, ddtPhiCorr = readControls(
            runTime, mesh, pimple)
        CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime)

        # Make the fluxes absolute
        ref.fvc.makeAbsolute(phi, U)

        runTime = ref.setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                                CoNum)
        runTime.increment()
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        mesh.update()
        if mesh.changing() and correctPhi:
            cumulativeContErr = _correctPhi(runTime, mesh, pimple, p, U, rAU,
                                            phi, pRefCell, pRefValue,
                                            cumulativeContErr)
            pass

        # Make the fluxes relative to the mesh motion
        ref.fvc.makeRelative(phi, U)

        if mesh.changing() and checkMeshCourantNo:
            meshCoNum, meanMeshCoNum = ref.meshCourantNo(runTime, mesh, phi)
            pass

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UEqn = fun_UEqn(mesh, phi, U, p, rAU, turbulence, pimple)
            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn(mesh, runTime, pimple, U, phi,
                                             turbulence, p, rAU, UEqn,
                                             pRefCell, pRefValue,
                                             cumulativeContErr, ddtPhiCorr)
                pass

            if pimple.turbCorr():
                turbulence.correct()
                pass
            pass
        runTime.write()

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

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

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

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMeshNoClear( runTime )
    
    p, U, phi, fluid, pRefCell, pRefValue = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl 
    
    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 )
        
        fluid.correct()
        UEqn = ref.fvm.ddt( U ) + ref.fvm.div( phi, U ) - ref.fvm.laplacian( fluid.ext_nu(), U ) - ( ref.fvc.grad( U )  & ref.fvc.grad( fluid.ext_nu() ) )
        
        ref.solve( UEqn == -ref.fvc.grad( p ) )
        
        # --- PISO loop

        for corr in range( nCorr ):
            rAU = 1.0 / UEqn.A()
            U << rAU * UEqn.H()
            phi << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, U, phi )
            
            ref.adjustPhi(phi, U, p)
            
            for nonOrth in range( nNonOrthCorr + 1): 
                
                pEqn = ( ref.fvm.laplacian( rAU, 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 -= rAU * 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" << ref.nl 

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

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()

    ref.ext_Info() << "\nStarting time loop\n" <<ref.nl
    
    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 )

        # Pressure-velocity PISO corrector

        # Momentum predictor

        # The initial C++ expression does not work properly, because of
        #  1. turbulence.divDevRhoReff( U ) - changes values for the U boundaries
        #  2. the order of expression arguments computation differs with C++
        # UEqn = fvm.ddt( U ) + fvm.div( phi, U ) + turbulence.divDevReff( U )

        UEqn = turbulence.divDevReff( U ) + ( ref.fvm.ddt( U ) + ref.fvm.div( phi, U ) )        

        UEqn.relax()

        if momentumPredictor :
            ref.solve( UEqn == -ref.fvc.grad( p ) )
            pass
           
        # --- 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 )
            
            # Non-orthogonal pressure corrector loop
            for nonOrth in range( nNonOrthCorr + 1 ):
                # Pressure corrector
                pEqn = ref.fvm.laplacian( rUA, p ) == ref.fvc.div( phi )

                pEqn.setReference( pRefCell, pRefValue )

                if corr == ( nCorr-1 ) and nonOrth == nNonOrthCorr :
                    pEqn.solve( mesh.solver( ref.word( "pFinal" ) ) ) 
                    pass
                else:
                    pEqn.solve()   
                    pass
                   
                if nonOrth == nNonOrthCorr:
                    phi -= pEqn.flux()
                    pass
                
                pass
            cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )       

            U -= rUA * ref.fvc.grad( p ) 
            U.correctBoundaryConditions()
            pass

        turbulence.correct()

        runTime.write()

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

    ref.ext_Info() << "End\n" << ref.nl 
    
    import os
    return os.EX_OK