Пример #1
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
Пример #2
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
Пример #3
0
 # Load boundary Fields
  from .. import derivedFvPatchFields
 
 # Initialise fluid field pointer lists
 from Foam.thermophysicalModels import PtrList_basicThermo
 thermof = PtrList_basicThermo( fluidRegions.size() )
 
 from Foam.finiteVolume import PtrList_volScalarField
 rhof = PtrList_volScalarField( fluidRegions.size() )
 Kf = PtrList_volScalarField( fluidRegions.size() )
 
 from Foam.finiteVolume import PtrList_volVectorField
 Uf = PtrList_volVectorField(fluidRegions.size())
 
 from Foam.finiteVolume import PtrList_surfaceScalarField
 phif = PtrList_surfaceScalarField( fluidRegions.size() )
 
 from Foam.compressible import PtrList_compressible_RASModel
 turb = PtrList_compressible_RASModel( fluidRegions.size() )
 
 DpDtf = PtrList_volScalarField( fluidRegions.size() )
 
 ghf = PtrList_volScalarField( fluidRegions.size() )
 pdf = PtrList_volScalarField( fluidRegions.size() )
 
 from Foam.OpenFOAM import scalarList
 initialMassf = scalarList( fluidRegions.size() )
 
 from Foam.OpenFOAM import dimensionedScalar, word, dimensionSet
 pRef = dimensionedScalar( word( "pRef" ),
                           dimensionSet( 1.0, -1.0, -2.0, 0.0, 0.0 ),