Esempio n. 1
0
def _createFields( runTime, mesh, R, Cv ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField    
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    psi = volScalarField( IOobject( word( "psi" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.NO_WRITE ),
                          1.0 / ( R * T ) )
    psi.oldTime()
    
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh ),
                          psi * p,
                          p.ext_boundaryField().types() )
    
    rhoU = volVectorField( IOobject( word( "rhoU" ),
                                     fileName( runTime.timeName() ) , 
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE ),
                           rho * U,
                           U.ext_boundaryField().types() )

    rhoE = volScalarField( IOobject( word( "rhoE" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE ),
                           rho * Cv * T + 0.5 * rho * ( rhoU / rho ).magSqr(),
                           T.ext_boundaryField().types() )
    
    return p, T, U, psi, rho, rhoU, rhoE
Esempio n. 2
0
def _createFields( runTime, mesh, Omega, gHat ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    ext_Info() << "Reading field h\n" << nl
    h = volScalarField( IOobject( word( "h" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.MUST_READ,
                                    IOobject.AUTO_WRITE ),
                        mesh )
    from Foam.OpenFOAM import dimLength, dimensionedScalar
    ext_Info() << "Reading field h0 if present\n" << nl
    h0 = volScalarField( IOobject( word( "h0" ),
                                   fileName( runTime.findInstance( fileName( word( "polyMesh" ) ), word( "points" ) ) ) ,
                                   mesh,
                                   IOobject.READ_IF_PRESENT ),
                         mesh,
                         dimensionedScalar( word( "h0" ), dimLength, 0.0 ) )
    
    from Foam.finiteVolume import volVectorField
    ext_Info() << "Reading field U\n" << nl
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    ext_Info() << "Creating field hU\n" << nl
    hU = volVectorField( IOobject( word( "hU" ),
                                   fileName( runTime.timeName() ),
                                   mesh ),
                         h * U,
                         U.ext_boundaryField().types() )
    
    ext_Info() << "Creating field hTotal for post processing\n" << nl
    hTotal = volScalarField( IOobject( word( "hTotal" ),
                                       fileName( runTime.timeName() ),
                                       mesh, 
                                       IOobject.READ_IF_PRESENT,
                                       IOobject.AUTO_WRITE ),
                             h + h0 )
                             
    hTotal.write()
    
    phi = createPhi( runTime, hU, mesh )
    
    ext_Info() << "Creating Coriolis Force" << nl
    from Foam.OpenFOAM import dimensionedVector
    F = dimensionedVector( word( "F" ), ( ( 2.0 * Omega ) & gHat ) * gHat )
    
    return h, h0, U, hU, hTotal, phi, F
Esempio n. 3
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo
    thermo = basicPsiThermo.New(mesh)

    p = thermo.p()
    e = thermo.e()
    T = thermo.T()
    psi = thermo.psi()
    mu = thermo.mu()

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    pbf, rhoBoundaryTypes = _rhoBoundaryTypes(p)

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

    from Foam.OpenFOAM import dimensionedScalar, dimless
    from Foam.finiteVolume import surfaceScalarField
    pos = surfaceScalarField(
        IOobject(word("pos"), fileName(runTime.timeName()), mesh), mesh,
        dimensionedScalar(word("pos"), dimless, 1.0))

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

    return thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid
Esempio n. 4
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo
    thermo = basicPsiThermo.New(mesh)

    p = thermo.p()
    e = thermo.e()
    psi = thermo.psi()
    rho = thermo.rho()

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh), rho())

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

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

    return p, e, psi, rho, U, phi, turbulence, thermo
Esempio n. 5
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.incompressible import createPhi

    phi = createPhi(runTime, mesh, U)

    from Foam.transportModels import singlePhaseTransportModel

    fluid = singlePhaseTransportModel(U, phi)

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell

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

    return p, U, phi, fluid, pRefCell, pRefValue
Esempio n. 6
0
def _createFields( runTime, mesh, rhoO, psi ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.AUTO_WRITE ),
                          rhoO + psi * p )
    
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    

    return p, U, rho, phi
Esempio n. 7
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh, U)

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(p,
                                     mesh.solutionDict().subDict(word("PISO")),
                                     pRefCell, pRefValue)

    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel(U, phi)

    from Foam import incompressible
    turbulence = incompressible.turbulenceModel.New(U, phi, laminarTransport)

    return p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport
Esempio n. 8
0
def createFields( runTime, mesh ):
    ext_Info() << "Reading field U\n" << nl
    
    from Foam.finiteVolume import volVectorField
    from Foam.OpenFOAM import IOobject, fileName, word
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume import volSymmTensorField
    from Foam.OpenFOAM import dimensionedSymmTensor, symmTensor
    from Foam.OpenFOAM import dimForce, dimArea
    sigma = volSymmTensorField( IOobject( word( "sigma" ),
                                          fileName( runTime.timeName() ),
                                          mesh,
                                          IOobject.READ_IF_PRESENT,
                                          IOobject.AUTO_WRITE ),
                                mesh,
                                dimensionedSymmTensor( word( "zero" ), dimForce/dimArea, symmTensor.zero)
                              )
    
    from materialModels.rheologyModel import rheologyModel
    rheology = rheologyModel( sigma )

    return U, sigma, rheology
Esempio n. 9
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    ext_Info() << "Reading field T\n" << nl
    T = volScalarField(
        IOobject(word("T"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

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

    ext_Info() << "Reading diffusivity D\n" << nl
    from Foam.OpenFOAM import dimensionedScalar
    DT = dimensionedScalar(transportProperties.lookup(word("DT")))

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh, U)

    return T, U, transportProperties, DT, phi
def createFields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    ext_Info() << "Reading thermophysical properties\n" << nl 

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
  
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )
    
    laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import incompressible
    turbulence = incompressible.RASModel.New( U, phi, laminarTransport )
    
    ext_Info() << "Calculating field beta*(g.h)\n" << nl
    from Foam.finiteVolume import surfaceScalarField
    betaghf = surfaceScalarField( word( "betagh" ), beta * ( g & mesh.Cf() ) )
    
    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )

    # Kinematic density for buoyancy force
    rhok = volScalarField( IOobject( word( "rhok" ),
                                     fileName( runTime.timeName() ),
                                     mesh ),
                           1.0 - beta * ( T - TRef ) )
    
    return T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, betaghf, pRefCell, pRefValue, rhok
Esempio n. 11
0
def create_fields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import basicRhoThermo
    thermo = basicRhoThermo.New( mesh )
    
    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.NO_WRITE ),
                          thermo.rho() )

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )

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

    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField( word( "gh" ), g & mesh.C() )
    
    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() )

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

    # Force p_rgh to be consistent with p
    p_rgh.ext_assign( p - rho * gh )

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    DpDt = volScalarField( word( "DpDt" ), fvc.DDt( surfaceScalarField( word( "phiU" ), phi / fvc.interpolate( rho ) ), p ) )

    return thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt
Esempio n. 12
0
def create_fields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo
    thermo = basicPsiThermo.New( mesh )

    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()
    
    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.READ_IF_PRESENT,
                                    IOobject.AUTO_WRITE ),
                          thermo.rho() )

    ext_Info() << "Reading field U\n" << nl
    
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )

    from Foam.OpenFOAM import dimensionedScalar
    pMin = dimensionedScalar( mesh.solutionDict().subDict( word( "PIMPLE" ) ).lookup( word( "pMin" ) ) )

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

    # initialMass = fvc.domainIntegrate(rho)

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    DpDt = fvc.DDt( surfaceScalarField( word( "phiU" ), phi / fvc.interpolate( rho ) ), p )

    from Foam.finiteVolume import MRFZones
    mrfZones = MRFZones( mesh )
    mrfZones.correctBoundaryVelocity( U )

    from Foam.finiteVolume import porousZones
    pZones = porousZones( mesh )
    
    from Foam.OpenFOAM import Switch
    pressureImplicitPorosity = Switch( False )
    
    return thermo, turbulence, p, h, psi, rho, U, phi, pMin, DpDt, mrfZones, pZones, pressureImplicitPorosity
