コード例 #1
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleFlux
def Ueqn(mesh, phi, U, p, turbulence, oCorr, nOuterCorr, momentumPredictor):
    from Foam import fvm, fvc
    UEqn = fvm.ddt(U) + fvm.div(phi, U) + turbulence.divDevReff(U)

    if (oCorr == nOuterCorr - 1):
        UEqn.relax(1.0)
        pass
    else:
        UEqn.relax()
        pass

    rUA = 1.0 / UEqn.A()

    from Foam.finiteVolume import solve
    if momentumPredictor:
        if (oCorr == nOuterCorr - 1):
            from Foam.OpenFOAM import word
            solve(UEqn == -fvc.grad(p), mesh.solver(word("UFinal")))
            pass
        else:
            solve(UEqn == -fvc.grad(p))
            pass
    else:
        U.ext_assign(rUA * (UEqn.H() - fvc.grad(p)))
        U.correctBoundaryConditions()
        pass

    return UEqn, rUA
コード例 #2
0
ファイル: __init__.py プロジェクト: asimurzin/icoFlux
    def step(self, getPISOControls):
        from Foam.OpenFOAM import ext_Info, nl

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

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = getPISOControls(self.mesh)

        from Foam.finiteVolume.cfdTools.incompressible import CourantNo

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

        from Foam import fvm

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

        from Foam import fvc
        from Foam.finiteVolume import solve

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

        # --- PISO loop

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

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

            from Foam.finiteVolume import adjustPhi

            adjustPhi(self.phi, self.U, self.p)

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

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

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

                pass

            from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

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

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

            pass

        self.runTime.write()

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

        self.runTime += self.runTime.deltaT()

        return self.runTime.value()
コード例 #3
0
def fun_UEqn( mesh, pZones, rho, U, phi, turbulence, mrfZones, p, momentumPredictor, oCorr, nOuterCorr ):
    
    from Foam import fvm
    UEqn = pZones.ddt( rho, U ) + fvm.div( phi, U ) + turbulence.divDevRhoReff( U )
    
    if oCorr == nOuterCorr-1:
       UEqn.relax( 1.0 )
       pass
    else:
       UEqn.relax()
       pass
    
    mrfZones.addCoriolis( rho, UEqn )
    pZones.addResistance( UEqn )
    
    rUA = 1.0 / UEqn.A()
    
    if momentumPredictor:
       from Foam import fvc
       from Foam.finiteVolume import solve
       if oCorr == nOuterCorr-1:
          from Foam.OpenFOAM import word
          solve( UEqn == -fvc.grad( p ), mesh.solver( word( "UFinal" ) ) )
          pass
       else:
          solve( UEqn == -fvc.grad( p ) )
          pass
    else:
       U.ext_assign( rUA * ( UEqn.H() - fvc.grad( p ) ) )
       U.correctBoundaryConditions()
       pass
    
    return UEqn
コード例 #4
0
def _pEqn(rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p,
          cumulativeContErr):
    from Foam.finiteVolume import volScalarField
    rUA = 1.0 / UEqn.A()
    U.ext_assign(rUA * UEqn.H())

    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    from Foam.OpenFOAM import word
    phid = surfaceScalarField(
        word("phid"),
        fvc.interpolate(thermo.psi()) *
        ((fvc.interpolate(U) & mesh.Sf()) + fvc.ddtPhiCorr(rUA, rho, U, phi)))

    for nonOrth in range(nNonOrthCorr + 1):
        from Foam import fvm
        pEqn = (fvm.ddt(psi, p) + fvm.div(phid, word("div(phid,p)")) -
                fvm.laplacian(rho * rUA, p))
        pEqn.solve()
        if (nonOrth == nNonOrthCorr):
            phi.ext_assign(pEqn.flux())
            pass
        pass
    from Foam.finiteVolume.cfdTools.compressible import rhoEqn
    rhoEqn(rho, phi)

    from Foam.finiteVolume.cfdTools.compressible import compressibleContinuityErrs
    cumulativeContErr = compressibleContinuityErrs(rho, thermo,
                                                   cumulativeContErr)

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

    return cumulativeContErr
コード例 #5
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleFlux
def Ueqn( mesh, phi, U, p, turbulence, oCorr, nOuterCorr, momentumPredictor ):
    from Foam import fvm, fvc
    UEqn = fvm.ddt(U) + fvm.div(phi, U) + turbulence.divDevReff(U)
    
    if ( oCorr == nOuterCorr - 1 ):
       UEqn.relax( 1.0 )
       pass
    else:
       UEqn.relax()
       pass
    
    rUA = 1.0/UEqn.A()
    
    from Foam.finiteVolume import solve
    if momentumPredictor:
       if ( oCorr == nOuterCorr - 1 ):
          from Foam.OpenFOAM import word
          solve( UEqn == -fvc.grad(p), mesh.solver( word( "UFinal" ) ) )
          pass
       else:
          solve( UEqn == -fvc.grad(p))
          pass
    else:
       U.ext_assign( rUA * ( UEqn.H() - fvc.grad( p ) ) )
       U.correctBoundaryConditions()
       pass
    
    return UEqn, rUA
