コード例 #1
0
    def _init__fvPatch__DimensionedField_scalar_volMesh__dictionary(
            self, *args):
        if len(args) != 3:
            raise AssertionError("len( args ) != 3")
        argc = 0

        from Foam.finiteVolume import fvPatch
        try:
            fvPatch.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != fvPatch")
        p = args[argc]
        argc += 1

        from Foam.finiteVolume import DimensionedField_scalar_volMesh
        try:
            DimensionedField_scalar_volMesh.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError(
                "args[ argc ].__class__ != DimensionedField_scalar_volMesh")
        iF = args[argc]
        argc += 1

        from Foam.OpenFOAM import dictionary
        try:
            dictionary.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != dictionary")
        dict_ = args[argc]
        argc += 1

        mixedFvPatchScalarField.__init__(self, p, iF)
        from Foam.OpenFOAM import word
        self.neighbourFieldName_ = word(
            dict_.lookup(word("neighbourFieldName")))
        self.KName_ = word(dict_.lookup(word("K")))

        from Foam.finiteVolume import fvPatchScalarField
        from Foam.OpenFOAM import word, scalarField, readBool
        fvPatchScalarField.ext_assign(
            self, scalarField(word("value"), dict_, p.size()))

        if dict_.found(word("refValue")):
            #Full restart
            self.refValue().ext_assign(
                scalarField(word("refValue"), dict_, p.size()))
            self.refGrad().ext_assign(
                scalarField(word("refGradient"), dict_, p.size()))
            self.valueFraction().ext_assign(
                scalarField(word("valueFraction"), dict_, p.size()))
        else:
            # Start from user entered data. Assume fixedValue.
            self.refValue().ext_assign(self)
            self.refGrad().ext_assign(0.0)
            self.valueFraction().ext_assign(1.0)
            pass

        return self
