Ejemplo n.º 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)

    turbulence, p, h, rho, U, phi, thermo, pZones, pMin,\
    pressureImplicitPorosity, initialMass, nUCorr, pRefCell, pRefValue  = _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 readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls(
            mesh)

        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(
            simple)

        p.storePrevIter()
        rho.storePrevIter()
        # Pressure-velocity SIMPLE corrector

        UEqn, trTU, trAU, eqnResidual, maxResidual = _UEqn( phi, U, p, turbulence, pZones,\
                                                                        pressureImplicitPorosity, nUCorr, eqnResidual, maxResidual )

        hEqn, eqnResidual, maxResidual = _hEqn(thermo, phi, h, turbulence, p,
                                               rho, eqnResidual, maxResidual)

        eqnResidual, maxResidual = _pEqn( mesh, rho, thermo, p, U, trTU, trAU, UEqn, phi, \
                                          runTime, pMin, pressureImplicitPorosity, nNonOrthCorr, eqnResidual,\
                                          maxResidual, cumulativeContErr, initialMass, pRefCell, pRefValue )

        turbulence.correct()

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

        convergenceCheck(runTime, maxResidual, convergenceCriterion)
        runTime.increment()
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
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)

    T, p, p_rgh, U, phi, laminarTransport, gh, ghf, TRef, Pr, Prt, turbulence, beta, pRefCell, pRefValue, rhok = createFields(
        runTime, mesh, g)

    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 readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls(
            mesh)

        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(
            simple)

        p_rgh.storePrevIter()

        UEqn, eqnResidual, maxResidual = fun_UEqn(phi, U, p_rgh, turbulence,
                                                  mesh, ghf, rhok, eqnResidual,
                                                  maxResidual,
                                                  momentumPredictor)

        TEqn, kappaEff = fun_TEqn(turbulence, phi, T, rhok, beta, TRef, Pr,
                                  Prt, eqnResidual, maxResidual)
        eqnResidual, maxResidual, cumulativeContErr = fun_pEqn( runTime, mesh, p, p_rgh, phi, U, UEqn, ghf, gh, rhok, eqnResidual, \
                                                            maxResidual, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue )

        turbulence.correct()

        runTime.write()

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

        convergenceCheck(maxResidual, convergenceCriterion)

        pass

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

    import os
    return os.EX_OK
Ejemplo n.º 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)

    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
Ejemplo n.º 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, 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
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 )
    
    g = readGravitationalAcceleration( runTime, mesh )
    
    thermo, rho, p, h, psi, U, phi, turbulence, pRefCell, pRefValue, initialMass = createFields( runTime, mesh )
    
    from Foam.radiation import createRadiationModel
    radiation = createRadiationModel( thermo )
    
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    ext_Info() << "\nStarting time loop\n" << nl;

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

       from Foam.finiteVolume.cfdTools.general.include import readSIMPLEControls
       simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
       
       UEqn, eqnResidual, maxResidual = eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
        
       p.storePrevIter()
       rho.storePrevIter()
       
       UEqn, eqnResidual, maxResidual = fun_UEqn( turbulence, phi, U, rho, g, p, mesh, eqnResidual, maxResidual )
       
       hEqn, eqnResidual, maxResidual = fun_hEqn( turbulence, phi, h, rho, radiation, p, thermo, eqnResidual, maxResidual )
       
       eqnResidual, maxResidual, cumulativeContErr = fun_pEqn( thermo, g, rho, UEqn, p, U, psi, phi, initialMass,\
                                                              runTime, mesh, nNonOrthCorr, pRefCell, eqnResidual, maxResidual, cumulativeContErr )
           
       turbulence.correct()

       runTime.write()

       ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                 << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                 << nl << nl
                 
       convergenceCheck( runTime, maxResidual, convergenceCriterion)          

    ext_Info() << "End\n"
    
    import os
    return os.EX_OK
Ejemplo n.º 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, rho, p, h, psi, U, phi, turbulence, initialMass, pRefCell, pRefValue = _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 readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
        
        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
                
        p.storePrevIter()
        rho.storePrevIter()
        
        # Pressure-velocity SIMPLE corrector
        UEqn, eqnResidual, maxResidual = Ueqn( mesh, phi, U, rho, p, g, turbulence, eqnResidual, maxResidual )
        
        hEqn, eqnResidual, maxResidual = _hEqn( phi, h, turbulence, rho, p, thermo, eqnResidual, maxResidual )
        
        eqnResidual, maxResidual, cumulativeContErr = pEqn( runTime, mesh, p, phi, psi, U, UEqn, g, rho, thermo, initialMass, \
                                                            eqnResidual, maxResidual, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue )
        
        turbulence.correct()

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

    import os
    return os.EX_OK
Ejemplo n.º 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)

    p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr = 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.loop():

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

        from Foam.finiteVolume.cfdTools.general.include import readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls(
            mesh)

        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(
            simple)

        p.storePrevIter()

        UEqn, trTU, trAU, eqnResidual, maxResidual = fun_UEqn(
            mesh, phi, U, p, turbulence, pZones, nUCorr,
            pressureImplicitPorosity, eqnResidual, maxResidual)

        eqnResidual, maxResidual = fun_pEqn( mesh, p, U, trTU, trAU, UEqn, phi, runTime, pressureImplicitPorosity, nNonOrthCorr, \
                                             eqnResidual, maxResidual, cumulativeContErr, pRefCell, pRefValue, )

        turbulence.correct()

        runTime.write()

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

        convergenceCheck(runTime, maxResidual, convergenceCriterion)
        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
