コード例 #1
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    simple = man.simpleControl(mesh)

    ref.ext_Info() << "\nCalculating temperature distribution\n" << ref.nl

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

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

        write(runTime, mesh, T)

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

        pass

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

    import os
    return os.EX_OK
コード例 #2
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    simple = man.simpleControl(mesh)

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

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

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

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

        runTime.write()
        pass

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

    import os
    return os.EX_OK
コード例 #3
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

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

    simple = man.simpleControl( mesh )

    ref.ext_Info() << "\nCalculating scalar transport\n" << ref.nl
        
    CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
    
    while simple.loop():
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        for nonOrth in range ( simple.nNonOrthCorr() + 1 ):
            ref.solve( ref.fvm.ddt( T ) + ref.fvm.div( phi, T ) - ref.fvm.laplacian( DT, T ) )
            pass

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

    import os
    return os.EX_OK
コード例 #4
0
def main_standalone( argc, argv ):
 
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pimple = man.pimpleControl(mesh)
    
    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K = createFields( runTime, mesh, pimple )
    
    mrfZones, pZones, pressureImplicitPorosity = createZones( mesh, U )
  
    cumulativeContErr = ref.initContinuityErrs()
  
    ref.ext_Info()<< "\nStarting time loop\n" << ref.nl;

    while runTime.run():
    
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )

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

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

        ref.rhoEqn( rho, phi )

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

            UEqn = fun_Ueqn( pimple, rho, p, U, phi, turbulence, mrfZones, pZones )
      
            fun_hEqn(pThermo, rho, p, h, phi, turbulence, dpdt, K )

            # --- PISO loop
            while (pimple.correct()):
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, pThermo, rho, p, h, psi, U, phi, mrfZones,
                                              turbulence, UEqn, dpdt, K, cumulativeContErr, rhoMax, rhoMin )
                pass
            
            if pimple.turbCorr():
                turbulence.correct()
                pass
            
            pass
        
        runTime.write()
            
        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info()<< "End\n" << ref.nl
        
    import os
    return os.EX_OK
コード例 #5
0
ファイル: __init__.py プロジェクト: asimurzin/laplacianFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    T, transportProperties, DT = _createFields( runTime, mesh )
    
    simple = man.simpleControl( mesh )

    ref.ext_Info() << "\nCalculating temperature distribution\n" << ref.nl
    
    while runTime.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        for nonOrth in range( simple.nNonOrthCorr() + 1 ):
            ref.solve( ref.fvm.ddt( T ) - ref.fvm.laplacian( DT, T ) )
            pass
        
        write( runTime, mesh, T )
        
        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        
        pass

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

    import os
    return os.EX_OK
コード例 #6
0
ファイル: __init__.py プロジェクト: asimurzin/potentialFlux
def main_standalone( argc, argv ):

    ref.argList.addBoolOption( ref.word( "writep" ), "write the final pressure field" )
    ref.argList.addBoolOption( ref.word( "initialiseUBCs" ), "initialise U boundary conditions" )
    
    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )
    
    mesh = man.createMesh( runTime )
    
    potentialFlow, nNonOrthCorr = readControls( mesh )

    p, U, phi, pRefCell, pRefValue = _createFields( runTime, mesh, potentialFlow,args )

    ref.ext_Info() << ref.nl << "Calculating potential flow" << ref.nl
    
    # Since solver contains no time loop it would never execute
    # function objects so do it ourselves.
    runTime.functionObjects().start()
    
    ref.adjustPhi(phi, U, p)
    
    for nonOrth in range( nNonOrthCorr + 1):
        pEqn = ( ref.fvm.laplacian( ref.dimensionedScalar( ref.word( "1" ), ref.dimTime / p.dimensions() * ref.dimensionSet( 0.0, 2.0, -2.0, 0.0, 0.0 ), 1.0 ), p ) 
                == ref.fvc.div( phi ) )
        
        pEqn.setReference( pRefCell, pRefValue )
        pEqn.solve()

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

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

    # Force the write
    U.write()
    phi.write()
    
    if args.optionFound( ref.word( "writep" ) ):
       p.write()
       pass
       
    runTime.functionObjects().end()
    
    ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        
    ref.ext_Info() << "End\n" << ref.nl 

    import os
    return os.EX_OK
コード例 #7
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    pimple = man.pimpleControl( mesh )
    
    ref.ext_Info() << "\nStarting time loop\n" <<ref.nl
    
    while runTime.run() :
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )

        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
      
        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
                
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        # --- Pressure-velocity PIMPLE corrector loop
        pimple.start()
        while pimple.loop():
            if pimple.nOuterCorr() != 1 :
               p.storePrevIter()
               pass
            
            UEqn, rAU = Ueqn( mesh, pimple, phi, U, p, turbulence )
            
            # --- PISO loop
            for corr in range( pimple.nCorr() ):
               cumulativeContErr = pEqn( runTime, mesh, pimple, U, rAU, UEqn, phi, p, corr, pRefCell, pRefValue, cumulativeContErr )
               pass
            
            if pimple.turbCorr():                             
                turbulence.correct()
                pass
            pimple.increment()
            pass

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

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

    import os
    return os.EX_OK
コード例 #8
0
ファイル: __init__.py プロジェクト: asimurzin/boundaryFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    U, phi, laminarTransport, turbulence, Ubar, gradP, flowDirection, flowMask = _createFields(
        runTime, mesh)

    faceId, patchId, nWallFaces, wallNormal, cellId, y = interrogateWallPatches(
        mesh)

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

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

        divR = turbulence.divDevReff(U)

        divR.source() << (flowMask & divR.source())

        UEqn = divR == gradP
        UEqn.relax()

        UEqn.solve()

        # Correct driving force for a constant mass flow rate

        UbarStar = flowMask & U.weightedAverage(mesh.V())

        U += Ubar - UbarStar
        gradP += (Ubar - UbarStar) / (1.0 / UEqn.A()).weightedAverage(mesh.V())

        turbulence.correct()

        ref.ext_Info() << "Uncorrected Ubar = " << ( flowDirection & UbarStar.value() ) << \
        ", pressure gradient = " << ( flowDirection & gradP.value() )<< ref.nl

        evaluateNearWall(turbulence, U, y, faceId, patchId, nWallFaces,
                         wallNormal, cellId, flowDirection)

        if runTime.outputTime():
            makeGraphs(runTime, mesh, U, turbulence, faceId, patchId,
                       nWallFaces, wallNormal, cellId, flowDirection, y)
            pass

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

        pass

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

    import os
    return os.EX_OK
コード例 #9
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    cumulativeContErr = ref.initContinuityErrs()

    pimple = man.pimpleControl(mesh)

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

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

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

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

        runTime.increment()

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

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

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

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

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

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
コード例 #10
0
ファイル: __init__.py プロジェクト: asimurzin/SRFPimpleFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )

    p, U, Urel, SRF, phi, turbulence, pRefCell, pRefValue, laminarTransport, sources = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    pimple = man.pimpleControl( mesh )
    
    ref.ext_Info() << "\nStarting time loop\n" <<ref.nl
    
    while runTime.run() :
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )

        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
      
        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
                
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UrelEqn = _UrelEqn( mesh, pimple, phi, Urel, p, turbulence, SRF, sources )
            
            # --- Pressure corrector loop
            while pimple.correct():
               cumulativeContErr = pEqn( runTime, mesh, pimple, Urel, UrelEqn, phi, p, pRefCell, pRefValue, cumulativeContErr, sources )
               pass
            
            # Update the absolute velocity
            U << Urel() + SRF.U() # mixed calculations
            
            if pimple.turbCorr():                             
                turbulence.correct()
                pass
            pass

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

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

    import os
    return os.EX_OK
コード例 #11
0
 def setUp(self):
     import os
     print os.path.abspath(os.path.curdir)
     argv = [
         "test", "-case",
         os.path.join(os.environ["PYTHONFLU_ROOT_DIR"],
                      "unittest/testFunctionObject")
     ]
     args = ref.setRootCase(len(argv), argv)
     self.runTime = man.createTime(args)
