Example #1
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 ) )
    e = man.volScalarField( pThermo.e(), man.Deps( pThermo ) )
    psi = man.volScalarField( pThermo.psi(), man.Deps( pThermo ) )

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh ),
                              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, rho, U )
 
    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New( rho, U, phi, pThermo )
    
    return pThermo, p, e, psi, rho, U, phi, turbulence
Example #2
0
def createFields( runTime, mesh, rhoO, psi ):
    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 )
    
    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.NO_READ,
                                            ref.IOobject.AUTO_WRITE ),
                              rhoO + psi * p )
  
    phi = man.compressibleCreatePhi( runTime, mesh, U, rho )
  
    return p, U, rho, phi
Example #3
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
def createFields( runTime, mesh, g ):
    
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    
    pThermo = man.basicPsiThermo.New( mesh );

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ), 
                                            ref.fileName( runTime.timeName() ),
                                            mesh, 
                                            ref.IOobject.NO_READ, 
                                            ref.IOobject.NO_WRITE ),
                              man( pThermo.rho(), man.Deps( pThermo ) ) );
    
    p = man( pThermo.p(), man.Deps( pThermo ) )
    h = man( pThermo.h(), man.Deps( pThermo ) )
    psi = man( pThermo.psi(), 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, rho, U );

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

    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 ) ) )
    
    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 );
    # Force p_rgh to be consistent with p
    p_rgh << p - rho * gh
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, p_rgh, mesh.solutionDict().subDict( ref.word( "SIMPLE" ) ), pRefCell, pRefValue );

    initialMass = ref.fvc.domainIntegrate( rho )
    totalVolume = mesh.V().ext_sum()
    
    return pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, pRefCell, pRefValue, initialMass, totalVolume
Example #5
0
def setRegionSolidFields( i, solidRegions, thermos ):
    mesh = solidRegions[ i ]
    thermo = thermos[ i ]

    rho = man.volScalarField( thermo.rho(), man.Deps( thermo ) )

    cp = man.volScalarField( thermo.Cp(), man.Deps( thermo ) )
    
    kappa = man.volScalarField( thermo.K(), man.Deps( thermo ) )
    # tmp<volSymmTensorField> tK = thermo.directionalK();
    
    # const volSymmTensorField& K = tK();
    T = man.volScalarField( thermo.T(), man.Deps( thermo ) )
    
    return mesh, thermo, rho, cp, kappa, T
Example #6
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
Example #7
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 _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 
Example #9
0
def _createFields(runTime, mesh):

    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)

    laminarTransport = man.singlePhaseTransportModel(U, phi)

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

    return p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport
def _UEqn( phi, U, p, rho, turbulence, mrfZones, pZones, pressureImplicitPorosity, nUCorr ):
    # Solve the Momentum equation
    UEqn = man.fvVectorMatrix( turbulence.divDevRhoReff( U ), man.Deps( turbulence ) )  + man.fvm.div( phi, U )
    
    UEqn.relax()
    
    mrfZones.addCoriolis( rho, UEqn )
    
    trAU = None
    trTU = None

    if pressureImplicitPorosity:
        tTU = man.volTensorField( ref.tensor( ref.I ) * UEqn.A(), man.Deps( UEqn ) )
        pZones.addResistance( UEqn, tTU )
        trTU = man.volTensorField( tTU.inv(), man.Deps( tTU ) )
        trTU.rename( ref.word( "rAU" ) )

        gradp = ref.fvc.grad(p)

        for UCorr in range( nUCorr ):
            U << ( trTU() & ( UEqn.H() - gradp ) ) # mixed calculations
            pass
        U.correctBoundaryConditions()
        pass
    else:
        pZones.addResistance( UEqn )
        ref.solve( UEqn == -ref.fvc.grad( p ) )
        trAU = man.volScalarField( 1.0 / UEqn.A(), man.Deps( UEqn ) )
        trAU.rename( ref.word( "rAU" ) )
        pass
    
    return UEqn, trAU, trTU
Example #11
0
def _createFields( runTime, mesh ):
        
    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 )
    
    fluid = man.singlePhaseTransportModel( U, phi )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PISO" ) ), pRefCell, pRefValue )

        
    return p, U, phi, fluid, pRefCell, pRefValue