Esempio n. 13
0
def _createFields(runTime, mesh, Omega, gHat):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    ext_Info() << "Reading field h\n" << nl
    h = volScalarField(
        IOobject(word("h"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)
    from Foam.OpenFOAM import dimLength, dimensionedScalar
    ext_Info() << "Reading field h0 if present\n" << nl
    h0 = volScalarField(
        IOobject(
            word("h0"),
            fileName(
                runTime.findInstance(fileName(word("polyMesh")),
                                     word("points"))), mesh,
            IOobject.READ_IF_PRESENT), mesh,
        dimensionedScalar(word("h0"), dimLength, 0.0))

    from Foam.finiteVolume import volVectorField
    ext_Info() << "Reading field U\n" << nl
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

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

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

    hTotal.write()

    phi = createPhi(runTime, hU, mesh)

    ext_Info() << "Creating Coriolis Force" << nl
    from Foam.OpenFOAM import dimensionedVector
    F = dimensionedVector(word("F"), ((2.0 * Omega) & gHat) * gHat)

    return h, h0, U, hU, hTotal, phi, F
Esempio n. 14
0
def create_fields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl
    
    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )

    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )

    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel( U, phi )

    from Foam import incompressible
    turbulence = incompressible.RASModel.New( U, phi, laminarTransport )

    from Foam.finiteVolume import porousZones
    pZones = porousZones( mesh )
    
    from Foam.OpenFOAM import Switch
    pressureImplicitPorosity = Switch( False )

    nUCorr = 0
    if pZones.size():
       # nUCorrectors for pressureImplicitPorosity
       if (mesh.solutionDict().subDict( word( "SIMPLE" ) ).found( word( "nUCorrectors" ) ) ) :
          from Foam.OpenFOAM import readInt
          nUCorr = readInt( mesh.solutionDict().subDict( word( "SIMPLE" ) ).lookup( word( "nUCorrectors" ) ) )
          pass
       if nUCorr > 0 :
          pressureImplicitPorosity = True
          pass
       pass

    return p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr
Esempio n. 15
0
def _createFields( runTime, mesh, R, Cv ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    ext_Info() << "Reading field T\n" << nl
    T = volScalarField( IOobject( word( "T" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    ext_Info() << "Calculating field e from T\n" << nl
    e = volScalarField( IOobject( word( "e" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.NO_READ,
                                  IOobject.NO_WRITE ),
                        Cv * T,
                        T.ext_boundaryField().types() )
    
    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    psi = volScalarField( IOobject( word( "psi" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.NO_WRITE ),
                          1.0 / ( R * T ) )
    psi.oldTime()
    
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh ),
                          psi * p )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )

    return p, T, e, U, psi, rho, phi 
def _createFields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    ext_Info() << "Reading thermophysical properties\n" << nl 

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
  
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )
    
    laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import incompressible
    turbulence = incompressible.RASModel.New( U, phi, laminarTransport )
    
    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue )

    # Kinematic density for buoyancy force
    rhok = volScalarField( IOobject( word( "rhok" ),
                                     fileName( runTime.timeName() ),
                                     mesh ),
                           1.0 - beta * ( T - TRef ) )
    
    return T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, pRefCell, pRefValue, rhok
Esempio n. 17
0
def create_fields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo
    thermo = basicPsiThermo.New(mesh)

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

    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), thermo.rho())

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

    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

    from Foam.OpenFOAM import dimensionedScalar
    pMin = dimensionedScalar(mesh.solutionDict().subDict(
        word("PIMPLE")).lookup(word("pMin")))

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

    # initialMass = fvc.domainIntegrate(rho)

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    DpDt = fvc.DDt(
        surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)), p)

    from Foam.finiteVolume import MRFZones
    mrfZones = MRFZones(mesh)
    mrfZones.correctBoundaryVelocity(U)

    from Foam.finiteVolume import porousZones
    pZones = porousZones(mesh)

    from Foam.OpenFOAM import Switch
    pressureImplicitPorosity = Switch(False)

    return thermo, turbulence, p, h, psi, rho, U, phi, pMin, DpDt, mrfZones, pZones, pressureImplicitPorosity
Esempio n. 18
0
def create_fields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl

    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    p = volScalarField(
        IOobject(word("p"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh, U)

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(
        p,
        mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue)

    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel(U, phi)

    from Foam import incompressible
    turbulence = incompressible.RASModel.New(U, phi, laminarTransport)

    from Foam.finiteVolume import porousZones
    pZones = porousZones(mesh)

    from Foam.OpenFOAM import Switch
    pressureImplicitPorosity = Switch(False)

    nUCorr = 0
    if pZones.size():
        # nUCorrectors for pressureImplicitPorosity
        if (mesh.solutionDict().subDict(word("SIMPLE")).found(
                word("nUCorrectors"))):
            from Foam.OpenFOAM import readInt
            nUCorr = readInt(mesh.solutionDict().subDict(
                word("SIMPLE")).lookup(word("nUCorrectors")))
            pass
        if nUCorr > 0:
            pressureImplicitPorosity = True
            pass
        pass

    return p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr
Esempio n. 19
0
def createFields(runTime, mesh, g):
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import autoPtr_basicPsiThermo, basicPsiThermo

    thermo = basicPsiThermo.New(mesh)

    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho())
    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New(rho, U, phi, thermo())

    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField(word("gh"), g & mesh.C())
    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField(word("ghf"), g & mesh.Cf())

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

    #Force p_rgh to be consistent with p
    p_rgh.ext_assign(p - rho * gh)

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(
        p, p_rgh,
        mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue)

    from Foam import fvc
    initialMass = fvc.domainIntegrate(rho)
    totalVolume = mesh.V().ext_sum()

    return thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, pRefCell, pRefValue, initialMass, totalVolume
Esempio n. 20
0
def create_fields(runTime, mesh, g):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicRhoThermo
    thermo = basicRhoThermo.New(mesh)

    from Foam.OpenFOAM import IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho())

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

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

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

    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField(word("ghf"), g & mesh.Cf())

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

    # Force p_rgh to be consistent with p
    p_rgh.ext_assign(p - rho * gh)

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    DpDt = volScalarField(
        word("DpDt"),
        fvc.DDt(surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)),
                p))

    return thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt
Esempio n. 21
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import basicPsiThermo
    thermo = basicPsiThermo.New( mesh )

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.READ_IF_PRESENT,
                                    IOobject.AUTO_WRITE ),
                          thermo.rho() )

    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()
   
    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    
    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )
    
    from Foam.OpenFOAM import dimensionedScalar
    pMin = dimensionedScalar( mesh.solutionDict().subDict( word( "SIMPLE" ) ).lookup( word( "pMin" ) ) )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New( rho,
                                            U,
                                            phi,
                                            thermo() )
    
    from Foam.OpenFOAM import dimensionedScalar
    from Foam import fvc   
    initialMass = fvc.domainIntegrate( rho )
    
    return thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, pMin
Esempio n. 22
0
def _createFields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl 

    from Foam.thermophysicalModels import basicRhoThermo
    thermo = basicRhoThermo.New( mesh )

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    rho= volScalarField( IOobject( word( "rho" ),
                                   fileName( runTime.timeName() ),
                                   mesh,
                                   IOobject.NO_READ,
                                   IOobject.NO_WRITE ),
                         thermo.rho() )

    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()
    
    ext_Info() << "Reading field U\n" << nl
    
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible 
    turbulence = compressible.turbulenceModel.New( rho, U, phi, thermo() )
    
    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    DpDt = volScalarField( word( "DpDt" ),
                           fvc.DDt( surfaceScalarField( word( "phiU" ), phi / fvc.interpolate( rho ) ), p ) )
    
    thermo.correct()

    initialMass = fvc.domainIntegrate(rho);
    
    totalVolume = mesh.V().ext_sum()
    
    return thermo, p, h, psi, phi, rho, U, turbulence, DpDt, initialMass, totalVolume
Esempio n. 23
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import basicPsiThermo
    thermo = basicPsiThermo.New( mesh )
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.NO_WRITE ),
                          thermo.rho() )

    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()
    
    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New( rho, U, phi, thermo() )
    
    thermo.correct()

    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )

    from Foam import fvc
    initialMass = fvc.domainIntegrate(rho)
    
    return thermo, rho, p, h, psi, U, phi, turbulence, initialMass, pRefCell, pRefValue