Ejemplo n.º 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 )
    
    g = readGravitationalAcceleration( runTime, mesh )
    
    thermo, rho, p, h, psi, U, phi, turbulence, pRefCell, pRefValue, initialMass = createFields( runTime, mesh )
    
    from Foam.radiation import createRadiationModel
    radiation = createRadiationModel( thermo )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    ext_Info() << "\nStarting time loop\n" << nl;

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

       from Foam.finiteVolume.cfdTools.general.include import readSIMPLEControls
       simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
       
       UEqn, eqnResidual, maxResidual = eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
        
       p.storePrevIter()
       rho.storePrevIter()
       
       UEqn, eqnResidual, maxResidual = fun_UEqn( turbulence, phi, U, rho, g, p, mesh, eqnResidual, maxResidual )
       
       hEqn, eqnResidual, maxResidual = fun_hEqn( turbulence, phi, h, rho, radiation, p, thermo, eqnResidual, maxResidual )
       
       eqnResidual, maxResidual, cumulativeContErr = fun_pEqn( thermo, g, rho, UEqn, p, U, psi, phi, initialMass,\
                                                              runTime, mesh, nNonOrthCorr, pRefCell, pRefValue, eqnResidual, maxResidual, cumulativeContErr )
           
       turbulence.correct()

       runTime.write()

       ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                 << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                 << nl << nl
                 
       convergenceCheck( runTime, maxResidual, convergenceCriterion)          

    ext_Info() << "End\n"
    
    import os
    return os.EX_OK
Ejemplo n.º 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)

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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 readSIMPLEControls

        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls(mesh)

        p.storePrevIter()

        UEqn = Ueqn(phi, U, p, turbulence)

        cumulativeContErr = pEqn(runTime, mesh, p, phi, U, UEqn, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue)

        turbulence.correct()

        runTime.write()

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

        runTime.increment()
        pass

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

    import os

    return os.EX_OK
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)
    
    T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, betaghf, pRefCell, pRefValue, rhok = createFields( runTime, mesh, g )
    
    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 readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
        
        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
                
        p.storePrevIter()
        
        UEqn, eqnResidual, maxResidual = fun_UEqn( phi, U, p, turbulence, mesh, g, rhok, eqnResidual, maxResidual )
        
        TEqn, kappaEff = fun_TEqn( turbulence, phi, T, rhok, beta, TRef, Pr, Prt, eqnResidual, maxResidual )
        eqnResidual, maxResidual, cumulativeContErr = fun_pEqn( runTime, mesh, p, phi, U, UEqn, g, rhok, eqnResidual, \
                                                            maxResidual, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue )
        
        turbulence.correct()

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

    import os
    return os.EX_OK
Ejemplo n.º 11
0
 def __init__( self, getTime, getMesh, getFields ):
     self.runTime = getTime()
     
     self.mesh = getMesh( self.runTime )
     
     self.transportProperties, self.nu, self.p, self.U, self.phi, self.pRefCell, self.pRefValue = getFields( self.runTime, self.mesh )
                                       
     from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
     self.cumulativeContErr = initContinuityErrs()
     
     self.runTime.increment()
     pass
Ejemplo n.º 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 )

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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 readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
        
        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
                
        p.storePrevIter()
        
        UEqn, eqnResidual, maxResidual = Ueqn( phi, U, p, turbulence, eqnResidual, maxResidual )
        
        eqnResidual, maxResidual, cumulativeContErr = pEqn( runTime, mesh, p, phi, U, UEqn, \
                                                            eqnResidual, maxResidual, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue )
        
        turbulence.correct()

        runTime.write();
        
        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        convergenceCheck( maxResidual, convergenceCriterion ) 
        
        runTime.increment()
        pass
        
    ext_Info() << "End\n" << nl 

    import os
    return os.EX_OK
Ejemplo n.º 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 )

    p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr = 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.loop() :
        
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.general.include import readSIMPLEControls
        simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls( mesh )
        
        eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )

        p.storePrevIter()


        UEqn, trTU, trAU, eqnResidual, maxResidual = fun_UEqn( mesh, phi, U, p, turbulence, pZones, nUCorr, pressureImplicitPorosity, eqnResidual, maxResidual )

        eqnResidual, maxResidual = fun_pEqn( mesh, p, U, trTU, trAU, UEqn, phi, runTime, pressureImplicitPorosity, nNonOrthCorr, \
                                             eqnResidual, maxResidual, cumulativeContErr, pRefCell, pRefValue, )

        turbulence.correct()

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

    import os
    return os.EX_OK
Ejemplo n.º 14
0
    def runSeparateNamespace(runTime, mesh):
        p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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 readSIMPLEControls

            simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls(mesh)

            eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(simple)

            p.storePrevIter()

            UEqn, eqnResidual, maxResidual = Ueqn(phi, U, p, turbulence, eqnResidual, maxResidual)

            eqnResidual, maxResidual, cumulativeContErr = pEqn(
                runTime,
                mesh,
                p,
                phi,
                U,
                UEqn,
                eqnResidual,
                maxResidual,
                nNonOrthCorr,
                cumulativeContErr,
                pRefCell,
                pRefValue,
            )

            turbulence.correct()

            runTime.write()

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

            convergenceCheck(maxResidual, convergenceCriterion)

            pass
    def runSeparateNamespace( runTime, mesh ):
        from Foam.finiteVolume.cfdTools.general.include  import readEnvironmentalProperties
        g, environmentalProperties = readEnvironmentalProperties( runTime, mesh )
    
        thermo, rho, p, h, T, U, phi, turbulence, gh, pRef, pd, p, pdRefCell, pdRefValue, radiation, initialMass  = createFields( runTime, mesh, g )
    
        from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
        cumulativeContErr = initContinuityErrs()
    
        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 readSIMPLEControls
           simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )

           eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck( simple )
        
           pd.storePrevIter()
           rho.storePrevIter()
           # Pressure-velocity SIMPLE corrector
           UEqn, eqnResidual, maxResidual = fun_UEqn( phi, U, turbulence, pd, rho, gh, eqnResidual, maxResidual )
       
           hEqn, eqnResidual, maxResidual = fun_hEqn( turbulence, phi, h, rho, radiation, p, thermo, eqnResidual, maxResidual )
       
           eqnResidual, maxResidual, cumulativeContErr = fun_pEqn( runTime, thermo, UEqn, U, phi, rho, gh, pd, p, initialMass, mesh, pRef, \
                                                               nNonOrthCorr, pdRefCell, pdRefValue, eqnResidual, maxResidual, cumulativeContErr )
           
           turbulence.correct()

           runTime.write()

           ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                     << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                     << nl << nl
                 
           convergenceCheck( runTime, maxResidual, convergenceCriterion)          
       
           runTime.increment()
           pass