Example #12
0
def createFields(runTime, mesh, g):
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl

    pThermo = man.basicRhoThermo.New(mesh)

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

    p = man.volScalarField(pThermo.p(), man.Deps(pThermo))
    h = man.volScalarField(pThermo.h(), man.Deps(pThermo))
    psi = man.volScalarField(pThermo.psi(), 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)

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

    ref.ext_Info() << "Calculating field g.h\n" << ref.nl
    gh = man.volScalarField(ref.word("gh"), man.volScalarField(g & mesh.C(), man.Deps(mesh)))
    ghf = man.surfaceScalarField(ref.word("ghf"), man.surfaceScalarField(g & mesh.Cf(), man.Deps(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,
    )

    # Force p_rgh to be consistent with p
    p_rgh << p - rho * gh

    ref.ext_Info() << "Creating field DpDt\n" << ref.nl

    DpDt = man.volScalarField(
        ref.word("DpDt"), man.fvc.DDt(man.surfaceScalarField(ref.word("phiU"), phi / man.fvc.interpolate(rho)), p)
    )

    return pThermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt
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
Example #14
0
def _createFields( runTime, mesh ):
    
    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( "PIMPLE" ) ), pRefCell, pRefValue )
    
    laminarTransport = man.singlePhaseTransportModel( U, phi )
    
    turbulence = man.incompressible.turbulenceModel.New( U, phi, laminarTransport )
    
    ref.ext_Info() << "Reading field rAU if present\n" << ref.nl
    rAU = man.volScalarField( man.IOobject( ref.word( "rAU" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.READ_IF_PRESENT,
                                            ref.IOobject.AUTO_WRITE ),
                              mesh,
                              runTime.deltaT(),
                              ref.zeroGradientFvPatchScalarField.typeName )
                              
    sources = man.IObasicSourceList(mesh)
    
    return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue, sources
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
Example #16
0
def fun_UEqn( mesh, U, p_rgh, ghf, rho, rhoPhi, turbulence, twoPhaseProperties, pimple ):
    muEff = man.surfaceScalarField( ref.word( "muEff" ),
                                    man.surfaceScalarField( twoPhaseProperties.muf(), man.Deps( twoPhaseProperties ) )
                                    + man.fvc.interpolate( rho * man.volScalarField( turbulence.ext_nut(), man.Deps( turbulence ) ) ) )

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

    UEqn.relax()
        
    if pimple.momentumPredictor():
        ref.solve( UEqn  == ref.fvc.reconstruct( ( - ghf * ref.fvc.snGrad( rho ) - ref.fvc.snGrad( p_rgh ) ) * mesh.magSf() ) )
        pass

    return UEqn
Example #17
0
def _createFields( runTime, mesh ):
    
    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 Urel\n" << ref.nl

    Urel = man.volVectorField( man.IOobject( ref.word( "Urel" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.MUST_READ,
                                             ref.IOobject.AUTO_WRITE ),
                               mesh )
  
    ref.ext_Info() << "Reading/calculating face flux field phi\n" << ref.nl
    phi = man.surfaceScalarField( man.IOobject( ref.word( "phi" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh,
                                                ref.IOobject.READ_IF_PRESENT,
                                                ref.IOobject.AUTO_WRITE ), 
                                  man.surfaceScalarField( ref.linearInterpolate( Urel ) & mesh.Sf(), man.Deps( mesh, Urel ) ) )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PIMPLE" ) ), pRefCell, pRefValue )
    
    laminarTransport = man.singlePhaseTransportModel( Urel, phi )
    
    turbulence = man.incompressible.turbulenceModel.New( Urel, phi, laminarTransport )
    
    ref.ext_Info() << "Creating SRF model\n" << ref.nl
    SRF = man.SRF.SRFModel.New( Urel ) 
    
    sources = man.IObasicSourceList( mesh )
    
    # Create the absolute velocity
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.NO_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            man.volVectorField( Urel() + SRF.U(), man.Deps( Urel, SRF ) ) ) # mixed  calculations

    return p, U, Urel, SRF, phi, turbulence, pRefCell, pRefValue, laminarTransport, sources
Example #18
0
def Ueqn( mesh, pimple, phi, U, p, turbulence, sources ):

    UEqn = man.fvm.ddt(U) + man.fvm.div(phi, U) + man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) ) \
           == man.fvVectorMatrix( sources(U), man.Deps( U ) )
    
    UEqn.relax()
    sources.constrain( UEqn )
    
    rAU = man.volScalarField( 1.0/UEqn.A(), man.Deps( UEqn ) )

    if pimple.momentumPredictor():
       ref.solve( UEqn == -man.fvc.grad( p ) )
       pass
    
    return UEqn, rAU
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
Example #20
0
def Ueqn( mesh, pimple, phi, U, p, turbulence, sources ):
    # The initial C++ expression does not work properly, because of
    #  1. turbulence.divDevRhoReff( U ) - changes values for the U boundaries
    #  2. the order of expression arguments computation differs with C++
    #UEqn = man.fvm.ddt(U) + man.fvm.div(phi, U) + man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) )           
    UEqn = man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) )  + ( man.fvm.ddt(U) + man.fvm.div(phi, U) )
    UEqn.relax()
    sources.constrain( UEqn )
    
    rAU = man.volScalarField( 1.0/UEqn.A(), man.Deps( UEqn ) )

    if pimple.momentumPredictor():
       ref.solve( UEqn == -ref.fvc.grad( p ) + sources( U ) )
       pass
    
    return UEqn, rAU