Esempio n. 24
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    ext_Info() << "Reading field p\n" << nl
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh(),
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh() )
    
    from Foam.finiteVolume import volVectorField
    ext_Info() << "Reading field U\n" << nl
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh() ,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh() )
    
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh(), U )
    
    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PIMPLE" ) ), pRefCell, pRefValue )
    
    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel( U, phi )
    
    from Foam import incompressible
    turbulence = incompressible.turbulenceModel.New( U, phi, laminarTransport )
    
    from Foam.finiteVolume import zeroGradientFvPatchScalarField
    ext_Info() << "Reading field rAU if present\n" << nl
    rAU = volScalarField( IOobject( word( "rAU" ),
                                    fileName( runTime.timeName() ),
                                    mesh(),
                                    IOobject.READ_IF_PRESENT,
                                    IOobject.AUTO_WRITE ),
                          mesh(),
                          runTime.deltaT(),
                          zeroGradientFvPatchScalarField.typeName )
    
    return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue
Esempio n. 25
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl

    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo

    thermo = basicPsiThermo.New(mesh)

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

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi

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

    from Foam.OpenFOAM import dimensionedScalar

    pMin = dimensionedScalar(mesh.solutionDict().subDict(word("PIMPLE")).lookup(word("pMin")))

    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible

    turbulence = compressible.turbulenceModel.New(rho, U, phi, thermo())

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField

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

    return p, h, psi, rho, U, phi, turbulence, thermo, pMin, DpDt
Esempio n. 26
0
def _createFields(runTime, mesh, g):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicRhoThermo
    thermo = basicRhoThermo.New(mesh)

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho())

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

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

    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

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

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    DpDt = volScalarField(
        word("DpDt"),
        fvc.DDt(surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)),
                p))

    thermo.correct()

    initialMass = fvc.domainIntegrate(rho)

    totalVolume = mesh.V().ext_sum()

    return thermo, p, h, psi, phi, rho, U, turbulence, DpDt, initialMass, totalVolume
Esempio n. 27
0
def createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() <<  "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import  basicThermo, autoPtr_basicThermo
    thermo = basicThermo.New( mesh )

    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()
    rho = thermo.rho()
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh ),
                          rho )
    ext_Info() << "Reading field U\n" << nl    
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
        
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )    
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New( rho,
                                                    U,
                                                    phi,
                                                    thermo() )
    ext_Info() << "Creating field DpDt\n" << nl
    
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    
    DpDt = fvc.DDt( surfaceScalarField(word( "phiU" ), phi / fvc.interpolate( rho ) ), p );
        
    return thermo, p, h, psi, rho, U, phi, turbulence, DpDt
Esempio n. 28
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
        
    ext_Info() << "Reading field p\n" << nl
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.NO_WRITE ),
                        mesh )
    
    from Foam.OpenFOAM import dimensionedScalar
    p.ext_assign( dimensionedScalar( word( "zero" ), p.dimensions(), 0.0 ) )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    from Foam.OpenFOAM import dimensionedVector, vector
    U.ext_assign( dimensionedVector( word( "0" ), U.dimensions(), vector.zero ) )

    from Foam.finiteVolume import surfaceScalarField
    from Foam import fvc
    phi = surfaceScalarField( IOobject( word( "phi" ),
                                        fileName( runTime.timeName() ),
                                        mesh,
                                        IOobject.NO_READ,
                                        IOobject.AUTO_WRITE ),
                              fvc.interpolate( U ) & mesh.Sf() )


    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )
           
    return p, U, phi, pRefCell, pRefValue
Esempio n. 29
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh, U)

    return p, U, phi
Esempio n. 30
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    from Foam.finiteVolume import volVectorField
    ext_Info() << "Reading field U\n" << nl
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh(),
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh())

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh(), U)

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(
        p,
        mesh.solutionDict().subDict(word("PIMPLE")), pRefCell, pRefValue)

    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel(U, phi)

    from Foam import incompressible
    turbulence = incompressible.turbulenceModel.New(U, phi, laminarTransport)

    from Foam.finiteVolume import zeroGradientFvPatchScalarField
    ext_Info() << "Reading field rAU if present\n" << nl
    rAU = volScalarField(
        IOobject(word("rAU"), fileName(runTime.timeName()), mesh(),
                 IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), mesh(),
        runTime.deltaT(), zeroGradientFvPatchScalarField.typeName)

    return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue
Esempio n. 31
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo
    thermo = basicPsiThermo.New(mesh)

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

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), thermo.rho())

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

    from Foam.OpenFOAM import dimensionedScalar
    pMin = dimensionedScalar(mesh.solutionDict().subDict(
        word("PIMPLE")).lookup(word("pMin")))

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

    ext_Info() << "Creating field DpDt\n" << nl
    from Foam import fvc
    from Foam.finiteVolume import surfaceScalarField
    DpDt = fvc.DDt(
        surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)), p)

    return p, h, psi, rho, U, phi, turbulence, thermo, pMin, DpDt
Esempio n. 32
0
def createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading transportProperties\n"

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    transportProperties = IOdictionary( IOobject( word( "transportProperties" ),
                                                  fileName( runTime.constant() ),
                                                  mesh,
                                                  IOobject.MUST_READ,
                                                  IOobject.NO_WRITE ) )

    from Foam.OpenFOAM import dimensionedScalar
    nu = dimensionedScalar( transportProperties.lookup( word( "nu" ) ) );

    ext_Info() << "Reading field p\n" << nl
    from Foam.finiteVolume import volScalarField
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue )

    return transportProperties, nu, p, U, phi, pRefCell, pRefValue
Esempio n. 33
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo
    thermo = basicPsiThermo.New( mesh )

    p = thermo.p()
    e = thermo.e()
    psi = thermo.psi()
    rho = thermo.rho()

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh ),
                          rho() )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )

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

    return p, e, psi, rho, U, phi, turbulence, thermo
