Ejemplo n.º 1
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
Ejemplo n.º 2
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createDynamicFvMesh(runTime)

    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)

    pimple = man.pimpleControl(mesh)

    phiAbs = ref.surfaceScalarField(ref.word("phiAbs"), phi)
    ref.fvc.makeAbsolute(phiAbs, U)

    cumulativeContErr = fun_correctPhi(
        runTime, mesh, phi, phiAbs, 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, correctPhi, checkMeshCourantNo = readControls(runTime, mesh, pimple)

        maxAlphaCo, alphaCoNum, meanAlphaCoNum = alphaCourantNo(runTime, mesh, alpha1, phi)

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

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

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

        timeBeforeMeshUpdate = runTime.elapsedCpuTime()

        fun_Urel(mesh, U)

        if mesh.changing():
            ref.ext_Info() << "Execution time for mesh.update() = " << runTime.elapsedCpuTime() - timeBeforeMeshUpdate << " s" << ref.nl
            gh << (g & mesh.C())
            ghf << (g & mesh.Cf())
            pass

        if mesh.changing() and correctPhi:
            cumulativeContErr = fun_correctPhi(
                runTime, mesh(), phi, phiAbs, p, p_rgh, rho, U, cumulativeContErr, pimple, pRefCell, pRefValue
            )
            pass

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

        twoPhaseProperties.correct()

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

        # --- Pressure-velocity PIMPLE corrector loop
        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,
                    phiAbs,
                    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
Ejemplo n.º 3
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, sources )
            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, U, phi, turbulence, p, rAU, UEqn, pRefCell, pRefValue, cumulativeContErr, ddtPhiCorr, 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