Ejemplo n.º 16
0
    def runSeparateNamespace(runTime, mesh):
        p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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 readSIMPLEControls
            simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls(
                mesh)

            eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(
                simple)

            p.storePrevIter()

            UEqn, eqnResidual, maxResidual = Ueqn(phi, U, p, turbulence,
                                                  eqnResidual, maxResidual)

            eqnResidual, maxResidual, cumulativeContErr = pEqn( runTime, mesh, p, phi, U, UEqn, \
                                                                eqnResidual, maxResidual, nNonOrthCorr, cumulativeContErr, pRefCell, pRefValue )

            turbulence.correct()

            runTime.write()

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

            convergenceCheck(maxResidual, convergenceCriterion)

            pass
Ejemplo n.º 17
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)
    
    T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, pRefCell, pRefValue, rhok = _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.general.include import CourantNo
    CoNum, meanCoNum, velMag = CourantNo( mesh, phi, 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.loop():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        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.general.include import CourantNo
        CoNum, meanCoNum, velMag = CourantNo( mesh, phi, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        UEqn = _Ueqn( U, phi, turbulence, p, rhok, g, mesh, momentumPredictor )
        
        TEqn, kappaEff = _TEqn( turbulence, T, phi, rhok, beta, TRef, Pr, Prt )
        
        # --- PISO loop
        for corr in range( nCorr ):
            pEqn = _pEqn( runTime, mesh, U, UEqn, phi, p, rhok, g, corr, nCorr, nNonOrthCorr, cumulativeContErr )
            pass

        turbulence.correct()

        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
Ejemplo n.º 18
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
Ejemplo n.º 19
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, rho, U, phi, thermo, pZones, pMin, pressureImplicitPorousity, initialMass, nUCorr, pRefCell, pRefValue = _createFields(
        runTime, mesh
    )

    from Foam.OpenFOAM import ext_Info, nl

    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible

    turbulence = compressible.turbulenceModel.New(rho, U, phi, thermo())

    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 readSIMPLEControls

        simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls(mesh)

        p.storePrevIter()
        rho.storePrevIter()
        # Pressure-velocity SIMPLE corrector

        UEqn, trTU, trAU = _UEqn(phi, U, p, turbulence, pZones, pressureImplicitPorousity, nUCorr)

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

        _pEqn(
            mesh,
            rho,
            thermo,
            p,
            U,
            trTU,
            trAU,
            UEqn,
            phi,
            runTime,
            pMin,
            pressureImplicitPorousity,
            nNonOrthCorr,
            cumulativeContErr,
            initialMass,
            pRefCell,
            pRefValue,
        )

        turbulence.correct()

        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
Ejemplo n.º 20
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.dynamicFvMesh import createDynamicFvMesh
    mesh = createDynamicFvMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readPISOControls
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh() )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh() )

    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    cumulativeContErr = fun_correctPhi( runTime, mesh(), phi, p, p_rgh, rho, U, cumulativeContErr, nNonOrthCorr, pRefCell, pRefValue)
    
    from Foam.finiteVolume.cfdTools.incompressible import CourantNo
    CoNum, meanCoNum = CourantNo( mesh(), phi, 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() :
        
        adjustTimeStep, maxCo, maxDeltaT, piso, nCorr, nNonOrthCorr, \
            momentumPredictor, transonic, nOuterCorr, correctPhi, checkMeshCourantNo = readControls( runTime, mesh() )
        
        maxAlphaCo, alphaCoNum, meanAlphaCoNum = alphaCourantNo( runTime, mesh(), alpha1, phi )
        
        CoNum, meanCoNum = CourantNo( mesh(), phi, runTime )
        
        from Foam import fvc
        # Make the fluxes absolute
        fvc.makeAbsolute( phi, U )
        
        runTime = setDeltaT(  runTime, adjustTimeStep, maxCo, CoNum, maxAlphaCo, alphaCoNum, maxDeltaT )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        timeBeforeMeshUpdate = runTime.elapsedCpuTime()

        # Do any mesh changes
        mesh.update()
        
        if mesh.changing():
            ext_Info() << "Execution time for mesh.update() = " << runTime.elapsedCpuTime() - timeBeforeMeshUpdate << " s" << nl
            gh.ext_assign( g & mesh.C() )
            ghf.ext_assign( g & mesh.Cf() )
            pass
        
        if mesh.changing() and correctPhi:
            cumulativeContErr = fun_correctPhi( runTime, mesh(), phi, p, p_rgh, rho, U, cumulativeContErr, nNonOrthCorr, pRefCell, pRefValue)
            pass

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

        if mesh.changing() and checkMeshCourantNo:
           from Foam.dynamicFvMesh import meshCourantNo
           meshCoNum, meanMeshCoNum = meshCourantNo( runTime, mesh(), phi )
           pass

        twoPhaseProperties.correct()
     
        alphaEqnSubCycle( runTime, piso, mesh(), phi, alpha1, rho, rhoPhi, rho1, rho2, interface )
        
        UEqn = _UEqn( mesh(), alpha1, U, p, p_rgh, ghf, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, momentumPredictor )

        # --- PISO loop
        for corr in range( nCorr ):
            cumulativeContErr = _pEqn( runTime, mesh(), UEqn, U, p, p_rgh, gh, ghf, phi, alpha1, rho, g, \
                                       interface, corr, nCorr, nNonOrthCorr, pRefCell, pRefValue, cumulativeContErr )
            pass
        
        turbulence.correct()

        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
Ejemplo n.º 21
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
Ejemplo n.º 22
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 createMeshNoClear
    mesh = createMeshNoClear(runTime)

    transportProperties, nu = readTransportProperties(runTime, mesh)

    p, U, phi = _createFields(runTime, mesh)

    turbulenceProperties, force, K, forceGen = readTurbulenceProperties(
        runTime, mesh, U)

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

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

    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.randomProcesses import fft
        from Foam.OpenFOAM import ReImSum
        force.internalField().ext_assign(
            ReImSum(
                fft.reverseTransform(
                    K / (K.mag() + 1.0e-6) ^ forceGen.newField(), K.nn())))

        globalProperties(runTime, U, nu, force)

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

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

        # --- PISO loop

        for corr in range(1):
            rUA = 1.0 / UEqn.A()

            U.ext_assign(rUA * UEqn.H())
            phi.ext_assign((fvc.interpolate(U) & mesh.Sf()) +
                           fvc.ddtPhiCorr(rUA, U, phi))

            pEqn = fvm.laplacian(rUA, p) == fvc.div(phi)

            pEqn.solve()

            phi.ext_assign(phi - pEqn.flux())

            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs(mesh, phi, runTime,
                                               cumulativeContErr)

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

        runTime.write()

        if runTime.outputTime():
            from Foam.randomProcesses import calcEk
            from Foam.OpenFOAM import word, fileName
            calcEk(U, K).write(fileName(runTime.timePath() / fileName("Ek")),
                               runTime.graphFormat())
            pass

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

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

    import os
    return os.EX_OK
Ejemplo n.º 23
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 regionProperties import regionProperties
    rp = regionProperties(runTime)

    from fluid import createFluidMeshes
    fluidRegions = createFluidMeshes(rp, runTime)

    from solid import createSolidMeshes
    solidRegions = createSolidMeshes(rp, runTime)

    from fluid import createFluidFields
    pdf, thermof, rhof, Kf, Uf, phif, turb, DpDtf, ghf, initialMassf, pRef = createFluidFields(
        fluidRegions, runTime, rp)

    from solid import createSolidField
    rhos, cps, rhosCps, Ks, Ts = createSolidField(solidRegions, runTime)

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

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

    if fluidRegions.size():
        from fluid import compressubibleMultiRegionCourantNo
        CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime, rhof,
                                                   phif)

        from fluid import setInitialDeltaT
        runTime = setInitialDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                                   CoNum)
        pass

    from Foam.OpenFOAM import ext_Info, nl

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

        if fluidRegions.size():
            from fluid import compressubibleMultiRegionCourantNo
            CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime,
                                                       rhof, phif)

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

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

        for i in range(fluidRegions.size()):
            ext_Info(
            ) << "\nSolving for fluid region " << fluidRegions[i].name() << nl

            from fluid import readFluidMultiRegionPISOControls
            piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readFluidMultiRegionPISOControls(
                fluidRegions[i])

            from fluid import solveFluid
            cumulativeContErr = solveFluid( i, fluidRegions, pdf, thermof, rhof, Kf, Uf, phif, turb, DpDtf, ghf, initialMassf, pRef,\
                                            nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, cumulativeContErr )

            pass

        for i in range(solidRegions.size()):
            ext_Info(
            ) << "\nSolving for solid region " << solidRegions[i].name() << nl

            from solid import readSolidMultiRegionPISOControls
            piso, nNonOrthCorr = readSolidMultiRegionPISOControls(
                solidRegions[i])

            from solid import solveSolid
            solveSolid(i, rhosCps, Ks, Ts, nNonOrthCorr)
            pass

        runTime.write()

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

    ext_Info() << "End\n"
    pass

    import os
    return os.EX_OK
    def runSeparateNamespace(runTime, mesh):
        from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration

        g = readGravitationalAcceleration(runTime, mesh)

        T, p, p_rgh, U, phi, laminarTransport, gh, ghf, TRef, Pr, Prt, turbulence, beta, pRefCell, pRefValue, rhok, kappat = createFields(
            runTime, mesh, g
        )

        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 readSIMPLEControls

            simple, nNonOrthCorr, momentumPredictor, transonic = readSIMPLEControls(mesh)

            eqnResidual, maxResidual, convergenceCriterion = initConvergenceCheck(simple)

            p_rgh.storePrevIter()

            UEqn, eqnResidual, maxResidual = fun_UEqn(
                phi, U, p_rgh, turbulence, mesh, ghf, rhok, eqnResidual, maxResidual, momentumPredictor
            )

            TEqn, kappaEff = fun_TEqn(turbulence, phi, T, rhok, beta, TRef, Pr, Prt, kappat, eqnResidual, maxResidual)

            eqnResidual, maxResidual, cumulativeContErr = fun_pEqn(
                runTime,
                mesh,
                p,
                p_rgh,
                phi,
                U,
                UEqn,
                ghf,
                gh,
                rhok,
                eqnResidual,
                maxResidual,
                nNonOrthCorr,
                cumulativeContErr,
                pRefCell,
                pRefValue,
            )

            turbulence.correct()

            runTime.write()

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

            convergenceCheck(maxResidual, convergenceCriterion)

            pass
