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

Source Code for Module PyFoam.Applications.PlotWatcher

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