コード例 #6
0
ファイル: __init__.py プロジェクト: asimurzin/rhoPisoFlux
def _hEqn( rho, h, phi, turbulence, DpDt, thermo ):
    from Foam import fvm
    from Foam.finiteVolume import solve
    solve( fvm.ddt(rho, h) + fvm.div( phi, h ) - fvm.laplacian( turbulence.alphaEff(), h ) == DpDt )

    thermo.correct()
    pass
コード例 #7
0
ファイル: __init__.py プロジェクト: asimurzin/interFlux
def _UEqn(mesh, alpha1, U, p, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, momentumPredictor):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import surfaceScalarField
    from Foam import fvc

    muEff = surfaceScalarField(word("muEff"), twoPhaseProperties.muf() + fvc.interpolate(rho * turbulence.ext_nut()))
    from Foam import fvm

    UEqn = fvm.ddt(rho, U) + fvm.div(rhoPhi, U) - fvm.laplacian(muEff, U) - (fvc.grad(U) & fvc.grad(muEff))

    UEqn.relax()

    if momentumPredictor:
        from Foam.finiteVolume import solve

        solve(
            UEqn
            == fvc.reconstruct(
                fvc.interpolate(rho) * (g & mesh.Sf())
                + (fvc.interpolate(interface.sigmaK()) * fvc.snGrad(alpha1) - fvc.snGrad(p)) * mesh.magSf()
            )
        )
        pass

    return UEqn
コード例 #8
0
ファイル: __init__.py プロジェクト: asimurzin/sonicTurbFlux
def _pEqn( rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p, cumulativeContErr ):
    from Foam.finiteVolume import volScalarField
    rUA = 1.0/UEqn.A()
    U.ext_assign( rUA*UEqn.H() )
            
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    from Foam.OpenFOAM import word
    phid = surfaceScalarField( word( "phid" ), 
                               fvc.interpolate( thermo.psi() ) * ( (fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) ) )
    
    
    for nonOrth in range( nNonOrthCorr + 1 ) :
        from Foam import fvm
        pEqn = ( fvm.ddt(psi, p) + fvm.div(phid, word( "div(phid,p)" ) ) - fvm.laplacian(rho*rUA, p) )
        pEqn.solve()
        if (nonOrth == nNonOrthCorr) :
           phi.ext_assign( pEqn.flux() )
           pass
        pass
    from Foam.finiteVolume.cfdTools.compressible import rhoEqn
    rhoEqn( rho, phi )               
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleContinuityErrs
    cumulativeContErr = compressibleContinuityErrs( rho, thermo, cumulativeContErr )
           
    U.ext_assign( U - rUA * fvc.grad(p) )
    U.correctBoundaryConditions()
    
    return cumulativeContErr
コード例 #9
0
def fun_UEqn(mesh, pZones, rho, U, phi, turbulence, mrfZones, p,
             momentumPredictor, oCorr, nOuterCorr):

    from Foam import fvm
    UEqn = pZones.ddt(rho, U) + fvm.div(phi, U) + turbulence.divDevRhoReff(U)

    if oCorr == nOuterCorr - 1:
        UEqn.relax(1.0)
        pass
    else:
        UEqn.relax()
        pass

    mrfZones.addCoriolis(rho, UEqn)
    pZones.addResistance(UEqn)

    rUA = 1.0 / UEqn.A()

    if momentumPredictor:
        from Foam import fvc
        from Foam.finiteVolume import solve
        if oCorr == nOuterCorr - 1:
            from Foam.OpenFOAM import word
            solve(UEqn == -fvc.grad(p), mesh.solver(word("UFinal")))
            pass
        else:
            solve(UEqn == -fvc.grad(p))
            pass
    else:
        U.ext_assign(rUA * (UEqn.H() - fvc.grad(p)))
        U.correctBoundaryConditions()
        pass

    return UEqn
コード例 #10
0
def fun_UEqn(mesh, U, p_rgh, ghf, rho, rhoPhi, turbulence, twoPhaseProperties, momentumPredictor, finalIter):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import surfaceScalarField
    from Foam import fvc

    muEff = surfaceScalarField(word("muEff"), twoPhaseProperties.muf() + fvc.interpolate(rho * turbulence.ext_nut()))

    from Foam import fvm, fvc

    UEqn = fvm.ddt(rho, U) + fvm.div(rhoPhi, U) - fvm.laplacian(muEff, U) - (fvc.grad(U) & fvc.grad(muEff))

    if finalIter:
        UEqn.relax(1.0)
        pass
    else:
        UEqn.relax()
        pass

    if momentumPredictor:
        from Foam.finiteVolume import solve

        solve(
            UEqn == fvc.reconstruct((-ghf * fvc.snGrad(rho) - fvc.snGrad(p_rgh)) * mesh.magSf()),
            mesh.solver(U.select(finalIter)),
        )
        pass

    return UEqn
コード例 #11
0
def _hEqn(rho, h, phi, turbulence, DpDt, thermo):
    from Foam import fvm
    from Foam.finiteVolume import solve
    solve(
        fvm.ddt(rho, h) + fvm.div(phi, h) -
        fvm.laplacian(turbulence.alphaEff(), h) == DpDt)
    thermo.correct()
    pass
コード例 #12
0
def _UEqn(U, rho, phi, turbulence, p):
    from Foam import fvm
    UEqn = fvm.ddt(rho, U) + fvm.div(phi, U) + turbulence.divDevRhoReff(U)

    from Foam import fvc
    from Foam.finiteVolume import solve
    solve(UEqn == -fvc.grad(p))
    return UEqn