コード例 #2
0
    def _init__fvPatch__DimensionedField_scalar_volMesh__dictionary( self, *args ) :
        if len( args ) != 3 :
            raise AssertionError( "len( args ) != 3" )
        argc = 0
        
        from Foam.finiteVolume import fvPatch        
        try:
            fvPatch.ext_isinstance( args[ argc ] )
        except TypeError:
            raise AssertionError( "args[ argc ].__class__ != fvPatch" )
        p = args[ argc ]; argc += 1
        
        from Foam.finiteVolume import DimensionedField_scalar_volMesh
        try:
            DimensionedField_scalar_volMesh.ext_isinstance( args[ argc ] )
        except TypeError:
            raise AssertionError( "args[ argc ].__class__ != DimensionedField_scalar_volMesh" )
        iF = args[ argc ]; argc += 1
        
        from Foam.OpenFOAM import dictionary
        try:
            dictionary.ext_isinstance( args[ argc ] )
        except TypeError:
            raise AssertionError( "args[ argc ].__class__ != dictionary" )
        dict_ = args[ argc ]; argc += 1
        
        mixedFvPatchScalarField.__init__( self, p, iF )
        from Foam.OpenFOAM import word
        self.neighbourFieldName_ = word( dict_.lookup( word( "neighbourFieldName" ) ) )
        self.KName_ = word( dict_.lookup( word( "K" ) ) )
       
        from Foam.finiteVolume import fvPatchScalarField
        from Foam.OpenFOAM import word, scalarField, readBool
        fvPatchScalarField.ext_assign( self, scalarField( word( "value" ), dict_, p.size() ) )
        
        if dict_.found( word( "refValue" ) ) :
            #Full restart
            self.refValue().ext_assign( scalarField( word( "refValue" ), dict_, p.size() ) )
            self.refGrad().ext_assign( scalarField( word( "refGradient" ), dict_, p.size() ) )
            self.valueFraction().ext_assign( scalarField( word( "valueFraction" ), dict_, p.size() ) )
            self.fixesValue_ = readBool( dict_.lookup( word( "fixesValue" ) ) )
        else:
            # Start from user entered data. Assume fixedValue.
            self.refValue().ext_assign( self )
            self.refGrad().ext_assign( 0.0 )
            self.valueFraction().ext_assign( 1.0 )
            self.fixesValue_ = True
            pass

        return self
    def _init__fvPatch__DimensionedField_scalar_volMesh__dictionary(
            self, *args):
        if len(args) != 3:
            raise AssertionError("len( args ) != 3")
        argc = 0

        from Foam.finiteVolume import fvPatch
        try:
            fvPatch.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != fvPatch")
        p = args[argc]
        argc += 1

        from Foam.finiteVolume import DimensionedField_scalar_volMesh
        try:
            DimensionedField_scalar_volMesh.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError(
                "args[ argc ].__class__ != DimensionedField_scalar_volMesh")
        iF = args[argc]
        argc += 1

        from Foam.OpenFOAM import dictionary
        try:
            dictionary.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != dictionary")
        dict_ = args[argc]

        fixedGradientFvPatchScalarField.__init__(self, p, iF)
        from chtMultiRegionFlux.r1_5.coupleManager import coupleManager
        self.coupleManager_ = coupleManager(p, dict_)
        from Foam.OpenFOAM import word
        self.KName_ = word(dict_.lookup(word("K")))

        if dict_.found(word("value")):
            from Foam.finiteVolume import fvPatchScalarField
            from Foam.OpenFOAM import scalarField
            fvPatchScalarField.ext_assign(
                self, scalarField(word("value"), dict_, p.size()))
            pass
        else:
            self.evaluate()
            pass

        return self
 def _init__fvPatch__DimensionedField_scalar_volMesh__dictionary( self, *args ):
     if len( args ) != 3 :
         raise AssertionError( "len( args ) != 3" )
     argc = 0
     
     from Foam.finiteVolume import fvPatch        
     try:
         fvPatch.ext_isinstance( args[ argc ] )
     except TypeError:
         raise AssertionError( "args[ argc ].__class__ != fvPatch" )
     p = args[ argc ]; argc += 1
     
     from Foam.finiteVolume import DimensionedField_scalar_volMesh
     try:
         DimensionedField_scalar_volMesh.ext_isinstance( args[ argc ] )
     except TypeError:
         raise AssertionError( "args[ argc ].__class__ != DimensionedField_scalar_volMesh" )
     iF = args[ argc ]; argc += 1
     
     from Foam.OpenFOAM import dictionary
     try:
         dictionary.ext_isinstance( args[ argc ] )
     except TypeError:
         raise AssertionError( "args[ argc ].__class__ != dictionary" )
     dict_ = args[ argc ]
     
     fixedValueFvPatchScalarField.__init__( self, p, iF )
     from chtMultiRegionFlux.r1_5.coupleManager import coupleManager
     self.coupleManager_ = coupleManager( p, dict_ )
     from Foam.OpenFOAM import word
     self.KName_ = word( dict_.lookup( word( "K" ) ) )
     
     if dict_.found( word( "value" ) ):
        from Foam.finiteVolume import fvPatchScalarField
        from Foam.OpenFOAM import scalarField
        fvPatchScalarField.ext_assign( self, scalarField( word( "value" ), dict_, p.size() ) )
        pass
     else:
        self.evaluate()
        pass
     
     return self