コード例 #12
0
ファイル: __init__.py プロジェクト: asimurzin/boundaryFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    U, phi, laminarTransport, turbulence, Ubar, gradP, flowDirection, flowMask = _createFields( runTime, mesh )
    
    faceId, patchId, nWallFaces, wallNormal, cellId, y = interrogateWallPatches( mesh )
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl 
    
    while runTime.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        divR = turbulence.divDevReff( U )

        divR.source()<<  ( flowMask & divR.source()  )
        
        UEqn = divR == gradP 
        UEqn.relax()

        UEqn.solve()
        
        # Correct driving force for a constant mass flow rate

        UbarStar = flowMask & U.weightedAverage(mesh.V())
        
        U +=  Ubar - UbarStar
        gradP += ( Ubar - UbarStar ) / ( 1.0 / UEqn.A() ).weightedAverage( mesh.V() )
        
        turbulence.correct()

        ref.ext_Info() << "Uncorrected Ubar = " << ( flowDirection & UbarStar.value() ) << \
        ", pressure gradient = " << ( flowDirection & gradP.value() )<< ref.nl
        
        evaluateNearWall( turbulence, U, y, faceId, patchId, nWallFaces, wallNormal, cellId, flowDirection )
        
        if runTime.outputTime():
            makeGraphs( runTime, mesh, U, turbulence, faceId, patchId, nWallFaces, wallNormal, cellId, flowDirection, y  )
            pass
    
        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        
        pass

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

    import os
    return os.EX_OK
コード例 #13
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = readGravitationalAcceleration(runTime, mesh)

    pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, \
         pRefCell, pRefValue, initialMass, totalVolume = createFields( runTime, mesh, g )

    radiation = man.radiation.createRadiationModel(pThermo)

    cumulativeContErr = ref.initContinuityErrs()

    simple = man.simpleControl(mesh)

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

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

        p_rgh.storePrevIter()
        rho.storePrevIter()

        UEqn = fun_Ueqn(simple, mesh, rho, U, phi, turbulence, ghf, p_rgh)

        fun_hEqn(pThermo, rho, p, h, phi, radiation, turbulence)

        cumulativeContErr = fun_pEqn(mesh, runTime, simple, pThermo, rho, p, h,
                                     psi, U, phi, turbulence, gh, ghf, p_rgh,
                                     UEqn, pRefCell, pRefValue,
                                     cumulativeContErr, initialMass)

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #14
0
ファイル: __init__.py プロジェクト: asimurzin/SRFSimpleFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    p, Urel, phi, pRefCell, pRefValue, laminarTransport, turbulence, SRF, sources = createFields(
        runTime, mesh)

    cumulativeContErr = ref.initContinuityErrs()

    simple = man.simpleControl(mesh)

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

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

        # --- Pressure-velocity SIMPLE corrector
        UrelEqn = fun_UrelEqn(Urel, phi, turbulence, p, sources, SRF)
        cumulativeContErr = fun_pEqn(mesh, runTime, simple, Urel, phi,
                                     turbulence, p, UrelEqn, pRefCell,
                                     pRefValue, cumulativeContErr, sources)

        turbulence.correct()

        Uabs = None
        if runTime.outputTime():
            Uabs = ref.volVectorField(
                ref.IOobject(ref.word("Uabs"),
                             ref.fileName(runTime.timeName()), mesh,
                             ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
                Urel() + SRF.U())  # mixed calculations
            pass

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #15
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pThermo, p, e, psi, rho, U, phi, turbulence = createFields(runTime, mesh)

    cumulativeContErr = ref.initContinuityErrs()

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

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

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

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        ref.rhoEqn(rho, phi)

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

        fun_eEqn(rho, e, phi, turbulence, p, pThermo)

        for corr in range(nCorr):
            cumulativeContErr = fun_pEqn(mesh, runTime, pThermo, rho, p, psi,
                                         U, phi, turbulence, UEqn,
                                         cumulativeContErr, nNonOrthCorr)
            pass

        turbulence.correct()

        rho << pThermo.rho()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #16
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = readGravitationalAcceleration(runTime, mesh)

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

    cumulativeContErr = ref.initContinuityErrs()

    simple = man.simpleControl(mesh)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #

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

    while simple.loop():

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

        p_rgh.storePrevIter()

        # Pressure-velocity SIMPLE corrector
        UEqn = fun_UEqn(mesh, simple, U, phi, turbulence, p, rhok, p_rgh, ghf)
        fun_TEqn(phi, turbulence, kappat, T, rhok, beta, TRef, Prt, Pr)

        cumulativeContErr = fun_pEqn(mesh, runTime, simple, p, rhok, U, phi,
                                     turbulence, gh, ghf, p_rgh, UEqn,
                                     pRefCell, pRefValue, cumulativeContErr)

        turbulence.correct()
        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #17
0
def main_standalone( argc, argv ):
  
  args = ref.setRootCase( argc, argv )
  
  runTime=man.createTime( args )
    
  mesh = man.createMesh( runTime )
    
  g = readGravitationalAcceleration( runTime, mesh );

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

  simple = man.simpleControl( mesh )


  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #

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

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

    p_rgh.storePrevIter()

    # Pressure-velocity SIMPLE corrector
    UEqn = fun_UEqn( mesh, simple, U, phi, turbulence, p, rhok, p_rgh, ghf )
    fun_TEqn( phi, turbulence, kappat, T, rhok, beta, TRef, Prt, Pr )

    cumulativeContErr = fun_pEqn( mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr )
    
    turbulence.correct()
    runTime.write()
    
    ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
               << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
               << ref.nl << ref.nl
    pass
  pass

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

  import os
  return os.EX_OK
コード例 #18
0
ファイル: __init__.py プロジェクト: asimurzin/SRFSimpleFlux
def main_standalone( argc, argv ):
    
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )
    
    mesh = man.createMesh( runTime )
        
    p, Urel, phi, pRefCell, pRefValue, laminarTransport, turbulence, SRF, sources = createFields( runTime, mesh )

    cumulativeContErr = ref.initContinuityErrs()
    
    simple = man.simpleControl (mesh)

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

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

        # --- Pressure-velocity SIMPLE corrector
        UrelEqn = fun_UrelEqn( Urel, phi, turbulence, p, sources, SRF )
        cumulativeContErr = fun_pEqn( mesh, runTime, simple, Urel, phi, turbulence, p, UrelEqn, pRefCell, pRefValue, cumulativeContErr, sources )

        turbulence.correct()
        
        Uabs = None
        if runTime.outputTime():
                Uabs = ref.volVectorField( ref.IOobject( ref.word( "Uabs" ),
                                                         ref.fileName( runTime.timeName() ),
                                                         mesh,
                                                         ref.IOobject.NO_READ,
                                                         ref.IOobject.AUTO_WRITE ),
                                           Urel() + SRF.U() ) # mixed calculations
                pass

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #19
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    g = readGravitationalAcceleration( runTime, mesh )

    pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, \
         pRefCell, pRefValue, initialMass, totalVolume = createFields( runTime, mesh, g )

    radiation = man.radiation.createRadiationModel( pThermo )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    simple = man.simpleControl( mesh )
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

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

        p_rgh.storePrevIter()
        rho.storePrevIter()
        
        UEqn = fun_Ueqn( simple, mesh, rho, U, phi, turbulence, ghf, p_rgh )

        fun_hEqn( pThermo, rho, p, h, phi, radiation, turbulence )

        cumulativeContErr = fun_pEqn( mesh, runTime, simple, pThermo, rho, p, h, psi, U, phi, turbulence, 
                                      gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr, initialMass)

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #20
0
ファイル: __init__.py プロジェクト: asimurzin/MRFSimpleFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    cumulativeContErr = ref.initContinuityErrs()

    simple = man.simpleControl(mesh)

    mrfZones = man.MRFZones(mesh)
    mrfZones.correctBoundaryVelocity(U)

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

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

        # --- Pressure-velocity SIMPLE corrector
        UEqn = fun_UEqn(U, phi, turbulence, p, sources, mrfZones)

        cumulativeContErr = fun_pEqn(mesh, runTime, simple, U, phi, turbulence,
                                     p, UEqn, mrfZones, pRefCell, pRefValue,
                                     cumulativeContErr, sources)

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #21
0
ファイル: __init__.py プロジェクト: asimurzin/sonicFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pThermo, p, e, psi, rho, U, phi, turbulence = createFields( runTime, mesh )

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

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

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh )
        
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )
        
        ref.rhoEqn( rho, phi );
        
        UEqn = fun_Ueqn( rho, U, phi, turbulence, p )

        fun_eEqn( rho, e, phi, turbulence, p, pThermo )

        for corr in range( nCorr ) :
            cumulativeContErr = fun_pEqn( mesh, runTime, pThermo, rho, p, psi, U, phi, turbulence, UEqn, cumulativeContErr, nNonOrthCorr )
            pass

        turbulence.correct()

        rho << pThermo.rho()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #22
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    simple = man.simpleControl( mesh )

    thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin = _createFields( runTime, mesh, simple )
    
    mrfZones, pZones, pressureImplicitPorosity, nUCorr = createZones( mesh, U, simple )
    
    cumulativeContErr = ref.initContinuityErrs()

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl
    
    while simple.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
                
        # Pressure-velocity SIMPLE corrector
        UEqn, trAU, trTU = _UEqn( phi, U, p, rho, turbulence, mrfZones, pZones, pressureImplicitPorosity, nUCorr )
            
        _hEqn( U, phi, h, turbulence, rho, p, thermo, pZones )
        
        cumulativeContErr = _pEqn( runTime,mesh, UEqn, rho, thermo, psi, U, p, phi, trTU, trAU, mrfZones, \
                                                             pRefCell, pRefValue, pressureImplicitPorosity, cumulativeContErr, simple, rhoMin, rhoMax  )
        
        turbulence.correct()
        
        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #23
