예제 #1
0
def read_controls( args, runTime, mesh ):
    from Foam.finiteVolume.cfdTools.general.include import readPISOControls
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )

    from Foam.OpenFOAM import word, readLabel
    nAlphaCorr = readLabel( piso.lookup( word( "nAlphaCorr" ) ) )

    nAlphaSubCycles = readLabel( piso.lookup( word( "nAlphaSubCycles" ) ) )

    if nAlphaSubCycles > 1 and nOuterCorr != 1:
        from Foam.OpenFOAM import ext_Info, nl
        ext_Info() << args.executable() << "FATAL ERROR: Sub-cycling alpha is only allowed for PISO, i.e. when the number of outer-correctors = 1" << nl;
        import os; os_exit( 1 ) 
        pass
    
    return piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, adjustTimeStep, maxCo, maxDeltaT, nAlphaCorr, nAlphaSubCycles
예제 #2
0
def readControls( runTime, mesh ):
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
    pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls( mesh )
    
    correctPhi = False
    from Foam.OpenFOAM import word
    if (pimple.found( word( "correctPhi" ) ) ):
       correctPhi = Switch( pimple.lookup( word( "correctPhi" ) ) )
       pass
  
    checkMeshCourantNo = False
    if ( pimple.found( word( "checkMeshCourantNo" ) ) ):
        checkMeshCourantNo = Switch( pimple.lookup( "checkMeshCourantNo" ) )
        pass

    return adjustTimeStep, maxCo, maxDeltaT, pimple, nOuterCorr, nCorr, nNonOrthCorr, \
           momentumPredictor, transonic, correctPhi, checkMeshCourantNo
예제 #3
0
def readControls(runTime, mesh):
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

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

    correctPhi = False
    from Foam.OpenFOAM import word
    if (pimple.found(word("correctPhi"))):
        correctPhi = Switch(pimple.lookup(word("correctPhi")))
        pass

    checkMeshCourantNo = False
    if (pimple.found(word("checkMeshCourantNo"))):
        checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo"))
        pass

    return adjustTimeStep, maxCo, maxDeltaT, pimple, nOuterCorr, nCorr, nNonOrthCorr, \
           momentumPredictor, transonic, correctPhi, checkMeshCourantNo
