示例#1
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
示例#2
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