コード例 #13
0
ファイル: __init__.py プロジェクト: asimurzin/sonicTurbFlux
def _UEqn( U, rho, phi, turbulence, p ):
    from Foam import fvm    
    UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) + turbulence.divDevRhoReff( U )
    
    from Foam import fvc
    from Foam.finiteVolume import solve
    solve( UEqn == -fvc.grad( p ) )
    return UEqn
コード例 #14
0
def Ueqn( phi, U, p, turbulence ):
    from Foam import fvm, fvc
    UEqn = fvm.div( phi, U ) + turbulence.divR( U ) 
    UEqn.relax()
    from Foam.finiteVolume import solve
    solve( UEqn == -fvc.grad(p) )
           
    return UEqn
コード例 #15
0
ファイル: __init__.py プロジェクト: asimurzin/sonicFlux
def _eEqn( rho, e, phi, turbulence, p, thermo ):
    from Foam import fvm, fvc
    from Foam.finiteVolume import solve
    solve( fvm.ddt( rho, e ) + fvm.div( phi, e ) - fvm.laplacian( turbulence.alphaEff(), e )
           == - p * fvc.div( phi / fvc.interpolate( rho ) ) )

    thermo.correct()
    pass
コード例 #16
0
ファイル: __init__.py プロジェクト: asimurzin/rhoPisoFlux
def _pEqn(rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p, DpDt,
          cumulativeContErr, corr, nCorr, nOuterCorr, transonic):
    rho.ext_assign(thermo.rho())

    rUA = 1.0 / UEqn.A()
    U.ext_assign(rUA * UEqn.H())

    from Foam import fvc, fvm
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import surfaceScalarField
    if transonic:
        phid = surfaceScalarField(
            word("phid"),
            fvc.interpolate(psi) * ((fvc.interpolate(U) & mesh.Sf()) +
                                    fvc.ddtPhiCorr(rUA, rho, U, phi)))

        for nonOrth in range(nNonOrthCorr + 1):
            pEqn = fvm.ddt(psi, p) + fvm.div(phid, p) - fvm.laplacian(
                rho * rUA, p)

            pEqn.solve()

            if nonOrth == nNonOrthCorr:
                phi == pEqn.flux()
                pass
            pass
        pass
    else:
        phi.ext_assign(
            fvc.interpolate(rho) * ((fvc.interpolate(U) & mesh.Sf()) +
                                    fvc.ddtPhiCorr(rUA, rho, U, phi)))

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

            pEqn.solve()

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

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

    from Foam.finiteVolume.cfdTools.compressible import compressibleContinuityErrs
    cumulativeContErr = compressibleContinuityErrs(rho, thermo,
                                                   cumulativeContErr)

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

    DpDt.ext_assign(
        fvc.DDt(surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)),
                p))

    return cumulativeContErr
コード例 #17
0
def _UEqn(phi, U, p, turbulence, pZones, pressureImplicitPorosity, nUCorr, eqnResidual, maxResidual):

    from Foam import fvm, fvc

    # Construct the Momentum equation

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

    UEqn = turbulence.divDevRhoReff(U) + (fvm.div(phi, U) - fvm.Sp(fvc.div(phi), U))

    UEqn.relax()

    # Include the porous media resistance and solve the momentum equation
    # either implicit in the tensorial resistance or transport using by
    # including the spherical part of the resistance in the momentum diagonal

    trAU = None
    trTU = None
    if pressureImplicitPorosity:
        from Foam.OpenFOAM import sphericalTensor, tensor

        tTU = tensor(sphericalTensor.I) * UEqn.A()

        pZones.addResistance(UEqn, tTU)

        trTU = tTU.inv()

        from Foam.OpenFOAM import word

        trTU.rename(word("rAU"))

        for UCorr in range(nUCorr):
            U.ext_assign(trTU & (UEqn.H() - fvc.grad(p)))
            pass

        U.correctBoundaryConditions()
    else:
        pZones.addResistance(UEqn)

        from Foam.finiteVolume import solve

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

        maxResidual = max(eqnResidual, maxResidual)

        trAU = 1.0 / UEqn.A()

        from Foam.OpenFOAM import word

        trAU.rename(word("rAU"))

        pass

    return UEqn, trTU, trAU, eqnResidual, maxResidual
コード例 #18
0
def _UEqn(phi, U, p, turbulence, pZones, pressureImplicitPorosity, nUCorr,
          eqnResidual, maxResidual):

    from Foam import fvm, fvc
    # Construct the Momentum equation

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

    UEqn = turbulence.divDevRhoReff(U) + (fvm.div(phi, U) -
                                          fvm.Sp(fvc.div(phi), U))

    UEqn.relax()

    # Include the porous media resistance and solve the momentum equation
    # either implicit in the tensorial resistance or transport using by
    # including the spherical part of the resistance in the momentum diagonal

    trAU = None
    trTU = None
    if pressureImplicitPorosity:
        from Foam.OpenFOAM import sphericalTensor, tensor
        tTU = tensor(sphericalTensor.I) * UEqn.A()

        pZones.addResistance(UEqn, tTU)

        trTU = tTU.inv()

        from Foam.OpenFOAM import word
        trTU.rename(word("rAU"))

        gradp = fvc.grad(p)

        for UCorr in range(nUCorr):
            U.ext_assign(trTU & (UEqn.H() - gradp))
            pass

        U.correctBoundaryConditions()
    else:
        pZones.addResistance(UEqn)

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

        maxResidual = max(eqnResidual, maxResidual)

        trAU = 1.0 / UEqn.A()

        from Foam.OpenFOAM import word
        trAU.rename(word("rAU"))

        pass

    return UEqn, trTU, trAU, eqnResidual, maxResidual