Esempio n. 34
0
def _createFields(runTime, mesh, R, Cv):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl

    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word
    p = volScalarField(
        IOobject(word("p"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

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

    ext_Info() << "Calculating field e from T\n" << nl
    e = volScalarField(
        IOobject(word("e"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), Cv * T,
        T.ext_boundaryField().types())

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    psi = volScalarField(
        IOobject(word("psi"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), 1.0 / (R * T))
    psi.oldTime()

    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh), psi * p)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

    return p, T, e, U, psi, rho, phi
Esempio n. 35
0
def createFields(runTime, mesh):
    ext_Info() << "Reading field U\n" << nl

    from Foam.finiteVolume import volVectorField
    from Foam.OpenFOAM import IOobject, fileName, word
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume import volSymmTensorField
    from Foam.OpenFOAM import dimensionedSymmTensor, symmTensor
    from Foam.OpenFOAM import dimForce, dimArea
    sigma = volSymmTensorField(
        IOobject(word("sigma"), fileName(runTime.timeName()), mesh,
                 IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), mesh,
        dimensionedSymmTensor(word("zero"), dimForce / dimArea,
                              symmTensor.zero))

    from materialModels.rheologyModel import rheologyModel
    rheology = rheologyModel(sigma)

    return U, sigma, rheology
Esempio n. 36
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    ext_Info() << "Reading field T\n" << nl
    T = volScalarField( IOobject( word( "T" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )


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


    ext_Info() << "Reading diffusivity D\n" << nl
    from Foam.OpenFOAM import dimensionedScalar
    DT = dimensionedScalar( transportProperties.lookup( word( "DT" ) ) )
 
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )
           
    return T, U, transportProperties, DT, phi 
Esempio n. 37
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

    from Foam.OpenFOAM import dimensionedScalar
    p.ext_assign(dimensionedScalar(word("zero"), p.dimensions(), 0.0))

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)
    from Foam.OpenFOAM import dimensionedVector, vector
    U.ext_assign(dimensionedVector(word("0"), U.dimensions(), vector.zero))

    from Foam.finiteVolume import surfaceScalarField
    from Foam import fvc
    phi = surfaceScalarField(
        IOobject(word("phi"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.AUTO_WRITE),
        fvc.interpolate(U) & mesh.Sf())

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(
        p,
        mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue)

    return p, U, phi, pRefCell, pRefValue
Esempio n. 38
0
def createFluidFields( fluidRegions, runTime ) :

    # Load boundary conditions
    from .. import derivedFvPatchFields

    # Initialise fluid field pointer lists
    from Foam.finiteVolume import PtrList_volScalarField
    rhoFluid = PtrList_volScalarField( fluidRegions.size() )
    KFluid =  PtrList_volScalarField( fluidRegions.size() )

    from Foam.finiteVolume import PtrList_volVectorField
    UFluid = PtrList_volVectorField( fluidRegions.size() )

    from Foam.finiteVolume import PtrList_surfaceScalarField
    phiFluid = PtrList_surfaceScalarField( fluidRegions.size() )    

    DpDtFluid = PtrList_volScalarField( fluidRegions.size() )
     
    from Foam.OpenFOAM import PtrList_uniformDimensionedVectorField
    gFluid = PtrList_uniformDimensionedVectorField( fluidRegions.size() )
 
    from Foam.compressible import PtrList_compressible_turbulenceModel
    turbulence = PtrList_compressible_turbulenceModel( fluidRegions.size() ) 
    
    from Foam.thermophysicalModels import PtrList_basicRhoThermo
    thermoFluid = PtrList_basicRhoThermo( fluidRegions.size() ) 
    
    p_rghFluid = PtrList_volScalarField( fluidRegions.size() )
    
    ghFluid = PtrList_volScalarField( fluidRegions.size() )
    
    ghfFluid = PtrList_surfaceScalarField(fluidRegions.size())
    
    from Foam.OpenFOAM import scalarList
    initialMassFluid = scalarList( fluidRegions.size() )
    
    #Populate fluid field pointer lists

    for index in range( fluidRegions.size() ) :
        from Foam.OpenFOAM import ext_Info, nl
        ext_Info() << "*** Reading fluid mesh thermophysical properties for region " \
            << fluidRegions[ index ].name() << nl << nl

        ext_Info()<< "    Adding to thermoFluid\n" << nl
        
        from Foam.thermophysicalModels import autoPtr_basicRhoThermo, basicRhoThermo
 
        thermo= basicRhoThermo.New( fluidRegions[ index ] )
        thermoFluid.ext_set( index, thermo )
        
        ext_Info()<< "    Adding to rhoFluid\n" << nl
        from Foam.OpenFOAM import word, fileName, IOobject
        from Foam.finiteVolume import volScalarField
        rhoFluid.ext_set( index, volScalarField( IOobject( word( "rho" ), 
                                                           fileName( runTime.timeName() ), 
                                                           fluidRegions[ index ], 
                                                           IOobject.NO_READ, 
                                                           IOobject.AUTO_WRITE ),
                                                 thermoFluid[ index ].rho() ) )
        
        ext_Info()<< "    Adding to KFluid\n" << nl
        KFluid.ext_set( index, volScalarField( IOobject( word( "K" ),
                                                         fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         IOobject.NO_READ,
                                                         IOobject.NO_WRITE ),
                                               thermoFluid[ index ].Cp().ptr() * thermoFluid[ index ].alpha() ) )
                                                       
        ext_Info()<< "    Adding to UFluid\n" << nl
        from Foam.finiteVolume import volVectorField
        UFluid.ext_set( index, volVectorField( IOobject( word( "U" ),
                                                         fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         IOobject.MUST_READ,
                                                         IOobject.AUTO_WRITE ),
                                               fluidRegions[ index ] ) )
        
        ext_Info()<< "    Adding to phiFluid\n" << nl
        from Foam.finiteVolume import surfaceScalarField
        from Foam.finiteVolume import linearInterpolate

        phiFluid.ext_set( index, surfaceScalarField( IOobject( word( "phi" ),
                                                               fileName( runTime.timeName() ),
                                                               fluidRegions[ index ],
                                                               IOobject.READ_IF_PRESENT,
                                                               IOobject.AUTO_WRITE),
                                                     linearInterpolate( rhoFluid[ index ] * UFluid[ index ] ) & fluidRegions[ index ].Sf() ) )
        
        ext_Info()<< "    Adding to gFluid\n" << nl
        from Foam.OpenFOAM import uniformDimensionedVectorField
        gFluid.ext_set( index, uniformDimensionedVectorField( IOobject( word( "g" ),
                                                                        fileName( runTime.constant() ),
                                                                        fluidRegions[ index ],
                                                                        IOobject.MUST_READ,
                                                                        IOobject.NO_WRITE ) ) )        
        
        ext_Info()<< "    Adding to turbulence\n" << nl
        from Foam import compressible
        turbulence.ext_set( index, compressible.turbulenceModel.New( rhoFluid[ index ],
                                                                     UFluid[ index ],
                                                                     phiFluid[ index ],
                                                                     thermoFluid[ index ] ) )
        ext_Info() << "    Adding to ghFluid\n" << nl
        ghFluid.ext_set( index, volScalarField( word( "gh" ) , gFluid[ index ] & fluidRegions[ index ].C() ) )

        ext_Info() << "    Adding to ghfFluid\n" << nl
        ghfFluid.ext_set( index, surfaceScalarField( word( "ghf" ), gFluid[ index ] & fluidRegions[ index ].Cf() ) )

        p_rghFluid.ext_set( index, volScalarField( IOobject( word( "p_rgh" ),
                                                         fileName( runTime.timeName() ),
                                                         fluidRegions[ index ],
                                                         IOobject.MUST_READ,
                                                         IOobject.AUTO_WRITE ),
                                               fluidRegions[ index ] ) )
        # Force p_rgh to be consistent with p
        p_rghFluid[ index ].ext_assign( thermoFluid[ index ].p() - rhoFluid[ index ] * ghFluid[ index ] )
        
        from Foam import fvc
        initialMassFluid[ index ] = fvc.domainIntegrate( rhoFluid[ index ] ).value() 
        
        ext_Info()<< "    Adding to DpDtFluid\n" << nl
        DpDtFluid.ext_set( index, volScalarField( word( "DpDt" ), fvc.DDt( surfaceScalarField( word( "phiU" ), 
                                                                                               phiFluid[ index ] / fvc.interpolate( rhoFluid[ index ] ) ),
                                                                           thermoFluid[ index ].p() ) ) )

    
    return thermoFluid, rhoFluid, KFluid, UFluid, phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid
Esempio n. 39
0
def _createFields(runTime, mesh, g):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi(runTime, mesh, U)

    ext_Info() << "Reading transportProperties\n" << nl
    from Foam.transportModels import twoPhaseMixture
    twoPhaseProperties = twoPhaseMixture(U, phi, word("alpha1"))

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

    # Need to store rho for ddt(rho, U)
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 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.
    from Foam.finiteVolume import surfaceScalarField
    rhoPhi = surfaceScalarField(
        IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi)

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

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

    pdRefCell = 0
    pdRefValue = 0.0

    from Foam.finiteVolume import setRefCell
    pdRefCell, pdRefValue = setRefCell(
        pd,
        mesh.solutionDict().subDict(word("PISO")), pdRefCell, pdRefValue)

    pRefValue = 0.0

    if pd.needReference():
        from Foam.OpenFOAM import readScalar, dimensionedScalar
        from Foam.finiteVolume import getRefCellValue
        pRefValue = readScalar(mesh.solutionDict().subDict(
            word("PISO")).lookup(word("pRefValue")))
        p.ext_assign(
            p + dimensionedScalar(word("p"), p.dimensions(), pRefValue -
                                  getRefCellValue(p, pdRefCell)))
        pass

    # Construct interface from alpha1 distribution
    from Foam.transportModels import interfaceProperties
    interface = interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    from Foam import incompressible
    turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties)

    return p, pd, gh, ghf, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pdRefCell, pdRefValue, pRefValue, interface, turbulence
Esempio n. 40
0
def createFluidFields(fluidRegions, runTime):

    # Load boundary conditions
    from .. import derivedFvPatchFields

    # Initialise fluid field pointer lists
    from Foam.finiteVolume import PtrList_volScalarField
    rhoFluid = PtrList_volScalarField(fluidRegions.size())
    KFluid = PtrList_volScalarField(fluidRegions.size())

    from Foam.finiteVolume import PtrList_volVectorField
    UFluid = PtrList_volVectorField(fluidRegions.size())

    from Foam.finiteVolume import PtrList_surfaceScalarField
    phiFluid = PtrList_surfaceScalarField(fluidRegions.size())

    DpDtFluid = PtrList_volScalarField(fluidRegions.size())

    from Foam.OpenFOAM import PtrList_uniformDimensionedVectorField
    gFluid = PtrList_uniformDimensionedVectorField(fluidRegions.size())

    from Foam.compressible import PtrList_compressible_turbulenceModel
    turbulence = PtrList_compressible_turbulenceModel(fluidRegions.size())

    from Foam.thermophysicalModels import PtrList_basicPsiThermo
    thermoFluid = PtrList_basicPsiThermo(fluidRegions.size())

    p_rghFluid = PtrList_volScalarField(fluidRegions.size())

    ghFluid = PtrList_volScalarField(fluidRegions.size())

    ghfFluid = PtrList_surfaceScalarField(fluidRegions.size())

    from Foam.OpenFOAM import scalarList
    initialMassFluid = scalarList(fluidRegions.size())

    #Populate fluid field pointer lists

    for index in range(fluidRegions.size()):
        from Foam.OpenFOAM import ext_Info, nl
        ext_Info() << "*** Reading fluid mesh thermophysical properties for region " \
            << fluidRegions[ index ].name() << nl << nl

        ext_Info() << "    Adding to thermoFluid\n" << nl

        from Foam.thermophysicalModels import autoPtr_basicPsiThermo, basicPsiThermo

        thermo = basicPsiThermo.New(fluidRegions[index])
        thermoFluid.ext_set(index, thermo)

        ext_Info() << "    Adding to rhoFluid\n" << nl
        from Foam.OpenFOAM import word, fileName, IOobject
        from Foam.finiteVolume import volScalarField
        rhoFluid.ext_set(
            index,
            volScalarField(
                IOobject(word("rho"), fileName(runTime.timeName()),
                         fluidRegions[index], IOobject.NO_READ,
                         IOobject.AUTO_WRITE), thermoFluid[index].rho()))

        ext_Info() << "    Adding to KFluid\n" << nl
        KFluid.ext_set(
            index,
            volScalarField(
                IOobject(word("K"), fileName(runTime.timeName()),
                         fluidRegions[index], IOobject.NO_READ,
                         IOobject.NO_WRITE),
                thermoFluid[index].Cp().ptr() * thermoFluid[index].alpha()))

        ext_Info() << "    Adding to UFluid\n" << nl
        from Foam.finiteVolume import volVectorField
        UFluid.ext_set(
            index,
            volVectorField(
                IOobject(word("U"), fileName(runTime.timeName()),
                         fluidRegions[index], IOobject.MUST_READ,
                         IOobject.AUTO_WRITE), fluidRegions[index]))

        ext_Info() << "    Adding to phiFluid\n" << nl
        from Foam.finiteVolume import surfaceScalarField
        from Foam.finiteVolume import linearInterpolate

        phiFluid.ext_set(
            index,
            surfaceScalarField(
                IOobject(word("phi"), fileName(runTime.timeName()),
                         fluidRegions[index], IOobject.READ_IF_PRESENT,
                         IOobject.AUTO_WRITE),
                linearInterpolate(rhoFluid[index] * UFluid[index])
                & fluidRegions[index].Sf()))

        ext_Info() << "    Adding to gFluid\n" << nl
        from Foam.OpenFOAM import uniformDimensionedVectorField
        gFluid.ext_set(
            index,
            uniformDimensionedVectorField(
                IOobject(word("g"), fileName(runTime.constant()),
                         fluidRegions[index], IOobject.MUST_READ,
                         IOobject.NO_WRITE)))

        ext_Info() << "    Adding to turbulence\n" << nl
        from Foam import compressible
        turbulence.ext_set(
            index,
            compressible.turbulenceModel.New(rhoFluid[index], UFluid[index],
                                             phiFluid[index],
                                             thermoFluid[index]))
        ext_Info() << "    Adding to ghFluid\n" << nl
        ghFluid.ext_set(
            index,
            volScalarField(word("gh"),
                           gFluid[index] & fluidRegions[index].C()))

        ext_Info() << "    Adding to ghfFluid\n" << nl
        ghfFluid.ext_set(
            index,
            surfaceScalarField(word("ghf"),
                               gFluid[index] & fluidRegions[index].Cf()))

        p_rghFluid.ext_set(
            index,
            volScalarField(
                IOobject(word("p_rgh"), fileName(runTime.timeName()),
                         fluidRegions[index], IOobject.MUST_READ,
                         IOobject.AUTO_WRITE), fluidRegions[index]))
        # Force p_rgh to be consistent with p
        p_rghFluid[index].ext_assign(thermoFluid[index].p() -
                                     rhoFluid[index] * ghFluid[index])

        from Foam import fvc
        initialMassFluid[index] = fvc.domainIntegrate(rhoFluid[index]).value()

        ext_Info() << "    Adding to DpDtFluid\n" << nl
        DpDtFluid.ext_set(
            index,
            volScalarField(
                word("DpDt"),
                fvc.DDt(
                    surfaceScalarField(
                        word("phiU"),
                        phiFluid[index] / fvc.interpolate(rhoFluid[index])),
                    thermoFluid[index].p())))

    return thermoFluid, rhoFluid, KFluid, UFluid, phiFluid, gFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid
def createFields( runTime, mesh, g ):
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import autoPtr_basicPsiThermo, basicPsiThermo

    thermo = basicPsiThermo.New(mesh)
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName
    rho =  volScalarField( IOobject( word( "rho" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE),
                           thermo.rho() )
    p = thermo.p()
    h = thermo.h()
    psi = thermo.psi()

    ext_Info()<< "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) 

    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField ( word( "gh" ), g & mesh.C() )
    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() )

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

    #Force p_rgh to be consistent with p
    p_rgh.ext_assign( p - rho*gh )

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, p_rgh, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )
    
    from Foam import fvc
    initialMass = fvc.domainIntegrate( rho )
    totalVolume = mesh.V().ext_sum()
    
                        
    return thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, pRefCell, pRefValue, initialMass, totalVolume
Esempio n. 42
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volVectorField
        
    ext_Info() << "Reading field U\n" << nl
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    ext_Info() << "Creating face flux\n" << nl
    from Foam.OpenFOAM import dimensionedScalar
    from Foam.finiteVolume import surfaceScalarField
    phi = surfaceScalarField( IOobject( word( "phi" ),
                                        fileName( runTime.timeName() ),
                                        mesh,
                                        IOobject.NO_READ,
                                        IOobject.NO_WRITE ),
                              mesh,
                              dimensionedScalar( word( "zero" ), mesh.Sf().dimensions()*U.dimensions(), 0.0) )

    
    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel( U, phi )
    
    from Foam import incompressible
    turbulence = incompressible.RASModel.New( U, phi, laminarTransport )
    
    transportProperties = IOdictionary( IOobject( word( "transportProperties" ),
                                        fileName( runTime.constant() ),
                                        mesh,
                                        IOobject.MUST_READ,
                                        IOobject.NO_WRITE ) )
    from Foam.OpenFOAM import dimensionedVector, vector
    Ubar = dimensionedVector( transportProperties.lookup( word( "Ubar" ) ) )
    
    flowDirection = ( Ubar / Ubar.mag() ).ext_value()
    flowMask = flowDirection.sqr()
    
    nWallFaces = 0.0
    from Foam.OpenFOAM import vector
    wallNormal = vector.zero
    
    patches = mesh.boundary()
    
    for patchi in range( mesh.boundary().size() ):
        currPatch = patches[patchi]
        
        from Foam.finiteVolume import wallFvPatch
        if wallFvPatch.ext_isType( currPatch ):
           
           for facei in range( currPatch.size() ):
               nWallFaces = nWallFaces +1
               
               if nWallFaces == 1:
                  wallNormal = - mesh.Sf().ext_boundaryField()[patchi][facei] / mesh.magSf().ext_boundaryField()[patchi][facei]
                  pass
               elif nWallFaces == 2:
                  wallNormal2 = mesh.Sf().ext_boundaryField()[patchi][facei] / mesh.magSf().ext_boundaryField()[patchi][facei]
                  
                  #- Check that wall faces are parallel
                  from Foam.OpenFOAM import mag
                  if mag(wallNormal & wallNormal2) > 1.01 or mag(wallNormal & wallNormal2) < 0.99:
                     ext_Info() << "boundaryFoam: wall faces are not parallel" << nl
                     import os
                     os.abort()
                     pass
                  pass
               else:
                  ext_Info() << "boundaryFoam: number of wall faces > 2" << nl
                  import os
                  os.abort()
               pass
           pass
        pass
    #- create position array for graph generation
    y = wallNormal & mesh.C().internalField()
    
    from Foam.OpenFOAM import dimensionSet, vector, word
    gradP = dimensionedVector( word( "gradP" ),
                               dimensionSet( 0.0, 1.0, -2.0, 0.0, 0.0 ),
                               vector( 0.0, 0.0, 0.0 ) )
              
    return U, phi, laminarTransport, turbulence, Ubar, wallNormal, flowDirection, flowMask, y, gradP
Esempio n. 43
0
def _createFields(runTime, mesh, R, Cv):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    p = volScalarField(
        IOobject(word("p"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)
    p.oldTime()

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

    psi = volScalarField(
        IOobject(word("psi"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.AUTO_WRITE), 1.0 / (R * T))
    psi.oldTime()

    pbf, rhoBoundaryTypes = _rhoBoundaryTypes(p)

    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.AUTO_WRITE), p * psi,
        rhoBoundaryTypes)

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    Ubf, rhoUboundaryTypes = _rhoUboundaryTypes(U)

    rhoU = volVectorField(
        IOobject(word("rhoU"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.AUTO_WRITE), rho * U,
        rhoUboundaryTypes)

    Tbf, rhoEboundaryTypes = _rhoEboundaryTypes(T)

    rhoE = volScalarField(
        IOobject(word("rhoE"), fileName(runTime.timeName()), mesh,
                 IOobject.NO_READ, IOobject.AUTO_WRITE),
        rho * Cv * T + 0.5 * rho * (rhoU / rho).magSqr(), rhoEboundaryTypes)

    phiHeader, phi, phiTypes = compressibleCreatePhi(runTime, mesh, rhoU)

    phi.oldTime()

    from Foam.finiteVolume import surfaceScalarField, linearInterpolate
    phiv = surfaceScalarField(
        IOobject(word("phiv"), fileName(runTime.timeName()), mesh),
        phi / linearInterpolate(rho),
        phi.ext_boundaryField().types())

    rhoU.correctBoundaryConditions()

    from Foam.finiteVolume import TfieldTable_scalar
    fields = TfieldTable_scalar()

    magRhoU = rhoU.mag()
    H = volScalarField(word("H"), (rhoE + p) / rho)

    fields.add(rho)
    fields.add(magRhoU)
    fields.add(H)

    return p, T, psi, pbf, rhoBoundaryTypes, rho, U, Ubf, rhoUboundaryTypes, rhoU, Tbf, rhoEboundaryTypes, rhoE, phi, phiv, rhoU, fields, magRhoU, H
Esempio n. 44
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicThermo, autoPtr_basicThermo
    thermo = basicThermo.New(mesh)

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh,
                 IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), thermo.rho())
    p = thermo.p()
    h = thermo.h()

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField(
        IOobject(word("U"), fileName(runTime.timeName()), mesh,
                 IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi(runTime, mesh, rho, U)

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell(
        p,
        mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue)

    from Foam.OpenFOAM import dimensionedScalar
    pMin = dimensionedScalar(mesh.solutionDict().subDict(
        word("SIMPLE")).lookup(word("pMin")))

    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New(rho, U, phi, thermo())

    from Foam import fvc
    initialMass = fvc.domainIntegrate(rho)

    from Foam.finiteVolume import porousZones
    pZones = porousZones(mesh)

    from Foam.OpenFOAM import Switch
    pressureImplicitPorosity = Switch(False)

    nUCorr = 0

    if pZones.size():
        # nUCorrectors for pressureImplicitPorosity
        if (mesh.solutionDict().subDict(word("SIMPLE")).found(
                word("nUCorrectors"))):
            from Foam.OpenFOAM import readInt
            nUCorr = readInt(mesh.solutionDict().subDict(
                word("SIMPLE")).lookup(word("nUCorrectors")))
            pass
        if nUCorr > 0:
            pressureImplicitPorosity = True
            pass
        pass

    return turbulence, p, h, rho, U, phi, thermo, pZones, pMin, pressureImplicitPorosity, initialMass, nUCorr, pRefCell, pRefValue
def createFields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    
    ext_Info() << "Reading thermophysical properties\n" << nl 

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
  
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )
    
    laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import incompressible
    turbulence = incompressible.RASModel.New( U, phi, laminarTransport )
    
    # Kinematic density for buoyancy force
    rhok = volScalarField( IOobject( word( "rhok" ),
                                     fileName( runTime.timeName() ),
                                     mesh ),
                           1.0 - beta * ( T - TRef ) )
    
    # kinematic turbulent thermal thermal conductivity m2/s
    ext_Info() << "Reading field kappat\n" << nl
    kappat = volScalarField( IOobject( word( "kappat" ),
                                       fileName( runTime.timeName() ),
                                       mesh,
                                       IOobject.MUST_READ,
                                       IOobject.AUTO_WRITE ),
                             mesh )
    
    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField( word( "gh" ), g & mesh.C() )
    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() )

    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.NO_READ,
                                  IOobject.AUTO_WRITE ),
                        p_rgh + rhok * gh )
    
    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( p, p_rgh, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue )
    
    if p_rgh.needReference():
       from Foam.finiteVolume import getRefCellValue
       from Foam.OpenFOAM import dimensionedScalar
       p.ext_assign( p + dimensionedScalar( word( "p" ), p.dimensions(), pRefValue - getRefCellValue( p, pRefCell) ) )
       pass
    
    return T, p, p_rgh, U, phi, laminarTransport, gh, ghf, TRef,Pr, Prt, turbulence, beta, pRefCell, pRefValue, rhok, kappat