0
ファイル: __init__.py プロジェクト: asimurzin/MRFSimpleFlux
def main_standalone( argc, argv ):
    
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )
    
    mesh = man.createMesh( runTime )
        
    p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence,sources = createFields( runTime, mesh )

    cumulativeContErr = ref.initContinuityErrs()
    
    simple = man.simpleControl (mesh)
    
    mrfZones =    man.MRFZones( mesh )
    mrfZones.correctBoundaryVelocity( U)

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

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

        # --- Pressure-velocity SIMPLE corrector
        UEqn = fun_UEqn( U, phi, turbulence, p, sources, mrfZones )
        
        cumulativeContErr = fun_pEqn( mesh, runTime, simple, U, phi, turbulence, p, UEqn, mrfZones, pRefCell, pRefValue, cumulativeContErr, sources )

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #24
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    simple = man.simpleControl( mesh )

    p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence = create_fields( runTime, mesh )
    
    pZones, pressureImplicitPorosity, nUCorr = createPorousZones( mesh, simple )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    ref.ext_Info()<< "\nStarting time loop\n" << ref.nl
    
    while simple.loop() :
        
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        p.storePrevIter()

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

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

        turbulence.correct()

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

    import os
    return os.EX_OK
コード例 #25
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    simple = man.simpleControl( mesh )

    thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin = _createFields( runTime, mesh, simple )
    
    cumulativeContErr = ref.initContinuityErrs()

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl
    
    while simple.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
                
        # Pressure-velocity SIMPLE corrector
        UEqn = _UEqn( phi, U, p, rho, turbulence )
            
        cumulativeContErr = _pEqn( runTime,mesh, UEqn, rho, thermo, psi, U, p, phi, \
                                                             pRefCell, pRefValue, cumulativeContErr, simple, rhoMin, rhoMax  )

        _hEqn( U, phi, h, turbulence, rho, p, thermo )
        
        
        turbulence.correct()
        
        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #26
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    gravitationalProperties, g, rotating, Omega, magg, gHat = readGravitationalAcceleration(
        runTime, mesh)

    h, h0, U, hU, hTotal, phi, F = _createFields(runTime, mesh, Omega, gHat)

    pimple = man.pimpleControl(mesh)

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

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

        CourantNo(runTime, mesh, h, phi, magg)

        pimple.start()
        while pimple.loop():

            phiv = ref.surfaceScalarField(
                ref.word("phiv"),
                phi() / ref.fvc.interpolate(h))  # mixed calculations

            hUEqn = ref.fvm.ddt(hU) + ref.fvm.div(phiv, hU)

            hUEqn.relax()

            if pimple.momentumPredictor():

                if rotating:
                    ref.solve(hUEqn + (F ^ hU) == -magg * h *
                              ref.fvc.grad(h + h0))
                    pass
                else:
                    ref.solve(hUEqn == -magg * h * ref.fvc.grad(h + h0))
                    pass

                # Constrain the momentum to be in the geometry if 3D geometry
                if mesh.nGeometricD() == 3:
                    hU -= (gHat & hU) * gHat
                    hU.correctBoundaryConditions()
                    pass

            for corr in range(pimple.nCorr()):
                hf = ref.fvc.interpolate(h)
                rUA = 1.0 / hUEqn.A()
                ghrUAf = magg * ref.fvc.interpolate(h * rUA)

                phih0 = ghrUAf * mesh.magSf() * ref.fvc.snGrad(h0)
                if rotating:
                    hU << rUA * (hUEqn.H() - (F ^ hU))
                    pass
                else:
                    hU << rUA * hUEqn.H()
                    pass

                phi << (ref.fvc.interpolate(hU) & mesh.Sf()
                        ) + ref.fvc.ddtPhiCorr(rUA, h, hU, phi) - phih0

                for nonOrth in range(pimple.nNonOrthCorr() + 1):
                    hEqn = ref.fvm.ddt(h) + ref.fvc.div(
                        phi) - ref.fvm.laplacian(ghrUAf, h)

                    hEqn.solve(
                        mesh.solver(
                            h.select(pimple.finalInnerIter(corr, nonOrth))))

                    if nonOrth == pimple.nNonOrthCorr():
                        phi += hEqn.flux()
                    pass

                hU -= rUA * h * magg * ref.fvc.grad(h + h0)

                #Constrain the momentum to be in the geometry if 3D geometry
                if mesh.nGeometricD() == 3:
                    hU -= (gHat & hU) * gHat
                    pass

                hU.correctBoundaryConditions()
                pass

            pimple.increment()
            pass

        U == hU / h
        hTotal == h + h0

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
コード例 #27
0
 def setUp(self):
     argv=["test","-case",me.pitzDir]
     args = ref.setRootCase( len(argv), argv )
     runTime = man.createTime(args)
     self.mesh = man.createMesh( runTime )
コード例 #28
0
ファイル: __init__.py プロジェクト: asimurzin/icoFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )

    transportProperties, nu, p, U, phi, pRefCell, pRefValue = createFields( runTime, mesh )

    cumulativeContErr = ref.initContinuityErrs()
    
    ref.ext_Info() << "\nStarting time loop\n"

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

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

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

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

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

        # --- PISO loop

        for corr in range( nCorr ) :
            rUA = 1.0 / UEqn.A()
            
            U << rUA * UEqn.H()
            phi << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rUA, U, phi )

            ref.adjustPhi( phi, U, p )

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

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

                if nonOrth == nNonOrthCorr:
                    phi -= pEqn.flux()
                    pass
                
                pass
            
            cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )

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

            pass

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

        pass

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

    import os
    return os.EX_OK