コード例 #19
0
def fun_hEqn( mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter ):
    from Foam import fvm
    hEqn = fvm.ddt( rho, h ) + fvm.div( phi, h ) - fvm.laplacian( turbulence.alphaEff(), h ) == DpDt

    hEqn.relax()
    hEqn.solve( mesh.solver( h.select( finalIter ) ) )

    thermo.correct()
    
    pass
コード例 #20
0
ファイル: __init__.py プロジェクト: asimurzin/simpleFlux
def Ueqn(phi, U, p, turbulence):
    from Foam import fvm, fvc

    UEqn = fvm.div(phi, U) + turbulence.divR(U)
    UEqn.relax()
    from Foam.finiteVolume import solve

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

    return UEqn
コード例 #21
0
ファイル: __init__.py プロジェクト: asimurzin/buoyantPisoFlux
def _hEqn( rho, h, phi, turbulence, thermo, DpDt ):
    from Foam import fvm
    hEqn = fvm.ddt( rho, h ) + fvm.div(phi, h) - fvm.laplacian( turbulence.alphaEff(), h ) == DpDt 

    hEqn.relax()
    hEqn.solve()

    thermo.correct()
    
    return hEqn
コード例 #22
0
ファイル: __init__.py プロジェクト: asimurzin/sonicFlux
def _eEqn(rho, e, phi, turbulence, p, thermo):
    from Foam import fvm, fvc
    from Foam.finiteVolume import solve
    solve(
        fvm.ddt(rho, e) + fvm.div(phi, e) -
        fvm.laplacian(turbulence.alphaEff(), e) == -p *
        fvc.div(phi / fvc.interpolate(rho)))

    thermo.correct()
    pass
コード例 #23
0
ファイル: __init__.py プロジェクト: asimurzin/simpleFlux
def Ueqn( phi, U, p, turbulence, eqnResidual, maxResidual ):
    from Foam import fvm, fvc
    UEqn = fvm.div( phi, U ) + turbulence.divDevReff( U ) 

    UEqn.relax()
    
    from Foam.finiteVolume import solve
    eqnResidual = solve( UEqn == -fvc.grad(p) ).initialResidual()
    maxResidual = max(eqnResidual, maxResidual)
      
    return UEqn, eqnResidual, maxResidual
コード例 #24
0
ファイル: __init__.py プロジェクト: asimurzin/simpleFlux
def Ueqn(phi, U, p, turbulence, eqnResidual, maxResidual):
    from Foam import fvm, fvc
    UEqn = fvm.div(phi, U) + turbulence.divDevReff(U)

    UEqn.relax()

    from Foam.finiteVolume import solve
    eqnResidual = solve(UEqn == -fvc.grad(p)).initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    return UEqn, eqnResidual, maxResidual
コード例 #25
0
def Ueqn( mesh, phi, U, rho, p, g, turbulence, eqnResidual, maxResidual ):
    from Foam import fvm, fvc
    UEqn = fvm.div( phi, U ) + turbulence.divDevRhoReff( U )
    UEqn.relax()
    
    from Foam.finiteVolume import solve
    eqnResidual = solve( UEqn() == fvc.reconstruct( fvc.interpolate( rho )*( g & mesh.Sf() ) - fvc.snGrad( p ) * mesh.magSf() ) ).initialResidual()
    
    maxResidual = max(eqnResidual, maxResidual)
       
    return UEqn, eqnResidual, maxResidual
コード例 #26
0
def fun_hEqn(mesh, rho, h, phi, DpDt, thermo, turbulence, finalIter):
    from Foam import fvm
    hEqn = fvm.ddt(rho, h) + fvm.div(phi, h) - fvm.laplacian(
        turbulence.alphaEff(), h) == DpDt

    hEqn.relax()
    hEqn.solve(mesh.solver(h.select(finalIter)))

    thermo.correct()

    pass
コード例 #27
0
ファイル: __init__.py プロジェクト: asimurzin/buoyantPisoFlux
def _hEqn(rho, h, phi, turbulence, thermo, DpDt):
    from Foam import fvm
    hEqn = fvm.ddt(rho, h) + fvm.div(phi, h) - fvm.laplacian(
        turbulence.alphaEff(), h) == DpDt

    hEqn.relax()
    hEqn.solve()

    thermo.correct()

    return hEqn
コード例 #28
0
def fun_UEqn( phi, U, turbulence, pd, rho, gh, eqnResidual, maxResidual ):
    from Foam import fvm, fvc 
    UEqn = fvm.div(phi, U) - fvm.Sp(fvc.div(phi), U)+ turbulence.divDevRhoReff(U)

    UEqn.relax();

    from Foam.finiteVolume import solve
    eqnResidual = solve( UEqn == -fvc.grad( pd ) - fvc.grad( rho ) * gh ).initialResidual()

    maxResidual = max(eqnResidual, maxResidual);
    
    return UEqn, eqnResidual, maxResidual