Ejemplo n.º 25
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
Ejemplo n.º 26
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, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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.incompressible import CourantNo
        CoNum, meanCoNum = CourantNo(mesh, phi, runTime)

        # Pressure-velocity PISO corrector

        from Foam import fvm
        #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) + (fvm.ddt(U) + fvm.div(phi, U))

        UEqn.relax()

        from Foam.finiteVolume import solve
        from Foam import fvc
        if momentumPredictor:
            solve(UEqn == -fvc.grad(p))
            pass

        # --- PISO loop

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

            phi.ext_assign((fvc.interpolate(U) & mesh.Sf()) +
                           fvc.ddtPhiCorr(rUA, U, phi))

            from Foam.finiteVolume import adjustPhi
            adjustPhi(phi, U, p)

            #Non-orthogonal pressure corrector loop
            for nonOrth in range(nNonOrthCorr + 1):
                #Pressure corrector
                pEqn = fvm.laplacian(rUA, p) == fvc.div(phi)

                pEqn.setReference(pRefCell, pRefValue)

                if corr == (nCorr - 1) and nonOrth == nNonOrthCorr:
                    from Foam.OpenFOAM import word
                    pEqn.solve(mesh.solver(word("pFinal")))
                    pass
                else:
                    pEqn.solve()
                    pass

                if nonOrth == nNonOrthCorr:
                    phi.ext_assign(phi - pEqn.flux())
                    pass

                pass
            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs(mesh, phi, runTime,
                                               cumulativeContErr)

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

        turbulence.correct()

        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
