示例#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
示例#3
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM import argList, word
    argList.validOptions.fget().insert( word( "writep" ), "" )
    
    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 = _createFields( runTime, mesh )
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << nl << "Calculating potential flow" << nl
        
    from Foam.finiteVolume.cfdTools.general.include import readSIMPLEControls
    simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic = readSIMPLEControls( mesh )
    
    from Foam.finiteVolume import adjustPhi
    adjustPhi(phi, U, p)
    
    from Foam.OpenFOAM import dimensionedScalar, word, dimTime, dimensionSet
    from Foam import fvc, fvm
    for nonOrth in range( nNonOrthCorr + 1):
        pEqn = fvm.laplacian( dimensionedScalar( word( "1" ), dimTime / p.dimensions() * dimensionSet( 0.0, 2.0, -2.0, 0.0, 0.0 ), 1.0 ), p ) == fvc.div( phi )

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

        if nonOrth == nNonOrthCorr:
           phi.ext_assign( phi - pEqn.flux() )
           pass
        pass
    
    ext_Info() << "continuity error = " << fvc.div( phi ).mag().weightedAverage( mesh.V() ).value() << nl

    U.ext_assign( fvc.reconstruct( phi ) )
    U.correctBoundaryConditions()
    ext_Info() << "Interpolated U error = " << ( ( ( fvc.interpolate( U ) & mesh.Sf() ) - phi ).sqr().sum().sqrt()  /mesh.magSf().sum() ).value() << nl

    # Force the write
    U.write()
    phi.write()
    
    if args.optionFound( word( "writep" ) ):
       p.write()
       pass
       
    ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
    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 )
    
    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
示例#5
0
def main_standalone( argc, argv ):

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

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

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

    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
示例#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 )
    
    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
示例#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
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
示例#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
示例#10
0
def main_standalone( argc, argv ):

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

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

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

    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
示例#11
0
def main_standalone( argc, argv ):

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

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

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

    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
示例#12
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
示例#14
0
def main_standalone(argc, argv):

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

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

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

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

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nCalculating temperature distribution\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)

        from Foam.finiteVolume import solve
        from Foam import fvm
        for nonOrth in range(nNonOrthCorr + 1):
            solve(fvm.ddt(T) - fvm.laplacian(DT, T))
            pass

        write(runTime, mesh, T)

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

        pass

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

    import os
    return os.EX_OK
示例#15
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 )
    
    T, transportProperties, DT = _createFields( runTime, mesh )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nCalculating temperature distribution\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 )
        
        from Foam.finiteVolume import solve
        from Foam import fvm
        for nonOrth in range( nNonOrthCorr + 1 ):
            solve( fvm.ddt( T ) - fvm.laplacian( DT, T ) )
            pass
        
        write( runTime, mesh, T )
        
        ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << nl << nl
        
        pass

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

    import os
    return os.EX_OK
示例#16
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)

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

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nCalculating scalar transport\n" << nl

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

    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)

        from Foam.finiteVolume import solve
        from Foam import fvm
        for nonOrth in range(nNonOrthCorr + 1):
            solve(fvm.ddt(T) + fvm.div(phi, T) - fvm.laplacian(DT, T))
            pass

        runTime.write()
        pass

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

    import os
    return os.EX_OK
示例#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 )
    
    T, U, transportProperties, DT, phi = _createFields( runTime, mesh )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nCalculating scalar transport\n" << nl
        
    from Foam.finiteVolume.cfdTools.incompressible import CourantNo
    CoNum, meanCoNum = CourantNo( mesh, phi, runTime )
    
    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 )
        
        from Foam.finiteVolume import solve
        from Foam import fvm
        for nonOrth in range ( nNonOrthCorr + 1 ):
            solve( fvm.ddt( T ) + fvm.div( phi, T ) - fvm.laplacian( DT, T ) )
            pass

        runTime.write()
        pass
        
    ext_Info() << "End\n" << nl 

    import os
    return os.EX_OK
示例#18
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
示例#19
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM import argList, word
    argList.validOptions.fget().insert(word("writep"), "")

    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 = _createFields(runTime, mesh)

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << nl << "Calculating potential flow" << nl

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

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

    from Foam.OpenFOAM import dimensionedScalar, word, dimTime, dimensionSet
    from Foam import fvc, fvm
    for nonOrth in range(nNonOrthCorr + 1):
        pEqn = fvm.laplacian(
            dimensionedScalar(
                word("1"), dimTime / p.dimensions() *
                dimensionSet(0.0, 2.0, -2.0, 0.0, 0.0), 1.0),
            p) == fvc.div(phi)

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

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

    ext_Info() << "continuity error = " << fvc.div(phi).mag().weightedAverage(
        mesh.V()).value() << nl

    U.ext_assign(fvc.reconstruct(phi))
    U.correctBoundaryConditions()
    ext_Info() << "Interpolated U error = " << (
        ((fvc.interpolate(U) & mesh.Sf()) - phi).sqr().sum().sqrt() /
        mesh.magSf().sum()).value() << nl

    # Force the write
    U.write()
    phi.write()

    if args.optionFound(word("writep")):
        p.write()
        pass

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

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

    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
示例#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)

    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