コード例 #29
0
ファイル: __init__.py プロジェクト: asimurzin/rhoCentralFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, \
                          neg, inviscid, phi, turbulence = _createFields( runTime, mesh )
    
    thermophysicalProperties, Pr = readThermophysicalProperties( runTime, mesh )
    
    fluxScheme = readFluxScheme( mesh )
    
    v_zero = ref.dimensionedScalar( ref.word( "v_zero" ), ref.dimVolume / ref.dimTime, 0.0)
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl
    
    while runTime.run() :
        # --- upwind interpolation of primitive fields on faces
        rho_pos = ref.fvc.interpolate( rho, pos, ref.word( "reconstruct(rho)" ) )
        rho_neg = ref.fvc.interpolate( rho, neg, ref.word( "reconstruct(rho)" ) )
        
        rhoU_pos = ref.fvc.interpolate( rhoU, pos, ref.word( "reconstruct(U)" ) )
        rhoU_neg = ref.fvc.interpolate( rhoU, neg, ref.word( "reconstruct(U)" ) )

        rPsi = 1.0 / psi
        rPsi_pos = ref.fvc.interpolate( rPsi, pos, ref.word( "reconstruct(T)" ) )
        rPsi_neg = ref.fvc.interpolate( rPsi, neg, ref.word( "reconstruct(T)" ) )

        e_pos = ref.fvc.interpolate( e, pos, ref.word( "reconstruct(T)" ) )
        e_neg = ref.fvc.interpolate( e, neg, ref.word( "reconstruct(T)" ) )

        U_pos = rhoU_pos / rho_pos
        U_neg = rhoU_neg / rho_neg

        p_pos = rho_pos * rPsi_pos
        p_neg = rho_neg * rPsi_neg

        phiv_pos = U_pos & mesh.Sf()
        phiv_neg = U_neg & mesh.Sf()

        c = ( thermo.Cp() / thermo.Cv() * rPsi ).sqrt()
        cSf_pos = ref.fvc.interpolate( c, pos, ref.word( "reconstruct(T)" ) ) * mesh.magSf()
        cSf_neg = ref.fvc.interpolate( c, neg, ref.word( "reconstruct(T)" ) ) * mesh.magSf()
   
        ap = ( phiv_pos + cSf_pos ).ext_max( phiv_neg + cSf_neg ).ext_max( v_zero )
        am = ( phiv_pos - cSf_pos ).ext_min( phiv_neg - cSf_neg ).ext_min( v_zero )

        a_pos = ap / ( ap - am )
        
        amaxSf = ref.surfaceScalarField( ref.word( "amaxSf" ), am.mag().ext_max( ap.mag() ) )
        
        aSf = am * a_pos

        if str( fluxScheme ) == "Tadmor":
           aSf << -0.5 * amaxSf
           a_pos << 0.5
           pass

        a_neg = 1.0 - a_pos
        
        phiv_pos *= a_pos
        phiv_neg *= a_neg
        
        aphiv_pos = phiv_pos - aSf
        aphiv_neg = phiv_neg + aSf
        
        # Reuse amaxSf for the maximum positive and negative fluxes
        # estimated by the central scheme
        amaxSf << aphiv_pos.mag().ext_max(  aphiv_neg.mag() )

        CoNum, meanCoNum = compressibleCourantNo( mesh, amaxSf, runTime )
        
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        
        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        phi << aphiv_pos * rho_pos + aphiv_neg * rho_neg

        phiUp = ( aphiv_pos * rhoU_pos + aphiv_neg * rhoU_neg) + ( a_pos * p_pos + a_neg * p_neg ) * mesh.Sf()

        phiEp = aphiv_pos * ( rho_pos * ( e_pos + 0.5*U_pos.magSqr() ) + p_pos ) + aphiv_neg * ( rho_neg * ( e_neg + 0.5 * U_neg.magSqr() ) + p_neg )\
                + aSf * p_pos - aSf * p_neg
        
   
        muEff = turbulence.muEff()
        tauMC = ref.volTensorField( ref.word( "tauMC" ) , muEff * ref.fvc.grad(U).T().dev2() ) 

        # --- Solve density
        ref.solve( ref.fvm.ddt( rho ) + ref.fvc.div( phi ) )
        
        # --- Solve momentum
        ref.solve( ref.fvm.ddt( rhoU ) + ref.fvc.div( phiUp ) )
        
        U.dimensionedInternalField() << rhoU.dimensionedInternalField() / rho.dimensionedInternalField()
        U.correctBoundaryConditions()
        
        rhoU.ext_boundaryField() << rho.ext_boundaryField() * U.ext_boundaryField()
        
        rhoBydt = rho / runTime.deltaT()
        
        if not inviscid:
           solve( fvm.ddt( rho, U ) - fvc.ddt( rho, U ) - fvm.laplacian( muEff, U ) - fvc.div( tauMC ) )
           rhoU << rho * U
           pass
        
        # --- Solve energy
        sigmaDotU = ( ref.fvc.interpolate( muEff ) * mesh.magSf() * ref.fvc.snGrad( U ) + 
                      ( mesh.Sf() & ref.fvc.interpolate( tauMC ) ) ) & ( a_pos * U_pos + a_neg * U_neg )

        ref.solve( ref.fvm.ddt( rhoE ) + ref.fvc.div( phiEp ) - ref.fvc.div( sigmaDotU ) )
        
        e << rhoE() / rho() - 0.5 * U.magSqr() # mixed calculations
        e.correctBoundaryConditions()
        thermo.correct()

        rhoE.ext_boundaryField() << rho.ext_boundaryField() * ( e.ext_boundaryField() + 0.5 * U.ext_boundaryField().magSqr() )
        
        if not inviscid :
           k = man.volScalarField( ref.word( "k" ) , thermo.Cp() * muEff / Pr )

           # The initial C++ expression does not work properly, because of
           #  1. the order of expression arguments computation differs with C++
           #solve( fvm.ddt( rho, e ) - fvc.ddt( rho, e ) - fvm.laplacian( thermo.alpha(), e ) \
           #                                             + fvc.laplacian( thermo.alpha(), e ) - fvc.laplacian( k, T ) )

           solve( -fvc.laplacian( k, T ) + ( fvc.laplacian( turbulence.alpha(), e ) \
                                         + (- fvm.laplacian( turbulence.alphaEff(), e ) + (- fvc.ddt( rho, e ) + fvm.ddt( rho, e ) ) ) ) )
           
           thermo.correct()
           rhoE << rho * ( e + 0.5 * U.magSqr() )
           pass
        
        p.dimensionedInternalField() << rho.dimensionedInternalField() / psi.dimensionedInternalField()
        p.correctBoundaryConditions()

        rho.ext_boundaryField() << psi.ext_boundaryField() * p.ext_boundaryField() 
        
        turbulence.correct()
        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #30
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = man.readGravitationalAcceleration(runTime, mesh)

    pimple = ref.pimpleControl(mesh)

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

    cumulativeContErr = ref.initContinuityErrs()

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

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

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

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

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

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

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

        runTime.increment()

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

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

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

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

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

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

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #31
0
ファイル: __init__.py プロジェクト: asimurzin/pisoFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )

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

    ref.ext_Info() << "\nStarting time loop\n" <<ref.nl
    
    while runTime.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

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

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

        # Pressure-velocity PISO corrector

        # Momentum predictor

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

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

        UEqn.relax()

        if momentumPredictor :
            ref.solve( UEqn == -ref.fvc.grad( p ) )
            pass
           
        # --- PISO loop

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

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

                pEqn.setReference( pRefCell, pRefValue )

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

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

        turbulence.correct()

        runTime.write()

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

    ref.ext_Info() << "End\n" << ref.nl 
    
    import os
    return os.EX_OK
コード例 #32
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue = createFields(
        runTime, mesh
    )

    cumulativeContErr = ref.initContinuityErrs()

    cumulativeAdjointContErr = initAdjointContinuityErrs()

    simple = man.simpleControl(mesh)

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

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

        laminarTransport.lookup(ref.word("lambda")) >> lambda_

        alpha += mesh.fieldRelaxationFactor(ref.word("alpha")) * (
            ((alpha + lambda_ * (Ua & U)).ext_max(zeroAlpha)).ext_min(alphaMax) - alpha
        )

        zeroCells(alpha, inletCells)

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

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

        p.ext_boundaryField().updateCoeffs()

        rAU = 1.0 / UEqn.A()
        U << rAU * UEqn.H()

        phi << (ref.fvc.interpolate(U) & mesh.Sf())
        ref.adjustPhi(phi, U, p)

        while simple.correctNonOrthogonal():
            pEqn = ref.fvm.laplacian(rAU, p) == ref.fvc.div(phi)

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

            if simple.finalNonOrthogonalIter():
                phi -= pEqn.flux()
                pass
            pass

        cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh, cumulativeContErr)

        # Explicitly relax pressure for momentum corrector
        p.relax()
        # Momentum corrector
        U -= rAU * ref.fvc.grad(p)
        U.correctBoundaryConditions()

        # Adjoint Pressure-velocity SIMPLE corrector
        # Adjoint Momentum predictor

        adjointTransposeConvection = ref.fvc.grad(Ua) & U
        # adjointTransposeConvection = ref.fvc.reconstruct( mesh.magSf() * ( ref.fvc.snGrad( Ua ) & ref.fvc.interpolate( U ) ) )
        zeroCells(adjointTransposeConvection, inletCells)

        UaEqn = ref.fvm.div(-phi, Ua) - adjointTransposeConvection + turbulence.divDevReff(Ua) + ref.fvm.Sp(alpha, Ua)

        UaEqn.relax()
        ref.solve(UaEqn == -ref.fvc.grad(pa))
        pa.ext_boundaryField().updateCoeffs()

        rAUa = 1.0 / UaEqn.A()
        Ua << rAUa * UaEqn.H()

        UaEqn.clear()
        phia << (ref.fvc.interpolate(Ua) & mesh.Sf())

        ref.adjustPhi(phia, Ua, pa)

        # Non-orthogonal pressure corrector loop
        while simple.correctNonOrthogonal():
            paEqn = ref.fvm.laplacian(rAUa, pa) == ref.fvc.div(phia)
            paEqn.setReference(paRefCell, paRefValue)
            paEqn.solve()

            if simple.finalNonOrthogonalIter():
                phia -= paEqn.flux()
                pass
            pass

        cumulativeAdjointContErr = adjointContinuityErrs(runTime, mesh, phia, cumulativeAdjointContErr)

        # Explicitly relax pressure for adjoint momentum corrector
        pa.relax()

        # Adjoint momentum corrector
        Ua -= rAUa * ref.fvc.grad(pa)
        Ua.correctBoundaryConditions()

        turbulence.correct()

        runTime.write()

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

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

    import os

    return os.EX_OK
