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 input=OptionGroup(self.parser,
41 "Input",
42 "Specifics of the input")
43 self.parser.add_option_group(input)
44
45 input.add_option("--solver-not-running-anymore",
46 action="store_true",
47 dest="solverNotRunning",
48 default=False,
49 help="It makes no sense to wait for further output, because the solver is not running anymore. Watcher ends as soon as he encounters the end of the file. Only makes sense with --persist or --hardcopy")
50
51 output=OptionGroup(self.parser,
52 "Output",
53 "What should be output to the terminal")
54 self.parser.add_option_group(output)
55
56 output.add_option("--tail",
57 type="long",
58 dest="tail",
59 default=5000L,
60 help="The length at the end of the file that should be output (in bytes. Default: %default)")
61 output.add_option("--silent",
62 action="store_true",
63 dest="silent",
64 default=False,
65 help="Logfile is not copied to the terminal")
66 output.add_option("--progress",
67 action="store_true",
68 default=False,
69 dest="progress",
70 help="Only prints the progress of the simulation, but swallows all the other output")
71 output.add_option("--replot-frequency",
72 action="store",
73 default=10,
74 type="float",
75 dest="replotFrequency",
76 help="If the tail of the file is not yet reached, how often the data should be plotted: Default: %default")
77
78 limit=OptionGroup(self.parser,
79 "Limits",
80 "Where the plots should start and end")
81 self.parser.add_option_group(limit)
82
83 limit.add_option("--start",
84 action="store",
85 type="float",
86 default=None,
87 dest="start",
88 help="Start time starting from which the data should be plotted. If undefined the initial time is used")
89
90 limit.add_option("--end",
91 action="store",
92 type="float",
93 default=None,
94 dest="end",
95 help="End time until which the data should be plotted. If undefined it is plotted till the end")
96
97 CommonPlotLines.addOptions(self)
98
100 self.processPlotOptions()
101 hereDir=path.dirname(self.parser.getArgs()[0])
102 self.processPlotLineOptions(autoPath=hereDir)
103 self.addLocalConfig(hereDir)
104
105 run=GnuplotWatcher(self.parser.getArgs()[0],
106 smallestFreq=self.opts.frequency,
107 persist=self.opts.persist,
108 tailLength=self.opts.tail,
109 silent=self.opts.silent,
110 hardcopy=self.opts.hardcopy,
111 hardcopyPrefix=self.opts.hardcopyPrefix,
112 hardcopyFormat=self.opts.hardcopyformat,
113 plotLinear=self.opts.linear,
114 plotCont=self.opts.cont,
115 plotBound=self.opts.bound,
116 plotIterations=self.opts.iterations,
117 plotCourant=self.opts.courant,
118 plotExecution=self.opts.execution,
119 plotDeltaT=self.opts.deltaT,
120 customRegexp=self.plotLines(),
121 writeFiles=self.opts.writeFiles,
122 raiseit=self.opts.raiseit,
123 progress=self.opts.progress,
124 start=self.opts.start,
125 end=self.opts.end,
126 singleFile=self.opts.singleDataFilesOnly,
127 replotFrequency=self.opts.replotFrequency,
128 plottingImplementation=self.opts.implementation,
129 solverNotRunning=self.opts.solverNotRunning)
130
131 run.start()
132