Example #21
0
def Ueqn( mesh, pimple, phi, U, p, turbulence ):

    UEqn = man.fvm.ddt(U) + man.fvm.div(phi, U) + man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) )
    
    UEqn.relax()
    
    rAU = man.volScalarField( 1.0/UEqn.A(), man.Deps( UEqn ) )

    if pimple.momentumPredictor():
       ref.solve( UEqn == -man.fvc.grad( p ) )
       pass
    else:
       U << rAU * ( UEqn.H() - ref.fvc.grad( p ) )
       U.correctBoundaryConditions()
       pass
    
    return UEqn, rAU
Example #22
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
Example #23
0
def fun_UEqn( mesh, phi, U, p, turbulence, pZones, nUCorr, pressureImplicitPorosity ):
    
    # Construct the Momentum equation

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

    UEqn = man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) ) + man.fvm.div( phi, U ) 

    UEqn.relax()

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

    trAU = None
    trTU = None
    if pressureImplicitPorosity :
        tTU = man.volTensorField( ref.tensor( ref.I ) * UEqn.A(), man.Deps( UEqn ) )

        pZones.addResistance( UEqn, tTU )
    
        trTU = man.volTensorField( tTU.inv(), man.Deps( tTU ) )
               
        trTU.rename( ref.word( "rAU" ) )
        
        for UCorr in range ( nUCorr ):
            U << ( trTU() & ( UEqn.H() - ref.fvc.grad( p ) ) ) # mixed calculations
            pass
        
        U.correctBoundaryConditions()
        pass
    else:
        pZones.addResistance( UEqn )
        
        ref.solve( UEqn == -man.fvc.grad( p ) )
        
        trAU = man.volScalarField( 1.0 / UEqn.A(), man.Deps( UEqn ) )
        
        trAU.rename( ref.word( "rAU" ) )
        pass
    
    return UEqn, trTU, trAU
Example #24
0
def fun_UEqn( mesh, phi, U, p, turbulence, pZones, nUCorr, pressureImplicitPorosity, sources ):
    
    # Construct the Momentum equation
    UEqn = man.fvm.div( phi, U ) + man.fvVectorMatrix( turbulence.divDevReff( U ), man.Deps( turbulence, U ) ) == man( sources( U ), man.Deps( U ) )

    UEqn.relax()
    
    sources.constrain( UEqn )

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

    trAU = None
    trTU = None
    if pressureImplicitPorosity :
        tTU = man.volTensorField( ref.tensor( ref.I ) * UEqn.A(), man.Deps( UEqn ) )

        pZones.addResistance( UEqn, tTU )
    
        trTU = man.volTensorField( tTU.inv(), man.Deps( tTU ) )
               
        trTU.rename( ref.word( "rAU" ) )
        
        for UCorr in range ( nUCorr ):
            U << ( trTU() & ( UEqn.H() - ref.fvc.grad( p ) ) ) # mixed calculations
            pass
        
        U.correctBoundaryConditions()
        pass
    else:
        pZones.addResistance( UEqn )
        
        ref.solve( UEqn == -man.fvc.grad( p ) )
        
        trAU = man.volScalarField( 1.0 / UEqn.A(), man.Deps( UEqn ) )
        
        trAU.rename( ref.word( "rAU" ) )
        pass
    
    return UEqn, trTU, trAU