コード例 #33
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    g = man.readGravitationalAcceleration( runTime, mesh)
    
    pimple = ref.pimpleControl( mesh )
    
    adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles = read_controls( args, runTime, pimple )

    cumulativeContErr = ref.initContinuityErrs()

    p_rgh, alpha1, alpha2, U, phi, twoPhaseProperties, rho10, rho20, psi1, psi2, pMin, \
                      gh, ghf, p, rho1, rho2, rho, rhoPhi, dgdt, interface, turbulence = _createFields( runTime, mesh, g )
    
    CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
    
    runTime = ref.setInitialDeltaT( runTime, adjustTimeStep, maxCo, CoNum )

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

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

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

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

        runTime.increment()

        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        # --- Outer-corrector loop
        while pimple.loop():
            alphaEqnsSubCycle( runTime, pimple, mesh, phi, alpha1, alpha2, rho, rho1, rho2, rhoPhi, dgdt, interface )

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

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

            # --- Pressure corrector loop
            while pimple.correct(): 
                fun_pEqn( runTime, mesh, pimple, UEqn, p, p_rgh, phi, U, rho, rho1, rho2, rho10, rho20, gh, ghf, dgdt, pMin, \
                          psi1, psi2, alpha1, alpha2, interface )
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass
            pass
        rho <<  alpha1 * rho1 + alpha2 * rho2

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #34
0
ファイル: __init__.py プロジェクト: asimurzin/channelFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    transportProperties, nu, Ubar, magUbar, flowDirection = readTransportProperties( runTime, mesh)
    
    p, U, phi, laminarTransport, sgsModel, pRefCell, pRefValue = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    gradP, gradPFile = createGradP( runTime)
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl 

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

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

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

        sgsModel.correct()

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

        if momentumPredictor:
           ref.solve( UEqn == -ref.fvc.grad( p ) )
           pass

        rAU = 1.0 / UEqn.A()

        for corr in range( nCorr ):
            U << rAU * UEqn.H()

            phi << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, U, phi )

            ref.adjustPhi(phi, U, p)

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

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

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

            cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )

            U -= rAU * ref.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 ) / rAU.weightedAverage( mesh.V() )

        U << U() + flowDirection * rAU * gragPplus # mixed caculations

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

        runTime.write()

        writeGradP( runTime, gradP )

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

        pass

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

    import os
    return os.EX_OK
コード例 #35
0
def main_standalone( argc, argv ):
  
    args = ref.setRootCase( argc, argv )
  
    runTime=man.createTime( args )
    
    mesh = man.createMesh( runTime )
    
    g = readGravitationalAcceleration( runTime, mesh );

    T, p_rgh, U, phi, laminarTransport, turbulence, rhok, \
       kappat, gh, ghf, p, pRefCell, pRefValue, beta, TRef, Pr, Prt  = createFields( runTime, mesh, g )
                                                        
    cumulativeContErr = ref.initContinuityErrs()
    
    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
  
    CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
    
    runTime = ref.setInitialDeltaT( runTime, adjustTimeStep, maxCo, CoNum )

    pimple = man.pimpleControl( mesh )
  
    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #

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

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

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )

        # Pressure-velocity PIMPLE corrector loop
        
        while pimple.loop():
            
            UEqn = fun_UEqn( mesh, pimple, U, phi, turbulence, p, rhok, p_rgh, ghf )
            fun_TEqn( phi, turbulence, kappat, T, rhok, beta, TRef, Prt, Pr )
            
            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr )
                pass
            if pimple.turbCorr():
               turbulence.correct()
               pass
            pass

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

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

    import os
    return os.EX_OK
コード例 #36
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    rp = ref.compressible.regionProperties(runTime)

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

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

    from fluid import createFluidFields
    thermoFluid, rhoFluid, kappaFluid, UFluid, phiFluid, gFluid, turbulence, KFluid, \
                 dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation = createFluidFields( fluidRegions, runTime )

    from solid import createSolidField
    thermos = createSolidField(solidRegions, runTime)

    from fluid import initContinuityErrs
    cumulativeContErr = initContinuityErrs(fluidRegions)

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

    from solid import readSolidTimeControls
    maxDi = readSolidTimeControls(runTime)

    from fluid import compressubibleMultiRegionCourantNo
    CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime, rhoFluid,
                                               phiFluid)

    from solid import solidRegionDiffusionNo
    DiNum = solidRegionDiffusionNo(solidRegions, runTime, thermos)

    runTime, CoNum, DiNum = setInitialMultiRegionDeltaT(
        adjustTimeStep, runTime, CoNum, DiNum, maxCo, maxDi, maxDeltaT)

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

        maxDi = readSolidTimeControls(runTime)

        nOuterCorr = readPIMPLEControls(runTime)

        CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime,
                                                   rhoFluid, phiFluid)

        DiNum = solidRegionDiffusionNo(solidRegions, runTime, thermos)

        runTime, CoNum, DiNum = setMultiRegionDeltaT(adjustTimeStep, runTime,
                                                     CoNum, DiNum, maxCo,
                                                     maxDi, maxDeltaT)

        runTime.increment()

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

        if nOuterCorr != 1:
            for i in range(fluidRegions.__len__()):
                from fluid import setRegionFluidFields
                mesh, thermo, rho, kappa, K, U, phi, turb, dpdt, p, psi, h, initialMass, p_rgh, gh, ghf, rad = \
                                     setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, kappaFluid, UFluid, \
                                                           phiFluid, turbulence, KFluid, dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation )

                from fluid import storeOldFluidFields
                storeOldFluidFields(p, rho)
                pass
            pass

        # --- PIMPLE loop
        for oCorr in range(nOuterCorr):
            finalIter = (oCorr == nOuterCorr - 1)
            for i in range(fluidRegions.__len__()):
                ref.ext_Info(
                ) << "\nSolving for fluid region " << fluidRegions[i].name(
                ) << ref.nl

                from fluid import setRegionFluidFields
                mesh, thermo, rho, kappa, K, U, phi, turb, dpdt, p, psi, h, initialMass, p_rgh, gh, ghf, rad = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, kappaFluid, UFluid, \
                                            phiFluid, turbulence, KFluid, dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation )

                from fluid import readFluidMultiRegionPIMPLEControls
                pimple, nCorr, nNonOrthCorr, momentumPredictor = readFluidMultiRegionPIMPLEControls(
                    mesh)

                from fluid import solveFluid
                cumulativeContErr = solveFluid( i, mesh, thermo, rad, thermoFluid, rho, kappa, K, U, phi, h, turb, dpdt, p, psi, initialMass, p_rgh, gh, \
                                                ghf, oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor, cumulativeContErr, finalIter )

                pass

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

                from solid import setRegionSolidFields
                mesh, thermo, rho, cp, tkappa, kappa = setRegionSolidFields(
                    i, solidRegions, thermos)

                from solid import readSolidMultiRegionPIMPLEControls
                pimple, nNonOrthCorr = readSolidMultiRegionPIMPLEControls(mesh)

                from solid import solveSolid
                solveSolid(mesh, thermo, rho, cp, tkappa, kappa, nNonOrthCorr,
                           finalIter)
                pass
            pass
        pass
        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #37