Ejemplo n.º 27
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)

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

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

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

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

    correctPhi(runTime, mesh, phi, pd, rho, U, cumulativeContErr, nNonOrthCorr,
               pdRefCell, pdRefValue)

    from Foam.finiteVolume.cfdTools.incompressible import CourantNo
    CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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():

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(
            mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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

        twoPhaseProperties.correct()

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

        UEqn = _UEqn(mesh, alpha1, U, pd, rho, rhoPhi, turbulence, ghf,
                     twoPhaseProperties, interface, momentumPredictor)

        # --- PISO loop
        for corr in range(nCorr):
            _pEqn(mesh, UEqn, U, p, pd, phi, alpha1, rho, ghf, interface, corr,
                  nCorr, nNonOrthCorr, pdRefCell, pdRefValue)
            pass

        from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
        cumulativeContErr = continuityErrs(mesh, phi, runTime,
                                           cumulativeContErr)

        p.ext_assign(pd + rho * gh)

        if pd.needReference():
            from Foam.OpenFOAM import dimensionedScalar
            from Foam.finiteVolume import getRefCellValue

            p.ext_assign(
                p +
                dimensionedScalar(word("p"), p.dimensions(), pRefValue -
                                  getRefCellValue(p, pdRefCell)))
            pass

        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
Ejemplo n.º 28
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.dynamicFvMesh import createDynamicFvMesh
    mesh = createDynamicFvMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
    pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls( mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue = _createFields( runTime, mesh )    
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" <<nl
    
    while runTime.run() :
        
        adjustTimeStep, maxCo, maxDeltaT, pimple, nOuterCorr, nCorr, nNonOrthCorr, \
                        momentumPredictor, transonic, correctPhi, checkMeshCourantNo = readControls( runTime, mesh )
        
        from Foam.finiteVolume.cfdTools.general.include import CourantNo
        CoNum, meanCoNum, velMag = CourantNo( mesh, phi, runTime )
        
        # Make the fluxes absolute
        from Foam import fvc
        fvc.makeAbsolute(phi, U)
      
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
                
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        meshChanged = mesh.update()
        
        if correctPhi and ( mesh.moving() or meshChanged ) :
           cumulativeContErr = _correctPhi( runTime, mesh, p, rAU, phi, nNonOrthCorr, pRefCell, pRefValue, cumulativeContErr  )
           pass
        
        # Make the fluxes relative to the mesh motion
        fvc.makeRelative( phi, U )
        
        
        if mesh.moving() and checkMeshCourantNo :
           from Foam.dynamicFvMesh import meshCourantNo
           meshCoNum, meanMeshCoNum = meshCourantNo( runTime, mesh, phi )
           pass
        
        from Foam import fvm
        #PIMPLE loop
        for ocorr in range( nOuterCorr ):
           if nOuterCorr != 1:
              p.storePrevIter()
              pass
           UEqn = _UEqn( mesh, phi, U, p, turbulence, ocorr, nOuterCorr, momentumPredictor )
           
           # --- PISO loop
           for corr in range( nCorr ):
              rAU.ext_assign( 1.0 / UEqn.A() )
              
              U.ext_assign( rAU * UEqn.H() )
              phi.ext_assign( fvc.interpolate( U ) & mesh.Sf() )
              
              if p.needReference() :
                 fvc.makeRelative( phi, U )
                 adjustPhi( phi, U, p )
                 fvc.makeAbsolute( phi, U )
                 pass
              
              for nonOrth in range( nNonOrthCorr + 1 ):
                 pEqn = ( fvm.laplacian( rAU, p ) == fvc.div( phi ) )
                 
                 pEqn.setReference( pRefCell, pRefValue )
                 
                 if ocorr == nOuterCorr - 1 and corr == nCorr - 1 \
                                            and nonOrth == nNonOrthCorr :
                    from Foam.OpenFOAM import word
                    pEqn.solve( mesh.solver( word( str( p.name() ) + "Final" ) ) )
                    pass
                 else:
                    pEqn.solve( mesh.solver( p.name() ) )
                    pass
                    
                 if nonOrth == nNonOrthCorr:
                    phi.ext_assign( phi - pEqn.flux() )
                    pass
                 
                 pass
                 
              from Foam.finiteVolume.cfdTools.general.include import ContinuityErrs
              cumulativeContErr = ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
                 
              # Explicitly relax pressure for momentum corrector
              if ocorr != nOuterCorr - 1:
                 p.relax()
                 pass
                 
              # Make the fluxes relative to the mesh motion
              fvc.makeRelative( phi, U )
              U.ext_assign( U - rAU * fvc.grad( p ) )
              U.correctBoundaryConditions()
              pass
           turbulence.correct()   
           pass

        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
Ejemplo n.º 29
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, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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.general.include import CourantNo
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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

        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            if nOuterCorr != 1:
                p.storePrevIter()
                pass

            UEqn, rUA = Ueqn(mesh, phi, U, p, turbulence, oCorr, nOuterCorr,
                             momentumPredictor)

            # --- PISO loop
            for corr in range(nCorr):
                cumulativeContErr = pEqn( runTime, mesh, U, rUA, UEqn, phi, p, nCorr, nOuterCorr,\
                                          nNonOrthCorr, oCorr, corr, pRefCell, pRefValue, cumulativeContErr )
                pass

            turbulence.correct()
            pass

        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
Ejemplo n.º 30
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)

    T, p, U, phi, laminarTransport, beta, TRef, Pr, Prt, turbulence, pRefCell, pRefValue, rhok = _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.general.include import CourantNo
    CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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.loop():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

        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.general.include import CourantNo
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, runTime)

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

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

        TEqn, kappaEff = _TEqn(turbulence, T, phi, rhok, beta, TRef, Pr, Prt)

        # --- PISO loop
        for corr in range(nCorr):
            pEqn = _pEqn(runTime, mesh, U, UEqn, phi, p, rhok, g, corr, nCorr,
                         nNonOrthCorr, cumulativeContErr)
            pass

        turbulence.correct()

        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