예제 #4
0
def main_standalone( argc, argv ):

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

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

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid = _createFields( runTime, mesh )
    
    thermophysicalProperties, Pr = readThermophysicalProperties( runTime, mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    fluxScheme = readFluxScheme( mesh )
    
    from Foam.OpenFOAM import dimensionedScalar, dimVolume, dimTime, word
    v_zero = dimensionedScalar( word( "v_zero" ) ,dimVolume/dimTime, 0.0)
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl
    
    while runTime.run() :
        # --- upwind interpolation of primitive fields on faces
        from Foam import fvc
        rho_pos = fvc.interpolate( rho, pos, word( "reconstruct(rho)" ) )
        rho_neg = fvc.interpolate( rho, neg, word( "reconstruct(rho)" ) )
        
        rhoU_pos = fvc.interpolate( rhoU, pos, word( "reconstruct(U)" ) )
        rhoU_neg = fvc.interpolate( rhoU, neg, word( "reconstruct(U)" ) )
        
        rPsi = 1.0 / psi
        rPsi_pos = fvc.interpolate( rPsi, pos, word( "reconstruct(T)" ) )
        rPsi_neg = fvc.interpolate( rPsi, neg, word( "reconstruct(T)" ) )
        
        e_pos = fvc.interpolate( e, pos, word( "reconstruct(T)" ) )
        e_neg = fvc.interpolate( e, neg, 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 = fvc.interpolate( c, pos, word( "reconstruct(T)" ) ) * mesh.magSf()
        cSf_neg = fvc.interpolate( c, neg, 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 )
        
        from Foam.finiteVolume import surfaceScalarField
        amaxSf = surfaceScalarField( word( "amaxSf" ), am.mag().ext_max( ap.mag() ) )
        
        CoNum, meanCoNum = compressibleCourantNo( mesh, amaxSf, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        aSf = am * a_pos

        if str( fluxScheme ) == "Tadmor":
           aSf.ext_assign( -0.5 * amaxSf )
           a_pos.ext_assign( 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

        phi = None

        phi = surfaceScalarField( word( "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
        
        from Foam.finiteVolume import volTensorField
        from Foam import fvc
        tauMC = volTensorField( word( "tauMC" ) , mu * fvc.grad(U).T().dev2() ) 
        
        # --- Solve density
        from Foam.finiteVolume import solve
        from Foam import fvm
        solve( fvm.ddt( rho ) + fvc.div( phi ) )
        
        # --- Solve momentum
        solve( fvm.ddt( rhoU ) + fvc.div( phiUp ) )
        
        U.dimensionedInternalField().ext_assign( rhoU.dimensionedInternalField() / rho.dimensionedInternalField() )
        U.correctBoundaryConditions()
        rhoU.ext_boundaryField().ext_assign( rho.ext_boundaryField() * U.ext_boundaryField() )
        
        rhoBydt = rho / runTime.deltaT()
        
        if not inviscid:
           solve( fvm.ddt( rho, U ) - fvc.ddt( rho, U ) - fvm.laplacian( mu, U ) - fvc.div( tauMC ) )
           rhoU.ext_assign( rho * U )
           pass
        
        # --- Solve energy
        sigmaDotU = ( fvc.interpolate( mu ) * mesh.magSf() * fvc.snGrad( U ) + ( mesh.Sf() & fvc.interpolate( tauMC ) ) ) & ( a_pos * U_pos + a_neg * U_neg )

        solve( fvm.ddt( rhoE ) + fvc.div( phiEp ) - fvc.div( sigmaDotU ) )
        
        e.ext_assign( rhoE / rho - 0.5 * U.magSqr() )
        e.correctBoundaryConditions()
        thermo.correct()
        from Foam.finiteVolume import volScalarField
        rhoE.ext_boundaryField().ext_assign( rho.ext_boundaryField() * ( e.ext_boundaryField() + 0.5 * U.ext_boundaryField().magSqr() ) )
        
        if not inviscid:
           k = volScalarField( word( "k" ) , thermo.Cp() * mu / 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( thermo.alpha(), e ) \
                                         + (- fvm.laplacian( thermo.alpha(), e ) + (- fvc.ddt( rho, e ) + fvm.ddt( rho, e ) ) ) ) )
           
           thermo.correct()
           rhoE.ext_assign( rho * ( e + 0.5 * U.magSqr() ) )
           pass
        
        p.dimensionedInternalField().ext_assign( rho.dimensionedInternalField() / psi.dimensionedInternalField() )
        p.correctBoundaryConditions()
        rho.ext_boundaryField().ext_assign( psi.ext_boundaryField() * p.ext_boundaryField() )
        
        runTime.write()

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

    ext_Info() << "End\n"

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

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

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

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

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

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

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

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

    ext_Info() << "End\n"
    pass

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

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

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

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    thermodynamicProperties, R, Cv, Cp, gamma, Pr = readThermodynamicProperties( runTime, mesh )
    
    p, T, psi, pbf, rhoBoundaryTypes, rho, U, Ubf, rhoUboundaryTypes, \
    rhoU, Tbf, rhoEboundaryTypes, rhoE, phi, phiv, rhoU, fields, magRhoU, H = _createFields( runTime, mesh, R, Cv )
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" << nl
    
    while runTime.loop():
        ext_Info() << "Time = " << runTime.value() << nl << nl
        
        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
        
        from Foam.OpenFOAM import readScalar, word
        HbyAblend = readScalar( piso.lookup( word( "HbyAblend" ) ) )
        
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
        CoNum = ( mesh.deltaCoeffs() * phiv.mag() / mesh.magSf() ).ext_max().value() * runTime.deltaT().value()
        
        ext_Info() << "Max Courant Number = " << CoNum << nl
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )

        for outerCorr in range( nOuterCorr):

            magRhoU.ext_assign( rhoU.mag() )
            H.ext_assign( ( rhoE + p ) / rho )
            
            from Foam.fv import multivariateGaussConvectionScheme_scalar
            mvConvection = multivariateGaussConvectionScheme_scalar( mesh, fields, phiv, mesh.divScheme( word( "div(phiv,rhoUH)" ) ) )
            
            from Foam.finiteVolume import solve
            from Foam import fvm
            solve( fvm.ddt( rho ) + mvConvection.fvmDiv( phiv, rho ) )
            
            tmp = mvConvection.interpolationScheme()()( magRhoU )
            
            rhoUWeights = tmp.ext_weights( magRhoU )
            
            from Foam.finiteVolume import weighted_vector
            rhoUScheme = weighted_vector(rhoUWeights)
            from Foam import fv, fvc
            rhoUEqn = fvm.ddt(rhoU) + fv.gaussConvectionScheme_vector( mesh, phiv, rhoUScheme ).fvmDiv( phiv, rhoU )
            solve( rhoUEqn == -fvc.grad( p ) )

            solve( fvm.ddt( rhoE ) + mvConvection.fvmDiv( phiv, rhoE ) == - mvConvection.fvcDiv( phiv, p ) )

            T.ext_assign( (rhoE - 0.5 * rho * ( rhoU / rho ).magSqr() ) / Cv / rho )
            psi.ext_assign( 1.0 / ( R * T ) )
            p.ext_assign( rho / psi )
            
            for corr in range( nCorr ):
                rrhoUA = 1.0 / rhoUEqn.A()
                from Foam.finiteVolume import surfaceScalarField
                rrhoUAf = surfaceScalarField( word( "rrhoUAf" ), fvc.interpolate( rrhoUA ) )
                HbyA = rrhoUA * rhoUEqn.H()
                
                from Foam.finiteVolume import LimitedScheme_vector_MUSCLLimiter_NVDTVD_limitFuncs_magSqr
                from Foam.OpenFOAM import IStringStream, word
                HbyAWeights = HbyAblend * mesh.weights() + ( 1.0 - HbyAblend ) * \
                              LimitedScheme_vector_MUSCLLimiter_NVDTVD_limitFuncs_magSqr( mesh, phi, IStringStream( "HbyA" )() ).weights( HbyA )
                
                from Foam.finiteVolume import surfaceInterpolationScheme_vector
                phi.ext_assign( ( surfaceInterpolationScheme_vector.ext_interpolate(HbyA, HbyAWeights) & mesh.Sf() ) \
                                  + HbyAblend * fvc.ddtPhiCorr( rrhoUA, rho, rhoU, phi ) )
                
                p.ext_boundaryField().updateCoeffs()
                
                phiGradp = rrhoUAf * mesh.magSf() * fvc.snGrad( p )
                
                phi.ext_assign( phi - phiGradp )
                
                resetPhiPatches( phi, rhoU, mesh )
                rhof = mvConvection.interpolationScheme()()(rho).interpolate(rho)

                phiv.ext_assign( phi/rhof )
                
                pEqn = fvm.ddt( psi, p ) + mvConvection.fvcDiv( phiv, rho ) + fvc.div( phiGradp ) - fvm.laplacian( rrhoUAf, p )
                
                pEqn.solve()
                phi.ext_assign( phi + phiGradp + pEqn.flux() )
                rho.ext_assign( psi * p )
                
                rhof.ext_assign( mvConvection.interpolationScheme()()( rho ).interpolate(rho) )
                phiv.ext_assign( phi / rhof )
                
                rhoU.ext_assign( HbyA - rrhoUA * fvc.grad(p) )
                rhoU.correctBoundaryConditions()

                pass
            pass
        
        U.ext_assign( rhoU / rho )

        runTime.write()

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

    ext_Info() << "End\n"

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

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

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

    from Foam.dynamicFvMesh import createDynamicFvMesh
    mesh = createDynamicFvMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readPISOControls
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh() )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh() )

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

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

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

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

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

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

        runTime.write()

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

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

    import os
    return os.EX_OK
예제 #8
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase

    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime

    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh

    mesh = createMesh(runTime)

    p, h, psi, rho, U, phi, turbulence, thermo, pMin, DpDt = _createFields(runTime, mesh)

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

    cumulativeContErr = initContinuityErrs()

    from Foam.OpenFOAM import ext_Info, nl

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

    while runTime.run():

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

        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

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

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

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo

        CoNum, meanCoNum, velMag = compressibleCourantNo(mesh, phi, rho, runTime)

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

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

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

        if nOuterCorr != 1:
            p.storePrevIter()
            rho.storePrevIter()
            pass

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn

        rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            UEqn = _UEqn(mesh, U, rho, phi, turbulence, p, oCorr, nOuterCorr, momentumPredictor)

            hEqn = _hEqn(mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr, nOuterCorr)

            # --- PISO loop

            for corr in range(nCorr):
                cumulativeContErr = _pEqn(
                    rho,
                    thermo,
                    UEqn,
                    nNonOrthCorr,
                    psi,
                    U,
                    mesh,
                    phi,
                    p,
                    DpDt,
                    pMin,
                    corr,
                    cumulativeContErr,
                    nCorr,
                    oCorr,
                    nOuterCorr,
                    transonic,
                )
                pass

            turbulence.correct()
            pass

        runTime.write()

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

        pass

    ext_Info() << "End\n"

    import os

    return os.EX_OK
예제 #9
0
def main_standalone( argc, argv ):

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

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

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readPISOControls
    piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, \
                                    pRefValue, interface, turbulence, g, gh, ghf = _createFields( runTime, mesh )

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

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

        turbulence.correct()

        runTime.write()

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

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

    import os
    return os.EX_OK
예제 #10
0
def main_standalone( argc, argv ):

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

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

    from Foam.OpenFOAM.include import createMesh
    mesh = createMesh( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt = create_fields( runTime, mesh, g )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info()<< "\nStarting time loop\n" << nl
    
    while runTime.run() :
        
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
        from Foam.finiteVolume.cfdTools.general.include import readPIMPLEControls
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls( mesh )
        
        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn  
        rhoEqn( rho, phi )
        
        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range( nOuterCorr ):
            finalIter = oCorr == ( nOuterCorr-1 )

            if nOuterCorr != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_UEqn( mesh, rho, phi, U, p_rgh, ghf, turbulence, finalIter, momentumPredictor )
            fun_hEqn( mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter )

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

            turbulence.correct()

            rho.ext_assign( thermo.rho() )
            pass

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

    import os
    return os.EX_OK
예제 #11
0
def main_standalone( argc, argv ):

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

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

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

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

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

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

    import os
    return os.EX_OK
예제 #12
0
def main_standalone( argc, argv ):

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

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

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

    p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport = _createFields( runTime, mesh )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" <<nl
    
    while runTime.run() :
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )

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

        from Foam.finiteVolume.cfdTools.general.include import CourantNo
        CoNum, meanCoNum = CourantNo( mesh, phi, runTime )
      
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
                
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        # --- Pressure-velocity PIMPLE corrector loop
        for oCorr in range(nOuterCorr):
            if nOuterCorr != 1 :
               p.storePrevIter()
               pass
            
            UEqn, rUA = Ueqn( mesh, phi, U, p, turbulence, oCorr, nOuterCorr, momentumPredictor )
            
            # --- PISO loop
            for corr in range( nCorr ):
               cumulativeContErr = pEqn( runTime, mesh, U, rUA, UEqn, phi, p, nCorr, nOuterCorr,\
                                         nNonOrthCorr, oCorr, corr, pRefCell, pRefValue, cumulativeContErr )
               pass
                                         
            turbulence.correct()
            pass

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

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

    import os
    return os.EX_OK
예제 #13
0
def main_standalone(argc, argv):

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

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

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

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

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

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

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

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

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

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

        runTime.increment()

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

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

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

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

            turbulence.correct()
            pass

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
예제 #14
0
def main_standalone(argc, argv):

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

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

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

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration(runTime, mesh)

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

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

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

    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

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

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

    while runTime.run():

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

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

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

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

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

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

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

            if nOuterCorr != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_UEqn(mesh, rho, phi, U, p_rgh, ghf, turbulence,
                            finalIter, momentumPredictor)
            fun_hEqn(mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter)

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

            turbulence.correct()

            rho.ext_assign(thermo.rho())
            pass

        runTime.write()

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

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #15
0
def main_standalone(argc, argv):

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

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

    from regionProperties import regionProperties
    rp = regionProperties(runTime)

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

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

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

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

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

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

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

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

    from Foam.OpenFOAM import ext_Info, nl

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

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

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

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

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

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

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

            pass

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

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

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

        runTime.write()

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

    ext_Info() << "End\n"
    pass

    import os
    return os.EX_OK
예제 #16
0
def main_standalone(argc, argv):

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

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

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

    thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid = _createFields(
        runTime, mesh)

    thermophysicalProperties, Pr = readThermophysicalProperties(runTime, mesh)

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

    fluxScheme = readFluxScheme(mesh)

    from Foam.OpenFOAM import dimensionedScalar, dimVolume, dimTime, word
    v_zero = dimensionedScalar(word("v_zero"), dimVolume / dimTime, 0.0)

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

    while runTime.run():
        # --- upwind interpolation of primitive fields on faces
        from Foam import fvc
        rho_pos = fvc.interpolate(rho, pos, word("reconstruct(rho)"))
        rho_neg = fvc.interpolate(rho, neg, word("reconstruct(rho)"))

        rhoU_pos = fvc.interpolate(rhoU, pos, word("reconstruct(U)"))
        rhoU_neg = fvc.interpolate(rhoU, neg, word("reconstruct(U)"))

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

        e_pos = fvc.interpolate(e, pos, word("reconstruct(T)"))
        e_neg = fvc.interpolate(e, neg, 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 = fvc.interpolate(c, pos,
                                  word("reconstruct(T)")) * mesh.magSf()
        cSf_neg = fvc.interpolate(c, neg,
                                  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)

        from Foam.finiteVolume import surfaceScalarField
        amaxSf = surfaceScalarField(word("amaxSf"), am.mag().ext_max(ap.mag()))

        aSf = am * a_pos

        if str(fluxScheme) == "Tadmor":
            aSf.ext_assign(-0.5 * amaxSf)
            a_pos.ext_assign(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.ext_assign(aphiv_pos.mag().ext_max(aphiv_neg.mag()))

        CoNum, meanCoNum = compressibleCourantNo(mesh, amaxSf, runTime)

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

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

        runTime.increment()

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

        phi = surfaceScalarField(word("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

        from Foam.finiteVolume import volTensorField
        from Foam import fvc
        tauMC = volTensorField(word("tauMC"), mu * fvc.grad(U).T().dev2())

        # --- Solve density
        from Foam.finiteVolume import solve
        from Foam import fvm
        solve(fvm.ddt(rho) + fvc.div(phi))

        # --- Solve momentum
        solve(fvm.ddt(rhoU) + fvc.div(phiUp))

        U.dimensionedInternalField().ext_assign(
            rhoU.dimensionedInternalField() / rho.dimensionedInternalField())
        U.correctBoundaryConditions()
        rhoU.ext_boundaryField().ext_assign(rho.ext_boundaryField() *
                                            U.ext_boundaryField())

        rhoBydt = rho / runTime.deltaT()

        if not inviscid:
            solve(
                fvm.ddt(rho, U) - fvc.ddt(rho, U) - fvm.laplacian(mu, U) -
                fvc.div(tauMC))
            rhoU.ext_assign(rho * U)
            pass

        # --- Solve energy
        sigmaDotU = (fvc.interpolate(mu) * mesh.magSf() * fvc.snGrad(U) +
                     (mesh.Sf() & fvc.interpolate(tauMC))) & (a_pos * U_pos +
                                                              a_neg * U_neg)

        solve(fvm.ddt(rhoE) + fvc.div(phiEp) - fvc.div(sigmaDotU))

        e.ext_assign(rhoE / rho - 0.5 * U.magSqr())
        e.correctBoundaryConditions()
        thermo.correct()
        from Foam.finiteVolume import volScalarField
        rhoE.ext_boundaryField().ext_assign(
            rho.ext_boundaryField() *
            (e.ext_boundaryField() + 0.5 * U.ext_boundaryField().magSqr()))

        if not inviscid:
            k = volScalarField(word("k"), thermo.Cp() * mu / 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( thermo.alpha(), e ) \
                                          + (- fvm.laplacian( thermo.alpha(), e ) + (- fvc.ddt( rho, e ) + fvm.ddt( rho, e ) ) ) ) )

            thermo.correct()
            rhoE.ext_assign(rho * (e + 0.5 * U.magSqr()))
            pass

        p.dimensionedInternalField().ext_assign(
            rho.dimensionedInternalField() / psi.dimensionedInternalField())
        p.correctBoundaryConditions()
        rho.ext_boundaryField().ext_assign(psi.ext_boundaryField() *
                                           p.ext_boundaryField())

        runTime.write()

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

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #17
0
def main_standalone(argc, argv):

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

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

    from regionProperties import regionProperties
    rp = 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, KFluid, UFluid, phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid = createFluidFields(
        fluidRegions, runTime)

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

    from fluid import initContinuityErrs
    cumulativeContErr = initContinuityErrs(fluidRegions.size())

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

    from Foam.OpenFOAM import ext_Info, nl

    if fluidRegions.size():
        from fluid import compressubibleMultiRegionCourantNo
        CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime,
                                                   rhoFluid, phiFluid)

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

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

        nOuterCorr = readPIMPLEControls(runTime)

        if fluidRegions.size():
            from fluid import compressubibleMultiRegionCourantNo
            CoNum = compressubibleMultiRegionCourantNo(fluidRegions, runTime,
                                                       rhoFluid, phiFluid)

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

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

        if nOuterCorr != 1:
            for i in range(fluidRegions.size()):
                from fluid import setRegionFluidFields
                mesh, thermo, rho, K, U, phi, g, turb, DpDt, p, psi, h, massIni = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                                            phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid )

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

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

                from fluid import setRegionFluidFields
                mesh, thermo, rho, K, U, phi, g, turb, DpDt, p, psi, h, massIni = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                                            phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid )

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

                from fluid import solveFluid
                cumulativeContErr = solveFluid( i, mesh, thermo, thermoFluid, rho, K, U, phi, g, h, turb, DpDt, p, psi, \
                                                massIni, oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor, cumulativeContErr )

                pass

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

                from solid import setRegionSolidFields
                mesh, rho, cp, K, T = setRegionSolidFields(
                    i, solidRegions, rhos, cps, Ks, Ts)

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

                from solid import solveSolid
                solveSolid(mesh, rho, cp, K, T, nNonOrthCorr)
                pass
            pass
        pass
        runTime.write()

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

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #18
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase

    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime

    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh

    mesh = createMesh(runTime)

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

    g = readGravitationalAcceleration(runTime, mesh)

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

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

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

    cumulativeContErr = initContinuityErrs()

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

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

    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

    from Foam.finiteVolume.cfdTools.incompressible import CourantNo

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

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

    runTime = setInitialDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

    from Foam.OpenFOAM import ext_Info, nl

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

    while runTime.run():
        pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic = readPIMPLEControls(mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum = CourantNo(mesh, phi, runTime)

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

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

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

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

            twoPhaseProperties.correct()

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

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

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

            turbulence.correct()
            pass

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

        pass

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

    import os

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

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

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

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

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)
    
    T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, pRefCell, pRefValue, rhok = _createFields( runTime, mesh, g )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import CourantNo
    CoNum, meanCoNum, velMag = CourantNo( mesh, phi, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" <<nl
    
    while runTime.loop():
        ext_Info() << "Time = " << runTime.timeName() << nl << nl

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

        turbulence.correct()

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

    import os
    return os.EX_OK
예제 #20
0
def main_standalone(argc, argv):

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

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

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

    p, h, psi, rho, U, phi, turbulence, thermo, DpDt = _createFields(
        runTime, mesh)

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

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

    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

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

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

    while runTime.run():

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

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

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

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

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

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        UEqn = _UEqn(U, rho, phi, turbulence, p, momentumPredictor)

        # --- PISO loop
        for corr in range(nCorr):
            _hEqn(rho, h, phi, turbulence, DpDt, thermo)

            cumulativeContErr = _pEqn( rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, \
                                phi, p, DpDt, cumulativeContErr, corr, nCorr, nOuterCorr, transonic )

        turbulence.correct()

        rho.ext_assign(thermo.rho())

        runTime.write()

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

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #21
0
def main_standalone(argc, argv):

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

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

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

    thermodynamicProperties, R, Cv, Cp, gamma, Pr = readThermodynamicProperties(
        runTime, mesh)

    p, T, psi, pbf, rhoBoundaryTypes, rho, U, Ubf, rhoUboundaryTypes, \
    rhoU, Tbf, rhoEboundaryTypes, rhoE, phi, phiv, rhoU, fields, magRhoU, H = _createFields( runTime, mesh, R, Cv )

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

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

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

        from Foam.OpenFOAM import readScalar, word
        HbyAblend = readScalar(piso.lookup(word("HbyAblend")))

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

        CoNum = (mesh.deltaCoeffs() * phiv.mag() /
                 mesh.magSf()).ext_max().value() * runTime.deltaT().value()

        ext_Info() << "Max Courant Number = " << CoNum << nl

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

        for outerCorr in range(nOuterCorr):

            magRhoU.ext_assign(rhoU.mag())
            H.ext_assign((rhoE + p) / rho)

            from Foam.fv import multivariateGaussConvectionScheme_scalar
            mvConvection = multivariateGaussConvectionScheme_scalar(
                mesh, fields, phiv, mesh.divScheme(word("div(phiv,rhoUH)")))

            from Foam.finiteVolume import solve
            from Foam import fvm
            solve(fvm.ddt(rho) + mvConvection.fvmDiv(phiv, rho))

            tmp = mvConvection.interpolationScheme()()(magRhoU)

            rhoUWeights = tmp.ext_weights(magRhoU)

            from Foam.finiteVolume import weighted_vector
            rhoUScheme = weighted_vector(rhoUWeights)
            from Foam import fv, fvc
            rhoUEqn = fvm.ddt(rhoU) + fv.gaussConvectionScheme_vector(
                mesh, phiv, rhoUScheme).fvmDiv(phiv, rhoU)
            solve(rhoUEqn == -fvc.grad(p))

            solve(
                fvm.ddt(rhoE) + mvConvection.fvmDiv(phiv, rhoE) ==
                -mvConvection.fvcDiv(phiv, p))

            T.ext_assign((rhoE - 0.5 * rho * (rhoU / rho).magSqr()) / Cv / rho)
            psi.ext_assign(1.0 / (R * T))
            p.ext_assign(rho / psi)

            for corr in range(nCorr):
                rrhoUA = 1.0 / rhoUEqn.A()
                from Foam.finiteVolume import surfaceScalarField
                rrhoUAf = surfaceScalarField(word("rrhoUAf"),
                                             fvc.interpolate(rrhoUA))
                HbyA = rrhoUA * rhoUEqn.H()

                from Foam.finiteVolume import LimitedScheme_vector_MUSCLLimiter_NVDTVD_limitFuncs_magSqr
                from Foam.OpenFOAM import IStringStream, word
                HbyAWeights = HbyAblend * mesh.weights() + ( 1.0 - HbyAblend ) * \
                              LimitedScheme_vector_MUSCLLimiter_NVDTVD_limitFuncs_magSqr( mesh, phi, IStringStream( "HbyA" )() ).weights( HbyA )

                from Foam.finiteVolume import surfaceInterpolationScheme_vector
                phi.ext_assign( ( surfaceInterpolationScheme_vector.ext_interpolate(HbyA, HbyAWeights) & mesh.Sf() ) \
                                  + HbyAblend * fvc.ddtPhiCorr( rrhoUA, rho, rhoU, phi ) )

                p.ext_boundaryField().updateCoeffs()

                phiGradp = rrhoUAf * mesh.magSf() * fvc.snGrad(p)

                phi.ext_assign(phi - phiGradp)

                resetPhiPatches(phi, rhoU, mesh)
                rhof = mvConvection.interpolationScheme()()(rho).interpolate(
                    rho)

                phiv.ext_assign(phi / rhof)

                pEqn = fvm.ddt(psi, p) + mvConvection.fvcDiv(
                    phiv, rho) + fvc.div(phiGradp) - fvm.laplacian(rrhoUAf, p)

                pEqn.solve()
                phi.ext_assign(phi + phiGradp + pEqn.flux())
                rho.ext_assign(psi * p)

                rhof.ext_assign(
                    mvConvection.interpolationScheme()()(rho).interpolate(rho))
                phiv.ext_assign(phi / rhof)

                rhoU.ext_assign(HbyA - rrhoUA * fvc.grad(p))
                rhoU.correctBoundaryConditions()

                pass
            pass

        U.ext_assign(rhoU / rho)

        runTime.write()

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

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #22
0
def main_standalone(argc, argv):

    from Foam.OpenFOAM.include import setRootCase

    args = setRootCase(argc, argv)

    from Foam.OpenFOAM.include import createTime

    runTime = createTime(args)

    from Foam.OpenFOAM.include import createMesh

    mesh = createMesh(runTime)

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

    g = readGravitationalAcceleration(runTime, mesh)

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

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

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

    cumulativeContErr = initContinuityErrs()

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

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

    adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)

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

    from Foam.finiteVolume.cfdTools.incompressible import CourantNo

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

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

    runTime = setInitialDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)

    from Foam.OpenFOAM import ext_Info, nl

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

    while runTime.run():

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, runTime)

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

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

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

        twoPhaseProperties.correct()

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

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

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

        from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

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

        p.ext_assign(pd + rho * gh)

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

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

        runTime.write()

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

        pass

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

    import os

    return os.EX_OK