コード例 #29
0
def fun_UEqn( phi, U, p_rgh, turbulence, mesh, ghf, rhok, eqnResidual, maxResidual, momentumPredictor ):
    from Foam import fvm, fvc
    UEqn = fvm.div( phi, U ) + turbulence.divDevReff( U ) 
    UEqn.relax()
    
    if momentumPredictor:
       from Foam.finiteVolume import solve
       eqnResidual = solve( UEqn == fvc.reconstruct( ( - ghf * fvc.snGrad( rhok ) - fvc.snGrad( p_rgh ) )* mesh.magSf() ) ).initialResidual()
       maxResidual = max(eqnResidual, maxResidual)
       pass
       
    return UEqn, eqnResidual, maxResidual
コード例 #30
0
def fun_UEqn( turbulence, phi, U, rho, g, p, ghf, p_rgh, mesh, eqnResidual, maxResidual, momentumPredictor ):
    from Foam import fvm, fvc 
    UEqn = fvm.div(phi, U) + turbulence.divDevRhoReff(U)

    UEqn.relax()
    if momentumPredictor:
       from Foam.finiteVolume import solve
       eqnResidual = solve( UEqn == fvc.reconstruct( (- ghf * fvc.snGrad( rho ) - fvc.snGrad( p_rgh ) ) * mesh.magSf() ) ).initialResidual()

       maxResidual = max(eqnResidual, maxResidual)
       pass
    
    return UEqn, eqnResidual, maxResidual
コード例 #31
0
def _hEqn( phi, h, turbulence, rho, p, thermo, eqnResidual, maxResidual ):
    from Foam import fvc, fvm
    hEqn = fvm.div( phi, h ) - fvm.Sp( fvc.div( phi ), h ) - fvm.laplacian( turbulence.alphaEff(), h ) \
            ==  fvc.div( phi / fvc.interpolate( rho ) * fvc.interpolate( p ) ) - p * fvc.div( phi / fvc.interpolate( rho ) ) 

    hEqn.relax()

    eqnResidual = hEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    thermo.correct()
    
    return hEqn, eqnResidual, maxResidual
コード例 #32
0
def solveMomentumEquation( momentumPredictor, U, rho, phi, pd, gh, turb ):
    # Solve the Momentum equation
    from Foam import fvm
    UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) + turb.divDevRhoReff( U )

    UEqn.relax()
    if momentumPredictor :
        from Foam import fvc
        from Foam.finiteVolume import solve
        solve( UEqn == -fvc.grad(pd) - fvc.grad(rho) * gh )
        pass
    
    return UEqn
コード例 #33
0
def fun_pEqn( runTime, mesh, UEqn, p, p_rgh, phi, U, rho, rho1, rho2, rho10, rho20, gh, ghf, dgdt, pMin, \
              psi1, psi2, alpha1, alpha2, interface, transonic, oCorr, nOuterCorr, corr, nCorr, nNonOrthCorr ):
    rUA = 1.0/UEqn.A()
    
    from Foam import fvc
    rUAf = fvc.interpolate( rUA )

    p_rghEqnComp = None

    from Foam import fvm
    if transonic:
        p_rghEqnComp = fvm.ddt( p_rgh ) + fvm.div( phi, p_rgh ) - fvm.Sp( fvc.div( phi ), p_rgh )
        pass
    else:
        p_rghEqnComp = fvm.ddt( p_rgh ) + fvc.div( phi, p_rgh ) - fvc.Sp( fvc.div( phi ), p_rgh ) 
        pass

    U.ext_assign( rUA * UEqn.H() )

    from Foam.finiteVolume import surfaceScalarField
    from Foam.OpenFOAM import word
    phiU = surfaceScalarField( word( "phiU" ),
                               ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) )

    phi.ext_assign(phiU + ( fvc.interpolate( interface.sigmaK() ) * fvc.snGrad( alpha1 ) - ghf * fvc.snGrad( rho ) ) * rUAf * mesh.magSf() )

    from Foam.finiteVolume import solve
    from Foam.OpenFOAM import scalar
    for nonOrth in range( nNonOrthCorr +1 ):
        p_rghEqnIncomp = fvc.div( phi ) - fvm.laplacian( rUAf, p_rgh ) 
        
        solve( ( alpha1.ext_max( scalar( 0 ) ) * ( psi1 / rho1 ) + alpha2.ext_max( scalar( 0 ) ) * ( psi2 / rho2 ) ) *p_rghEqnComp() + p_rghEqnIncomp,
               mesh.solver( p_rgh.select( oCorr == ( nOuterCorr - 1 ) and corr == ( nCorr-1 ) and nonOrth == nNonOrthCorr )  ) )

        if nonOrth == nNonOrthCorr:
            dgdt.ext_assign( ( alpha2.pos() * ( psi2 / rho2 ) - alpha1.pos() * ( psi1 / rho1 ) ) * ( p_rghEqnComp & p_rgh ) )
            phi.ext_assign( phi + p_rghEqnIncomp.flux() )
            pass

    U.ext_assign( U + rUA * fvc.reconstruct( ( phi - phiU ) / rUAf ) )
    U.correctBoundaryConditions()

    p.ext_assign( ( ( p_rgh + gh * ( alpha1 * rho10 + alpha2 * rho20 ) ) /( 1.0 - gh * ( alpha1 * psi1 + alpha2 * psi2 ) ) ).ext_max( pMin ) )

    rho1.ext_assign( rho10 + psi1 * p )
    rho2.ext_assign( rho20 + psi2 * p )

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "max(U) " << U.mag().ext_max().value() << nl
    ext_Info() << "min(p_rgh) " << p_rgh.ext_min().value() << nl
    pass