0
ファイル: __init__.py プロジェクト: asimurzin/rhoPimpleFlux
def main_standalone( argc, argv ):
 
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, DpDt = createFields( runTime, mesh )
  
    cumulativeContErr = ref.initContinuityErrs()
  
    pimple = man.pimpleControl(mesh)

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

    while runTime.run():
    
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )

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

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

        ref.rhoEqn( rho, phi )

        # --- Pressure-velocity PIMPLE corrector loop
        pimple.start()
        while pimple.loop():
            if pimple.nOuterCorr() != 1:
                p.storePrevIter()
                rho.storePrevIter()
                pass
            
            UEqn, rAU = fun_Ueqn( pimple, rho, p, U, phi, turbulence )
      
            fun_hEqn( pThermo, rho, p, h, phi, turbulence, DpDt )

            # --- PISO loop
            for corr in range( pimple.nCorr() ):
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, pThermo, rho, p, h, psi, U, phi, 
                                              turbulence, UEqn, rAU, DpDt, cumulativeContErr, corr, rhoMax, rhoMin )
                pass
            
            if pimple.turbCorr():
                turbulence.correct()
                pass
            
            pimple.increment()
            pass
        
        runTime.write()
            
        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info()<< "End\n" << ref.nl
        
    import os
    return os.EX_OK
コード例 #38
0
ファイル: __init__.py プロジェクト: asimurzin/interFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pimple = man.pimpleControl( mesh )
        
    cumulativeContErr = ref.initContinuityErrs()
    
    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh )

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
    
    cumulativeContErr = correctPhi( runTime, mesh, phi, p, p_rgh, rho, U, cumulativeContErr, pimple, pRefCell, pRefValue)
    
    CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
    
    runTime = ref.setInitialDeltaT( runTime, adjustTimeStep, maxCo, CoNum )
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl
    
    while runTime.run() :
                
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )        
        maxAlphaCo, alphaCoNum, meanAlphaCoNum = alphaCourantNo( runTime, mesh, alpha1, phi )
        runTime = setDeltaT(  runTime, adjustTimeStep, maxCo, CoNum, maxAlphaCo, alphaCoNum, maxDeltaT )
        
        runTime.increment()
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        twoPhaseProperties.correct()
     
        alphaEqnSubCycle( runTime, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface )
        
        while pimple.loop():
            UEqn = _UEqn( mesh, alpha1, U, p, p_rgh, ghf, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, pimple )

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

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

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

    import os
    return os.EX_OK
コード例 #39
0
def main_standalone(argc, argv):
    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = ref.readGravitationalAcceleration(runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, dpdt, K = createFields(
        runTime, mesh, g)

    cumulativeContErr = ref.initContinuityErrs()

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

    CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

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

    pimple = man.pimpleControl(mesh)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

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

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

        ref.rhoEqn(rho, phi)

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

            UEqn = fun_Ueqn(pimple, mesh, rho, U, phi, turbulence, ghf, p_rgh,
                            K)
            fun_hEqn(thermo, rho, p, h, phi, turbulence, dpdt, K)

            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn(mesh, runTime, pimple, thermo,
                                             rho, p, h, psi, U, phi,
                                             turbulence, gh, ghf, p_rgh, UEqn,
                                             dpdt, K, cumulativeContErr)
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass

            pass
        rho << thermo.rho()

        runTime.write()

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

    import os
    return os.EX_OK
コード例 #40
0
 def setUp(self):
     argv = ["test", "-case", me.pitzDir]
     args = ref.setRootCase(len(argv), argv)
     runTime = man.createTime(args)
     self.mesh = man.createMesh(runTime)
コード例 #41
0
ファイル: __init__.py プロジェクト: asimurzin/interDyMFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createDynamicFvMesh(runTime)

    cumulativeContErr = ref.initContinuityErrs()

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

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

    pimple = man.pimpleControl(mesh)

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

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

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

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

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT, correctPhi, checkMeshCourantNo = readControls(runTime, mesh, pimple)

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

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

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

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

        timeBeforeMeshUpdate = runTime.elapsedCpuTime()

        fun_Urel(mesh, U)

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

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

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

        twoPhaseProperties.correct()

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

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():
            UEqn = _UEqn(
                mesh(), alpha1, U, p, p_rgh, ghf, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, pimple
            )

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

        runTime.write()

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

        pass

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

    import os

    return os.EX_OK
コード例 #42
0
if __name__ == "__main__" :
    import os
    from Foam import FOAM_VERSION
    
    argv = None
    if FOAM_VERSION( "<", "010500" ) :
        a_dir = os.path.join( os.environ[ "HYBRIDFLU_ROOT_DIR" ], 'hybridFlu', 'examples' )
        argv = [ __file__, a_dir, 'case_unv2foam' ]
    else:
        a_dir = os.path.join( os.environ[ "HYBRIDFLU_ROOT_DIR" ], 'hybridFlu', 'examples', 'case_unv2foam' )
        argv = [ __file__, '-case', a_dir ]
        pass
    
    args = ref.setRootCase( len( argv ), argv )

    runTime = man.createTime( args )

    a_path = str( runTime.path() )
    a_root_dir, a_case = os.path.split( a_path )
    an_unv_file_name = os.path.join( a_path, "mesh" + os.path.extsep + "unv" )
    
    if FOAM_VERSION( "<", "010500" ) :
        os.system( "unv2foam %s %s %s" %( a_root_dir, a_case, an_unv_file_name ))
        pass
    else :
        os.system( "unv2foam %s -case %s" %( an_unv_file_name, a_path ))
        pass
    

    mesh = man.createMesh( runTime )
コード例 #43
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMeshNoClear(runTime)

    transportProperties, nu = readTransportProperties(runTime, mesh)

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

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

    cumulativeContErr = ref.initContinuityErrs()

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

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

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

        force.internalField() << (ref.ReImSum(
            ref.fft.reverseTransform(
                K / (K.mag() + 1.0e-6) ^ forceGen.newField(), K.nn())))

        globalProperties(runTime, U, nu, force)

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

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

        # --- PISO loop

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

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

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

            pEqn.solve()

            phi -= pEqn.flux()

            cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                                   cumulativeContErr)

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

        runTime.write()

        if runTime.outputTime():
            ref.calcEk(U, K).ext_write(
                ref.fileName(runTime.path()) / ref.fileName("graphs") /
                ref.fileName(runTime.timeName()), ref.word("Ek"),
                runTime.graphFormat())
            pass

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

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

    import os
    return os.EX_OK