예제 #23
0
def main_standalone(argc, argv):

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

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

    from Foam.dynamicFvMesh import createDynamicFvMesh
    mesh = createDynamicFvMesh(runTime)

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

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

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

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

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

    while runTime.run():

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

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

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

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

        runTime.increment()

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

        mesh.update()

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

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

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

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

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

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

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

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

                    pEqn.setReference(pRefCell, pRefValue)

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

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

                    pass

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

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

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

        turbulence.correct()

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
예제 #24
0
def main_standalone(argc, argv):

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

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

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

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration(runTime, mesh)

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

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

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

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

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

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

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

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

    while runTime.run():

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls(
            mesh)
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls(runTime)
        CoNum, meanCoNum, velMag = CourantNo(mesh, phi, runTime)

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

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

        twoPhaseProperties.correct()

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

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

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

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

        p.ext_assign(pd + rho * gh)

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

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

        runTime.write()

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

        pass

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

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

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

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

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

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration(runTime, mesh)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        turbulence.correct()

        runTime.write()

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

        pass

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

    import os
    return os.EX_OK
예제 #26
0
def main_standalone( argc, argv ):

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

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

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

    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)
    
    thermo, p, h, psi, phi, rho, U, turbulence, DpDt, initialMass, totalVolume = _createFields( runTime, mesh, g )
    
    from Foam.finiteVolume.cfdTools.general.include import initContinuityErrs
    cumulativeContErr = initContinuityErrs()
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
    CoNum, meanCoNum, velMag = compressibleCourantNo( mesh, phi, rho, runTime )
    
    from Foam.finiteVolume.cfdTools.general.include import setInitialDeltaT
    runTime = setInitialDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nStarting time loop\n" <<nl
    
    while runTime.run():
        from Foam.finiteVolume.cfdTools.general.include import readTimeControls
        adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
        from Foam.finiteVolume.cfdTools.general.include import readPISOControls
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = readPISOControls( mesh )
        
        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum, velMag = compressibleCourantNo( mesh, phi, rho, runTime )
        
        from Foam.finiteVolume.cfdTools.general.include import setDeltaT
        runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        
        runTime.increment()
        ext_Info() << "Time = " << runTime.timeName() << nl << nl
        
        from Foam.finiteVolume.cfdTools.compressible import rhoEqn  
        rhoEqn( rho, phi )
        
        UEqn = _Ueqn(  U, phi, turbulence, p, rho, g, mesh, momentumPredictor )
        
        hEqn = _hEqn( rho, h, phi, turbulence, thermo, DpDt )
        
        # --- PISO loop
        for corr in range( nCorr ):
            cumulativeContErr = _pEqn( runTime, mesh, UEqn, thermo, p, psi, U, rho, phi, DpDt, g,\
                                       initialMass, totalVolume, corr, nCorr, nNonOrthCorr, cumulativeContErr )
            pass

        turbulence.correct()

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

    import os
    return os.EX_OK