コード例 #5
0
    def updateCoeffs( self ) :
        try:
            if self.updated() :
                return
            
            from Foam.meshTools import directMappedPatchBase
            mpp = directMappedPatchBase.ext_refCast( self.patch().patch() )
            
            nbrMesh = mpp.sampleMesh()
            intFld = self.patchInternalField()
            
            if self.interfaceOwner( nbrMesh ):
               # Note: other side information could be cached - it only needs
               # to be updated the first time round the iteration (i.e. when
               # switching regions) but unfortunately we don't have this information.
               distMap = mpp.map()
               from Foam.finiteVolume import fvMesh
               nbrPatch = fvMesh.ext_refCast( nbrMesh ).boundary()[ mpp.samplePolyPatch().index() ]
               
               # Calculate the temperature by harmonic averaging
               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               from Foam.finiteVolume import volScalarField
               nbrField = solidWallMixedTemperatureCoupledFvPatchScalarField.ext_refCast( volScalarField.ext_lookupPatchField( nbrPatch, self.neighbourFieldName_ ) )
               
               #Swap to obtain full local values of neighbour internal field
               nbrIntFld = nbrField.patchInternalField()
               
               from Foam.OpenFOAM import mapDistribute, Pstream
               mapDistribute.distribute( Pstream.defaultCommsType.fget(), 
                                         distMap.schedule(), 
                                         distMap.constructSize(), 
                                         distMap.subMap(),       #what to send
                                         distMap.constructMap(), #what to receive
                                         nbrIntFld() ) 
               
               # Swap to obtain full local values of neighbour K*delta
               nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs()
              
               mapDistribute.distribute( Pstream.defaultCommsType.fget(), 
                                         distMap.schedule(), 
                                         distMap.constructSize(), 
                                         distMap.subMap(),       #what to send
                                         distMap.constructMap(), #what to receive
                                         nbrKDelta() ) 
               
               myKDelta = self.K()*self.patch().deltaCoeffs()
               
               # Calculate common wall temperature. Reuse *this to store common value.
                              
               Twall = ( myKDelta*intFld +  nbrKDelta*nbrIntFld ) / ( myKDelta + nbrKDelta )

               # Assign to me
               from Foam.finiteVolume import fvPatchScalarField
               fvPatchScalarField.ext_assign( self, Twall )
               mapDistribute.distribute( Pstream.defaultCommsType.fget(),
                                         distMap.schedule(),
                                         nbrField.size(),
                                         distMap.constructMap(),     # reverse : what to send
                                         distMap.subMap(),
                                         Twall() )
               
               fvPatchScalarField.ext_assign( nbrField, Twall )
               pass
               
            # Switch between fixed value (of harmonic avg) or gradient
            # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            nFixed = 0
               
            #Like snGrad but bypass switching on refValue/refGrad.
            normalGradient = ( self-intFld )*self.patch().deltaCoeffs()
            
            if self.debug: 
              Q = ( self.K() * self.patch().magSf() * normalGradient() ).gSum()
              ext_Info ()<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" << "updateCoeffs() :"\
                         << " patch:" << self.patch().name()<< " heatFlux:" << Q << " walltemperature "\
                         << " min:" << self.gMin() << " max:" << self.gMax() << " avg:" << self.gAverage() << nl
              pass           

            for i in range( self.size() ):
               # if outgoing flux use fixed value.
               if normalGradient()[i] < 0.0:
                  self.refValue()[i] = self[i] 
                  self.refGrad()[i] = 0.0  # not used
                  self.valueFraction()[i] = 1.0 
                  nFixed+=1
                  pass
               else:
                  self.refValue()[i]=  0.0  # not used
                  self.refGrad()[i] = normalGradient()[i] 
                  self.valueFraction()[i] =  0.0 
                  pass
              
                        
            from Foam.OpenFOAM import ext_reduce, sumOp_label
                        
            nFixed = ext_reduce( nFixed, sumOp_label() )
            self.fixesValue_ = ( nFixed > 0 )
            
            if (self.debug):
               from Foam.OpenFOAM import returnReduce
               nTotSize = returnReduce(self.size(), sumOp_label())
               ext_Info() << "solidWallMixedTemperatureCoupledFvPatchScalarField::" << "updateCoeffs() :" \
                          << " patch:" << self.patch().name() << " out of:" << nTotSize << " fixedBC:" << nFixed \
                          << " gradient:" << nTotSize-nFixed << nl
               pass                 
            
            mixedFvPatchScalarField.updateCoeffs( self )
            
            pass
        except Exception, exc:
            import sys, traceback
            traceback.print_exc( file = sys.stdout )
            raise exc