コード例 #44
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, \
           lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue = createFields( runTime, mesh )

    cumulativeContErr = ref.initContinuityErrs()

    cumulativeAdjointContErr = initAdjointContinuityErrs()

    simple = man.simpleControl(mesh)

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

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

        laminarTransport.lookup(ref.word("lambda")) >> lambda_

        alpha += mesh.fieldRelaxationFactor(ref.word("alpha")) * ((
            (alpha + lambda_ *
             (Ua & U)).ext_max(zeroAlpha)).ext_min(alphaMax) - alpha)

        zeroCells(alpha, inletCells)

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

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

        p.ext_boundaryField().updateCoeffs()

        rAU = 1.0 / UEqn.A()
        U << rAU * UEqn.H()

        phi << (ref.fvc.interpolate(U) & mesh.Sf())
        ref.adjustPhi(phi, U, p)

        while simple.correctNonOrthogonal():
            pEqn = ref.fvm.laplacian(rAU, p) == ref.fvc.div(phi)

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

            if simple.finalNonOrthogonalIter():
                phi -= pEqn.flux()
                pass
            pass

        cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                               cumulativeContErr)

        # Explicitly relax pressure for momentum corrector
        p.relax()
        # Momentum corrector
        U -= rAU * ref.fvc.grad(p)
        U.correctBoundaryConditions()

        # Adjoint Pressure-velocity SIMPLE corrector
        # Adjoint Momentum predictor

        adjointTransposeConvection = (ref.fvc.grad(Ua) & U)
        # adjointTransposeConvection = ref.fvc.reconstruct( mesh.magSf() * ( ref.fvc.snGrad( Ua ) & ref.fvc.interpolate( U ) ) )
        zeroCells(adjointTransposeConvection, inletCells)

        UaEqn = ref.fvm.div(
            -phi, Ua) - adjointTransposeConvection + turbulence.divDevReff(
                Ua) + ref.fvm.Sp(alpha, Ua)

        UaEqn.relax()
        ref.solve(UaEqn == -ref.fvc.grad(pa))
        pa.ext_boundaryField().updateCoeffs()

        rAUa = 1.0 / UaEqn.A()
        Ua << rAUa * UaEqn.H()

        UaEqn.clear()
        phia << (ref.fvc.interpolate(Ua) & mesh.Sf())

        ref.adjustPhi(phia, Ua, pa)

        # Non-orthogonal pressure corrector loop
        while simple.correctNonOrthogonal():
            paEqn = ref.fvm.laplacian(rAUa, pa) == ref.fvc.div(phia)
            paEqn.setReference(paRefCell, paRefValue)
            paEqn.solve()

            if simple.finalNonOrthogonalIter():
                phia -= paEqn.flux()
                pass
            pass

        cumulativeAdjointContErr = adjointContinuityErrs(
            runTime, mesh, phia, cumulativeAdjointContErr)

        # Explicitly relax pressure for adjoint momentum corrector
        pa.relax()

        # Adjoint momentum corrector
        Ua -= rAUa * ref.fvc.grad(pa)
        Ua.correctBoundaryConditions()

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #45
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    gravitationalProperties, g, rotating, Omega, magg, gHat = readGravitationalAcceleration(runTime, mesh)

    h, h0, U, hU, hTotal, phi, F = _createFields(runTime, mesh, Omega, gHat)

    pimple = man.pimpleControl(mesh)

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

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

        CourantNo(runTime, mesh, h, phi, magg)

        pimple.start()
        while pimple.loop():

            phiv = ref.surfaceScalarField(ref.word("phiv"), phi() / ref.fvc.interpolate(h))  # mixed calculations

            hUEqn = ref.fvm.ddt(hU) + ref.fvm.div(phiv, hU)

            hUEqn.relax()

            if pimple.momentumPredictor():

                if rotating:
                    ref.solve(hUEqn + (F ^ hU) == -magg * h * ref.fvc.grad(h + h0))
                    pass
                else:
                    ref.solve(hUEqn == -magg * h * ref.fvc.grad(h + h0))
                    pass

                # Constrain the momentum to be in the geometry if 3D geometry
                if mesh.nGeometricD() == 3:
                    hU -= (gHat & hU) * gHat
                    hU.correctBoundaryConditions()
                    pass

            for corr in range(pimple.nCorr()):
                hf = ref.fvc.interpolate(h)
                rUA = 1.0 / hUEqn.A()
                ghrUAf = magg * ref.fvc.interpolate(h * rUA)

                phih0 = ghrUAf * mesh.magSf() * ref.fvc.snGrad(h0)
                if rotating:
                    hU << rUA * (hUEqn.H() - (F ^ hU))
                    pass
                else:
                    hU << rUA * hUEqn.H()
                    pass

                phi << (ref.fvc.interpolate(hU) & mesh.Sf()) + ref.fvc.ddtPhiCorr(rUA, h, hU, phi) - phih0

                for nonOrth in range(pimple.nNonOrthCorr() + 1):
                    hEqn = ref.fvm.ddt(h) + ref.fvc.div(phi) - ref.fvm.laplacian(ghrUAf, h)

                    hEqn.solve(mesh.solver(h.select(pimple.finalInnerIter(corr, nonOrth))))

                    if nonOrth == pimple.nNonOrthCorr():
                        phi += hEqn.flux()
                    pass

                hU -= rUA * h * magg * ref.fvc.grad(h + h0)

                # Constrain the momentum to be in the geometry if 3D geometry
                if mesh.nGeometricD() == 3:
                    hU -= (gHat & hU) * gHat
                    pass

                hU.correctBoundaryConditions()
                pass

            pimple.increment()
            pass

        U == hU / h
        hTotal == h + h0

        runTime.write()

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

        pass

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

    import os

    return os.EX_OK
コード例 #46
0
def main_standalone(argc, argv):
    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = ref.readGravitationalAcceleration(runTime, mesh)

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

    cumulativeContErr = ref.initContinuityErrs()

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

    CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

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

    pimple = man.pimpleControl(mesh)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

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

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

        ref.rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        pimple.start()
        while pimple.loop():
            if pimple.nOuterCorr() != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_Ueqn(pimple, mesh, rho, U, phi, turbulence, ghf, p_rgh)
            fun_hEqn(thermo, rho, p, h, phi, turbulence, DpDt)

            # --- PISO loop
            for corr in range(pimple.nCorr()):
                cumulativeContErr = fun_pEqn(
                    mesh,
                    runTime,
                    pimple,
                    thermo,
                    rho,
                    p,
                    h,
                    psi,
                    U,
                    phi,
                    turbulence,
                    gh,
                    ghf,
                    p_rgh,
                    UEqn,
                    DpDt,
                    cumulativeContErr,
                    corr,
                )
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass

            pimple.increment()
            pass
        rho << thermo.rho()

        runTime.write()

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

    import os

    return os.EX_OK
コード例 #47
0
ファイル: __init__.py プロジェクト: asimurzin/potentialFlux
def main_standalone(argc, argv):

    ref.argList.addBoolOption(ref.word("writep"),
                              "write the final pressure field")
    ref.argList.addBoolOption(ref.word("initialiseUBCs"),
                              "initialise U boundary conditions")

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    potentialFlow, nNonOrthCorr = readControls(mesh)

    p, U, phi, pRefCell, pRefValue = _createFields(runTime, mesh,
                                                   potentialFlow, args)

    ref.ext_Info() << ref.nl << "Calculating potential flow" << ref.nl

    # Since solver contains no time loop it would never execute
    # function objects so do it ourselves.
    runTime.functionObjects().start()

    ref.adjustPhi(phi, U, p)

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

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

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

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

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

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

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

    runTime.functionObjects().end()

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

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

    import os
    return os.EX_OK
コード例 #48
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMeshNoClear( runTime )
    
    p, U, phi, fluid, pRefCell, pRefValue = _createFields( runTime, mesh )
    
    cumulativeContErr = ref.initContinuityErrs()
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl 
    
    while runTime.loop() :
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh ) 
        
        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
        
        fluid.correct()
        UEqn = ref.fvm.ddt( U ) + ref.fvm.div( phi, U ) - ref.fvm.laplacian( fluid.ext_nu(), U ) - ( ref.fvc.grad( U )  & ref.fvc.grad( fluid.ext_nu() ) )
        
        ref.solve( UEqn == -ref.fvc.grad( p ) )
        
        # --- PISO loop

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

                if nonOrth == nNonOrthCorr:
                   phi -=  pEqn.flux()
                   pass
                
                pass
                
            cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
               
            U -= rAU * ref.fvc.grad( p )
            U.correctBoundaryConditions()
            pass
        
        runTime.write()
        
        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        
        pass

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

    import os
    return os.EX_OK
コード例 #49
0
ファイル: __init__.py プロジェクト: asimurzin/dnsFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMeshNoClear( runTime )
    
    transportProperties, nu = readTransportProperties( runTime, mesh )
    
    p, U, phi = _createFields( runTime, mesh )
    
    turbulenceProperties, force, K, forceGen = readTurbulenceProperties( runTime, mesh, U )
    
    cumulativeContErr = ref.initContinuityErrs()

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

    while runTime.loop():
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
       
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh )
       
        force.internalField() << ( ref.ReImSum( ref.fft.reverseTransform( K / ( K.mag() + 1.0e-6 ) ^ forceGen.newField(), K.nn() ) ) )
        
        globalProperties( runTime, U, nu, force )
        
        UEqn = ref.fvm.ddt( U ) + ref.fvm.div( phi, U ) - ref.fvm.laplacian( nu, U ) == force 

        ref.solve( UEqn == - man.fvc.grad( p ) )
        
        # --- PISO loop

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

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

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

            pEqn.solve()

            phi -= pEqn.flux()

            cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )  

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

        runTime.write()
        
        if runTime.outputTime():
            ref.calcEk( U, K ).ext_write( ref.fileName( runTime.path() )/ref.fileName("graphs")/ref.fileName( runTime.timeName() ), 
                                          ref.word( "Ek" ), 
                                          runTime.graphFormat() )
            pass

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

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

    import os
    return os.EX_OK
コード例 #50
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleDyMFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createDynamicFvMesh(runTime)

    cumulativeContErr = ref.initContinuityErrs()

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

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

    pimple = man.pimpleControl(mesh)

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

    while runTime.run():

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

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

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

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

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

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

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

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

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

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

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

    import os
    return os.EX_OK