Esempio n. 46
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl

    ext_Info() << "Reading thermophysical properties\n" << nl

    from Foam.thermophysicalModels import basicThermo, autoPtr_basicThermo

    thermo = basicThermo.New(mesh)

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh, IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE),
        thermo.rho(),
    )
    p = thermo.p()
    h = thermo.h()

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi

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

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell

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

    from Foam.OpenFOAM import dimensionedScalar

    pMin = dimensionedScalar(mesh.solutionDict().subDict(word("SIMPLE")).lookup(word("pMin")))

    # ext_Info() << "Creating turbulence model\n" << nl
    # from Foam import compressible
    # turbulence = compressible.turbulenceModel.New( rho, U, phi, thermo() )

    from Foam import fvc

    initialMass = fvc.domainIntegrate(rho)

    from Foam.finiteVolume import porousZones

    pZones = porousZones(mesh)

    from Foam.OpenFOAM import Switch

    pressureImplicitPorousity = Switch(False)

    nUCorr = 0

    if pZones.size():
        mesh.solutionDict().subDict(word("SIMPLE")).lookup(
            word("pressureImplicitPorousity")
        ) >> pressureImplicitPorousity
        pass

    return p, h, rho, U, phi, thermo, pZones, pMin, pressureImplicitPorousity, initialMass, nUCorr, pRefCell, pRefValue