Ejemplo n.º 31
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 )
    
    transportProperties, nu, Ubar, magUbar, flowDirection = readTransportProperties( runTime, mesh)
    
    p, U, phi, laminarTransport, sgsModel, pRefCell, pRefValue = _createFields( runTime, mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    gradP, gradPFile = createGradP( runTime)
    
    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.incompressible import CourantNo
        CoNum, meanCoNum = CourantNo( mesh, phi, runTime )

        sgsModel.correct()

        from Foam import fvm
        UEqn = fvm.ddt( U ) + fvm.div( phi, U ) + sgsModel.divDevBeff( U ) == flowDirection * gradP

        if momentumPredictor:
           from Foam.finiteVolume import solve
           from Foam import fvc
           solve( UEqn == -fvc.grad( p ) )
           pass

        rUA = 1.0 / UEqn.A()

        for corr in range( nCorr ):
            U.ext_assign( rUA * UEqn.H() )
            from Foam import fvc
            phi.ext_assign( ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, U, phi ) )

            from Foam.finiteVolume import adjustPhi
            adjustPhi(phi, U, p)

            from Foam.OpenFOAM import word

            for nonOrth in range( nNonOrthCorr + 1 ):
                pEqn = fvm.laplacian( rUA, p ) == fvc.div( phi ) 
                pEqn.setReference( pRefCell, pRefValue )

                if corr == nCorr-1 and nonOrth == nNonOrthCorr:
                   pEqn.solve( mesh.solver( word( str( p.name() ) + "Final" ) ) )
                   pass
                else:
                   pEqn.solve( mesh.solver( p.name() ) )
                   pass

                if nonOrth == nNonOrthCorr:
                   phi.ext_assign( phi - pEqn.flux() )
                   pass
                pass

            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )

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

        # Correct driving force for a constant mass flow rate

        # Extract the velocity in the flow direction
        magUbarStar = ( flowDirection & U ).weightedAverage( mesh.V() )

        # Calculate the pressure gradient increment needed to
        # adjust the average flow-rate to the correct value
        gragPplus = ( magUbar - magUbarStar ) / rUA.weightedAverage( mesh.V() )

        U.ext_assign( U + flowDirection * rUA * gragPplus )

        gradP +=gragPplus
        ext_Info() << "Uncorrected Ubar = " << magUbarStar.value() << " " << "pressure gradient = " << gradP.value() << nl

        runTime.write()

        writeGradP( runTime, gradP )

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

        pass

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

    import os
    return os.EX_OK
Ejemplo n.º 32
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)
    
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, \
           adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles = read_controls( args, runTime, mesh )

    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = 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 )
    
    from Foam.finiteVolume.cfdTools.incompressible import CourantNo
    CoNum, meanCoNum = CourantNo( mesh, phi, 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():
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, \
               adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles = read_controls( args, runTime, mesh )

        from Foam.finiteVolume.cfdTools.incompressible import CourantNo
        CoNum, meanCoNum = CourantNo( mesh, phi, 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 import fvm, fvc
        from Foam.finiteVolume import solve
        # --- Outer-corrector loop
        for oCorr in range( nOuterCorr ):
            alphaEqnsSubCycle( runTime, piso, mesh, phi, alpha1, alpha2, rho, rho1, rho2, rhoPhi, dgdt, interface, oCorr )


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

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

            # --- PISO loop
            for corr in range( nCorr ): 
                fun_pEqn( runTime, mesh, UEqn, p, p_rgh, phi, U, rho, rho1, rho2, rho10, rho20, gh, ghf, dgdt, pMin, \
                          psi1, psi2, alpha1, alpha2, interface, transonic, oCorr, nOuterCorr, corr, nCorr, nNonOrthCorr )
                pass

        rho.ext_assign( alpha1 * rho1 + alpha2 * rho2 )

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
Ejemplo n.º 33
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 createMeshNoClear
    mesh = createMeshNoClear( runTime )
    
    transportProperties, nu = readTransportProperties( runTime, mesh )
    
    p, U, phi = _createFields( runTime, mesh )
    
    turbulenceProperties, force, K, forceGen = readTurbulenceProperties( runTime, mesh, U )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

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

    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.randomProcesses import fft
        from Foam.OpenFOAM import ReImSum
        force.internalField().ext_assign( ReImSum( fft.reverseTransform( K / ( K.mag() + 1.0e-6 ) ^ forceGen.newField(), K.nn() ) ) )
        
        globalProperties( runTime, U, nu, force )
        
        from Foam import fvm
        UEqn = fvm.ddt( U ) + fvm.div( phi, U ) - fvm.laplacian( nu, U ) == force 
        
        from Foam import fvc
        from Foam.finiteVolume import solve
        solve( UEqn == -fvc.grad( p ) )
        
        # --- PISO loop

        for corr  in range( 1 ):
            rUA = 1.0 / UEqn.A()

            U.ext_assign( rUA*UEqn.H() )
            phi.ext_assign( ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, U, phi ) )

            pEqn = fvm.laplacian( rUA, p ) == fvc.div( phi )

            pEqn.solve()

            phi.ext_assign( phi - pEqn.flux() )

            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )

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

        runTime.write()
        
        if runTime.outputTime():
            from Foam.randomProcesses import calcEk
            from Foam.OpenFOAM import word, fileName
            calcEk( U, K ).write( fileName( runTime.timePath() / fileName( "Ek" ) ), runTime.graphFormat() )
            pass

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

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

    import os
    return os.EX_OK
Ejemplo n.º 34
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)

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

    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(mesh)

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

    cumulativeContErr = initContinuityErrs()

    p, pd, gh, ghf, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pdRefCell, pdRefValue, pRefValue, interface, turbulence = _createFields(
        runTime, mesh, g
    )

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

    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

    correctPhi(runTime, mesh, phi, pd, rho, U, cumulativeContErr, nNonOrthCorr, pdRefCell, pdRefValue)

    from Foam.finiteVolume.cfdTools.incompressible import CourantNo

    CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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():

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, 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

        twoPhaseProperties.correct()

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

        UEqn = _UEqn(
            mesh, alpha1, U, pd, rho, rhoPhi, turbulence, ghf, twoPhaseProperties, interface, momentumPredictor
        )

        # --- PISO loop
        for corr in range(nCorr):
            _pEqn(
                mesh, UEqn, U, p, pd, phi, alpha1, rho, ghf, interface, corr, nCorr, nNonOrthCorr, pdRefCell, pdRefValue
            )
            pass

        from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

        cumulativeContErr = continuityErrs(mesh, phi, runTime, cumulativeContErr)

        p.ext_assign(pd + rho * gh)

        if pd.needReference():
            from Foam.OpenFOAM import dimensionedScalar
            from Foam.finiteVolume import getRefCellValue

            p.ext_assign(p + dimensionedScalar(word("p"), p.dimensions(), pRefValue - getRefCellValue(p, pdRefCell)))
            pass

        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