예제 #27
0
def main_standalone(argc, argv):

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

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

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

    thermo, turbulence, p, h, psi, rho, U, phi, pMin, DpDt, mrfZones, pZones, pressureImplicitPorosity = create_fields(
        runTime, mesh)

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

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

    while runTime.run():

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

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

        from Foam.finiteVolume.cfdTools.compressible import compressibleCourantNo
        CoNum, meanCoNum = compressibleCourantNo(mesh, phi, rho, runTime)

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

        runTime.increment()

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

        if nOuterCorr != 1:
            p.storePrevIter()
            rho.storePrevIter()
            pass

        from Foam.finiteVolume.cfdTools.compressible import rhoEqn
        rhoEqn(rho, phi)

        for oCorr in range(nOuterCorr):
            UEqn = fun_UEqn(mesh, pZones, rho, U, phi, turbulence, mrfZones, p,
                            momentumPredictor, oCorr, nOuterCorr)
            hEqn = fun_hEqn(mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr,
                            nOuterCorr)

            for corr in range(nCorr):
                fun_pEqn(mesh, thermo, p, rho, psi, U, phi, DpDt, pMin, UEqn,
                         mrfZones, nNonOrthCorr, nCorr, oCorr, nOuterCorr,
                         corr, transonic, cumulativeContErr)
                pass
            turbulence.correct()
            pass

        runTime.write()

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

        pass

    ext_Info() << "End\n"

    import os
    return os.EX_OK