コード例 #34
0
def solveEnthalpyEquation( rho, DpDt, phi, turb, thermo ):
    h = thermo.h()
    
    from Foam import fvm
    hEqn = ( ( fvm.ddt( rho, h ) + fvm.div( phi, h ) - fvm.laplacian( turb.alphaEff(), h ) ) == DpDt )
    hEqn.relax()
    hEqn.solve()
    thermo.correct()
    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Min/max T:" << thermo.T().ext_min() << ' ' \
        << thermo.T().ext_max() << nl
        
    return hEqn
コード例 #35
0
def _Ueqn( U, phi, turbulence, p, rhok, g, mesh, momentumPredictor ):
    from Foam import fvm
    # Solve the momentum equation

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

    UEqn.relax()

    from Foam.finiteVolume import solve
    from Foam import fvc
    if momentumPredictor:
       solve( UEqn == fvc.reconstruct( ( fvc.interpolate( rhok ) * ( g & mesh.Sf() ) - fvc.snGrad( p ) * mesh.magSf() ) ) )
       
    return UEqn
コード例 #36
0
def fun_UEqn( rho, U, phi, ghf, p_rgh, turb, mesh, momentumPredictor ) :
    # Solve the Momentum equation
    from Foam import fvm
    UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) + turb.divDevRhoReff( U )

    UEqn.relax()
    
    if momentumPredictor :
        from Foam import fvc
        from Foam.finiteVolume import solve
        solve( UEqn == fvc.reconstruct( ( -ghf * fvc.snGrad( rho ) - fvc.snGrad( p_rgh ) )*mesh.magSf() ) )
        pass
    
    return UEqn
コード例 #37
0
def fun_UEqn( mesh, rho, phi, U, p_rgh, ghf, turbulence, finalIter, momentumPredictor ):
    
    from Foam import fvm, fvc    
    # Solve the Momentum equation
    UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) + turbulence.divDevRhoReff( U )

    UEqn.relax()

    if momentumPredictor:
       from Foam.finiteVolume import solve
       solve( UEqn == fvc.reconstruct( ( - ghf * fvc.snGrad( rho ) - fvc.snGrad( p_rgh ) ) * mesh.magSf() ), 
              mesh.solver( U.select( finalIter) ) );

    return UEqn
コード例 #38
0
def _Ueqn( U, phi, turbulence, p, rhok, g, mesh, momentumPredictor ):
    from Foam import fvm
    # Solve the momentum equation

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

    UEqn.relax()

    from Foam.finiteVolume import solve
    from Foam import fvc
    if momentumPredictor:
       solve( UEqn == fvc.reconstruct( ( fvc.interpolate( rhok ) * ( g & mesh.Sf() ) - fvc.snGrad( p ) * mesh.magSf() ) ) )
       
    return UEqn
コード例 #39
0
def fun_UEqn( rho, U, phi, g, p, turb, mesh, momentumPredictor ) :
    # Solve the Momentum equation
    from Foam import fvm
    UEqn = fvm.ddt( rho, U ) + fvm.div( phi, U ) + turb.divDevRhoReff( U )

    UEqn.relax()
    
    if momentumPredictor :
        from Foam import fvc
        from Foam.finiteVolume import solve
        solve( UEqn == fvc.reconstruct( fvc.interpolate( rho ) * ( g & mesh.Sf() )  - fvc.snGrad( p ) * mesh.magSf() ) )
        pass
    
    return UEqn
コード例 #40
0
ファイル: __init__.py プロジェクト: asimurzin/rhoPisoFlux
def _pEqn( rho, thermo, UEqn, nNonOrthCorr, psi, U, mesh, phi, p, DpDt, cumulativeContErr, corr, nCorr, nOuterCorr, transonic ):
    rho.ext_assign( thermo.rho() )

    rUA = 1.0/UEqn.A()
    U.ext_assign( rUA * UEqn.H() )

    from Foam import fvc, fvm
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import surfaceScalarField
    if transonic: 
       phid = surfaceScalarField( word( "phid" ), 
                                  fvc.interpolate( psi ) * ( ( fvc.interpolate( U ) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) ) )
       
       for nonOrth in range( nNonOrthCorr + 1 ) :
           pEqn = fvm.ddt( psi, p ) + fvm.div( phid, p ) - fvm.laplacian( rho * rUA, p )
           
           pEqn.solve()
           
           if nonOrth == nNonOrthCorr:
              phi == pEqn.flux()
              pass
           pass
       pass
    else:
       phi.ext_assign( fvc.interpolate( rho ) * ( ( fvc.interpolate(U) & mesh.Sf() ) + fvc.ddtPhiCorr( rUA, rho, U, phi ) ) )
       
       for nonOrth in range( nNonOrthCorr + 1 ) :
           pEqn = fvm.ddt( psi, p ) + fvc.div( phi ) - fvm.laplacian( rho * rUA, p )
           
           pEqn.solve()
                      
           if nonOrth == nNonOrthCorr:
              phi.ext_assign( phi + pEqn.flux() )
              pass
           pass
       pass
        
    from Foam.finiteVolume.cfdTools.compressible import rhoEqn
    rhoEqn( rho, phi )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleContinuityErrs
    cumulativeContErr = compressibleContinuityErrs( rho, thermo, cumulativeContErr )

    U.ext_assign( U - rUA * fvc.grad( p ) )
    U.correctBoundaryConditions()
    
    DpDt.ext_assign( fvc.DDt( surfaceScalarField( word( "phiU" ), phi / fvc.interpolate( rho ) ), p ) )

    return cumulativeContErr