Ejemplo n.º 35
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
Ejemplo n.º 36
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
Ejemplo n.º 37
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
Ejemplo n.º 38
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 regionProperties import regionProperties
    rp = regionProperties( runTime )

    from fluid import createFluidMeshes
    fluidRegions = createFluidMeshes( rp, runTime )
    
    from solid import createSolidMeshes
    solidRegions = createSolidMeshes( rp, runTime )
    
    from fluid import createFluidFields
    pdf, thermof, rhof, Kf, Uf, phif, turb, DpDtf, ghf, initialMassf, pRef = createFluidFields( fluidRegions, runTime, rp )
    
    from solid import createSolidField
    rhos, cps, rhosCps, Ks, Ts = createSolidField( solidRegions, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()

    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    if fluidRegions.size() :
       from fluid import compressubibleMultiRegionCourantNo
       CoNum = compressubibleMultiRegionCourantNo( fluidRegions, runTime, rhof, phif )
                
       from fluid import setInitialDeltaT
       runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
       pass
    
    from Foam.OpenFOAM import ext_Info, nl
    
    while runTime.run():
       from Foam.finiteVolume.cfdTools.general.include import readTimeControls
       adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
       
       if fluidRegions.size() :
          from fluid import compressubibleMultiRegionCourantNo
          CoNum = compressubibleMultiRegionCourantNo( fluidRegions, runTime, rhof, phif )

          from Foam.finiteVolume.cfdTools.general.include import setDeltaT   
          runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
          pass
       
       runTime.increment()
       ext_Info()<< "Time = " << runTime.timeName() << nl << nl
       
       for i in range( fluidRegions.size() ):
           ext_Info() << "\nSolving for fluid region " << fluidRegions[ i ].name() << nl
           
           from fluid import readFluidMultiRegionPISOControls
           piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readFluidMultiRegionPISOControls( fluidRegions[ i ] )

           from fluid import solveFluid
           cumulativeContErr = solveFluid( i, fluidRegions, pdf, thermof, rhof, Kf, Uf, phif, turb, DpDtf, ghf, initialMassf, pRef,\
                                           nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, cumulativeContErr )
           
           pass
        
       for i in range( solidRegions.size() ):
           ext_Info() << "\nSolving for solid region " << solidRegions[ i ].name() << nl
           
           from solid import readSolidMultiRegionPISOControls
           piso, nNonOrthCorr = readSolidMultiRegionPISOControls( solidRegions[ i ] )
               
           from solid import solveSolid
           solveSolid( i, rhosCps,  Ks, Ts, nNonOrthCorr )
           pass
       
       runTime.write();

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

    ext_Info() << "End\n"
    pass

       
    import os
    return os.EX_OK
Ejemplo n.º 39
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
Ejemplo n.º 40
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)

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

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

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

    cumulativeContErr = initContinuityErrs()

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

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

    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

    from Foam.finiteVolume.cfdTools.incompressible import CourantNo

    CoNum, meanCoNum = CourantNo(mesh, phi, 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():
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls(mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum = CourantNo(mesh, phi, 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

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

            twoPhaseProperties.correct()

            alphaEqn(mesh, phi, alpha1, alphatab, Dab, rhoPhi, rho, rho1, rho2, turbulence)

            UEqn = fun_UEqn(
                mesh, U, p_rgh, ghf, rho, rhoPhi, turbulence, twoPhaseProperties, momentumPredictor, finalIter
            )

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

            turbulence.correct()
            pass

        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
Ejemplo n.º 41
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, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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.incompressible import CourantNo
        CoNum, meanCoNum = CourantNo( mesh, phi, runTime )

        # Pressure-velocity PISO corrector

        from Foam import fvm        
        #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 ) + ( fvm.ddt( U ) + fvm.div( phi, U ) )        

        UEqn.relax()

        from Foam.finiteVolume import solve
        from Foam import fvc
        if momentumPredictor :
           solve( UEqn == -fvc.grad( p ) )
           pass
           
        # --- PISO loop

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

            phi.ext_assign( ( fvc.interpolate(U) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, U, phi ) )
         
            from Foam.finiteVolume import adjustPhi
            adjustPhi( phi, U, p )
            
            #Non-orthogonal pressure corrector loop
            for nonOrth in range( nNonOrthCorr + 1 ):
                #Pressure corrector
                pEqn = fvm.laplacian( rUA, p ) == fvc.div( phi )

                pEqn.setReference( pRefCell, pRefValue )

                if corr == ( nCorr-1 ) and nonOrth == nNonOrthCorr :
                   from Foam.OpenFOAM import word
                   pEqn.solve( mesh.solver( word( "pFinal" ) ) ) 
                   pass
                else:
                   pEqn.solve()   
                   pass
                   
                if nonOrth == nNonOrthCorr:
                   phi.ext_assign( phi - pEqn.flux() )
                   pass
                
                pass
            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )       

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

        turbulence.correct()

        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
Ejemplo n.º 42
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 createMeshNoClear
    mesh = createMeshNoClear( runTime )
    
    p, U, phi, fluid, pRefCell, pRefValue = _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.incompressible import CourantNo
        CoNum, meanCoNum, velMag = CourantNo( mesh, phi, runTime )
        
        fluid.correct()
        from Foam import fvm, fvc
        
        UEqn = fvm.ddt( U ) + fvm.div( phi, U ) - fvm.laplacian( fluid.ext_nu(), U )
        
        from Foam.finiteVolume import solve
        solve( UEqn == -fvc.grad( p ) )
        
        # --- PISO loop

        for corr in range( nCorr ):
            rUA = 1.0 / UEqn.A()
            U.ext_assign( rUA * UEqn.H() )
            phi.ext_assign( ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, U, phi ) )
            
            from Foam.finiteVolume import adjustPhi
            adjustPhi(phi, U, p)
            
            for nonOrth in range( nNonOrthCorr + 1): 
                
                pEqn = ( fvm.laplacian( rUA, p ) == fvc.div( phi ) )
                
                pEqn.setReference( pRefCell, pRefValue )
                pEqn.solve()

                if nonOrth == nNonOrthCorr:
                   phi.ext_assign( phi - pEqn.flux() )
                   pass
                
                pass
                
            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
            cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )     
               
            U.ext_assign( U - rUA * fvc.grad( p ) )
            U.correctBoundaryConditions()
            pass
        
        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
