コード例 #1
0
ファイル: __init__.py プロジェクト: asimurzin/rhopSonicFlux
def readThermodynamicProperties( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermodynamicProperties\n" << nl
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    thermodynamicProperties = IOdictionary( IOobject( word( "thermodynamicProperties" ),
                                                      fileName( runTime.constant() ),
                                                      mesh,
                                                      IOobject.MUST_READ,
                                                      IOobject.NO_WRITE ) )

    from Foam.OpenFOAM import dimensionedScalar
    R = dimensionedScalar( thermodynamicProperties.lookup( word( "R" ) ) )
    
    Cv = dimensionedScalar( thermodynamicProperties.lookup( word( "Cv" ) ) )

    Cp = Cv + R

    gamma = Cp / Cv
    
    from Foam.OpenFOAM import dimless
    Pr = dimensionedScalar( word( "Pr" ), dimless, 1.0 )
    if thermodynamicProperties.found( word( "Pr" ) ) :
       Pr = dimensionedScalar( thermodynamicProperties.lookup( "Pr" ) )
       pass

    return thermodynamicProperties, R, Cv, Cp, gamma, Pr
コード例 #2
0
ファイル: __init__.py プロジェクト: asimurzin/laplacianFlux
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 transportProperties\n" << nl

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

    ext_Info() << "Reading diffusivity DT\n" << nl
    from Foam.OpenFOAM import dimensionedScalar
    DT = dimensionedScalar( transportProperties.lookup( word( "DT" ) ) )
        
    return T, transportProperties, DT
コード例 #3
0
ファイル: __init__.py プロジェクト: asimurzin/sonicLiquidFlux
def readThermodynamicProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl

    ext_Info() << "Reading thermodynamicProperties\n" << nl

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

    thermodynamicProperties = IOdictionary(
        IOobject(
            word("thermodynamicProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE
        )
    )

    from Foam.OpenFOAM import dimensionedScalar

    rho0 = dimensionedScalar(thermodynamicProperties.lookup(word("rho0")))

    p0 = dimensionedScalar(thermodynamicProperties.lookup(word("p0")))

    psi = dimensionedScalar(thermodynamicProperties.lookup(word("psi")))

    # Density offset, i.e. the constant part of the density
    rhoO = dimensionedScalar(word("rhoO"), rho0 - psi * p0)

    return thermodynamicProperties, rho0, p0, psi, rhoO
コード例 #4
0
 def __init__(self, runTime):
     from Foam.OpenFOAM import IOobject, word, fileName
     IOdictionary.__init__(
         self,
         IOobject(word("regionProperties"),
                  fileName(runTime.time().constant()), runTime.db(),
                  IOobject.MUST_READ, IOobject.NO_WRITE))
     from Foam.OpenFOAM import wordList
     self.fluidRegionNames = wordList(self.lookup(word("fluidRegionNames")))
     self.solidRegionNames = wordList(self.lookup(word("solidRegionNames")))
     pass
コード例 #5
0
    def __init__( self, runTime ):
        from Foam.OpenFOAM import IOobject, word, fileName
        IOdictionary.__init__( self, IOobject( word( "regionProperties" ), 
                                               fileName( runTime.time().constant() ), 
                                               runTime.db(), 
                                               IOobject.MUST_READ, 
                                               IOobject.NO_WRITE  ) )
        from Foam.OpenFOAM import wordList
        self.fluidRegionNames = wordList( self.lookup( word( "fluidRegionNames" ) ) )
        self.solidRegionNames = wordList( self.lookup( word( "solidRegionNames" ) ) )
	pass
コード例 #6
0
ファイル: __init__.py プロジェクト: asimurzin/sonicLiquidFlux
def readTransportProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading transportProperties\n" << nl

    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
    mu = dimensionedScalar(transportProperties.lookup(word("mu")))

    return transportProperties, mu
コード例 #7
0
ファイル: __init__.py プロジェクト: giovastabile/pythonFlu
def readEnvironmentalProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nReading environmentalProperties" << nl

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

    return g, environmentalProperties
コード例 #8
0
ファイル: __init__.py プロジェクト: asimurzin/sonicFlux
def readingTransportProperties( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading transportProperties\n" << nl
    
    from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word
    transportProperties = IOdictionary( IOobject( word( "transportProperties" ),
                                                  fileName( runTime.constant() ),
                                                  mesh,
                                                  IOobject.MUST_READ,
                                                  IOobject.NO_WRITE ) )
    from Foam.OpenFOAM import dimensionedScalar
    mu = dimensionedScalar( transportProperties.lookup( word( "mu" ) ) )
    
    return transportProperties, mu
コード例 #9
0
def readThermodynamicProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermodynamicProperties\n" << nl

    from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word
    thermodynamicProperties = IOdictionary(
        IOobject(word("thermodynamicProperties"), fileName(runTime.constant()),
                 mesh, IOobject.MUST_READ, IOobject.NO_WRITE))
    from Foam.OpenFOAM import dimensionedScalar
    R = dimensionedScalar(thermodynamicProperties.lookup(word("R")))

    Cv = dimensionedScalar(thermodynamicProperties.lookup(word("Cv")))

    return thermodynamicProperties, R, Cv
コード例 #10
0
ファイル: __init__.py プロジェクト: alexey4petrov/pythonFlu
def readEnvironmentalProperties( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nReading environmentalProperties" << nl
    
    from Foam.OpenFOAM import IOdictionary, fileName, word, IOobject
    environmentalProperties = IOdictionary( IOobject( word( "environmentalProperties" ),
                                                      fileName( runTime.constant() ),
                                                      mesh,
                                                      IOobject.MUST_READ,
                                                      IOobject.NO_WRITE ) )
    from Foam.OpenFOAM import dimensionedVector
    g = dimensionedVector( environmentalProperties.lookup( word( "g" ) ) )
    
    return g, environmentalProperties
コード例 #11
0
    def updateCoeffs( self ) :
        try:
            
            if self.updated() :
               return
            from Foam.finiteVolume import volScalarField
            from Foam.OpenFOAM import word
            rhop = volScalarField.ext_lookupPatchField( self.patch(), word( "rho" ) )
            from Foam.finiteVolume import volVectorField            
            rhoUp =volVectorField.ext_lookupPatchField( self.patch(), word( "rhoU" ) )
            
            T = volScalarField.ext_lookupObject( self.db(), word( "T" ) )
            patchi = self.patch().index()
            Tp = T.ext_boundaryField()[patchi] 
            
            Tp.evaluate()

            from Foam.OpenFOAM import IOdictionary
            thermodynamicProperties = IOdictionary.ext_lookupObject( self.db(), word( "thermodynamicProperties" ) )
            
            from Foam.OpenFOAM import dimensionedScalar
            Cv = dimensionedScalar( thermodynamicProperties.lookup( word( "Cv" ) ) )
                   
            self.valueFraction().ext_assign( rhop.ext_snGrad() / ( rhop.ext_snGrad() -  rhop * self.patch().deltaCoeffs()  ) )
            self.refValue().ext_assign( 0.5 * rhop * ( rhoUp / rhop ).magSqr() )

            self.refGrad().ext_assign( rhop * Cv.value() * Tp.ext_snGrad() +\
                                       ( self.refValue() - ( 0.5 * rhop.patchInternalField()\
                                                          * ( rhoUp.patchInternalField() /rhop.patchInternalField() ).magSqr() ) ) * self.patch().deltaCoeffs() )
            mixedFvPatchScalarField.updateCoeffs( self )
            pass
        except Exception, exc:
            import sys, traceback
            traceback.print_exc( file = sys.stdout )
            raise exc
コード例 #12
0
ファイル: __init__.py プロジェクト: asimurzin/sonicFlux
def readThermodynamicProperties( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermodynamicProperties\n" << nl
    
    from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word
    thermodynamicProperties = IOdictionary( IOobject( word( "thermodynamicProperties" ),
                                                      fileName( runTime.constant() ),
                                                      mesh,
                                                      IOobject.MUST_READ,
                                                      IOobject.NO_WRITE ) )
    from Foam.OpenFOAM import dimensionedScalar
    R = dimensionedScalar( thermodynamicProperties.lookup( word( "R" ) ) )
    
    Cv = dimensionedScalar( thermodynamicProperties.lookup( word( "Cv" ) ) )
    
    return thermodynamicProperties, R, Cv
コード例 #13
0
ファイル: __init__.py プロジェクト: asimurzin/materialModels
    def updateCoeffs(self):
        try:
           if self.updated():
              return

           from Foam.OpenFOAM import IOdictionary
           rheology = IOdictionary.ext_lookupObject( self.db(), self.rheologyName_ )
           from Foam.OpenFOAM import scalarField
           
           # Python does not wait for evaluation of the closure expression, it destroys return values if it is no more in use
           a_rheology_mu = rheology.mu()
           a_rheology_mu_boundaryField = a_rheology_mu.ext_boundaryField()
           mu = scalarField( a_rheology_mu_boundaryField[self.patch().index()] )
           
           a_rheology_lambda = rheology._lambda()
           a_rheology_lambda_boundaryField = a_rheology_lambda.ext_boundaryField()
           lambda_ = scalarField( a_rheology_lambda_boundaryField[ self.patch().index() ] )

           n = self.patch().nf()
           from Foam.finiteVolume import volTensorField
           from Foam.OpenFOAM import word
           gradU =volTensorField.ext_lookupPatchField( self.patch(), word( "grad(" +str( self.UName_ ) + ")" ) )
           
           from Foam.OpenFOAM import ext_Info
           self.gradient().ext_assign( ( ( self.traction_ -  self.pressure_ * n ) - ( n & ( mu * gradU.ext_T() - ( mu + lambda_ ) * gradU ) ) \
                                          - n * lambda_ * gradU.tr() ) / ( 2.0 * mu + lambda_) )
           
           from Foam.finiteVolume import fixedGradientFvPatchVectorField
           fixedGradientFvPatchVectorField.updateCoeffs( self )
        except Exception, exc:
            import sys, traceback
            traceback.print_exc( file = sys.stdout )
            raise exc   
コード例 #14
0
def createFluidMeshes( rp, runTime ) :

    from Foam.finiteVolume import fvMesh, PtrList_fvMesh
    fluidRegions = PtrList_fvMesh( rp.fluidRegionNames.size() )
    from Foam.OpenFOAM import word, fileName, IOobject
    for index in range( rp.fluidRegionNames.size() ) :

        from Foam.OpenFOAM import ext_Info, nl
        ext_Info()<< "Create fluid mesh for region " << rp.fluidRegionNames[ index ] \
                  << " for time = " << runTime.timeName() << nl << nl
        mesh = fvMesh( IOobject( rp.fluidRegionNames[ index ],
                                 fileName( runTime.timeName() ),
                                 runTime,
                                 IOobject.MUST_READ ) ) 

        fluidRegions.ext_set( index, mesh )
        # Force calculation of geometric properties to prevent it being done
        # later in e.g. some boundary evaluation
        # (void)fluidRegions[i].weights();
        # (void)fluidRegions[i].deltaCoeffs();
        
        from Foam.OpenFOAM import IOdictionary, autoPtr_IOdictionary
        # Attach environmental properties to each region
        environmentalProperties = autoPtr_IOdictionary( IOdictionary( IOobject( word( "environmentalProperties" ),
                                                                                fileName( runTime.constant() ),
                                                                                fluidRegions[ index ],
                                                                                IOobject.MUST_READ,
                                                                                IOobject.NO_WRITE ) ) )
        
        environmentalProperties.ptr().store()
                
    return fluidRegions
コード例 #15
0
def readThermophysicalProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysicalProperties\n" << nl

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    # Pr defined as a separate constant to enable calculation of k, currently
    # inaccessible through thermo
    thermophysicalProperties = IOdictionary(
        IOobject(word("thermophysicalProperties"),
                 fileName(runTime.constant()), mesh, IOobject.MUST_READ,
                 IOobject.NO_WRITE))

    from Foam.OpenFOAM import dimensionedScalar, dimless
    Pr = dimensionedScalar(word("Pr"), dimless, 1.0)

    if thermophysicalProperties.found(word("Pr")):
        Pr = thermophysicalProperties.lookup(word("Pr"))
        pass
    return thermophysicalProperties, Pr
コード例 #16
0
def readTransportProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    ext_Info() << "\nReading transportProperties\n" << nl

    transportProperties = IOdictionary(
        IOobject(word("transportProperties"), fileName(runTime.constant()),
                 mesh, IOobject.MUST_READ, IOobject.NO_WRITE, False))

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

    #  Read centerline velocity for channel simulations
    Ubar = dimensionedVector(transportProperties.lookup(word("Ubar")))

    magUbar = Ubar.mag()
    from Foam.OpenFOAM import vector
    flowDirection = (Ubar / magUbar).ext_value()

    return transportProperties, nu, Ubar, magUbar, flowDirection
コード例 #17
0
ファイル: __init__.py プロジェクト: asimurzin/rhoCentralFlux
def readThermophysicalProperties( runTime, mesh ):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermophysicalProperties\n" << nl
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    # Pr defined as a separate constant to enable calculation of k, currently
    # inaccessible through thermo
    thermophysicalProperties = IOdictionary( IOobject( word( "thermophysicalProperties" ),
                                                       fileName( runTime.constant() ),
                                                       mesh,
                                                       IOobject.MUST_READ,
                                                       IOobject.NO_WRITE ) )
    
    from Foam.OpenFOAM import dimensionedScalar, dimless
    Pr = dimensionedScalar(word( "Pr" ), dimless, 1.0)
    
    if thermophysicalProperties.found( word( "Pr" ) ):
       Pr = thermophysicalProperties.lookup( word( "Pr" ) )
       pass
    return thermophysicalProperties, Pr
コード例 #18
0
ファイル: __init__.py プロジェクト: asimurzin/sonicLiquidFlux
def readThermodynamicProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermodynamicProperties\n" << nl

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

    from Foam.OpenFOAM import dimensionedScalar
    rho0 = dimensionedScalar(thermodynamicProperties.lookup(word("rho0")))

    p0 = dimensionedScalar(thermodynamicProperties.lookup(word("p0")))

    psi = dimensionedScalar(thermodynamicProperties.lookup(word("psi")))

    # Density offset, i.e. the constant part of the density
    rhoO = dimensionedScalar(word("rhoO"), rho0 - psi * p0)

    return thermodynamicProperties, rho0, p0, psi, rhoO
コード例 #19
0
ファイル: __init__.py プロジェクト: asimurzin/icoFlux
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
コード例 #20
0
def readThermodynamicProperties(runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Reading thermodynamicProperties\n" << nl

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

    from Foam.OpenFOAM import dimensionedScalar
    R = dimensionedScalar(thermodynamicProperties.lookup(word("R")))

    Cv = dimensionedScalar(thermodynamicProperties.lookup(word("Cv")))

    Cp = Cv + R

    gamma = Cp / Cv

    from Foam.OpenFOAM import dimless
    Pr = dimensionedScalar(word("Pr"), dimless, 1.0)
    if thermodynamicProperties.found(word("Pr")):
        Pr = dimensionedScalar(thermodynamicProperties.lookup("Pr"))
        pass

    return thermodynamicProperties, R, Cv, Cp, gamma, Pr
コード例 #21
0
    def __init__(self, sigma):
        from Foam.finiteVolume import volSymmTensorField
        try:
            volSymmTensorField.ext_isinstance( sigma )
        except TypeError:
            raise AssertionError( "args[ argc ].__class__ != volSymmTensorField" )
        
        from Foam.OpenFOAM import IOobject, word, fileName
        IOdictionary.__init__(self, IOobject( word( "rheologyProperties" ),
                                              fileName( sigma.time().constant() ),
                                              sigma.db(),
                                              IOobject.MUST_READ,
                                              IOobject.NO_WRITE ) )
        self.sigma_ = sigma
        
        self.typeName = word( "rheologyModel" )
        from Foam.OpenFOAM import Switch
        self.planeStress_ = Switch( self.lookup( word( "planeStress" ) ) )

        from materialModels.rheologyModel.rheologyLaws import rheologyLaw
        self.lawPtr_ = rheologyLaw.New( word( "law" ), self.sigma_, self.subDict( word( "rheology" ) ) )
        pass
コード例 #22
0
def readGravitationalAcceleration(runTime, mesh):
    from Foam.OpenFOAM import IOdictionary, word, fileName, IOobject
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nReading gravitationalProperties" << nl

    gravitationalProperties = IOdictionary(
        IOobject(word("gravitationalProperties"), fileName(runTime.constant()),
                 mesh, IOobject.MUST_READ, IOobject.NO_WRITE))

    from Foam.OpenFOAM import dimensionedVector, Switch, dimTime
    g = dimensionedVector(gravitationalProperties.lookup(word("g")))
    rotating = Switch(gravitationalProperties.lookup(word("rotating")))

    if rotating:
        Omega = dimensionedVector(gravitationalProperties.lookup(
            word("Omega")))
    else:
        Omega = dimensionedVector(word("Omega"), -dimTime, vector(0, 0, 0))

    magg = g.mag()
    gHat = g / magg

    return gravitationalProperties, g, rotating, Omega, magg, gHat
コード例 #23
0
ファイル: __init__.py プロジェクト: asimurzin/channelFlux
def readTransportProperties( runTime, mesh):
    from Foam.OpenFOAM import ext_Info, nl
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName
    ext_Info() << "\nReading transportProperties\n" << nl
    
    transportProperties = IOdictionary( IOobject( word( "transportProperties" ),
                                                  fileName( runTime.constant() ),
                                                  mesh,
                                                  IOobject.MUST_READ,
                                                  IOobject.NO_WRITE,
                                                  False ) )
    
    from Foam.OpenFOAM import dimensionedScalar, dimensionedVector
    nu = dimensionedScalar( transportProperties.lookup( word( "nu" ) ) )
    
    #  Read centerline velocity for channel simulations
    Ubar = dimensionedVector( transportProperties.lookup( word( "Ubar" ) ) )

    magUbar = Ubar.mag()
    from Foam.OpenFOAM import vector
    flowDirection = ( Ubar / magUbar ).ext_value()
    
    return transportProperties, nu, Ubar, magUbar, flowDirection
コード例 #24
0
def readGravitationalAcceleration( runTime, mesh ):
    from Foam.OpenFOAM import IOdictionary, word, fileName, IOobject
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "\nReading gravitationalProperties" << nl
    
    gravitationalProperties = IOdictionary( IOobject( word( "gravitationalProperties" ),
                                            fileName( runTime.constant() ),
                                            mesh,
                                            IOobject.MUST_READ,
                                            IOobject.NO_WRITE ) )
    
    from Foam.OpenFOAM import dimensionedVector,Switch, dimTime
    g = dimensionedVector( gravitationalProperties.lookup( word( "g" ) ) )
    rotating = Switch( gravitationalProperties.lookup( word( "rotating" ) ) )
    
    if rotating:
       Omega = dimensionedVector( gravitationalProperties.lookup( word( "Omega" ) ) )
    else:
       Omega = dimensionedVector( word( "Omega" ), -dimTime, vector( 0,0,0 ) )
    
    magg = g.mag()
    gHat = g / magg
    
    return gravitationalProperties, g, rotating, Omega, magg, gHat
コード例 #25
0
ファイル: __init__.py プロジェクト: asimurzin/dnsFlux
def readTurbulenceProperties(runTime, mesh, U):
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName, ext_Info, nl

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

    from Foam.OpenFOAM import dimensionedScalar, dimTime
    force = U / dimensionedScalar(word("dt"), dimTime,
                                  runTime.deltaT().value())

    from Foam.randomProcesses import Kmesh, UOprocess
    K = Kmesh(mesh)
    forceGen = UOprocess(K, runTime.deltaT().value(), turbulenceProperties)

    return turbulenceProperties, force, K, forceGen
コード例 #26
0
    def updateCoeffs(self):
        try:

            if self.updated():
                return
            from Foam.finiteVolume import volScalarField
            from Foam.OpenFOAM import word
            rhop = volScalarField.ext_lookupPatchField(self.patch(),
                                                       word("rho"))
            from Foam.finiteVolume import volVectorField
            rhoUp = volVectorField.ext_lookupPatchField(
                self.patch(), word("rhoU"))

            T = volScalarField.ext_lookupObject(self.db(), word("T"))
            patchi = self.patch().index()
            Tp = T.ext_boundaryField()[patchi]

            Tp.evaluate()

            from Foam.OpenFOAM import IOdictionary
            thermodynamicProperties = IOdictionary.ext_lookupObject(
                self.db(), word("thermodynamicProperties"))

            from Foam.OpenFOAM import dimensionedScalar
            Cv = dimensionedScalar(thermodynamicProperties.lookup(word("Cv")))

            self.valueFraction().ext_assign(
                rhop.ext_snGrad() /
                (rhop.ext_snGrad() - rhop * self.patch().deltaCoeffs()))
            self.refValue().ext_assign(0.5 * rhop * (rhoUp / rhop).magSqr())

            self.refGrad().ext_assign( rhop * Cv.value() * Tp.ext_snGrad() +\
                                       ( self.refValue() - ( 0.5 * rhop.patchInternalField()\
                                                          * ( rhoUp.patchInternalField() /rhop.patchInternalField() ).magSqr() ) ) * self.patch().deltaCoeffs() )
            mixedFvPatchScalarField.updateCoeffs(self)
            pass
        except Exception, exc:
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
            raise exc
コード例 #27
0
ファイル: __init__.py プロジェクト: asimurzin/materialModels
    def updateCoeffs(self):
        try:
            if self.updated():
                return

            from Foam.OpenFOAM import IOdictionary
            rheology = IOdictionary.ext_lookupObject(self.db(),
                                                     self.rheologyName_)
            from Foam.OpenFOAM import scalarField

            # Python does not wait for evaluation of the closure expression, it destroys return values if it is no more in use
            a_rheology_mu = rheology.mu()
            a_rheology_mu_boundaryField = a_rheology_mu.ext_boundaryField()
            mu = scalarField(a_rheology_mu_boundaryField[self.patch().index()])

            a_rheology_lambda = rheology._lambda()
            a_rheology_lambda_boundaryField = a_rheology_lambda.ext_boundaryField(
            )
            lambda_ = scalarField(
                a_rheology_lambda_boundaryField[self.patch().index()])

            n = self.patch().nf()
            from Foam.finiteVolume import volTensorField
            from Foam.OpenFOAM import word
            gradU = volTensorField.ext_lookupPatchField(
                self.patch(), word("grad(" + str(self.UName_) + ")"))

            from Foam.OpenFOAM import ext_Info
            self.gradient().ext_assign( ( ( self.traction_ -  self.pressure_ * n ) - ( n & ( mu * gradU.ext_T() - ( mu + lambda_ ) * gradU ) ) \
                                           - n * lambda_ * gradU.tr() ) / ( 2.0 * mu + lambda_) )

            from Foam.finiteVolume import fixedGradientFvPatchVectorField
            fixedGradientFvPatchVectorField.updateCoeffs(self)
        except Exception, exc:
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
            raise exc
コード例 #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 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
コード例 #29
0
                                                           IOobject.AUTO_WRITE ),
                                                 linearInterpolate( rhof[ index ]*Uf[ index ] ) & fluidRegions[ index ].Sf() ) )

         
        ext_Info() << "    Adding to turb\n" << nl
        from Foam import compressible
        turb.ext_set( index, compressible.RASModel.New( rhof[ index ], Uf[ index ], phif[ index ], thermof[ index ] ) )
        
        ext_Info() << "    Adding to DpDtf\n" << nl
        from Foam import fvc
        DpDtf.ext_set( index, volScalarField( fvc.DDt( surfaceScalarField( word( "phiU" ),
                                                                           phif[ index ] / fvc.interpolate( rhof[ index ] ) ),
                                                       thermof[ index ].p() ) ) )
        
        from Foam.OpenFOAM import IOdictionary
        environmentalProperties = IOdictionary.ext_lookupObject( fluidRegions[ index ], word( "environmentalProperties" ) )
        
        from Foam.OpenFOAM import dimensionedVector
        g = dimensionedVector( environmentalProperties.lookup( word( "g" ) ) )
        ext_Info() << "    Adding to ghf\n" << nl
        ghf.ext_set( index, volScalarField( word( "gh" ),
                                            g & fluidRegions[ index ].C() ) )
        
        ext_Info() << "    Updating p from pd\n" << nl
        thermof[ index ].p() == pdf[ index ] + rhof[ index ] * ghf[ index ] + pRef
        thermof[ index ].correct() 

        initialMassf[ index ] = fvc.domainIntegrate( rhof[ index ] ).value()
    
    
    return pdf, thermof, rhof, Kf, Uf, phif, turb, DpDtf, ghf, initialMassf, pRef
コード例 #30
0
ファイル: __init__.py プロジェクト: asimurzin/boundaryFlux
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