Example #25
0
def _createFields( runTime, mesh ):
        
    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 )

    return p, U, phi
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
Example #27
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
Example #29
0
def createFluidFields( fluidRegions, runTime ) :
    
    # Initialise fluid field pointer lists
    thermoFluid = list() 
    rhoFluid = list()
    KFluid = list()
    UFluid = list()
    phiFluid = list()
    gFluid = list()
    turbulence =list()
    p_rghFluid = list()
    ghFluid = list()
    ghfFluid = list()
    radiation =list()
    DpDtFluid =list()
    initialMassFluid = list()
    
    #Populate fluid field pointer lists

    for index in range( fluidRegions.__len__() ) :
        ref.ext_Info() << "*** Reading fluid mesh thermophysical properties for region " \
            << fluidRegions[ index ].name() << ref.nl << ref.nl

        ref.ext_Info()<< "    Adding to thermoFluid\n" << ref.nl
        
        thermo = man.basicRhoThermo.New( fluidRegions[ index ] )
        thermoFluid.append( thermo )
        
        ref.ext_Info()<< "    Adding to rhoFluid\n" << ref.nl
        rhoFluid.append( man.volScalarField( man.IOobject( ref.word( "rho" ), 
                                                           ref.fileName( runTime.timeName() ), 
                                                           fluidRegions[ index ], 
                                                           ref.IOobject.NO_READ, 
                                                           ref.IOobject.AUTO_WRITE ),
                                              man.volScalarField( thermoFluid[ index ].rho(), man.Deps( thermoFluid[ index ] ) ) ) )
        
        ref.ext_Info()<< "    Adding to KFluid\n" << ref.nl
        KFluid.append( man.volScalarField( man.IOobject( ref.word( "K" ),
                                                         ref.fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         ref.IOobject.NO_READ,
                                                         ref.IOobject.NO_WRITE ),
                                            man.volScalarField( thermoFluid[ index ].Cp() * thermoFluid[ index ].alpha(), 
                                                                man.Deps( thermoFluid[ index ] ) ) ) )
                                                       
        ref.ext_Info()<< "    Adding to UFluid\n" << ref.nl
        UFluid.append( man.volVectorField( man.IOobject( ref.word( "U" ),
                                                         ref.fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         ref.IOobject.MUST_READ,
                                                         ref.IOobject.AUTO_WRITE ),
                                           fluidRegions[ index ] ) )
        
        ref.ext_Info()<< "    Adding to phiFluid\n" << ref.nl
        phiFluid.append( man.surfaceScalarField( man.IOobject( ref.word( "phi" ),
                                                               ref.fileName( runTime.timeName() ),
                                                               fluidRegions[ index ],
                                                               ref.IOobject.READ_IF_PRESENT,
                                                               ref.IOobject.AUTO_WRITE),
                                                  man.linearInterpolate( rhoFluid[ index ] * UFluid[ index ] ) & 
                                                  man.surfaceVectorField( fluidRegions[ index ].Sf(), man.Deps( fluidRegions[ index ] ) ) ) )
        
        ref.ext_Info()<< "    Adding to gFluid\n" << ref.nl
        gFluid.append( man.uniformDimensionedVectorField( man.IOobject( ref.word( "g" ),
                                                                        ref.fileName( runTime.constant() ),
                                                                        fluidRegions[ index ],
                                                                        ref.IOobject.MUST_READ,
                                                                        ref.IOobject.NO_WRITE ) ) )        
        
        ref.ext_Info()<< "    Adding to turbulence\n" << ref.nl
        turbulence.append( man.compressible.turbulenceModel.New( rhoFluid[ index ],
                                                                 UFluid[ index ],
                                                                 phiFluid[ index ],
                                                                 thermoFluid[ index ] ) )
        ref.ext_Info() << "    Adding to ghFluid\n" << ref.nl
        ghFluid.append( man.volScalarField( ref.word( "gh" ) , 
                                            gFluid[ index ] & man.volVectorField( fluidRegions[ index ].C(), man.Deps( fluidRegions[ index ] ) ) ) )

        ref.ext_Info() << "    Adding to ghfFluid\n" << ref.nl
        ghfFluid.append( man.surfaceScalarField( ref.word( "ghf" ), 
                                                 gFluid[ index ] & man.surfaceVectorField( fluidRegions[ index ].Cf(), man.Deps( fluidRegions[ index ] ) ) ) )

        p_rghFluid.append( man.volScalarField( man.IOobject( ref.word( "p_rgh" ),
                                                             ref.fileName( runTime.timeName() ),
                                                             fluidRegions[ index ],
                                                             ref.IOobject.MUST_READ,
                                                             ref.IOobject.AUTO_WRITE ),
                                               fluidRegions[ index ] ) )
        # Force p_rgh to be consistent with p
        p_rghFluid[ index ] << thermoFluid[ index ].p()() - rhoFluid[ index ] * ghFluid[ index ]
        
        radiation.append( man.radiation.radiationModel.New( man.volScalarField( thermoFluid[ index ].T(), man.Deps( thermoFluid[ index ] ) ) ) )
        
        initialMassFluid.append( ref.fvc.domainIntegrate( rhoFluid[ index ] ).value()  )
        
        ref.ext_Info()<< "    Adding to DpDtFluid\n" << ref.nl
        DpDtFluid.append( man.volScalarField( ref.word( "DpDt" ), 
                                              man.fvc.DDt( man.surfaceScalarField( ref.word( "phiU" ), 
                                                                                   phiFluid[ index ] / man.fvc.interpolate( rhoFluid[ index ] ) ),
                                                           man.volScalarField( thermoFluid[ index ].p(), man.Deps( thermoFluid[ index ] ) ) ) ) )

    
    return thermoFluid, rhoFluid, KFluid, UFluid, phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation
Example #30
0
def createFluidFields( fluidRegions, runTime ) :
    
    # Initialise fluid field pointer lists
    thermoFluid = list() 
    rhoFluid = list()
    kappaFluid = list()
    UFluid = list()
    phiFluid = list()
    gFluid = list()
    turbulence =list()
    p_rghFluid = list()
    ghFluid = list()
    ghfFluid = list()
    radiation =list()
    KFluid = list()
    dpdtFluid =list()
    initialMassFluid = list()
    
    #Populate fluid field pointer lists

    for index in range( fluidRegions.__len__() ) :
        ref.ext_Info() << "*** Reading fluid mesh thermophysical properties for region " \
            << fluidRegions[ index ].name() << ref.nl << ref.nl

        ref.ext_Info()<< "    Adding to thermoFluid\n" << ref.nl
        
        thermo = man.basicRhoThermo.New( fluidRegions[ index ] )
        thermoFluid.append( thermo )
        
        ref.ext_Info()<< "    Adding to rhoFluid\n" << ref.nl
        rhoFluid.append( man.volScalarField( man.IOobject( ref.word( "rho" ), 
                                                           ref.fileName( runTime.timeName() ), 
                                                           fluidRegions[ index ], 
                                                           ref.IOobject.NO_READ, 
                                                           ref.IOobject.AUTO_WRITE ),
                                              man.volScalarField( thermoFluid[ index ].rho(), man.Deps( thermoFluid[ index ] ) ) ) )
        
        ref.ext_Info()<< "    Adding to kappaFluid\n" << ref.nl
        kappaFluid.append( man.volScalarField( man.IOobject( ref.word( "kappa" ),
                                                             ref.fileName( runTime.timeName() ),
                                                             fluidRegions[ index ],
                                                             ref.IOobject.NO_READ,
                                                             ref.IOobject.NO_WRITE ),
                                               man.volScalarField( thermoFluid[ index ].Cp() * thermoFluid[ index ].alpha(), 
                                                                   man.Deps( thermoFluid[ index ] ) ) ) )
                                                       
        ref.ext_Info()<< "    Adding to UFluid\n" << ref.nl
        UFluid.append( man.volVectorField( man.IOobject( ref.word( "U" ),
                                                         ref.fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         ref.IOobject.MUST_READ,
                                                         ref.IOobject.AUTO_WRITE ),
                                           fluidRegions[ index ] ) )
        
        ref.ext_Info()<< "    Adding to phiFluid\n" << ref.nl
        phiFluid.append( man.surfaceScalarField( man.IOobject( ref.word( "phi" ),
                                                               ref.fileName( runTime.timeName() ),
                                                               fluidRegions[ index ],
                                                               ref.IOobject.READ_IF_PRESENT,
                                                               ref.IOobject.AUTO_WRITE),
                                                  man.linearInterpolate( rhoFluid[ index ] * UFluid[ index ] ) & 
                                                  man.surfaceVectorField( fluidRegions[ index ].Sf(), man.Deps( fluidRegions[ index ] ) ) ) )
        
        ref.ext_Info()<< "    Adding to gFluid\n" << ref.nl
        gFluid.append( man.uniformDimensionedVectorField( man.IOobject( ref.word( "g" ),
                                                                        ref.fileName( runTime.constant() ),
                                                                        fluidRegions[ index ],
                                                                        ref.IOobject.MUST_READ,
                                                                        ref.IOobject.NO_WRITE ) ) )        
        
        ref.ext_Info()<< "    Adding to turbulence\n" << ref.nl
        turbulence.append( man.compressible.turbulenceModel.New( rhoFluid[ index ],
                                                                 UFluid[ index ],
                                                                 phiFluid[ index ],
                                                                 thermoFluid[ index ] ) )
        ref.ext_Info() << "    Adding to ghFluid\n" << ref.nl
        ghFluid.append( man.volScalarField( ref.word( "gh" ) , 
                                            gFluid[ index ] & man.volVectorField( fluidRegions[ index ].C(), man.Deps( fluidRegions[ index ] ) ) ) )

        ref.ext_Info() << "    Adding to ghfFluid\n" << ref.nl
        ghfFluid.append( man.surfaceScalarField( ref.word( "ghf" ), 
                                                 gFluid[ index ] & man.surfaceVectorField( fluidRegions[ index ].Cf(), man.Deps( fluidRegions[ index ] ) ) ) )

        p_rghFluid.append( man.volScalarField( man.IOobject( ref.word( "p_rgh" ),
                                                             ref.fileName( runTime.timeName() ),
                                                             fluidRegions[ index ],
                                                             ref.IOobject.MUST_READ,
                                                             ref.IOobject.AUTO_WRITE ),
                                               fluidRegions[ index ] ) )
        # Force p_rgh to be consistent with p
        p_rghFluid[ index ] << thermoFluid[ index ].p()() - rhoFluid[ index ] * ghFluid[ index ]
        
        radiation.append( man.radiation.radiationModel.New( man.volScalarField( thermoFluid[ index ].T(), man.Deps( thermoFluid[ index ] ) ) ) )
        
        initialMassFluid.append( ref.fvc.domainIntegrate( rhoFluid[ index ] ).value()  )
        
        ref.ext_Info() << "    Adding to KFluid\n" << ref.nl
        KFluid.append( man.volScalarField( ref.word( "K" ),
                                           man.volScalarField( 0.5 * UFluid[ index ].magSqr(), man.Deps( UFluid[ index ] ) ) ) )
        
        ref.ext_Info()<< "    Adding to dpdtFluid\n" << ref.nl
        dpdtFluid.append( man.volScalarField( ref.word( "dpdt" ), 
                                              man.volScalarField( ref.fvc.ddt( thermoFluid[ index ].p() ), man.Deps( thermoFluid[ index ] ) ) ) )

    
    return thermoFluid, rhoFluid, kappaFluid, UFluid, phiFluid, gFluid, turbulence, KFluid, dpdtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation
Example #31
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
Example #32
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
Example #33
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
    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 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