Ejemplo n.º 43
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
Ejemplo n.º 44
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
Ejemplo n.º 45
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 readPISOControls
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh )

    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    correctPhi( runTime, mesh, phi, p, p_rgh, rho, U, cumulativeContErr, nNonOrthCorr, pRefCell, pRefValue)
    
    from Foam.finiteVolume.cfdTools.incompressible import CourantNo
    CoNum, meanCoNum = CourantNo( mesh, phi, 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() :
                
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
        CoNum, meanCoNum = CourantNo( mesh, phi, runTime )        
        maxAlphaCo, alphaCoNum, meanAlphaCoNum = alphaCourantNo( runTime, mesh, alpha1, phi )
        runTime = setDeltaT(  runTime, adjustTimeStep, maxCo, CoNum, maxAlphaCo, alphaCoNum, maxDeltaT )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        twoPhaseProperties.correct()
     
        alphaEqnSubCycle( runTime, piso, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface )
        
        UEqn = _UEqn( mesh, alpha1, U, p, p_rgh, ghf, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, momentumPredictor )

        # --- PISO loop
        for corr in range( nCorr ):
            _pEqn( runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, alpha1, rho, g, interface, corr, nCorr, nNonOrthCorr, pRefCell, pRefValue, cumulativeContErr )
            pass
        
        from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
        cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )

        turbulence.correct()

        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
Ejemplo n.º 46
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.dynamicFvMesh import createDynamicFvMesh
    mesh = createDynamicFvMesh(runTime)

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

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

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

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

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT, pimple, nOuterCorr, nCorr, nNonOrthCorr, \
                        momentumPredictor, transonic, correctPhi, checkMeshCourantNo = readControls( runTime, mesh )

        from Foam.finiteVolume.cfdTools.general.include import CourantNo
        CoNum, meanCoNum = CourantNo(mesh, phi, runTime)

        # Make the fluxes absolute
        from Foam import fvc
        fvc.makeAbsolute(phi, U)

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

        runTime.increment()

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

        mesh.update()

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

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

        if mesh.changing() and checkMeshCourantNo:
            from Foam.dynamicFvMesh import meshCourantNo
            meshCoNum, meanMeshCoNum = meshCourantNo(runTime, mesh, phi)
            pass

        from Foam import fvm
        #PIMPLE loop
        for ocorr in range(nOuterCorr):
            if nOuterCorr != 1:
                p.storePrevIter()
                pass
            UEqn = _UEqn(mesh, phi, U, p, turbulence, ocorr, nOuterCorr,
                         momentumPredictor)

            # --- PISO loop
            for corr in range(nCorr):
                rAU.ext_assign(1.0 / UEqn.A())

                U.ext_assign(rAU * UEqn.H())
                phi.ext_assign(fvc.interpolate(U) & mesh.Sf())

                if p.needReference():
                    fvc.makeRelative(phi, U)
                    adjustPhi(phi, U, p)
                    fvc.makeAbsolute(phi, U)
                    pass

                for nonOrth in range(nNonOrthCorr + 1):
                    pEqn = (fvm.laplacian(rAU, p) == fvc.div(phi))

                    pEqn.setReference(pRefCell, pRefValue)

                    if ocorr == nOuterCorr - 1 and corr == nCorr - 1 \
                                               and nonOrth == nNonOrthCorr :
                        from Foam.OpenFOAM import word
                        pEqn.solve(mesh.solver(word(str(p.name()) + "Final")))
                        pass
                    else:
                        pEqn.solve(mesh.solver(p.name()))
                        pass

                    if nonOrth == nNonOrthCorr:
                        phi.ext_assign(phi - pEqn.flux())
                        pass

                    pass

                from Foam.finiteVolume.cfdTools.general.include import ContinuityErrs
                cumulativeContErr = ContinuityErrs(phi, runTime, mesh,
                                                   cumulativeContErr)

                # Explicitly relax pressure for momentum corrector
                if ocorr != nOuterCorr - 1:
                    p.relax()
                    pass

                # Make the fluxes relative to the mesh motion
                fvc.makeRelative(phi, U)
                U.ext_assign(U - rAU * fvc.grad(p))
                U.correctBoundaryConditions()
                pass
            pass

        turbulence.correct()

        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
Ejemplo n.º 47
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
Ejemplo n.º 48
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
Ejemplo n.º 49
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)

    transportProperties, nu, p, U, phi, pRefCell, pRefValue = 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"

    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.incompressible import CourantNo

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

        from Foam import fvm

        UEqn = fvm.ddt(U) + fvm.div(phi, U) - fvm.laplacian(nu, U)

        from Foam import fvc
        from Foam.finiteVolume import solve

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

        # --- PISO loop

        for corr in range(nCorr):
            rUA = 1.0 / UEqn.A()

            U.ext_assign(rUA * UEqn.H())
            phi.ext_assign((fvc.interpolate(U) & mesh.Sf()) + fvc.ddtPhiCorr(rUA, U, phi))

            from Foam.finiteVolume import adjustPhi

            adjustPhi(phi, U, p)

            for nonOrth in range(nNonOrthCorr + 1):
                pEqn = fvm.laplacian(rUA, p) == fvc.div(phi)

                pEqn.setReference(pRefCell, pRefValue)
                pEqn.solve()

                if nonOrth == nNonOrthCorr:
                    phi.ext_assign(phi - pEqn.flux())
                    pass

                pass

            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

            cumulativeContErr = continuityErrs(mesh, phi, runTime, cumulativeContErr)

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

            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
Ejemplo n.º 50
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
Ejemplo n.º 51
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, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _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.general.include import CourantNo
        CoNum, meanCoNum = CourantNo( mesh, phi, 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
        
        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            if nOuterCorr != 1 :
               p.storePrevIter()
               pass
            
            UEqn, rUA = Ueqn( mesh, phi, U, p, turbulence, oCorr, nOuterCorr, momentumPredictor )
            
            # --- PISO loop
            for corr in range( nCorr ):
               cumulativeContErr = pEqn( runTime, mesh, U, rUA, UEqn, phi, p, nCorr, nOuterCorr,\
                                         nNonOrthCorr, oCorr, corr, pRefCell, pRefValue, cumulativeContErr )
               pass
                                         
            turbulence.correct()
            pass

        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