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

Source Code for Module PyFoam.Basics.OutputFile

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