def PtrList_init_Istream_iNew(is_, inewt): #This function is constructor for PtrList(from Istream and Inew). But we not use OpenFOAM's PtrList, #we use Python's list. The reference code you can see in OpenFOAM "PtrListIO.C" from Foam.OpenFOAM import token firstToken = token(is_) is_.fatalCheck( "PtrList<T>::read(Istream& is, const INew& inewt) : reading first token" ) result = [] if firstToken.isLabel(): # Read size of list s = firstToken.labelToken() # Read beginning of contents listDelimiter = is_.readBeginList("PtrList") if s: if listDelimiter == token.BEGIN_LIST: for index in range(s): result.append(inewt(is_)) is_.fatalCheck( "PtrList<T>::read(Istream& is, const INew& inewt) : reading entry" ) else: result.append(inewt(is_)) is_.fatalCheck( "PtrList<T>::read(Istream& is, const INew& inewt) : reading the single entry" ) for index in range(s): result.append(inewt(is_).clone()) is_.readEndList("PtrList") elif firstToken.isPunctuation(): if firstToken.pToken() != token.BEGIN_LIST: raise IOError("incorrect first token, '(', found %s" % firstToken.info()) lastToken = token(is_) sllPtrs = [] while not (lastToken.isPunctuation() and lastToken.pToken() == token.END_LIST): is_.putBack(lastToken) sllPtrs.append(inewt(is_)) is_ >> lastToken for index in range(len(sllPtrs)): result.append(sllPtrs[index]) else: raise IOError( "incorrect first token, expected <int> or '(', found %s" % firstToken.info()) return result
def write( self, os ) : mixedFvPatchScalarField.write( self, os ) from Foam.OpenFOAM import keyType, word, token os.writeKeyword( keyType( "neighbourFieldName" ) ) << self.neighbourFieldName_ << token( token.END_STATEMENT ) << nl os.writeKeyword( keyType( "K" ) ) << self.KName_ << token( token.END_STATEMENT ) << nl os.writeKeyword( keyType( "fixesValue" ) ) << self.fixesValue_ << token( token.END_STATEMENT ) << nl pass
def writeEntries(self, os): from Foam.OpenFOAM import word, token, nl os.writeKeyword(word("neighbourRegionName")) os << self.neighbourRegionName_ << token(token.END_STATEMENT) << nl os.writeKeyword(word("neighbourPatchName")) os << self.neighbourPatchName_ << token(token.END_STATEMENT) << nl os.writeKeyword(word("neighbourFieldName")) os << self.neighbourFieldName_ << token(token.END_STATEMENT) << nl pass
def writeEntries( self, os ): from Foam.OpenFOAM import word, token, nl os.writeKeyword( word( "neighbourRegionName" ) ) os << self.neighbourRegionName_ << token( token.END_STATEMENT ) << nl os.writeKeyword( word( "neighbourPatchName" ) ) os << self.neighbourPatchName_ << token( token.END_STATEMENT ) << nl os.writeKeyword( word( "neighbourFieldName" ) ) os << self.neighbourFieldName_ << token( token.END_STATEMENT ) << nl pass
def write( self, os ) : from Foam.finiteVolume import fvPatchScalarField fvPatchScalarField.write( self, os ) from Foam.OpenFOAM import keyType, word, token os.writeKeyword( keyType( word( "valueFraction" ) ) ) << self.valueFraction() << token( token.END_STATEMENT ) << nl os.writeKeyword( keyType( word( "refValue" ) ) ) << self.refValue() << token( token.END_STATEMENT ) << nl os.writeKeyword( keyType( word( "refGrad" ) ) ) << self.refGrad() << token( token.END_STATEMENT ) << nl self.writeEntry( word( "value" ), os ); pass
def PtrList_init_Istream_iNew( is_, inewt ): #This function is constructor for PtrList(from Istream and Inew). But we not use OpenFOAM's PtrList, #we use Python's list. The reference code you can see in OpenFOAM "PtrListIO.C" from Foam.OpenFOAM import token firstToken = token(is_); is_.fatalCheck("PtrList<T>::read(Istream& is, const INew& inewt) : reading first token" ) result = [] if firstToken.isLabel(): # Read size of list s = firstToken.labelToken() # Read beginning of contents listDelimiter = is_.readBeginList("PtrList") if s: if listDelimiter == token.BEGIN_LIST: for index in range(s): result.append( inewt( is_ ) ) is_.fatalCheck( "PtrList<T>::read(Istream& is, const INew& inewt) : reading entry" ) else: result.append( inewt( is_ ) ) is_.fatalCheck( "PtrList<T>::read(Istream& is, const INew& inewt) : reading the single entry" ) for index in range(s): result.append( inewt( is_ ).clone() ) is_.readEndList("PtrList") elif firstToken.isPunctuation(): if firstToken.pToken() != token.BEGIN_LIST: raise IOError("incorrect first token, '(', found %s" %firstToken.info() ) lastToken = token (is_) sllPtrs = [] while not ( lastToken.isPunctuation() and lastToken.pToken() == token.END_LIST ): is_.putBack( lastToken ) sllPtrs.append( inewt(is_) ) is_ >> lastToken for index in range( len( sllPtrs ) ): result.append( sllPtrs[ index ] ) else: raise IOError("incorrect first token, expected <int> or '(', found %s" %firstToken.info() ) return result
def write( self, os): try: from Foam.finiteVolume import fvPatchVectorField fvPatchVectorField.write( self, os ) from Foam.OpenFOAM import word, token os.writeKeyword( word( "U" ) ) << self.UName_ << token( token.END_STATEMENT ) << nl os.writeKeyword( word( "rheology" ) ) << self.rheologyName_ << token( token.END_STATEMENT ) << nl self.traction_.writeEntry( word( "traction" ), os) self.pressure_.writeEntry( word( "pressure" ), os) self.writeEntry( word( "value" ), os) pass except Exception, exc: import sys, traceback traceback.print_exc( file = sys.stdout ) raise exc
def write(self, os): from Foam.finiteVolume import fvPatchScalarField fvPatchScalarField.write(self, os) from Foam.OpenFOAM import keyType, word, token os.writeKeyword(keyType( word("valueFraction"))) << self.valueFraction() << token( token.END_STATEMENT) << nl os.writeKeyword(keyType(word("refValue"))) << self.refValue() << token( token.END_STATEMENT) << nl os.writeKeyword(keyType(word("refGrad"))) << self.refGrad() << token( token.END_STATEMENT) << nl self.writeEntry(word("value"), os) pass
def write(self, os): try: from Foam.finiteVolume import fvPatchVectorField fvPatchVectorField.write(self, os) from Foam.OpenFOAM import word, token os.writeKeyword(word("U")) << self.UName_ << token( token.END_STATEMENT) << nl os.writeKeyword(word("rheology")) << self.rheologyName_ << token( token.END_STATEMENT) << nl self.traction_.writeEntry(word("traction"), os) self.pressure_.writeEntry(word("pressure"), os) self.writeEntry(word("value"), os) pass except Exception, exc: import sys, traceback traceback.print_exc(file=sys.stdout) raise exc
def write( self, os ): try: from Foam.finiteVolume import fvPatchScalarField fvPatchScalarField.write( self, os) self.coupleManager_.writeEntries( os ) from Foam.OpenFOAM import word, token, nl os.writeKeyword( word( "K" ) ) << self.KName_ << token( token.END_STATEMENT ) << nl self.writeEntry( word( "value" ), os ) pass except Exception, exc: import sys, traceback traceback.print_exc( file = sys.stdout ) raise exc
def write(self, os): try: from Foam.finiteVolume import fvPatchScalarField fvPatchScalarField.write(self, os) self.coupleManager_.writeEntries(os) from Foam.OpenFOAM import word, token, nl os.writeKeyword(word("K")) << self.KName_ << token( token.END_STATEMENT) << nl self.writeEntry(word("value"), os) except Exception, exc: import sys, traceback traceback.print_exc(file=sys.stdout) raise exc