コード例 #41
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleDyMFlux
def _UEqn( mesh, phi, U, p, turbulence, ocorr, nOuterCorr, momentumPredictor ):
    from Foam import fvm
    UEqn = fvm.ddt(U) + fvm.div(phi, U) + turbulence.divDevReff( U ) 
    
    if ocorr != nOuterCorr - 1:
       UEqn.relax()
       pass
    
    if momentumPredictor:
       from Foam.finiteVolume import solve
       from Foam import fvc
       solve( UEqn == -fvc.grad( p ) )
       pass
    
    return UEqn
コード例 #42
0
def _TEqn( turbulence, T, phi, rhok, beta, TRef, Pr, Prt ):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import volScalarField
    kappaEff = volScalarField( word( "kappaEff" ),
                               turbulence.nu() / Pr + turbulence.ext_nut() / Prt )
    from Foam import fvc, fvm
    TEqn = fvm.ddt( T ) + fvm.div( phi, T ) - fvm.laplacian( kappaEff, T ) 

    TEqn.relax()

    TEqn.solve()

    rhok.ext_assign( 1.0 - beta * ( T - TRef ) )
    
    return TEqn, kappaEff
コード例 #43
0
def _TEqn( turbulence, T, phi, rhok, beta, TRef, Pr, Prt ):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import volScalarField
    kappaEff = volScalarField( word( "kappaEff" ),
                               turbulence.nu() / Pr + turbulence.ext_nut() / Prt )
    from Foam import fvc, fvm
    TEqn = fvm.ddt( T ) + fvm.div( phi, T ) - fvm.laplacian( kappaEff, T ) 

    TEqn.relax()

    TEqn.solve()

    rhok.ext_assign( 1.0 - beta * ( T - TRef ) )
    
    return TEqn, kappaEff
コード例 #44
0
ファイル: __init__.py プロジェクト: asimurzin/pimpleDyMFlux
def _UEqn(mesh, phi, U, p, turbulence, ocorr, nOuterCorr, momentumPredictor):
    from Foam import fvm
    UEqn = fvm.ddt(U) + fvm.div(phi, U) + turbulence.divDevReff(U)

    if ocorr != nOuterCorr - 1:
        UEqn.relax()
        pass

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

    return UEqn
コード例 #45
0
def fun_UEqn(mesh, rho, phi, U, p_rgh, ghf, turbulence, finalIter,
             momentumPredictor):

    from Foam import fvm, fvc
    # Solve the Momentum equation
    UEqn = fvm.ddt(rho, U) + fvm.div(phi, U) + turbulence.divDevRhoReff(U)

    UEqn.relax()

    if momentumPredictor:
        from Foam.finiteVolume import solve
        solve(
            UEqn == fvc.reconstruct(
                (-ghf * fvc.snGrad(rho) - fvc.snGrad(p_rgh)) * mesh.magSf()),
            mesh.solver(U.select(finalIter)))

    return UEqn
コード例 #46
0
def fun_hEqn( mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr, nOuterCorr ):
    from Foam import fvm
    hEqn = fvm.ddt(rho, h) + fvm.div( phi, h ) - fvm.laplacian( turbulence.alphaEff(), h ) == DpDt

    if oCorr == nOuterCorr-1:
       hEqn.relax()
       from Foam.OpenFOAM import word
       hEqn.solve(mesh.solver( word( "hFinal" ) ) )
       pass
    else:
       hEqn.relax()
       hEqn.solve()
       pass
    thermo.correct()
    pass
    
    return hEqn
コード例 #47
0
def fun_TEqn( turbulence, phi, T, rhok, beta, TRef, Pr, Prt, eqnResidual, maxResidual ):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import volScalarField
    kappaEff = volScalarField( word( "kappaEff" ),
                               turbulence.nu() / Pr + turbulence.ext_nut() / Prt )

    from Foam import fvc, fvm
    TEqn = fvm.div( phi, T ) - fvm.Sp( fvc.div( phi ), T ) - fvm.laplacian( kappaEff, T ) 

    TEqn.relax()

    eqnResidual = TEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    rhok.ext_assign( 1.0 - beta * ( T - TRef ) )
    
    return TEqn, kappaEff
