Пример #1
0
def createFields(runTime, mesh, pimple):
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl

    pThermo = man.basicPsiThermo.New(mesh)

    p = man.volScalarField(pThermo.p(), man.Deps(pThermo))
    h = man.volScalarField(pThermo.h(), man.Deps(pThermo))
    psi = man.volScalarField(pThermo.psi(), man.Deps(pThermo))

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        man.volScalarField(pThermo.rho(), man.Deps(pThermo)))

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    phi = man.compressibleCreatePhi(runTime, mesh, U, rho)

    rhoMax = ref.dimensionedScalar(pimple.dict().lookup(ref.word("rhoMax")))
    rhoMin = ref.dimensionedScalar(pimple.dict().lookup(ref.word("rhoMin")))

    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New(rho, U, phi, pThermo)

    ref.ext_Info() << "Creating field dpdt\n" << ref.nl
    dpdt = man.volScalarField(ref.word("dpdt"), man.fvc.ddt(p))

    ref.ext_Info() << "Creating field kinetic energy K\n" << ref.nl
    K = man.volScalarField(ref.word("K"),
                           man.volScalarField(0.5 * U.magSqr(), man.Deps(U)))

    return pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K
Пример #2
0
def _createFields(runTime, mesh):
    # Load boundary condition
    from BCs import rho

    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    thermo = man.basicPsiThermo.New(mesh)

    p = man.volScalarField(thermo.p(), man.Deps(thermo))
    e = man.volScalarField(thermo.e(), man.Deps(thermo))
    T = man.volScalarField(thermo.T(), man.Deps(thermo))
    psi = man.volScalarField(thermo.psi(), man.Deps(thermo))
    mu = man.volScalarField(thermo.mu(), man.Deps(thermo))

    inviscid = True
    if mu.internalField().max() > 0.0:
        inviscid = False
        pass

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    pbf, rhoBoundaryTypes = _rhoBoundaryTypes(p)

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
        man.volScalarField(thermo.rho(), man.Deps(thermo)), rhoBoundaryTypes)
    rhoU = man.volVectorField(
        man.IOobject(ref.word("rhoU"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE), rho * U)
    rhoE = man.volScalarField(
        man.IOobject(ref.word("rhoE"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE),
        rho * (e + man.volScalarField(0.5 * U.magSqr(), man.Deps(U))))

    pos = man.surfaceScalarField(
        man.IOobject(ref.word("pos"), ref.fileName(runTime.timeName()), mesh),
        mesh, ref.dimensionedScalar(ref.word("pos"), ref.dimless, 1.0))

    neg = man.surfaceScalarField(
        man.IOobject(ref.word("neg"), ref.fileName(runTime.timeName()), mesh),
        mesh, ref.dimensionedScalar(ref.word("neg"), ref.dimless, -1.0))

    phi = man.surfaceScalarField(
        ref.word("phi"),
        man.surfaceVectorField(mesh.Sf(), man.Deps(mesh))
        & man.fvc.interpolate(rhoU))

    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New(rho, U, phi, thermo)

    return thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid, phi, turbulence
Пример #3
0
def readThermodynamicProperties( runTime, mesh ):
    ref.ext_Info() << "Reading thermodynamicProperties\n" << ref.nl

    thermodynamicProperties = man.IOdictionary( man.IOobject( ref.word( "thermodynamicProperties" ),
                                                              ref.fileName( runTime.constant() ),
                                                              mesh,
                                                              ref.IOobject.MUST_READ_IF_MODIFIED,
                                                              ref.IOobject.NO_WRITE ) )
    rho0 = ref.dimensionedScalar( thermodynamicProperties.lookup( ref.word( "rho0" ) ) )
    p0 = ref.dimensionedScalar( thermodynamicProperties.lookup( ref.word( "p0" ) ) )
    psi = ref.dimensionedScalar( thermodynamicProperties.lookup(ref.word( "psi" ) ) )
    # Density offset, i.e. the constant part of the density
    rhoO = ref.dimensionedScalar( ref.word( "rhoO" ), rho0 - psi * p0 )
  
    return thermodynamicProperties, rho0, p0, psi, rhoO
Пример #4
0
def setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                          phiFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation ):
    mesh = fluidRegions[ i ]

    thermo = thermoFluid[ i ]
    rho = rhoFluid[ i ]
    K = KFluid[ i ]
    U = UFluid[ i ]
    phi = phiFluid[ i ]
    
    turb = turbulence[ i ]
    DpDt = DpDtFluid[ i ]

    p = thermo.p()
    psi = thermo.psi()
    h = thermo.h()
    
    p_rgh = p_rghFluid[ i ]
    gh = ghFluid[ i ]
    ghf = ghfFluid[ i ]
    
    rad = radiation[ i ]
    
    initialMass = ref.dimensionedScalar( ref.word( "massIni" ), ref.dimMass, initialMassFluid[ i ] )

    return mesh, thermo, rho, K, U, phi, turb, DpDt, p, psi, h, initialMass, p_rgh, gh, ghf, rad
Пример #5
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Creating face flux\n" << ref.nl
    phi = man.surfaceScalarField(
        man.IOobject(ref.word("phi"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE), mesh,
        ref.dimensionedScalar(ref.word("zero"),
                              mesh.Sf().dimensions() * U.dimensions(), 0.0))

    laminarTransport = man.singlePhaseTransportModel(U, phi)

    turbulence = man.incompressible.RASModel.New(U, phi, laminarTransport)

    transportProperties = man.IOdictionary(
        man.IOobject(ref.word("transportProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE))
    Ubar = ref.dimensionedVector(transportProperties.lookup(ref.word("Ubar")))

    flowDirection = (Ubar / Ubar.mag()).ext_value()
    flowMask = flowDirection.sqr()

    gradP = ref.dimensionedVector(ref.word("gradP"),
                                  ref.dimensionSet(0.0, 1.0, -2.0, 0.0, 0.0),
                                  ref.vector(0.0, 0.0, 0.0))

    return U, phi, laminarTransport, turbulence, Ubar, gradP, flowDirection, flowMask
Пример #6
0
def _createFields( runTime, mesh ):
    ref.ext_Info() << "Reading field T\n" << ref.nl
    T = man.volScalarField( man.IOobject( ref.word( "T" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                             mesh )

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )


    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )


    ref.ext_Info() << "Reading diffusivity D\n" << ref.nl

    DT = ref.dimensionedScalar( transportProperties.lookup( ref.word( "DT" ) ) )

    phi = man.createPhi( runTime, mesh, U )
           
    return T, U, transportProperties, DT, phi 
Пример #7
0
def _createFields(runTime, mesh, potentialFlow, args):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(ref.word("p"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE), mesh)

    p << ref.dimensionedScalar(ref.word("zero"), p.dimensions(), 0.0)

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    U << ref.dimensionedVector(ref.word("0"), U.dimensions(), ref.vector.zero)

    phi = man.surfaceScalarField(
        man.IOobject(ref.word("phi"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
        man.fvc.interpolate(U)
        & man.surfaceVectorField(mesh.Sf(), man.Deps(mesh)))

    if args.optionFound(ref.word("initialiseUBCs")):
        U.correctBoundaryConditions()
        phi << (ref.fvc.interpolate(U) & mesh.Sf())
        pass

    pRefCell = 0
    pRefValue = 0.0

    pRefCell, pRefValue = ref.setRefCell(p, potentialFlow, pRefCell, pRefValue)

    return p, U, phi, pRefCell, pRefValue
Пример #8
0
def _createFields(runTime, mesh, potentialFlow):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(
            ref.word("p"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE
        ),
        mesh,
    )

    p << ref.dimensionedScalar(ref.word("zero"), p.dimensions(), 0.0)

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(
            ref.word("U"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE
        ),
        mesh,
    )

    U << ref.dimensionedVector(ref.word("0"), U.dimensions(), ref.vector.zero)

    phi = man.surfaceScalarField(
        man.IOobject(
            ref.word("phi"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE
        ),
        man.fvc.interpolate(U) & man.surfaceVectorField(mesh.Sf(), man.Deps(mesh)),
    )

    pRefCell = 0
    pRefValue = 0.0

    pRefCell, pRefValue = ref.setRefCell(p, potentialFlow, pRefCell, pRefValue)

    return p, U, phi, pRefCell, pRefValue
def setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, kappaFluid, UFluid, phiFluid, turbulence, \
                          initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation, pRefCellFluid, pRefValueFluid ):
    mesh = fluidRegions[ i ]

    thermo = thermoFluid[ i ]
    rho = rhoFluid[ i ]
    kappa = kappaFluid[ i ]
    U = UFluid[ i ]
    phi = phiFluid[ i ]
    
    turb = turbulence[ i ]

    p = thermo.p()
    psi = thermo.psi()
    h = thermo.h()
    
    p_rgh = p_rghFluid[ i ]
    gh = ghFluid[ i ]
    ghf = ghfFluid[ i ]
    
    rad = radiation[ i ]
    
    initialMass = ref.dimensionedScalar( ref.word( "initialMass" ), ref.dimMass, initialMassFluid[ i ] )
    
    pRefCell = pRefCellFluid[ i ]
    pRefValue = pRefValueFluid[ i ]

    return mesh, thermo, rho, kappa, U, phi, turb, p, psi, h, initialMass, p_rgh, gh, ghf, rad, pRefCell, pRefValue
Пример #10
0
def setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                          phiFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation ):
    mesh = fluidRegions[i]

    thermo = thermoFluid[i]
    rho = rhoFluid[i]
    K = KFluid[i]
    U = UFluid[i]
    phi = phiFluid[i]

    turb = turbulence[i]
    DpDt = DpDtFluid[i]

    p = thermo.p()
    psi = thermo.psi()
    h = thermo.h()

    p_rgh = p_rghFluid[i]
    gh = ghFluid[i]
    ghf = ghfFluid[i]

    rad = radiation[i]

    initialMass = ref.dimensionedScalar(ref.word("massIni"), ref.dimMass,
                                        initialMassFluid[i])

    return mesh, thermo, rho, K, U, phi, turb, DpDt, p, psi, h, initialMass, p_rgh, gh, ghf, rad
Пример #11
0
def _createFields(runTime, mesh):
    ref.ext_Info() << "Reading field T\n" << ref.nl
    T = man.volScalarField(
        man.IOobject(ref.word("T"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary(
        man.IOobject(ref.word("transportProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    ref.ext_Info() << "Reading diffusivity D\n" << ref.nl

    DT = ref.dimensionedScalar(transportProperties.lookup(ref.word("DT")))

    phi = man.createPhi(runTime, mesh, U)

    return T, U, transportProperties, DT, phi
Пример #12
0
def createFields( runTime, mesh ):
    ref.ext_Info() << "Reading transportProperties\n"

    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )

    nu = ref.dimensionedScalar( transportProperties.lookup( ref.word( "nu" ) ) ) 

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                          ref.fileName( runTime.timeName() ), 
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ), mesh );


    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ), mesh );

    phi = man.createPhi( runTime, mesh, U )

    pRefCell = 0
    pRefValue = 0.0
   
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PISO" ) ), pRefCell, pRefValue )

    return transportProperties, nu, p, U, phi, pRefCell, pRefValue
def readTransportProperties( U, phi ):
  
  laminarTransport = man.singlePhaseTransportModel( U, phi )

  # Thermal expansion coefficient [1/K]
  beta = ref.dimensionedScalar( laminarTransport.lookup( ref.word( "beta" ) ) )

  # Reference temperature [K]
  TRef = ref.dimensionedScalar( laminarTransport.lookup( ref.word( "TRef" ) ) )

  # Laminar Prandtl number
  Pr = ref.dimensionedScalar( laminarTransport.lookup( ref.word( "Pr" ) ) )

  # Turbulent Prandtl number
  Prt = ref.dimensionedScalar( laminarTransport.lookup( ref.word( "Prt" ) ) )
  
  return laminarTransport, beta, TRef, Pr, Prt
Пример #14
0
def readThermodynamicProperties(runTime, mesh):
    ref.ext_Info() << "Reading thermodynamicProperties\n" << ref.nl

    thermodynamicProperties = man.IOdictionary(
        man.IOobject(ref.word("thermodynamicProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))
    rho0 = ref.dimensionedScalar(
        thermodynamicProperties.lookup(ref.word("rho0")))
    p0 = ref.dimensionedScalar(thermodynamicProperties.lookup(ref.word("p0")))
    psi = ref.dimensionedScalar(thermodynamicProperties.lookup(
        ref.word("psi")))
    # Density offset, i.e. the constant part of the density
    rhoO = ref.dimensionedScalar(ref.word("rhoO"), rho0 - psi * p0)

    return thermodynamicProperties, rho0, p0, psi, rhoO
Пример #15
0
def main_standalone( argc, argv ):

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

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

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

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

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

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

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

    import os
    return os.EX_OK
Пример #16
0
    def step(self, nCorr=1, nNonOrthCorr=1):
        U_ = self.U
        p_ = self.p
        phi_ = self.phi
        runTime_ = self.runTime
        mesh_ = U_.mesh()
        
        runTime_.increment()
        
        # Read transport properties
        nu = ref.dimensionedScalar(self.transportProperties.lookup(ref.word("nu")))

        tmp_UEqn = ( ref.fvm.ddt( U_ ) + ref.fvm.div( phi_, U_ ) - ref.fvm.laplacian( nu, U_ ) )
        UEqn = tmp_UEqn()
        
        self.velocityRes = ref.solve( UEqn == -ref.fvc.grad( p_ ) ).initialResidual()
        
        # --- PISO loop
        for corr in range(nCorr):
            tmp_rUA = 1.0 / UEqn.A()
            rUA = tmp_rUA()
            
            U_ << rUA * UEqn.H()
            
            phi_ << ( ref.fvc.interpolate(U_) & mesh_.Sf() )
            
            for nonOrth in range(nNonOrthCorr):
                tmp_pEqn = ( ref.fvm.laplacian( rUA, p_ ) == ref.fvc.div( phi_ ) )
                pEqn = tmp_pEqn()
                
                pEqn.setReference( self.pRefCell, self.pRefValue )
                pressureRes = pEqn.solve().initialResidual()
                
                if nonOrth == 0:
                    self.pressureRes = pressureRes
                
                if nonOrth == nNonOrthCorr:
                    phi_ -= pEqn.flux()
            
            # Continuity errors
            tmp_contErr = ref.fvc.div( phi_ );
            contErr = tmp_contErr()

            sumLocalContErr = (
                runTime_.deltaT().value()
                * contErr.mag().weightedAverage( mesh_.V() ).value()
            )

            globalContErr = (
                runTime_.deltaT().value()
                * contErr.weightedAverage( mesh_.V() ).value()
            )
            
            print "time step continuity errors : sum local = " + str(sumLocalContErr) + ", global = " + str(globalContErr)
            
            # Correct velocity
            U_-= rUA * ref.fvc.grad( p_ )
            U_.correctBoundaryConditions()
Пример #17
0
def _createFields(runTime, mesh, Omega, gHat):

    ref.ext_Info() << "Reading field h\n" << ref.nl
    h = man.volScalarField(
        man.IOobject(
            ref.word("h"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE
        ),
        mesh,
    )

    ref.ext_Info() << "Reading field h0 if present\n" << ref.nl
    h0 = man.volScalarField(
        man.IOobject(
            ref.word("h0"),
            ref.fileName(runTime.findInstance(ref.fileName(ref.word("polyMesh")), ref.word("points"))),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
        ),
        mesh,
        ref.dimensionedScalar(ref.word("h0"), ref.dimLength, 0.0),
    )

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(
            ref.word("U"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE
        ),
        mesh,
    )

    ref.ext_Info() << "Creating field hU\n" << ref.nl
    hU = man.volVectorField(
        man.IOobject(ref.word("hU"), ref.fileName(runTime.timeName()), mesh), h * U, U.ext_boundaryField().types()
    )

    ref.ext_Info() << "Creating field hTotal for post processing\n" << ref.nl
    hTotal = man.volScalarField(
        man.IOobject(
            ref.word("hTotal"),
            ref.fileName(runTime.timeName()),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
            ref.IOobject.AUTO_WRITE,
        ),
        h + h0,
    )

    hTotal.write()

    phi = createPhi(runTime, hU, mesh)

    ref.ext_Info() << "Creating Coriolis Force" << ref.nl

    F = ref.dimensionedVector(ref.word("F"), ((2.0 * Omega) & gHat) * gHat)

    return h, h0, U, hU, hTotal, phi, F
Пример #18
0
def createFields(runTime, mesh, pimple):
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl

    pThermo = man.basicPsiThermo.New(mesh)

    p = man.volScalarField(pThermo.p(), man.Deps(pThermo))
    h = man.volScalarField(pThermo.h(), man.Deps(pThermo))
    psi = man.volScalarField(pThermo.psi(), man.Deps(pThermo))

    rho = man.volScalarField(
        man.IOobject(
            ref.word("rho"),
            ref.fileName(runTime.timeName()),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
            ref.IOobject.AUTO_WRITE,
        ),
        man.volScalarField(pThermo.rho(), man.Deps(pThermo)),
    )

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(
            ref.word("U"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE
        ),
        mesh,
    )

    phi = man.compressibleCreatePhi(runTime, mesh, U, rho)

    rhoMax = ref.dimensionedScalar(pimple.dict().lookup(ref.word("rhoMax")))
    rhoMin = ref.dimensionedScalar(pimple.dict().lookup(ref.word("rhoMin")))

    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New(rho, U, phi, pThermo)

    ref.ext_Info() << "Creating field dpdt\n" << ref.nl
    dpdt = man.volScalarField(ref.word("dpdt"), man.fvc.ddt(p))

    ref.ext_Info() << "Creating field kinetic energy K\n" << ref.nl
    K = man.volScalarField(ref.word("K"), man.volScalarField(0.5 * U.magSqr(), man.Deps(U)))

    return pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K
Пример #19
0
def _createFields( runTime, mesh, simple ):
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    
    thermo = man.basicPsiThermo.New( mesh )

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.READ_IF_PRESENT,
                                            ref.IOobject.AUTO_WRITE ),
                              man.volScalarField( thermo.rho(), man.Deps( thermo ) ) )

    p = man.volScalarField( thermo.p(), man.Deps( thermo ) )
    h = man.volScalarField( thermo.h(), man.Deps( thermo ) )
    psi = man.volScalarField( thermo.psi(), man.Deps( thermo ) )
   
    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )

    phi = man.compressibleCreatePhi( runTime, mesh, rho, U )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, simple.dict(), pRefCell, pRefValue )
    
    rhoMax = ref.dimensionedScalar( simple.dict().lookup( ref.word( "rhoMax" ) ) )
    rhoMin = ref.dimensionedScalar( simple.dict().lookup( ref.word( "rhoMin" ) ) )
    
    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.RASModel.New( rho,
                                                U,
                                                phi,
                                                thermo )
    
    initialMass = ref.fvc.domainIntegrate( rho )
    
    return thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin
Пример #20
0
def _createFields( runTime, mesh, simple ):
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    
    thermo = man.basicPsiThermo.New( mesh )

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.READ_IF_PRESENT,
                                            ref.IOobject.AUTO_WRITE ),
                              man.volScalarField( thermo.rho(), man.Deps( thermo ) ) )

    p = man.volScalarField( thermo.p(), man.Deps( thermo ) )
    h = man.volScalarField( thermo.h(), man.Deps( thermo ) )
    psi = man.volScalarField( thermo.psi(), man.Deps( thermo ) )
   
    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )

    phi = man.compressibleCreatePhi( runTime, mesh, rho, U )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, simple.dict(), pRefCell, pRefValue )
    
    rhoMax = ref.dimensionedScalar( simple.dict().lookup( ref.word( "rhoMax" ) ) )
    rhoMin = ref.dimensionedScalar( simple.dict().lookup( ref.word( "rhoMin" ) ) )
    
    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.RASModel.New( rho,
                                                U,
                                                phi,
                                                thermo )
    
    initialMass = ref.fvc.domainIntegrate( rho )
    
    return thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin
Пример #21
0
def setInitialrDeltaT(runTime, mesh, pimple):
    maxDeltaT = pimple.dict().lookupOrDefault(ref.word("maxDeltaT"), ref.GREAT)
    rDeltaT = man.volScalarField(
        man.IOobject(ref.word("rDeltaT"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.NO_READ,
                     ref.IOobject.AUTO_WRITE), mesh, 1.0 /
        ref.dimensionedScalar(ref.word("maxDeltaT"), ref.dimTime, maxDeltaT),
        ref.zeroGradientFvPatchScalarField.typeName)

    return maxDeltaT, rDeltaT
Пример #22
0
def fun_correctPhi(runTime, mesh, phi, phiAbs, p, p_rgh, rho, U, cumulativeContErr, pimple, pRefCell, pRefValue):

    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh, cumulativeContErr)
    pcorrTypes = ref.wordList(p_rgh.ext_boundaryField().size(), ref.zeroGradientFvPatchScalarField.typeName)

    for i in range(p.ext_boundaryField().size()):
        if p_rgh.ext_boundaryField()[i].fixesValue():
            pcorrTypes[i] = ref.fixedValueFvPatchScalarField.typeName
            pass
        pass

    pcorr = ref.volScalarField(
        ref.IOobject(
            ref.word("pcorr"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.NO_READ, ref.IOobject.NO_WRITE
        ),
        mesh,
        ref.dimensionedScalar(ref.word("pcorr"), p_rgh.dimensions(), 0.0),
        pcorrTypes,
    )

    rAUf = ref.dimensionedScalar(ref.word("(1|A(U))"), ref.dimTime / rho.dimensions(), 1.0)

    ref.adjustPhi(phi, U, pcorr)

    ref.fvc.makeAbsolute(phi, U)

    while pimple.correctNonOrthogonal():
        pcorrEqn = ref.fvm.laplacian(rAUf, pcorr) == ref.fvc.div(phi)

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

        if pimple.finalNonOrthogonalIter():
            phi -= pcorrEqn.flux()
            phiAbs << phi
            ref.fvc.makeRelative(phi, U)
            pass

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

    return cumulativeContErr
def setInitialrDeltaT ( runTime, mesh, pimple ):
    maxDeltaT = pimple.dict().lookupOrDefault( ref.word( "maxDeltaT" ), ref.GREAT ); 
    rDeltaT = man.volScalarField( man.IOobject( ref.word( "rDeltaT" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh,
                                                ref.IOobject.NO_READ,
                                                ref.IOobject.AUTO_WRITE ),
                                  mesh,
                                  1.0 / ref.dimensionedScalar( ref.word( "maxDeltaT" ), ref.dimTime, maxDeltaT ),
                                  ref.zeroGradientFvPatchScalarField.typeName )
    
    return maxDeltaT, rDeltaT
Пример #24
0
def readTransportProperties(runTime, mesh):
    ref.ext_Info() << "Reading transportProperties\n" << ref.nl

    transportProperties = man.IOdictionary(
        man.IOobject(ref.word("transportProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    mu = ref.dimensionedScalar(transportProperties.lookup(ref.word("mu")))

    return transportProperties, mu
Пример #25
0
def readTransportProperties( runTime, mesh ):
    
    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                           mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )

    nu = ref.dimensionedScalar( transportProperties.lookup( ref.word( "nu" ) ) )

    return transportProperties, nu
Пример #26
0
def correctPhi(runTime, mesh, phi, p, p_rgh, rho, U, cumulativeContErr, pimple,
               pRefCell, pRefValue):

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

    pcorrTypes = ref.wordList(p_rgh.ext_boundaryField().size(),
                              ref.zeroGradientFvPatchScalarField.typeName)

    for i in range(p.ext_boundaryField().size()):
        if p_rgh.ext_boundaryField()[i].fixesValue():
            pcorrTypes[i] = ref.fixedValueFvPatchScalarField.typeName
            pass
        pass

    pcorr = ref.volScalarField(
        ref.IOobject(ref.word("pcorr"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE), mesh(),
        ref.dimensionedScalar(ref.word("pcorr"), p_rgh.dimensions(), 0.0),
        pcorrTypes)

    rAUf = ref.dimensionedScalar(ref.word("(1|A(U))"),
                                 ref.dimTime / rho.dimensions(), 1.0)

    ref.adjustPhi(phi, U, pcorr)

    while pimple.correctNonOrthogonal():
        pcorrEqn = ref.fvm.laplacian(rAUf, pcorr) == ref.fvc.div(phi)

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

        if pimple.finalNonOrthogonalIter():
            phi -= pcorrEqn.flux()
            pass

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

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

    rAU = ref.volScalarField(ref.word("rAU"), 1.0 / UEqn.A())

    rAUf = ref.surfaceScalarField(ref.word("(1|A(U))"),
                                  ref.fvc.interpolate(rAU))

    U << rAU * UEqn.H()

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

    ref.adjustPhi(phi, U, p_rgh)

    buoyancyPhi = rAUf * ghf() * ref.fvc.snGrad(rhok) * mesh.magSf()
    phi -= buoyancyPhi

    for nonOrth in range(simple.nNonOrthCorr() + 1):
        p_rghEqn = ref.fvm.laplacian(rAUf, p_rgh) == ref.fvc.div(phi)

        p_rghEqn.setReference(pRefCell, ref.getRefCellValue(p_rgh, pRefCell))

        p_rghEqn.solve()

        if nonOrth == simple.nNonOrthCorr():
            # Calculate the conservative fluxes
            phi -= p_rghEqn.flux()

            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U -= rAU * ref.fvc.reconstruct(
                (buoyancyPhi + p_rghEqn.flux()) / rAUf)
            U.correctBoundaryConditions()
            pass
        pass

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

    p << p_rgh + rhok * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar(
            ref.word("p"), p.dimensions(),
            pRefValue - ref.getRefCellValue(p, pRefCell))
        p_rgh << p - rhok * gh
        pass

    return cumulativeContErr
Пример #28
0
def readTurbulenceProperties( runTime, mesh, U ):
    
    ref.ext_Info() << "Reading turbulenceProperties\n" << ref.nl
    turbulenceProperties = man.IOdictionary( man.IOobject( ref.word( "turbulenceProperties" ),
                                                           ref.fileName( runTime.constant() ),
                                                           mesh,
                                                           ref.IOobject.MUST_READ_IF_MODIFIED,
                                                           ref.IOobject.NO_WRITE ) )

    force = U / ref.dimensionedScalar( ref.word( "dt" ), ref.dimTime, runTime.deltaTValue() )

    K = man.Kmesh( mesh )
    forceGen = man.UOprocess( K, runTime.deltaTValue(), turbulenceProperties )
    
    return turbulenceProperties, force, K, forceGen
Пример #29
0
def createFields( runTime, mesh ):
    ref.ext_Info()<< "Reading thermophysical properties\n" << ref.nl
    
    pThermo = man.basicPsiThermo.New( mesh )
    
    p = man.volScalarField( pThermo.p(), man.Deps( pThermo ) )
    h = man.volScalarField( pThermo.h(), man.Deps( pThermo ) )
    psi = man.volScalarField( pThermo.psi(), man.Deps( pThermo ) )
    
    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.READ_IF_PRESENT,
                                            ref.IOobject.AUTO_WRITE ),
                              man.volScalarField( pThermo.rho(), man.Deps( pThermo ) ) )
    
    ref.ext_Info()<< "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )

    phi = man.compressibleCreatePhi( runTime, mesh, U, rho )

    rhoMax = ref.dimensionedScalar( mesh.solutionDict().subDict( ref.word( "PIMPLE" ) ).lookup( ref.word( "rhoMax" ) ) )
    rhoMin = ref.dimensionedScalar( mesh.solutionDict().subDict( ref.word( "PIMPLE" ) ).lookup( ref.word( "rhoMin" ) ) )

    ref.ext_Info()<< "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New( rho, U, phi, pThermo );
  
    ref.ext_Info()<< "Creating field DpDt\n" << ref.nl;
    DpDt = man.fvc.DDt( man.surfaceScalarField( ref.word( "phiU" ), phi / man.fvc.interpolate( rho ) ), p )
  
    return pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, DpDt
Пример #30
0
def alphaEqns(runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1,
              alpha2, phi, interface, nAlphaCorr):

    alphaScheme = ref.word("div(phi,alpha)")
    alpharScheme = ref.word("div(phirb,alpha)")

    phir = phic * interface.nHatf()

    for gCorr in range(nAlphaCorr):
        Sp = ref.volScalarField.DimensionedInternalField(
            ref.IOobject(ref.word("Sp"), ref.fileName(runTime.timeName()),
                         mesh), mesh,
            ref.dimensionedScalar(ref.word("Sp"), dgdt.dimensions(), 0.0))

        Su = ref.volScalarField.DimensionedInternalField(
            ref.IOobject(ref.word("Su"), ref.fileName(runTime.timeName()),
                         mesh),
            # Divergence term is handled explicitly to be
            # consistent with the explicit transport solution
            divU * alpha1.ext_min(1.0))
        for celli in range(dgdt.size()):
            if dgdt[celli] > 0.0 and alpha1[celli] > 0.0:
                Sp[celli] -= dgdt[celli] * alpha1[celli]
                Su[celli] += dgdt[celli] * alpha1[celli]
                pass
            elif dgdt[celli] < 0.0 and alpha1[celli] < 1.0:
                Sp[celli] += dgdt[celli] * (1.0 - alpha1[celli])
                pass
            pass

        phiAlpha1 = ref.fvc.flux(phi, alpha1, alphaScheme) + ref.fvc.flux(
            -ref.fvc.flux(-phir, alpha2, alpharScheme), alpha1, alpharScheme)

        ref.MULES.explicitSolve(ref.geometricOneField(), alpha1, phi,
                                phiAlpha1, Sp, Su, 1.0, 0.0)

        rho1f = ref.fvc.interpolate(rho1)
        rho2f = ref.fvc.interpolate(rho2)
        rhoPhi << phiAlpha1 * (rho1f - rho2f) + phi * rho2f

        alpha2 << 1.0 - alpha1

        pass

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() << "  Min(alpha2) = " << alpha2.ext_min().value() << nl
    pass
Пример #31
0
def readTurbulenceProperties(runTime, mesh, U):

    ref.ext_Info() << "Reading turbulenceProperties\n" << ref.nl
    turbulenceProperties = man.IOdictionary(
        man.IOobject(ref.word("turbulenceProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    force = U / ref.dimensionedScalar(ref.word("dt"), ref.dimTime,
                                      runTime.deltaTValue())

    K = man.Kmesh(mesh)
    forceGen = man.UOprocess(K, runTime.deltaTValue(), turbulenceProperties)

    return turbulenceProperties, force, K, forceGen
Пример #32
0
def createGradP( runTime ):
    gradP = ref.dimensionedScalar( ref.word( "gradP" ),
                                   ref.dimensionSet( 0.0, 1.0, -2.0, 0.0, 0.0 ),
                                   0.0 )

    gradPFile = ref.IFstream( runTime.path()/ref.fileName( runTime.timeName() )/ref.fileName( "uniform" )/ ref.fileName( "gradP.raw" ) )
    
    if gradPFile.good():
       gradPFile >> gradP
       ref.ext_Info() << "Reading average pressure gradient" << ref.nl << ref.nl
       pass
    else:
       ref.ext_Info() << "Initializing with 0 pressure gradient" << ref.nl << ref.nl
       pass
    
    return gradP, gradPFile
Пример #33
0
def readThermophysicalProperties( runTime, mesh ):
    ref.ext_Info() << "Reading thermophysicalProperties\n" << ref.nl
    
    # Pr defined as a separate constant to enable calculation of k, currently
    # inaccessible through thermo
    thermophysicalProperties = man.IOdictionary( man.IOobject( ref.word( "thermophysicalProperties" ),
                                                               ref.fileName( runTime.constant() ),
                                                               mesh,
                                                               ref.IOobject.MUST_READ,
                                                               ref.IOobject.NO_WRITE ) )
    
    Pr = ref.dimensionedScalar( ref.word( "Pr" ),
                                ref.dimless,
                                thermophysicalProperties.subDict( ref.word( "mixture" ) ).subDict( ref.word( "transport" ) ).lookup( ref.word( "Pr" ) ) )
    
    return thermophysicalProperties, Pr
Пример #34
0
def alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ):

    alphaScheme = ref.word( "div(phi,alpha)" )
    alpharScheme = ref.word( "div(phirb,alpha)" )

    phir = phic*interface.nHatf()
    
    for gCorr in range( nAlphaCorr ):
        Sp = ref.volScalarField.DimensionedInternalField( ref.IOobject( ref.word( "Sp" ),
                                                                        ref.fileName( runTime.timeName() ),
                                                                        mesh ),
                                                           mesh,
                                                           ref.dimensionedScalar( ref.word( "Sp" ), dgdt.dimensions(), 0.0 ) )

        Su = ref.volScalarField.DimensionedInternalField( ref.IOobject( ref.word( "Su" ),
                                                                        ref.fileName( runTime.timeName() ),
                                                                        mesh ),
                                                          # Divergence term is handled explicitly to be
                                                          # consistent with the explicit transport solution
                                                          divU * alpha1.ext_min( 1.0 ) )
        for celli in range( dgdt.size() ):
            if dgdt[ celli ] > 0.0 and alpha1[ celli ] > 0.0:
                Sp[ celli ] -= dgdt[ celli ] * alpha1[ celli ]
                Su[ celli ] += dgdt[ celli ] * alpha1[ celli ]
                pass
            elif dgdt[ celli ] < 0.0 and alpha1[ celli ] < 1.0:
                Sp[ celli ] += dgdt[ celli ] * ( 1.0 - alpha1[ celli ] )
                pass
            pass

        phiAlpha1 = ref.fvc.flux( phi, alpha1, alphaScheme ) + ref.fvc.flux( - ref.fvc.flux( -phir, alpha2, alpharScheme ), alpha1, alpharScheme )
        
        ref.MULES.explicitSolve( ref.geometricOneField(), alpha1, phi, phiAlpha1, Sp, Su, 1.0, 0.0 )
        
        rho1f = ref.fvc.interpolate( rho1 )
        rho2f = ref.fvc.interpolate( rho2 )
        rhoPhi << phiAlpha1 * ( rho1f - rho2f ) + phi * rho2f

        alpha2 << 1.0 - alpha1

        pass

    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() << "  Min(alpha2) = " << alpha2.ext_min().value() << nl
    pass
Пример #35
0
def _correctPhi(runTime, mesh, pimple, p, U, rAU, phi, pRefCell, pRefValue,
                cumulativeContErr):
    if mesh.changing():
        for patchi in range(U.ext_boundaryField().size()):
            if U.ext_boundaryField()[patchi].fixesValue():
                U.ext_boundaryField()[patchi].initEvaluate()
                pass
            pass
        for patchi in range(U.ext_boundaryField().size()):
            if U.ext_boundaryField()[patchi].fixesValue():
                U.ext_boundaryField()[patchi].evaluate()
                phi.ext_boundaryField()[patchi] << (
                    U.ext_boundaryField()[patchi]
                    & mesh.Sf().ext_boundaryField()[patchi])
                pass
            pass
        pass

    pcorrTypes = ref.wordList(p.ext_boundaryField().size(),
                              ref.zeroGradientFvPatchScalarField.typeName)

    for i in range(p.ext_boundaryField().size()):
        if p.ext_boundaryField()[i].fixesValue():
            pcorrTypes[i] = ref.fixedValueFvPatchScalarField.typeName
            pass
        pass

    pcorr = ref.volScalarField(
        ref.IOobject(ref.word("pcorr"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE), mesh,
        ref.dimensionedScalar(ref.word("pcorr"), p.dimensions(), 0.0),
        pcorrTypes)

    while pimple.correctNonOrthogonal():
        pcorrEqn = (ref.fvm.laplacian(rAU, pcorr) == ref.fvc.div(phi))

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

        if pimple.finalNonOrthogonalIter():
            phi << phi() - pcorrEqn.flux()  # mixed calculations
            pass
        pass
    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                           cumulativeContErr)

    return cumulativeContErr
def setrDeltaT( runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT ):
    pimpleDict = pimple.dict()

    maxCo = pimpleDict.lookupOrDefault( ref.word( "maxCo" ), ref.scalar( 0.8 ) ) 
    rDeltaTSmoothingCoeff = pimpleDict.lookupOrDefault( ref.word( "rDeltaTSmoothingCoeff" ) , ref.scalar( 0.02 ) )
    rDeltaTDampingCoeff = pimpleDict.lookupOrDefault( ref.word( "rDeltaTDampingCoeff" ), ref.scalar( 1.0 ) )

    maxDeltaT = pimpleDict.lookupOrDefault( ref.word( "maxDeltaT" ), ref.GREAT )

    rDeltaT0 = ref.volScalarField( ref.word( "rDeltaT0" ), rDeltaT )

    # Set the reciprocal time-step from the local Courant number
    tmp = ref.fvc.surfaceSum( phi.mag() )
    tmp1= ( tmp.dimensionedInternalField() / ( ( 2 * maxCo ) * mesh.V() * rho.dimensionedInternalField() ) )
    print tmp1

    rDeltaT.dimensionedInternalField() << tmp1().max( 1.0 / ref.dimensionedScalar( ref.word( "maxDeltaT" ), ref.dimTime, maxDeltaT ) )
    

    if pimple.transonic():
        phid = ref.surfaceScalarField( ref.word( "phid" ),
                                       ref.fvc.interpolate( psi ) * ( ref.fvc.interpolate( U ) & mesh.Sf() ) )

        rDeltaT.dimensionedInternalField() << rDeltaT.dimensionedInternalField().max( ref.fvc.surfaceSum( phid.mag() ).dimensionedInternalField() / 
                                                                                      ( ( 2 * maxCo ) * mesh.V() * psi.dimensionedInternalField() ) )
        pass

    # Update tho boundary values of the reciprocal time-step
    rDeltaT.correctBoundaryConditions()

    ref.ext_Info() << "Flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl

    if rDeltaTSmoothingCoeff < 1.0:
        ref.fvc.smooth( rDeltaT, rDeltaTSmoothingCoeff )
        pass

    ref.ext_Info() << "Smoothed flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl

    # Limit rate of change of time scale
    # - reduce as much as required
    # - only increase at a fraction of old time scale
    if rDeltaTDampingCoeff < 1.0 and runTime.timeIndex() > ( runTime.startTimeIndex() + 1 ) :
        rDeltaT = rDeltaT0 * ( rDeltaT / rDeltaT0 ).max( ref.scalar( 1.0 ) - rDeltaTDampingCoeff )

        Info<< "Damped flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl
        pass
    pass
def fun_pEqn( mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr ):

  rAU = ref.volScalarField( ref.word( "rAU" ), 1.0 / UEqn.A() )
  
  rAUf = ref.surfaceScalarField( ref.word( "(1|A(U))" ), ref.fvc.interpolate( rAU ) )

  U << rAU * UEqn.H()

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

  ref.adjustPhi( phi, U, p_rgh );

  buoyancyPhi = rAUf * ghf() * ref.fvc.snGrad( rhok ) * mesh.magSf()
  phi -= buoyancyPhi

  while simple.correctNonOrthogonal():
    p_rghEqn = ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi )

    p_rghEqn.setReference( pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )
    
    p_rghEqn.solve()

    if simple.finalNonOrthogonalIter():
      # Calculate the conservative fluxes
      phi -= p_rghEqn.flux()
      
      # Explicitly relax pressure for momentum corrector
      p_rgh.relax()

      # Correct the momentum source with the pressure gradient flux
      # calculated from the relaxed pressure
      U -= rAU * ref.fvc.reconstruct( ( buoyancyPhi + p_rghEqn.flux() ) / rAUf )
      U.correctBoundaryConditions()
      pass
    pass

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

  p << p_rgh + rhok * gh

  if p_rgh.needReference():
    p += ref.dimensionedScalar( ref.word( "p" ), p.dimensions(), pRefValue - ref.getRefCellValue( p, pRefCell ) )
    p_rgh << p - rhok * gh
    pass
  
  return cumulativeContErr
Пример #38
0
def _pEqn( runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, phiAbs, alpha1, rho, g, interface, pimple, pRefCell, pRefValue, cumulativeContErr ):
    rAU = 1.0 / UEqn.A()
    rAUf = ref.fvc.interpolate( rAU )

    U << rAU * UEqn.H()
    phiAbs << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phiAbs )

    if p_rgh.needReference():
        ref.fvc.makeRelative( phiAbs, U )
        ref.adjustPhi( phiAbs, U, p_rgh )
        ref.fvc.makeAbsolute( phiAbs, U )
        pass
    phi << phiAbs + ( ref.fvc.interpolate( interface.sigmaK() ) * ref.fvc.snGrad( alpha1 ) - ghf * ref.fvc.snGrad( rho ) ) * rAUf * mesh.magSf()

    while pimple.correctNonOrthogonal():
        p_rghEqn = ( ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi ) )

        p_rghEqn.setReference( pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )

        p_rghEqn.solve( mesh.solver( p_rgh.select( pimple.finalInnerIter() ) ) )
        
        if pimple.finalNonOrthogonalIter():
            phi -= p_rghEqn.flux()
            pass
        pass

    U += rAU * ref.fvc.reconstruct( ( phi() - phiAbs ) / rAUf ) # mixed calculations
    U.correctBoundaryConditions()

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

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

    p == p_rgh + rho * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar( ref.word( "p" ),
                                    p.dimensions(),
                                    pRefValue - ref.getRefCellValue( p, pRefCell ) );
        p_rgh << p - rho * gh
        pass
    
    return cumulativeContErr
Пример #39
0
def _correctPhi( runTime, mesh, pimple, p, U, rAU, phi, pRefCell, pRefValue, cumulativeContErr ):
    if mesh.changing():
       for patchi in range( U.ext_boundaryField().size() ):
           if U.ext_boundaryField()[patchi].fixesValue():
              U.ext_boundaryField()[patchi].initEvaluate()
              pass
           pass
       for patchi in range( U.ext_boundaryField().size() ):
           if U.ext_boundaryField()[patchi].fixesValue():
              U.ext_boundaryField()[patchi].evaluate()
              phi.ext_boundaryField()[patchi] << ( U.ext_boundaryField()[patchi] & mesh.Sf().ext_boundaryField()[patchi] )
              pass
           pass
       pass
       
    pcorrTypes = ref.wordList( p.ext_boundaryField().size(), ref.zeroGradientFvPatchScalarField.typeName )
    
    for i in range( p.ext_boundaryField().size() ):
        if p.ext_boundaryField()[i].fixesValue():
           pcorrTypes[i] = ref.fixedValueFvPatchScalarField.typeName
           pass
        pass
    
    pcorr = ref.volScalarField( ref.IOobject( ref.word( "pcorr" ),
                                              ref.fileName( runTime.timeName() ),
                                              mesh,
                                              ref.IOobject.NO_READ,
                                              ref.IOobject.NO_WRITE ),
                                mesh,
                                ref.dimensionedScalar( ref.word( "pcorr" ), p.dimensions(), 0.0),
                                pcorrTypes )
     
    while pimple.correctNonOrthogonal():
        pcorrEqn = ( ref.fvm.laplacian( rAU, pcorr ) == ref.fvc.div( phi ) )

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

        if pimple.finalNonOrthogonalIter():
           phi << phi() - pcorrEqn.flux() # mixed calculations
           pass
        pass
    cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )     

    return cumulativeContErr
Пример #40
0
def _pEqn(runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, alpha1, rho, g,
          interface, corr, pimple, pRefCell, pRefValue, cumulativeContErr):
    rAU = 1.0 / UEqn.A()

    rAUf = ref.fvc.interpolate(rAU)

    U << rAU * UEqn.H()

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

    ref.adjustPhi(phiU, U, p)

    phi << (phiU +
            (ref.fvc.interpolate(interface.sigmaK()) * ref.fvc.snGrad(alpha1) -
             ghf * ref.fvc.snGrad(rho)) * rAUf * mesh.magSf())

    for nonOrth in range(pimple.nNonOrthCorr() + 1):
        p_rghEqn = ref.fvm.laplacian(rAUf, p_rgh) == ref.fvc.div(phi)
        p_rghEqn.setReference(pRefCell, pRefValue)

        p_rghEqn.solve(
            mesh.solver(p_rgh.select(pimple.finalInnerIter(corr, nonOrth))))

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

    U += rAU * ref.fvc.reconstruct((phi() - phiU) / rAUf)  # mixed calculations
    U.correctBoundaryConditions()

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

    p == p_rgh + rho * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar(
            ref.word("p"), p.dimensions(),
            pRefValue - ref.getRefCellValue(p, pRefCell))
        p_rgh << p - rho * gh
        pass
    return cumulativeContErr
Пример #41
0
def _createFields(runTime, mesh, Omega, gHat):

    ref.ext_Info() << "Reading field h\n" << ref.nl
    h = man.volScalarField(
        man.IOobject(ref.word("h"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field h0 if present\n" << ref.nl
    h0 = man.volScalarField(
        man.IOobject(
            ref.word("h0"),
            ref.fileName(
                runTime.findInstance(ref.fileName(ref.word("polyMesh")),
                                     ref.word("points"))), mesh,
            ref.IOobject.READ_IF_PRESENT), mesh,
        ref.dimensionedScalar(ref.word("h0"), ref.dimLength, 0.0))

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Creating field hU\n" << ref.nl
    hU = man.volVectorField(
        man.IOobject(ref.word("hU"), ref.fileName(runTime.timeName()), mesh),
        h * U,
        U.ext_boundaryField().types())

    ref.ext_Info() << "Creating field hTotal for post processing\n" << ref.nl
    hTotal = man.volScalarField(
        man.IOobject(ref.word("hTotal"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.READ_IF_PRESENT,
                     ref.IOobject.AUTO_WRITE), h + h0)

    hTotal.write()

    phi = createPhi(runTime, hU, mesh)

    ref.ext_Info() << "Creating Coriolis Force" << ref.nl

    F = ref.dimensionedVector(ref.word("F"), ((2.0 * Omega) & gHat) * gHat)

    return h, h0, U, hU, hTotal, phi, F
Пример #42
0
def readTransportProperties( runTime, mesh):
    ref.ext_Info() << "\nReading transportProperties\n" << ref.nl
    
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE,
                                                          False ) )
    
    nu = ref.dimensionedScalar( transportProperties.lookup( ref.word( "nu" ) ) )
    
    #  Read centerline velocity for channel simulations
    Ubar = ref.dimensionedVector( transportProperties.lookup( ref.word( "Ubar" ) ) )

    magUbar = Ubar.mag()
    flowDirection = ( Ubar / magUbar ).ext_value()
    
    return transportProperties, nu, Ubar, magUbar, flowDirection
Пример #43
0
def _createFields( runTime, mesh ):
        
    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh ) 
    
    ref.ext_Info() << "Creating face flux\n" << ref.nl
    phi = man.surfaceScalarField( man.IOobject( ref.word( "phi" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh,
                                                ref.IOobject.NO_READ,
                                                ref.IOobject.NO_WRITE ),
                                  mesh,
                                  ref.dimensionedScalar( ref.word( "zero" ), mesh.Sf().dimensions()*U.dimensions(), 0.0) )

    
    laminarTransport = man.singlePhaseTransportModel( U, phi )
    
    turbulence = man.incompressible.RASModel.New( U, phi, laminarTransport )
    
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ,
                                                          ref.IOobject.NO_WRITE ) )
    Ubar = ref.dimensionedVector( transportProperties.lookup( ref.word( "Ubar" ) ) )
    
    flowDirection = ( Ubar / Ubar.mag() ).ext_value()
    flowMask = flowDirection.sqr()
    
    gradP = ref.dimensionedVector( ref.word( "gradP" ),
                                   ref.dimensionSet( 0.0, 1.0, -2.0, 0.0, 0.0 ),
                                   ref.vector( 0.0, 0.0, 0.0) )

    
    
              
    return U, phi, laminarTransport, turbulence, Ubar, gradP, flowDirection, flowMask
Пример #44
0
def fun_pEqn( runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, rho, pimple, corr, pRefCell, pRefValue, cumulativeContErr ):
    rAU = 1.0/UEqn.A()
     
    rAUf = ref.fvc.interpolate( rAU )
    
    U << rAU * UEqn.H()

    phiU = ref.surfaceScalarField( ref.word( "phiU" ),
                                   ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
                               
    ref.adjustPhi( phiU, U, p )
    
    phi << phiU - ghf * ref.fvc.snGrad( rho ) * rAUf * mesh.magSf()

    for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
        p_rghEqn = ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi ) 
        p_rghEqn.setReference(pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )

        p_rghEqn.solve( mesh.solver( p_rgh.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )
        
        if nonOrth == pimple.nNonOrthCorr():
           phi -= p_rghEqn.flux()
           pass
        pass
    
    U += rAU * ref.fvc.reconstruct( ( phi() - phiU ) / rAUf ) # mixed calculations
    U.correctBoundaryConditions()

    cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
    
    p == p_rgh + rho * gh

    if p_rgh.needReference():
       p += ref.dimensionedScalar( ref.word( "p" ),
                                   p.dimensions(),
                                   pRefValue - ref.getRefCellValue( p, pRefCell ) )
       p_rgh << p - rho * gh
       pass
    
    return cumulativeContErr
Пример #45
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field p_rgh\n" << ref.nl
    p_rgh = man.volScalarField(
        man.IOobject(ref.word("p_rgh"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field alpha1\n" << ref.nl
    man.interfaceProperties  # Load corresponding library to be able to use the following BC - "constantAlphaContactAngleFvPatchScalarField"
    alpha1 = man.volScalarField(
        man.IOobject(ref.word("alpha1"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE),
        mesh)

    ref.ext_Info() << "Reading field U\n" << ref.nl

    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    phi = man.createPhi(runTime, mesh, U)

    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    twoPhaseProperties = man.twoPhaseMixture(U, phi)

    rho1 = twoPhaseProperties.rho1()
    rho2 = twoPhaseProperties.rho2()

    # Need to store rho for ddt(rho, U)
    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT),
        alpha1 * rho1 + (1.0 - alpha1) * rho2,
        alpha1.ext_boundaryField().types())
    rho.oldTime()

    # Mass flux
    # Initialisation does not matter because rhoPhi is reset after the
    # alpha1 solution before it is used in the U equation.
    rhoPhi = man.surfaceScalarField(
        man.IOobject(ref.word("rho*phi"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.NO_READ, ref.IOobject.NO_WRITE),
        rho1 * phi)

    # Construct interface from alpha1 distribution
    interface = man.interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    turbulence = man.incompressible.turbulenceModel.New(
        U, phi, twoPhaseProperties)

    g = man.readGravitationalAcceleration(runTime, mesh)

    #dimensionedVector g0(g);

    #Read the data file and initialise the interpolation table
    #interpolationTable<vector> timeSeriesAcceleration( runTime.path()/runTime.caseConstant()/"acceleration.dat" );

    ref.ext_Info() << "Calculating field g.h\n" << ref.nl
    gh = man.volScalarField(ref.word("gh"),
                            g & man.volVectorField(mesh.C(), man.Deps(mesh)))
    ghf = man.surfaceScalarField(
        ref.word("ghf"), g & man.surfaceVectorField(mesh.Cf(), man.Deps(mesh)))

    p = man.volScalarField(
        man.IOobject(ref.word("p"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
        p_rgh + rho * gh)

    pRefCell = 0
    pRefValue = 0.0

    pRefCell, pRefValue = ref.setRefCell(
        p, p_rgh,
        mesh.solutionDict().subDict(ref.word("PIMPLE")), pRefCell, pRefValue)

    if p_rgh.needReference():
        p += ref.dimensionedScalar(
            ref.word("p"), p.dimensions(),
            pRefValue - ref.getRefCellValue(p, pRefCell))
        p_rgh << p - rho * gh
        pass

    return p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, pRefValue, interface, turbulence, g, gh, ghf
def createFields( runTime, mesh, g ):
  
  ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
  
  ref.ext_Info() << "Reading field T\n" << ref.nl
  T = man.volScalarField( man.IOobject( ref.word( "T" ),
                                        ref.fileName( runTime.timeName() ),
                                        mesh,
                                        ref.IOobject.MUST_READ,
                                        ref.IOobject.AUTO_WRITE ), mesh )

  ref.ext_Info() << "Reading field p_rgh\n" << ref.nl
  p_rgh = man.volScalarField( man.IOobject( ref.word( "p_rgh" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.MUST_READ,
                                            ref.IOobject.AUTO_WRITE ),
                                mesh )
  
  ref.ext_Info() << "Reading field U\n" << ref.nl
  U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                        ref.fileName( runTime.timeName() ),
                                        mesh,
                                        ref.IOobject.MUST_READ,
                                        ref.IOobject.AUTO_WRITE ), mesh )
  phi = man.createPhi( runTime, mesh, U )
    
  laminarTransport, beta, TRef, Pr, Prt = readTransportProperties( U, phi )
  
  ref.ext_Info()<< "Creating turbulence model\n" << ref.nl
  turbulence = man.incompressible.RASModel.New(U, phi, laminarTransport)

  # Kinematic density for buoyancy force
  rhok = man.volScalarField( man.IOobject( ref.word( "rhok" ),
                                           ref.fileName( runTime.timeName() ),
                                           mesh ), man( 1.0 - beta * ( T() - TRef ), man.Deps( T ) ) )
  
  # kinematic turbulent thermal thermal conductivity m2/s
  ref.ext_Info() << "Reading field kappat\n" << ref.nl
  kappat = man.volScalarField( man.IOobject( ref.word( "kappat" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.MUST_READ,
                                             ref.IOobject.AUTO_WRITE ), mesh )

  ref.ext_Info() << "Calculating field g.h\n" << ref.nl
  gh = man.volScalarField( ref.word( "gh" ), man( g & mesh.C(), man.Deps( mesh ) ) )
  
  ghf = man.surfaceScalarField( ref.word( "ghf" ), man( g & mesh.Cf(), man.Deps( mesh ) ) )

  p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                        ref.fileName( runTime.timeName() ),
                                        mesh,
                                        ref.IOobject.NO_READ,
                                        ref.IOobject.AUTO_WRITE ), p_rgh + rhok * gh )

  pRefCell = 0
  pRefValue = 0.0

  pRefCell, pRefValue = ref.setRefCell( p, p_rgh, mesh.solutionDict().subDict( ref.word( "SIMPLE" ) ), pRefCell, pRefValue )

  if p_rgh.needReference():
    p += ref.dimensionedScalar( ref.word( "p" ),p.dimensions(), pRefValue - ref.getRefCellValue( p, pRefCell ) )
    pass
  
  return T, p_rgh, U, phi, laminarTransport, turbulence, rhok, kappat, gh, ghf, p, pRefCell, pRefValue, beta, TRef, Pr, Prt
Пример #47
0
def _createFields(runTime, mesh, g):

    ref.ext_Info() << "Reading field p_rgh\n" << ref.nl
    p_rgh = man.volScalarField(
        man.IOobject(ref.word("p_rgh"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field alpha1\n" << ref.nl
    alpha1 = man.volScalarField(
        man.IOobject(ref.word("alpha1"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE),
        mesh)

    ref.ext_Info() << "Calculating field alpha1\n" << ref.nl
    alpha2 = man.volScalarField(ref.word("alpha2"), 1.0 - alpha1)

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    phi = man.createPhi(runTime, mesh, U)

    ref.ext_Info() << "Reading transportProperties\n" << ref.nl

    twoPhaseProperties = man.twoPhaseMixture(U, phi)

    rho10 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase1Name()).lookup(
            ref.word("rho0")))
    rho20 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase2Name()).lookup(
            ref.word("rho0")))

    psi1 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase1Name()).lookup(
            ref.word("psi")))
    psi2 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase2Name()).lookup(
            ref.word("psi")))

    pMin = ref.dimensionedScalar(twoPhaseProperties.lookup(ref.word("pMin")))

    ref.ext_Info() << "Calculating field g.h\n" << ref.nl
    gh = man.volScalarField(ref.word("gh"),
                            g & man.volVectorField(mesh.C(), man.Deps(mesh)))

    ghf = man.surfaceScalarField(
        ref.word("ghf"), g & man.surfaceVectorField(mesh.Cf(), man.Deps(mesh)))

    p = man.volScalarField(
        man.IOobject(ref.word("p"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
        ((p_rgh + gh * (alpha1 * rho10 + alpha2 * rho20)) /
         (1.0 - gh * (alpha1 * psi1 + alpha2 * psi2))).ext_max(pMin))  #

    rho1 = rho10 + psi1 * p
    rho2 = rho20 + psi2 * p

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        alpha1 * rho1 + alpha2 * rho2)

    # Mass flux
    # Initialisation does not matter because rhoPhi is reset after the
    # alpha1 solution before it is used in the U equation.
    rhoPhi = man.surfaceScalarField(
        man.IOobject(ref.word("rho*phi"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.NO_READ, ref.IOobject.NO_WRITE),
        man.fvc.interpolate(rho) * phi)

    dgdt = alpha2.pos() * man.fvc.div(phi) / alpha2.ext_max(0.0001)

    # Construct interface from alpha1 distribution
    interface = man.interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    turbulence = man.incompressible.turbulenceModel.New(
        U, phi, twoPhaseProperties)

    return p_rgh, alpha1, alpha2, U, phi, twoPhaseProperties, rho10, rho20, psi1, psi2, pMin, \
           gh, ghf, p, rho1, rho2, rho, rhoPhi, dgdt, interface, turbulence
Пример #48
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

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

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

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

        U_pos = rhoU_pos / rho_pos
        U_neg = rhoU_neg / rho_neg

        p_pos = rho_pos * rPsi_pos
        p_neg = rho_neg * rPsi_neg

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    import os
    return os.EX_OK
Пример #49
0
    def step(self):
        if self.runTime_.end():
            ref.ext_Info() << "Reached end time.  Exiting" << ref.nl
            return

        self.runTime_.increment()

        # Read transport properties
        nu = ref.dimensionedScalar(self.transportProperties_.lookup(ref.word("nu")))

        if self.mesh_.nInternalFaces():
            SfUfbyDelta = self.mesh_.deltaCoeffs() * self.phi_.mag()
            CoNum = (SfUfbyDelta / self.mesh_.magSf()).ext_max().value() * self.runTime_.deltaT().value()
            meanCoNum = (SfUfbyDelta.sum() / self.mesh_.magSf().sum()).value() * self.runTime_.deltaT().value()

            ref.ext_Info() << "Courant Number mean: " << meanCoNum << " max: " << CoNum << ref.nl
            pass

        # Read controls
        piso = self.mesh_.solutionDict().subDict(ref.word("PISO"))
        nCorr = ref.readInt(piso.lookup(ref.word("nCorrectors")))

        nNonOrthCorr = 0
        if piso.found(ref.word("nNonOrthogonalCorrectors")):
            nNonOrthCorr = ref.readInt(piso.lookup(ref.word("nNonOrthogonalCorrectors")))
            pass

        UEqn = ref.fvm.ddt(self.U_) + ref.fvm.div(self.phi_, self.U_) - ref.fvm.laplacian(nu, self.U_)

        self.velocityRes_ = ref.solve(UEqn == -ref.fvc.grad(self.p_)).initialResidual()

        # --- PISO loop

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

            self.U_ << rUA * UEqn.H()
            self.phi_ << (ref.fvc.interpolate(self.U_) & self.mesh_.Sf()) + ref.fvc.ddtPhiCorr(rUA, self.U_, self.phi_)

            #           adjustPhi(phi_, U_, p_);

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

                pEqn.setReference(self.pRefCell_, self.pRefValue_)
                self.pressureRes_ = pEqn.solve().initialResidual()

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

            # Continuity errors
            contErr = ref.fvc.div(self.phi_)

            sumLocalContErr = self.runTime_.deltaT().value() * contErr.mag().weightedAverage(self.mesh_.V()).value()

            globalContErr = self.runTime_.deltaT().value() * contErr.weightedAverage(self.mesh_.V()).value()

            ref.ext_Info() << "time step continuity errors : sum local = " << sumLocalContErr << ", global = " << globalContErr << ref.nl

            # Correct velocity
            self.U_ -= rUA * ref.fvc.grad(self.p_)
            self.U_.correctBoundaryConditions()

            pass
Пример #50
0
def main_standalone(argc, argv):

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

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    potentialFlow, nNonOrthCorr = readControls(mesh)

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

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

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

    ref.adjustPhi(phi, U, p)

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

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

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

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

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

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

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

    runTime.functionObjects().end()

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

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

    import os
    return os.EX_OK
def createFields(runTime, mesh):
    # Load boundary conditions
    import adjointOutletPressure
    import adjointOutletVelocity

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(ref.word("p"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField(
        man.IOobject(ref.word("U"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    phi = man.createPhi(runTime, mesh, U)

    pRefCell = 0
    pRefValue = 0.0
    ref.setRefCell(p,
                   mesh.solutionDict().subDict(ref.word("SIMPLE")), pRefCell,
                   pRefValue)

    ref.ext_Info() << "Reading field pa\n" << ref.nl
    pa = man.volScalarField(
        man.IOobject(ref.word("pa"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    ref.ext_Info() << "Reading field Ua\n" << ref.nl
    Ua = man.volVectorField(
        man.IOobject(ref.word("Ua"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE), mesh)

    phia = createPhia(runTime, mesh, Ua)

    paRefCell = 0
    paRefValue = 0.0
    ref.setRefCell(pa,
                   mesh.solutionDict().subDict(ref.word("SIMPLE")), paRefCell,
                   paRefValue)

    laminarTransport = man.singlePhaseTransportModel(U, phi)

    turbulence = man.incompressible.RASModel.New(U, phi, laminarTransport)

    zeroSensitivity = ref.dimensionedScalar(ref.word("0"),
                                            ref.dimVelocity * ref.dimVelocity,
                                            0.0)
    zeroAlpha = ref.dimensionedScalar(ref.word("0"), ref.dimless / ref.dimTime,
                                      0.0)

    lambda_ = ref.dimensionedScalar(laminarTransport.lookup(
        ref.word("lambda")))
    alphaMax = ref.dimensionedScalar(
        laminarTransport.lookup(ref.word("alphaMax")))

    inletCells = mesh.boundary()[ref.word("inlet")].faceCells()
    # outletCells = mesh.boundary()[ ref.word( "outlet" ) ].faceCells()

    alpha = man.volScalarField(
        man.IOobject(ref.word("alpha"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        lambda_ * (Ua & U).ext_max(zeroSensitivity))

    zeroCells(alpha, inletCells)
    # zeroCells( alpha, outletCells )

    return p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, \
           lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue
Пример #52
0
def setrDeltaT(runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT):
    pimpleDict = pimple.dict()

    maxCo = pimpleDict.lookupOrDefault(ref.word("maxCo"), ref.scalar(0.8))
    rDeltaTSmoothingCoeff = pimpleDict.lookupOrDefault(
        ref.word("rDeltaTSmoothingCoeff"), ref.scalar(0.02))
    rDeltaTDampingCoeff = pimpleDict.lookupOrDefault(
        ref.word("rDeltaTDampingCoeff"), ref.scalar(1.0))

    maxDeltaT = pimpleDict.lookupOrDefault(ref.word("maxDeltaT"), ref.GREAT)

    rDeltaT0 = ref.volScalarField(ref.word("rDeltaT0"), rDeltaT)

    # Set the reciprocal time-step from the local Courant number
    tmp = ref.fvc.surfaceSum(phi.mag())
    tmp1 = (tmp.dimensionedInternalField() /
            ((2 * maxCo) * mesh.V() * rho.dimensionedInternalField()))
    print tmp1

    rDeltaT.dimensionedInternalField() << tmp1().max(
        1.0 /
        ref.dimensionedScalar(ref.word("maxDeltaT"), ref.dimTime, maxDeltaT))

    if pimple.transonic():
        phid = ref.surfaceScalarField(
            ref.word("phid"),
            ref.fvc.interpolate(psi) * (ref.fvc.interpolate(U) & mesh.Sf()))

        rDeltaT.dimensionedInternalField() << rDeltaT.dimensionedInternalField(
        ).max(
            ref.fvc.surfaceSum(phid.mag()).dimensionedInternalField() /
            ((2 * maxCo) * mesh.V() * psi.dimensionedInternalField()))
        pass

    # Update tho boundary values of the reciprocal time-step
    rDeltaT.correctBoundaryConditions()

    ref.ext_Info() << "Flow time scale min/max = " << (
        1 / rDeltaT.internalField()).gMin() << ", " << (
            1 / rDeltaT.internalField()).gMax() << ref.nl

    if rDeltaTSmoothingCoeff < 1.0:
        ref.fvc.smooth(rDeltaT, rDeltaTSmoothingCoeff)
        pass

    ref.ext_Info() << "Smoothed flow time scale min/max = " << (
        1 / rDeltaT.internalField()).gMin() << ", " << (
            1 / rDeltaT.internalField()).gMax() << ref.nl

    # Limit rate of change of time scale
    # - reduce as much as required
    # - only increase at a fraction of old time scale
    if rDeltaTDampingCoeff < 1.0 and runTime.timeIndex() > (
            runTime.startTimeIndex() + 1):
        rDeltaT = rDeltaT0 * (
            rDeltaT / rDeltaT0).max(ref.scalar(1.0) - rDeltaTDampingCoeff)

        Info << "Damped flow time scale min/max = " << (
            1 / rDeltaT.internalField()).gMin() << ", " << (
                1 / rDeltaT.internalField()).gMax() << ref.nl
        pass
    pass
Пример #53
0
def _createFields( runTime, mesh ):
    # Load boundary condition
    from BCs import rho
    
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    thermo = man.basicPsiThermo.New( mesh )
    
    p = man.volScalarField( thermo.p(), man.Deps( thermo ) )
    e = man.volScalarField( thermo.e(), man.Deps( thermo ) ) 
    T = man.volScalarField( thermo.T(), man.Deps( thermo ) )
    psi = man.volScalarField( thermo.psi(), man.Deps( thermo ) )
    mu = man.volScalarField( thermo.mu(), man.Deps( thermo ) )
    
    inviscid = True
    if mu.internalField().max() > 0.0:
       inviscid = False
       pass
    
    ref.ext_Info() << "Reading field U\n" << ref.nl
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )
    
    pbf, rhoBoundaryTypes = _rhoBoundaryTypes( p )
    
    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.NO_READ,
                                            ref.IOobject.AUTO_WRITE ),
                             man.volScalarField( thermo.rho(), man.Deps( thermo ) ),
                             rhoBoundaryTypes )
    rhoU = man.volVectorField( man.IOobject( ref.word( "rhoU" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.NO_READ,
                                             ref.IOobject.NO_WRITE ),
                               rho*U )
    rhoE = man.volScalarField( man.IOobject( ref.word( "rhoE" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.NO_READ,
                                             ref.IOobject.NO_WRITE ),
                               rho * ( e + man.volScalarField( 0.5 * U.magSqr(), man.Deps( U ) ) ) )
    
    pos = man.surfaceScalarField( man.IOobject( ref.word( "pos" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh ),
                                  mesh,
                                  ref.dimensionedScalar( ref.word( "pos" ), ref.dimless, 1.0) )
    
    neg = man.surfaceScalarField( man.IOobject( ref.word( "neg" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh ),
                                  mesh,
                                  ref.dimensionedScalar( ref.word( "neg" ), ref.dimless, -1.0 ) )

   
    phi = man.surfaceScalarField( ref.word( "phi" ),
                                  man.surfaceVectorField( mesh.Sf(), man.Deps( mesh ) ) & man.fvc.interpolate( rhoU ) )
  
    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New( rho, U, phi, thermo )
    
    return thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid, phi, turbulence