예제 #28
0
def main_standalone( argc, argv ):

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

    from Foam.OpenFOAM.include import createTime
    runTime = createTime( args )
    
    from regionProperties import regionProperties
    rp = 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, KFluid, UFluid, phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid = createFluidFields( fluidRegions, runTime )

    from solid import createSolidField
    rhos, cps, rhosCps, Ks, Ts = createSolidField( solidRegions, runTime )
    
    from fluid import initContinuityErrs
    cumulativeContErr = initContinuityErrs( fluidRegions.size() )
    
    from Foam.finiteVolume.cfdTools.general.include import readTimeControls
    adjustTimeStep, maxCo, maxDeltaT = readTimeControls( runTime )
    
    from Foam.OpenFOAM import ext_Info, nl

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

        nOuterCorr = readPIMPLEControls( runTime )
        
        if fluidRegions.size() :
            from fluid import compressubibleMultiRegionCourantNo
            CoNum = compressubibleMultiRegionCourantNo( fluidRegions, runTime, rhoFluid, phiFluid )

            from Foam.finiteVolume.cfdTools.general.include import setDeltaT   
            runTime = setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
            pass
        
        runTime.increment()
        ext_Info()<< "Time = " << runTime.timeName() << nl << nl      
                
        if nOuterCorr != 1 :
            for i in range( fluidRegions.size() ):
                from fluid import setRegionFluidFields
                mesh, thermo, rho, K, U, phi, g, turb, DpDt, p, psi, h, massIni = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                                            phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid )
                
                from fluid import storeOldFluidFields
                storeOldFluidFields( p, rho )
                pass
            pass
        
        # --- PIMPLE loop
        for oCorr in range( nOuterCorr ):
            for i in range( fluidRegions.size() ):
                ext_Info() << "\nSolving for fluid region " << fluidRegions[ i ].name() << nl

                from fluid import setRegionFluidFields
                mesh, thermo, rho, K, U, phi, g, turb, DpDt, p, psi, h, massIni = \
                      setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                                            phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid )
                
                from fluid import readFluidMultiRegionPIMPLEControls
                pimple, nCorr, nNonOrthCorr, momentumPredictor = readFluidMultiRegionPIMPLEControls( mesh ) 
                
                from fluid import solveFluid
                cumulativeContErr = solveFluid( i, mesh, thermo, thermoFluid, rho, K, U, phi, g, h, turb, DpDt, p, psi, \
                                                massIni, oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor, cumulativeContErr )
                
                pass
                
            for i in range( solidRegions.size() ):
               ext_Info() << "\nSolving for solid region " << solidRegions[ i ].name() << nl
               
               from solid import setRegionSolidFields
               mesh, rho, cp, K, T = setRegionSolidFields( i, solidRegions, rhos, cps, Ks, Ts )
               
               from solid import readSolidMultiRegionPIMPLEControls
               pimple, nNonOrthCorr = readSolidMultiRegionPIMPLEControls( mesh )
               
               from solid import solveSolid
               solveSolid( mesh, rho, cp, K, T, nNonOrthCorr )
               pass                
            pass
        pass
        runTime.write()

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

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