コード例 #48
0
def fun_hEqn( turbulence, phi, h, rho, radiation, p, thermo, eqnResidual, maxResidual  ):
    
    from Foam import fvc, fvm    
    left_exp = fvm.div( phi, h ) - fvm.Sp( fvc.div( phi ), h ) - fvm.laplacian( turbulence.alphaEff(), h )
    right_exp = fvc.div( phi/fvc.interpolate( rho )*fvc.interpolate( p ) ) - p*fvc.div( phi/fvc.interpolate( rho ) ) + radiation.Sh( thermo() )
    
    hEqn = (left_exp == right_exp )

    hEqn.relax()

    eqnResidual = hEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    thermo.correct()

    radiation.correct()
    
    return hEqn, eqnResidual, maxResidual
コード例 #49
0
def fun_hEqn( turbulence, phi, h, rho, radiation, p, thermo, eqnResidual, maxResidual  ):
    
    from Foam import fvc, fvm    
    left_exp = fvm.div( phi, h ) - fvm.Sp( fvc.div( phi ), h ) - fvm.laplacian( turbulence.alphaEff(), h )
    right_exp = fvc.div( phi/fvc.interpolate( rho )*fvc.interpolate( p ) ) - p*fvc.div( phi/fvc.interpolate( rho ) ) + radiation.Sh( thermo() )
    
    hEqn = (left_exp == right_exp )

    hEqn.relax()

    eqnResidual = hEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    thermo.correct()

    radiation.correct()
    
    return hEqn, eqnResidual, maxResidual
コード例 #50
0
def fun_hEqn(mesh, rho, h, phi, turbulence, DpDt, thermo, oCorr, nOuterCorr):
    from Foam import fvm
    hEqn = fvm.ddt(rho, h) + fvm.div(phi, h) - fvm.laplacian(
        turbulence.alphaEff(), h) == DpDt

    if oCorr == nOuterCorr - 1:
        hEqn.relax()
        from Foam.OpenFOAM import word
        hEqn.solve(mesh.solver(word("hFinal")))
        pass
    else:
        hEqn.relax()
        hEqn.solve()
        pass
    thermo.correct()
    pass

    return hEqn
コード例 #51
0
ファイル: __init__.py プロジェクト: asimurzin/rhoPisoFlux
def _UEqn(U, rho, phi, turbulence, p, momentumPredictor):
    from Foam import fvm
    # Solve the Momentum equation

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

    UEqn = turbulence.divDevRhoReff(U) + (fvm.ddt(rho, U) + fvm.div(phi, U))

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

    return UEqn
コード例 #52
0
def _UEqn(phi, U, p, turbulence, eqnResidual, maxResidual):
    from Foam import fvm, fvc
    # Solve the Momentum equation

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

    UEqn.relax()

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

    maxResidual = max(eqnResidual, maxResidual)

    return UEqn, eqnResidual, maxResidual
コード例 #53
0
def _hEqn(thermo, phi, h, turbulence, p, rho, eqnResidual, maxResidual):
    from Foam.finiteVolume import fvScalarMatrix
    from Foam import fvc, fvm

    left_expr = fvm.div(phi, h) - fvm.Sp(fvc.div(phi), h) - fvm.laplacian(
        turbulence.alphaEff(), h)
    from Foam.OpenFOAM import word
    right_expr = fvc.div(phi / fvc.interpolate(rho) * fvc.interpolate(
        p, word("div(U,p)"))) - p * fvc.div(phi / fvc.interpolate(rho))

    hEqn = (left_expr == right_expr)

    hEqn.relax()

    eqnResidual = hEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    thermo.correct()

    return hEqn, eqnResidual, maxResidual
コード例 #54
0
ファイル: __init__.py プロジェクト: asimurzin/interFlux
def _UEqn( mesh, alpha1, U, p, rho, rhoPhi, turbulence, g, twoPhaseProperties, interface, momentumPredictor ):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import surfaceScalarField
    from Foam import fvc
    muEff = surfaceScalarField( word( "muEff" ),
                                twoPhaseProperties.muf() + fvc.interpolate( rho * turbulence.ext_nut() ) )
    from Foam import fvm

    UEqn = fvm.ddt( rho, U ) + fvm.div( rhoPhi, U ) - fvm.laplacian( muEff, U ) - ( fvc.grad( U ) & fvc.grad( muEff ) )
    
    UEqn.relax()

    if momentumPredictor:
       from Foam.finiteVolume import solve
       solve( UEqn == \
                   fvc.reconstruct( fvc.interpolate( rho ) * ( g & mesh.Sf() ) + \
                                    ( fvc.interpolate( interface.sigmaK() ) * fvc.snGrad( alpha1 ) - fvc.snGrad( p ) ) * mesh.magSf() ) )
       pass
    
    return UEqn
コード例 #55
0
def fun_TEqn(turbulence, phi, T, rhok, beta, TRef, Pr, Prt, eqnResidual,
             maxResidual):
    from Foam.OpenFOAM import word
    from Foam.finiteVolume import volScalarField
    kappaEff = volScalarField(
        word("kappaEff"),
        turbulence.nu() / Pr + turbulence.ext_nut() / Prt)

    from Foam import fvc, fvm
    TEqn = fvm.div(phi, T) - fvm.Sp(fvc.div(phi), T) - fvm.laplacian(
        kappaEff, T)

    TEqn.relax()

    eqnResidual = TEqn.solve().initialResidual()
    maxResidual = max(eqnResidual, maxResidual)

    rhok.ext_assign(1.0 - beta * (T - TRef))

    return TEqn, kappaEff