コード例 #51
0
ファイル: __init__.py プロジェクト: asimurzin/interFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pimple = man.pimpleControl(mesh)

    cumulativeContErr = ref.initContinuityErrs()

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

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

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

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

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

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

    while runTime.run():

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

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

        twoPhaseProperties.correct()

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

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

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

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

            pass

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
コード例 #52
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pimple = man.pimpleControl(mesh)

    maxDeltaT, rDeltaT = setInitialrDeltaT(runTime, mesh, pimple)

    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K = createFields(
        runTime, mesh, pimple)

    mrfZones, pZones, pressureImplicitPorosity = createZones(mesh, U)

    cumulativeContErr = ref.initContinuityErrs()

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

    while runTime.run():

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

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

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

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

        setrDeltaT(runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT)

        ref.rhoEqn(rho, phi)

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

            turbulence.correct()

            UEqn = fun_Ueqn(pimple, rho, p, U, phi, turbulence, mrfZones,
                            pZones)

            fun_hEqn(pThermo, rho, p, h, phi, turbulence, dpdt, K)

            # --- PISO loop
            while (pimple.correct()):
                cumulativeContErr = fun_pEqn(mesh, runTime, pimple, pThermo,
                                             rho, p, h, psi, U, phi, mrfZones,
                                             turbulence, UEqn, dpdt, K,
                                             cumulativeContErr, rhoMax, rhoMin)
                pass

            pass

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #53
0
ファイル: __init__.py プロジェクト: asimurzin/pisoFlux
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    cumulativeContErr = ref.initContinuityErrs()

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

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

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

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

        # Pressure-velocity PISO corrector

        # Momentum predictor

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

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

        UEqn.relax()

        if momentumPredictor:
            ref.solve(UEqn == -ref.fvc.grad(p))
            pass

        # --- PISO loop

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

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

            ref.adjustPhi(phi, U, p)

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

                pEqn.setReference(pRefCell, pRefValue)

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

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

                pass
            cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh, cumulativeContErr)

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

        turbulence.correct()

        runTime.write()

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

        pass

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

    import os

    return os.EX_OK
コード例 #54
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

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

    transportProperties, mu = readTransportProperties(runTime, mesh)

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

    cumulativeContErr = ref.initContinuityErrs()

    #// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

    while runTime.loop():

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

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

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        ref.rhoEqn(rho, phi)

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

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

        # --- PISO loop
        for corr in range(nCorr):

            rAU = 1.0 / UEqn.A()
            U << rAU * UEqn.H()

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

            phi << (rhoO / psi) * phid
            pEqn = ref.fvm.ddt(psi, p()) + ref.fvc.div(phi()) + ref.fvm.div(
                phid, p()) - ref.fvm.laplacian(rho() * rAU, p())

            pEqn.solve()

            phi += pEqn.flux()

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

            U -= rAU * ref.fvc.grad(p)
            U.correctBoundaryConditions()
            pass
        rho << rhoO + psi * p

        runTime.write()

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

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

    import os
    return os.EX_OK
コード例 #55
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleDyMFlux
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createDynamicFvMesh( runTime )
    
    cumulativeContErr = ref.initContinuityErrs()

    p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue, sources = _createFields( runTime, mesh )    
    
    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
    
    pimple = man.pimpleControl( mesh )
    
    ref.ext_Info() << "\nStarting time loop\n" <<ref.nl
    
    while runTime.run() :
        
        adjustTimeStep, maxCo, maxDeltaT, pimpleDic, correctPhi, checkMeshCourantNo, ddtPhiCorr = readControls( runTime, mesh, pimple )
        CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime )
        
        # Make the fluxes absolute
        ref.fvc.makeAbsolute(phi, U)

        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        runTime.increment()
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl
        
        mesh.update()
        if mesh.changing() and correctPhi :
           cumulativeContErr = _correctPhi( runTime, mesh, pimple, p, U, rAU, phi, pRefCell, pRefValue, cumulativeContErr  )
           pass
        
        # Make the fluxes relative to the mesh motion
        ref.fvc.makeRelative( phi, U )
        
        if mesh.changing() and checkMeshCourantNo :
           meshCoNum, meanMeshCoNum = ref.meshCourantNo( runTime, mesh, phi )
           pass
        
        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UEqn = fun_UEqn( mesh, phi, U, p, rAU, turbulence, pimple, sources )
            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, U, phi, turbulence, p, rAU, UEqn, pRefCell, pRefValue, cumulativeContErr, ddtPhiCorr, sources )
                pass
            
            if pimple.turbCorr():
                turbulence.correct()
                pass
            pass
        runTime.write()
        
        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        pass

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

    import os
    return os.EX_OK
コード例 #56
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )
    
    rp = ref.compressible.regionProperties( runTime )
    
    from fluid import createFluidMeshes
    fluidRegions = createFluidMeshes( rp, runTime )
    
    from solid import createSolidMeshes,createSolidField
    solidRegions = createSolidMeshes( rp,runTime )
    

    from fluid import createFluidFields
    thermoFluid, rhoFluid, kappaFluid, UFluid, phiFluid, gFluid, turbulence, KFluid, \
                 dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation = createFluidFields( fluidRegions, runTime )

    from solid import createSolidField
    thermos = createSolidField( solidRegions, runTime )
    
    from fluid import initContinuityErrs
    cumulativeContErr = initContinuityErrs( fluidRegions )
    
    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
    
    from solid import readSolidTimeControls
    maxDi= readSolidTimeControls( runTime )
    
    from fluid import compressubibleMultiRegionCourantNo
    CoNum = compressubibleMultiRegionCourantNo( fluidRegions, runTime, rhoFluid, phiFluid )
    
    from solid import solidRegionDiffusionNo
    DiNum = solidRegionDiffusionNo( solidRegions, runTime, thermos )
    
    runTime, CoNum, DiNum = setInitialMultiRegionDeltaT( adjustTimeStep, runTime, CoNum, DiNum, maxCo, maxDi, maxDeltaT )

    while runTime.run() :
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        
        maxDi= readSolidTimeControls( runTime )
        
        nOuterCorr = readPIMPLEControls( runTime )
        
        CoNum = compressubibleMultiRegionCourantNo( fluidRegions, runTime, rhoFluid, phiFluid )

        DiNum = solidRegionDiffusionNo( solidRegions, runTime, thermos )
           
        runTime, CoNum, DiNum = setMultiRegionDeltaT( adjustTimeStep, runTime, CoNum, DiNum, maxCo, maxDi, maxDeltaT )
                
        runTime.increment()
        
        ref.ext_Info()<< "Time = " << runTime.timeName() << ref.nl << ref.nl
                
        if nOuterCorr != 1 :
            for i in range( fluidRegions.__len__() ):
                from fluid import setRegionFluidFields
                mesh, thermo, rho, kappa, K, U, phi, turb, dpdt, p, psi, h, initialMass, p_rgh, gh, ghf, rad = \
                                     setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, kappaFluid, UFluid, \
                                                           phiFluid, turbulence, KFluid, dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation )
                
                from fluid import storeOldFluidFields
                storeOldFluidFields( p, rho )
                pass
            pass
        
        # --- PIMPLE loop
        for oCorr in range( nOuterCorr ):
            finalIter = ( oCorr == nOuterCorr-1 )
            for i in range( fluidRegions.__len__() ):
                ref.ext_Info() << "\nSolving for fluid region " << fluidRegions[ i ].name() << ref.nl

                from fluid import setRegionFluidFields
                mesh, thermo, rho, kappa, K, U, phi, turb, dpdt, p, psi, h, initialMass, p_rgh, gh, ghf, rad = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, kappaFluid, UFluid, \
                                            phiFluid, turbulence, KFluid, dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation )
                
                from fluid import readFluidMultiRegionPIMPLEControls
                pimple, nCorr, nNonOrthCorr, momentumPredictor = readFluidMultiRegionPIMPLEControls( mesh ) 
                
                from fluid import solveFluid
                cumulativeContErr = solveFluid( i, mesh, thermo, rad, thermoFluid, rho, kappa, K, U, phi, h, turb, dpdt, p, psi, initialMass, p_rgh, gh, \
                                                ghf, oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor, cumulativeContErr, finalIter )
                
                pass
                
            for i in range( solidRegions.__len__() ):
               ref.ext_Info() << "\nSolving for solid region " << solidRegions[ i ].name() << ref.nl
               
               from solid import setRegionSolidFields
               mesh, thermo, rho, cp, tkappa, kappa = setRegionSolidFields( i, solidRegions, thermos )
               
               from solid import readSolidMultiRegionPIMPLEControls
               pimple, nNonOrthCorr = readSolidMultiRegionPIMPLEControls( mesh )
               
               from solid import solveSolid
               solveSolid( mesh, thermo, rho, cp, tkappa, kappa, nNonOrthCorr, finalIter )
               pass                
            pass
        pass
        runTime.write()

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

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