Package PyFoam :: Package Basics :: Module OutputFile
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Basics.OutputFile

 1  #  ICE Revision: $Id: OutputFile.py 7581 2007-06-27 15:29:14Z bgschaid $  
 2  """Output of time-dependent data""" 
 3   
 4  from BasicFile import BasicFile 
 5   
6 -class OutputFile(BasicFile):
7 """output of time dependent data""" 8
9 - def __init__(self,name,titles=[]):
10 """ 11 @param name: name of the file 12 @param titles: Titles of the columns 13 """ 14 BasicFile.__init__(self,name) 15 16 self.setTitles(titles)
17 18 # def __del__(self): 19 # print "Deleting File",self.name 20
21 - def setTitles(self,titles):
22 """ 23 Sets the titles anew. Only has an effect if the file hasn't been opened yet 24 25 @param titles: The new titles 26 """ 27 self.titles=titles
28
29 - def outputAtStart(self):
30 """ 31 Write column titles if present 32 """ 33 if len(self.titles)>0: 34 fh=self.getHandle() 35 fh.write("# time") 36 for c in self.titles: 37 fh.write(" \t"+c) 38 fh.write("\n")
39
40 - def write(self,time,data):
41 """write data set 42 43 @param time: the current time 44 @param data: tuple with data""" 45 self.writeLine( (time,)+data)
46