Esempio n. 47
0
def _createFields(runTime, mesh, g):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.incompressible import createPhi

    phi = createPhi(runTime, mesh, U)

    ext_Info() << "Reading transportProperties\n" << nl
    from Foam.transportModels import twoPhaseMixture

    twoPhaseProperties = twoPhaseMixture(U, phi)

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

    from Foam.OpenFOAM import dimensionedScalar

    Dab = dimensionedScalar(twoPhaseProperties.lookup(word("Dab")))

    # Read the reciprocal of the turbulent Schmidt number
    alphatab = dimensionedScalar(twoPhaseProperties.lookup(word("alphatab")))

    # Need to store rho for ddt(rho, U)

    from Foam.OpenFOAM import scalar

    rho = volScalarField(word("rho"), alpha1 * rho1 + (scalar(1) - alpha1) * rho2)
    rho.oldTime()

    # Mass flux
    # Initialisation does not matter because rhoPhi is reset after the
    # alpha1 solution before it is used in the U equation.
    from Foam.finiteVolume import surfaceScalarField

    rhoPhi = surfaceScalarField(
        IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi
    )

    # Construct incompressible turbulence model
    from Foam import incompressible

    turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties)

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

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

    pRefCell = 0
    pRefValue = 0.0
    from Foam.finiteVolume import setRefCell, getRefCellValue

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

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

    return (
        p_rgh,
        alpha1,
        U,
        phi,
        twoPhaseProperties,
        rho1,
        rho2,
        Dab,
        alphatab,
        rho,
        rhoPhi,
        turbulence,
        gh,
        ghf,
        p,
        pRefCell,
        pRefValue,
    )
