Package PyFoam :: Package Applications :: Module PlotWatcher
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.PlotWatcher

 1  #  ICE Revision: $Id: PlotWatcher.py 9161 2008-08-04 08:01:05Z bgschaid $  
 2  """ 
 3  Class that implements pyFoamPlotWatcher 
 4  """ 
 5   
 6  from PyFoam.Execution.GnuplotRunner import GnuplotWatcher 
 7   
 8  from PyFoamApplication import PyFoamApplication 
 9   
10  from CommonPlotLines import CommonPlotLines 
11  from CommonPlotOptions import CommonPlotOptions 
12   
13  from os import path 
14   
15 -class PlotWatcher(PyFoamApplication, 16 CommonPlotOptions, 17 CommonPlotLines):
18 - def __init__(self,args=None):
19 description=""" 20 Gets the name of a logfile which is assumed to be the output of a 21 OpenFOAM-solver. Parses the logfile for information about the 22 convergence of the solver and generates gnuplot-graphs. Watches the 23 file until interrupted. 24 """ 25 26 CommonPlotOptions.__init__(self,persist=False) 27 CommonPlotLines.__init__(self) 28 PyFoamApplication.__init__(self, 29 args=args, 30 description=description, 31 usage="%prog [options] <logfile>", 32 changeVersion=False, 33 interspersed=True, 34 nr=1)
35
36 - def addOptions(self):
37 CommonPlotOptions.addOptions(self) 38 39 self.parser.add_option("--tail", 40 type="long", 41 dest="tail", 42 default=5000L, 43 help="The length at the end of the file that should be output (in bytes)") 44 self.parser.add_option("--silent", 45 action="store_true", 46 dest="silent", 47 default=False, 48 help="Logfile is not copied to the terminal") 49 self.parser.add_option("--progress", 50 action="store_true", 51 default=False, 52 dest="progress", 53 help="Only prints the progress of the simulation, but swallows all the other output") 54 self.parser.add_option("--start", 55 action="store", 56 type="float", 57 default=None, 58 dest="start", 59 help="Start time starting from which the data should be plotted. If undefined the initial time is used") 60 61 self.parser.add_option("--end", 62 action="store", 63 type="float", 64 default=None, 65 dest="end", 66 help="End time until which the data should be plotted. If undefined it is plotted till the end") 67 68 CommonPlotLines.addOptions(self)
69
70 - def run(self):
71 self.processPlotOptions() 72 self.processPlotLineOptions(autoPath=path.dirname(self.parser.getArgs()[0])) 73 74 run=GnuplotWatcher(self.parser.getArgs()[0], 75 smallestFreq=self.opts.frequency, 76 persist=self.opts.persist, 77 tailLength=self.opts.tail, 78 silent=self.opts.silent, 79 plotLinear=self.opts.linear, 80 plotCont=self.opts.cont, 81 plotBound=self.opts.bound, 82 plotIterations=self.opts.iterations, 83 plotCourant=self.opts.courant, 84 plotExecution=self.opts.execution, 85 plotDeltaT=self.opts.deltaT, 86 customRegexp=self.plotLines(), 87 writeFiles=self.opts.writeFiles, 88 raiseit=self.opts.raiseit, 89 progress=self.opts.progress, 90 start=self.opts.start, 91 end=self.opts.end) 92 93 run.start()
94