1
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):
36
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 output.add_option("--replot-frequency",
61 action="store",
62 default=10,
63 type="float",
64 dest="replotFrequency",
65 help="If the tail of the file is not yet reached, how often the data should be plotted: Default: %default")
66
67 limit=OptionGroup(self.parser,
68 "Limits",
69 "Where the plots should start and end")
70 self.parser.add_option_group(limit)
71
72 limit.add_option("--start",
73 action="store",
74 type="float",
75 default=None,
76 dest="start",
77 help="Start time starting from which the data should be plotted. If undefined the initial time is used")
78
79 limit.add_option("--end",
80 action="store",
81 type="float",
82 default=None,
83 dest="end",
84 help="End time until which the data should be plotted. If undefined it is plotted till the end")
85
86 CommonPlotLines.addOptions(self)
87
89 self.processPlotOptions()
90 self.processPlotLineOptions(autoPath=path.dirname(self.parser.getArgs()[0]))
91
92 run=GnuplotWatcher(self.parser.getArgs()[0],
93 smallestFreq=self.opts.frequency,
94 persist=self.opts.persist,
95 tailLength=self.opts.tail,
96 silent=self.opts.silent,
97 hardcopy=self.opts.hardcopy,
98 hardcopyPrefix=self.opts.hardcopyPrefix,
99 hardcopyFormat=self.opts.hardcopyformat,
100 plotLinear=self.opts.linear,
101 plotCont=self.opts.cont,
102 plotBound=self.opts.bound,
103 plotIterations=self.opts.iterations,
104 plotCourant=self.opts.courant,
105 plotExecution=self.opts.execution,
106 plotDeltaT=self.opts.deltaT,
107 customRegexp=self.plotLines(),
108 writeFiles=self.opts.writeFiles,
109 raiseit=self.opts.raiseit,
110 progress=self.opts.progress,
111 start=self.opts.start,
112 end=self.opts.end,
113 singleFile=self.opts.singleDataFilesOnly,
114 replotFrequency=self.opts.replotFrequency,
115 plottingImplementation=self.opts.implementation)
116
117 run.start()
118