Esempio n. 48
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.incompressible import createPhi

    phi = createPhi(runTime, mesh, U)

    ext_Info() << "Reading transportProperties\n" << nl
    from Foam.transportModels import twoPhaseMixture

    twoPhaseProperties = twoPhaseMixture(U, phi)

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

    # Need to store rho for ddt(rho, U)
    rho = volScalarField(
        IOobject(word("rho"), fileName(runTime.timeName()), mesh, 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.
    from Foam.finiteVolume import surfaceScalarField

    rhoPhi = surfaceScalarField(
        IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi
    )

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell

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

    # Construct interface from alpha1 distribution
    from Foam.transportModels import interfaceProperties

    interface = interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    from Foam import incompressible

    turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties)

    return p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, pRefValue, interface, turbulence
Esempio n. 49
0
def _createFields( runTime, mesh, R, Cv ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading field p\n" << nl
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh ) 
    p.oldTime()

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

    psi = volScalarField( IOobject( word( "psi" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.AUTO_WRITE ),
                          1.0 / ( R * T ) )
    psi.oldTime()

    pbf, rhoBoundaryTypes = _rhoBoundaryTypes( p )
    
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.AUTO_WRITE ),
                          p * psi,
                          rhoBoundaryTypes )
                          
    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    Ubf, rhoUboundaryTypes = _rhoUboundaryTypes( U )

    rhoU = volVectorField( IOobject( word( "rhoU" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.AUTO_WRITE ),
                           rho * U,
                           rhoUboundaryTypes )

    Tbf, rhoEboundaryTypes = _rhoEboundaryTypes( T )

    rhoE = volScalarField( IOobject( word( "rhoE" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.AUTO_WRITE ),
                           rho * Cv * T + 0.5 * rho * ( rhoU / rho ).magSqr(),
                           rhoEboundaryTypes )
                           
    phiHeader, phi, phiTypes = compressibleCreatePhi( runTime, mesh, rhoU )
    
    phi.oldTime()
    
    from Foam.finiteVolume import surfaceScalarField, linearInterpolate
    phiv = surfaceScalarField( IOobject( word( "phiv" ),
                                         fileName( runTime.timeName() ),
                                         mesh ),
                               phi / linearInterpolate( rho ),
                               phi.ext_boundaryField().types() )
    
    rhoU.correctBoundaryConditions()
    
    from Foam.finiteVolume import TfieldTable_scalar
    fields = TfieldTable_scalar()
    
    magRhoU = rhoU.mag()
    H = volScalarField( word( "H" ) , ( rhoE + p ) / rho )

    fields.add( rho )
    fields.add( magRhoU )
    fields.add( H )
    
    return p, T, psi, pbf, rhoBoundaryTypes, rho, U, Ubf, rhoUboundaryTypes, rhoU, Tbf, rhoEboundaryTypes, rhoE, phi, phiv, rhoU, fields, magRhoU, H 
def createFields(runTime, mesh, g):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField

    ext_Info() << "Reading thermophysical properties\n" << nl

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

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

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField

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

    from Foam.finiteVolume.cfdTools.incompressible import createPhi

    phi = createPhi(runTime, mesh, U)

    laminarTransport, beta, TRef, Pr, Prt = readTransportProperties(U, phi)

    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import incompressible

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

    # Kinematic density for buoyancy force
    rhok = volScalarField(IOobject(word("rhok"), fileName(runTime.timeName()), mesh), 1.0 - beta * (T - TRef))

    # kinematic turbulent thermal thermal conductivity m2/s
    ext_Info() << "Reading field kappat\n" << nl
    kappat = volScalarField(
        IOobject(word("kappat"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh
    )

    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField(word("gh"), g & mesh.C())
    from Foam.finiteVolume import surfaceScalarField

    ghf = surfaceScalarField(word("ghf"), g & mesh.Cf())

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

    pRefCell = 0
    pRefValue = 0.0

    from Foam.finiteVolume import setRefCell

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

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

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

    return (
        T,
        p,
        p_rgh,
        U,
        phi,
        laminarTransport,
        gh,
        ghf,
        TRef,
        Pr,
        Prt,
        turbulence,
        beta,
        pRefCell,
        pRefValue,
        rhok,
        kappat,
    )
Esempio n. 51
0
                                                       IOobject.NO_READ, 
                                                       IOobject.AUTO_WRITE ),
                                             thermof[ index ].rho() ) )
        
        ext_Info()<< "    Adding to Kf\n" << nl
        Kf.ext_set( index, volScalarField( IOobject( word( "K" ),
                                                 fileName( runTime.timeName() ),
                                                 fluidRegions[ index ],
                                                 IOobject.NO_READ,
                                                 IOobject.NO_WRITE ),
                                       thermof[ index ].rho() * thermof[ index ].Cp() * thermof[ index ].alpha() ) )
        
        ext_Info() << "    Adding to Uf\n" << nl
        Uf.ext_set( index, volVectorField( IOobject( word( "U" ),
                                                     fileName( runTime.timeName() ),
                                                     fluidRegions[ index ],
                                                     IOobject.MUST_READ,
                                                     IOobject.AUTO_WRITE ),
                                           fluidRegions[ index ] ) )
        
        ext_Info() << "    Adding to phif\n" << nl
        from Foam.finiteVolume import linearInterpolate
        phif.ext_set( index, surfaceScalarField( IOobject( word( "phi" ),
                                                           fileName( runTime.timeName() ),
                                                           fluidRegions[ index ],
                                                           IOobject.READ_IF_PRESENT,
                                                           IOobject.AUTO_WRITE ),
                                                 linearInterpolate( rhof[ index ]*Uf[ index ] ) & fluidRegions[ index ].Sf() ) )

         
        ext_Info() << "    Adding to turb\n" << nl
        from Foam import compressible
def createFields( runTime, mesh, g ):
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import autoPtr_basicThermo, basicThermo
    thermo = basicThermo.New( mesh )
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName
    rho =  volScalarField( IOobject( word( "rho" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE),
                           thermo.rho() )
    p = thermo.p()
    h = thermo.h()
    T = thermo.T()

    ext_Info()<< "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    from Foam.finiteVolume.cfdTools.compressible import compressibleCreatePhi
    phi = compressibleCreatePhi( runTime, mesh, rho, U )
    
    ext_Info() << "Creating turbulence model\n" << nl
    from Foam import compressible
    turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) 

    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField ( word( "gh" ), g & mesh.C() )
    
    from Foam.OpenFOAM import dimensionedScalar
    pRef = dimensionedScalar( word( "pRef" ), p.dimensions(), thermo.lookup( word( "pRef" ) ) )
    
    ext_Info() << "Creating field pd\n" << nl
    pd = volScalarField( IOobject( word( "pd" ),
                                   fileName( runTime.timeName() ),
                                   mesh,
                                   IOobject.MUST_READ,
                                   IOobject.AUTO_WRITE ),
                         mesh )
    
    p.ext_assign( pd + rho * gh + pRef )
    thermo.correct()
    
    pdRefCell = 0
    pdRefValue = 0.0
    from Foam.finiteVolume import setRefCell
    pRefCell, pRefValue = setRefCell( pd, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pdRefCell, pdRefValue )
    
    ext_Info() << "Creating radiation model\n" << nl
    
    from Foam.radiation import radiationModel
    radiation =radiationModel.New( T )
    
    from Foam import fvc
    initialMass = fvc.domainIntegrate( rho )
    
                        
    return thermo, rho, p, h, T, U, phi, turbulence, gh, pRef, pd, p, pdRefCell, pdRefValue, radiation, initialMass 
Esempio n. 53
0
def _createFields( runTime, mesh ):
    # Load boundary condition
    from BCs import rho

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysical properties\n" << nl
    
    from Foam.thermophysicalModels import basicPsiThermo
    thermo = basicPsiThermo.New( mesh )
    
    p = thermo.p()
    e = thermo.e()
    T = thermo.T()
    psi = thermo.psi()
    mu = thermo.mu()
    
    inviscid = True
    if mu.internalField().max() > 0.0:
       inviscid = False
       pass
    
    ext_Info() << "Reading field U\n" << nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    pbf, rhoBoundaryTypes = _rhoBoundaryTypes( p )
    
    from Foam.finiteVolume import volScalarField
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.NO_READ,
                                    IOobject.AUTO_WRITE ),
                          thermo.rho(),
                          rhoBoundaryTypes )
    rhoU = volVectorField( IOobject( word( "rhoU" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE ),
                           rho*U )
    rhoE = volScalarField( IOobject( word( "rhoE" ),
                                     fileName( runTime.timeName() ),
                                     mesh,
                                     IOobject.NO_READ,
                                     IOobject.NO_WRITE ),
                           rho * ( e + 0.5 * U.magSqr() ) )
    
    from Foam.OpenFOAM import dimensionedScalar, dimless
    from Foam.finiteVolume import surfaceScalarField
    pos = surfaceScalarField( IOobject( word( "pos" ),
                                        fileName( runTime.timeName() ),
                                        mesh ),
                              mesh,
                              dimensionedScalar( word( "pos" ), dimless, 1.0) )
    
    neg = surfaceScalarField( IOobject( word( "neg" ),
                                        fileName( runTime.timeName() ),
                                        mesh ),
                              mesh,
                              dimensionedScalar( word( "neg" ), dimless, -1.0 ) )
    
    return thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid
Esempio n. 54
0
def _createFields( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
        
    ext_Info() << "Reading field p\n" << nl
    p_rgh = volScalarField( IOobject( word( "p_rgh" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
    
    ext_Info() << "Reading field alpha1\n" << nl
    alpha1 = volScalarField( IOobject( word( "alpha1" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                                mesh )
    
    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )
                        
    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )
    
    
    ext_Info() << "Reading transportProperties\n" << nl
    from Foam.transportModels import twoPhaseMixture
    twoPhaseProperties = twoPhaseMixture(U, phi)
    
    rho1 = twoPhaseProperties.rho1()
    rho2 = twoPhaseProperties.rho2()
    
    # Need to store rho for ddt(rho, U)
    rho = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    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.
    from Foam.finiteVolume import surfaceScalarField
    rhoPhi = surfaceScalarField( IOobject( word( "rho*phi" ),
                                           fileName( runTime.timeName() ),
                                           mesh,
                                           IOobject.NO_READ,
                                           IOobject.NO_WRITE ),
                                 rho1 * phi )
    
    # Construct interface from alpha1 distribution
    from Foam.transportModels import interfaceProperties
    interface = interfaceProperties( alpha1, U, twoPhaseProperties )


    # Construct incompressible turbulence model
    from Foam import incompressible
    turbulence = incompressible.turbulenceModel.New( U, phi, twoPhaseProperties ) 
    
    from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration
    g = readGravitationalAcceleration( runTime, mesh)

    
    #dimensionedVector g0(g);

    #Read the data file and initialise the interpolation table
    #interpolationTable<vector> timeSeriesAcceleration( runTime.path()/runTime.caseConstant()/"acceleration.dat" );
    
    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField( word( "gh" ), g & mesh.C() )
    ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() )
    
    p = volScalarField( IOobject( word( "p" ),
                        fileName( runTime.timeName() ),
                        mesh,
                        IOobject.NO_READ,
                        IOobject.AUTO_WRITE ),
                        p_rgh + rho * gh )

    pRefCell = 0
    pRefValue = 0.0
    
    from Foam.finiteVolume import setRefCell, getRefCellValue
    pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue )
    
    if p_rgh.needReference():
       p.ext_assign( p + dimensionedScalar( word( "p" ),
                                           p.dimensions(),
                                           pRefValue - getRefCellValue(p, pRefCell) ) )
       p_rgh.ext_assign( p - rho * gh )
       pass

    return p_rgh, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, pRefValue, interface, turbulence, g, gh, ghf
Esempio n. 55
0
def _createFields(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volVectorField

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

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

    from Foam.transportModels import singlePhaseTransportModel
    laminarTransport = singlePhaseTransportModel(U, phi)

    from Foam import incompressible
    turbulence = incompressible.RASModel.New(U, phi, laminarTransport)

    transportProperties = IOdictionary(
        IOobject(word("transportProperties"), fileName(runTime.constant()),
                 mesh, IOobject.MUST_READ, IOobject.NO_WRITE))
    from Foam.OpenFOAM import dimensionedVector, vector
    Ubar = dimensionedVector(transportProperties.lookup(word("Ubar")))

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

    nWallFaces = 0.0
    from Foam.OpenFOAM import vector
    wallNormal = vector.zero

    patches = mesh.boundary()

    for patchi in range(mesh.boundary().size()):
        currPatch = patches[patchi]

        from Foam.finiteVolume import wallFvPatch
        if wallFvPatch.ext_isA(currPatch):

            for facei in range(currPatch.size()):
                nWallFaces = nWallFaces + 1

                if nWallFaces == 1:
                    wallNormal = -mesh.Sf().ext_boundaryField(
                    )[patchi][facei] / mesh.magSf().ext_boundaryField(
                    )[patchi][facei]
                    pass
                elif nWallFaces == 2:
                    wallNormal2 = mesh.Sf().ext_boundaryField(
                    )[patchi][facei] / mesh.magSf().ext_boundaryField(
                    )[patchi][facei]

                    #- Check that wall faces are parallel
                    from Foam.OpenFOAM import mag
                    if mag(wallNormal
                           & wallNormal2) > 1.01 or mag(wallNormal
                                                        & wallNormal2) < 0.99:
                        ext_Info(
                        ) << "boundaryFoam: wall faces are not parallel" << nl
                        import os
                        os.abort()
                        pass
                    pass
                else:
                    ext_Info(
                    ) << "boundaryFoam: number of wall faces > 2" << nl
                    import os
                    os.abort()
                pass
            pass
        pass
    #- create position array for graph generation
    y = wallNormal & mesh.C().internalField()

    from Foam.OpenFOAM import dimensionSet, vector, word
    gradP = dimensionedVector(word("gradP"),
                              dimensionSet(0.0, 1.0, -2.0, 0.0, 0.0),
                              vector(0.0, 0.0, 0.0))

    return U, phi, laminarTransport, turbulence, Ubar, wallNormal, flowDirection, flowMask, y, gradP
Esempio n. 56
0
def _createFields( runTime, mesh, g ):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    from Foam.finiteVolume import volScalarField
        
    ext_Info() << "Reading field p_rgh\n" << nl
    p_rgh = volScalarField( IOobject( word( "p_rgh" ),
                                        fileName( runTime.timeName() ),
                                        mesh,
                                        IOobject.MUST_READ,
                                        IOobject.AUTO_WRITE ),
                              mesh )

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

    ext_Info() << "Calculating field alpha1\n" << nl
    from Foam.OpenFOAM import scalar
    alpha2 = volScalarField( word( "alpha2" ), scalar( 1 ) - alpha1 )

    ext_Info() << "Reading field U\n" << nl
    from Foam.finiteVolume import volVectorField
    U = volVectorField( IOobject( word( "U" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.MUST_READ,
                                  IOobject.AUTO_WRITE ),
                        mesh )

    from Foam.finiteVolume.cfdTools.incompressible import createPhi
    phi = createPhi( runTime, mesh, U )

    ext_Info() << "Reading transportProperties\n" << nl
    
    from Foam.transportModels import twoPhaseMixture
    twoPhaseProperties = twoPhaseMixture (U, phi)
    
    from Foam.OpenFOAM import dimensionedScalar
    rho10 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( word( "rho0" ) ) )
    rho20 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( word( "rho0" ) ) )
   
    psi1 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( word( "psi" ) ) )
    psi2 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( word( "psi" ) ) )

    pMin = dimensionedScalar( twoPhaseProperties.lookup( word( "pMin" ) ) )
    
    ext_Info() << "Calculating field g.h\n" << nl
    gh = volScalarField( word( "gh" ), g & mesh.C() )
    
    from Foam.finiteVolume import surfaceScalarField
    ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() )

    p = volScalarField( IOobject( word( "p" ),
                                  fileName( runTime.timeName() ),
                                  mesh,
                                  IOobject.NO_READ,
                                  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 = volScalarField( IOobject( word( "rho" ),
                                    fileName( runTime.timeName() ),
                                    mesh,
                                    IOobject.READ_IF_PRESENT,
                                    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.
    from Foam import fvc
    rhoPhi = surfaceScalarField( IOobject( word( "rho*phi" ),
                                           fileName( runTime.timeName() ),
                                           mesh,
                                           IOobject.NO_READ,
                                           IOobject.NO_WRITE ),
                                 fvc.interpolate( rho ) * phi )

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

    # Construct interface from alpha1 distribution
    from Foam.transportModels import interfaceProperties
    interface = interfaceProperties( alpha1, U, twoPhaseProperties )

    # Construct incompressible turbulence model
    from Foam import incompressible
    turbulence = 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