1
2 """Runner that outputs the residuals of the linear solver with Gnuplot"""
3
4 from StepAnalyzedCommon import StepAnalyzedCommon
5 from BasicRunner import BasicRunner
6 from BasicWatcher import BasicWatcher
7
8 from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer
9 from PyFoam.LogAnalysis.SteadyConvergedLineAnalyzer import SteadyConvergedLineAnalyzer
10 from PyFoam.Basics.TimeLineCollection import TimeLineCollection
11 from PyFoam.Error import error
12
13 from os import path
14
16 """Class that collects the Gnuplotting-Stuff for two other classes"""
17 - def __init__(self,
18 fname,
19 smallestFreq=0.,
20 persist=None,
21 splitThres=2048,
22 plotLinear=True,
23 plotCont=True,
24 plotBound=True,
25 plotIterations=False,
26 plotCourant=False,
27 plotExecution=False,
28 plotDeltaT=False,
29 hardcopy=False,
30 hardcopyFormat="png",
31 hardcopyPrefix=None,
32 customRegexp=None,
33 writeFiles=False,
34 raiseit=False,
35 progress=False,
36 start=None,
37 end=None,
38 singleFile=False,
39 plottingImplementation=None):
40 """
41 TODO: Docu
42 """
43 StepAnalyzedCommon.__init__(self,
44 fname,
45 BoundingLogAnalyzer(doTimelines=True,
46 doFiles=writeFiles,
47 progress=progress,
48 singleFile=singleFile,
49 startTime=start,
50 endTime=end),
51 smallestFreq=smallestFreq)
52
53 self.startTime=start
54 self.endTime=end
55
56 self.plots=self.createPlots(persist=persist,
57 raiseit=raiseit,
58 start=start,
59 end=end,
60 writeFiles=writeFiles,
61 splitThres=splitThres,
62 plotLinear=plotLinear,
63 plotCont=plotCont,
64 plotBound=plotBound,
65 plotIterations=plotIterations,
66 plotCourant=plotCourant,
67 plotExecution=plotExecution,
68 plotDeltaT=plotDeltaT,
69 customRegexp=customRegexp,
70 plottingImplementation=plottingImplementation)
71
72 self.hardcopy=hardcopy
73 self.hardcopyFormat=hardcopyFormat
74 self.hardcopyPrefix=hardcopyPrefix
75
81
95
97 - def __init__(self,
98 argv=None,
99 smallestFreq=0.,
100 persist=None,
101 plotLinear=True,
102 plotCont=True,
103 plotBound=True,
104 plotIterations=False,
105 plotCourant=False,
106 plotExecution=False,
107 plotDeltaT=False,
108 customRegexp=None,
109 hardcopy=False,
110 hardcopyFormat="png",
111 hardcopyPrefix=None,
112 writeFiles=False,
113 server=False,
114 lam=None,
115 raiseit=False,
116 steady=False,
117 progress=False,
118 restart=False,
119 logname=None,
120 compressLog=False,
121 noLog=False,
122 singleFile=False,
123 plottingImplementation=None,
124 remark=None,
125 jobId=None):
126 """@param smallestFreq: smallest Frequency of output
127 @param persist: Gnuplot window persistst after run
128 @param steady: Is it a steady run? Then stop it after convergence"""
129 BasicRunner.__init__(self,
130 argv=argv,
131 silent=progress,
132 server=server,
133 lam=lam,
134 restart=restart,
135 logname=logname,
136 compressLog=compressLog,
137 noLog=noLog,
138 remark=remark,
139 jobId=jobId)
140 GnuplotCommon.__init__(self,
141 "Gnuplotting",
142 smallestFreq=smallestFreq,
143 persist=persist,
144 plotLinear=plotLinear,
145 plotCont=plotCont,
146 plotBound=plotBound,
147 plotIterations=plotIterations,
148 plotCourant=plotCourant,
149 plotExecution=plotExecution,
150 plotDeltaT=plotDeltaT,
151 customRegexp=customRegexp,
152 hardcopy=hardcopy,
153 hardcopyFormat=hardcopyFormat,
154 hardcopyPrefix=hardcopyPrefix,
155 writeFiles=writeFiles,
156 raiseit=raiseit,
157 progress=progress,
158 singleFile=singleFile,
159 plottingImplementation=plottingImplementation)
160 self.steady=steady
161 if self.steady:
162 self.steadyAnalyzer=SteadyConvergedLineAnalyzer()
163 self.addAnalyzer("Convergence",self.steadyAnalyzer)
164
172
177
179 - def __init__(self,
180 logfile,
181 smallestFreq=0.,
182 persist=None,
183 silent=False,
184 tailLength=1000,
185 sleep=0.1,
186 replotFrequency=3600,
187 plotLinear=True,
188 plotCont=True,
189 plotBound=True,
190 plotIterations=False,
191 plotCourant=False,
192 plotExecution=False,
193 plotDeltaT=False,
194 customRegexp=None,
195 writeFiles=False,
196 hardcopy=False,
197 hardcopyFormat="png",
198 hardcopyPrefix=None,
199 raiseit=False,
200 progress=False,
201 start=None,
202 end=None,
203 singleFile=False,
204 plottingImplementation=None,
205 solverNotRunning=False):
206 """@param smallestFreq: smallest Frequency of output
207 @param persist: Gnuplot window persistst after run"""
208 BasicWatcher.__init__(self,
209 logfile,
210 silent=(silent or progress),
211 tailLength=tailLength,
212 sleep=sleep,
213 follow=not solverNotRunning)
214 GnuplotCommon.__init__(self,
215 logfile,
216 smallestFreq=smallestFreq,
217 persist=persist,
218 plotLinear=plotLinear,
219 plotCont=plotCont,
220 plotBound=plotBound,
221 plotIterations=plotIterations,
222 plotCourant=plotCourant,
223 plotExecution=plotExecution,
224 plotDeltaT=plotDeltaT,
225 customRegexp=customRegexp,
226 hardcopy=hardcopy,
227 hardcopyFormat=hardcopyFormat,
228 hardcopyPrefix=hardcopyPrefix,
229 writeFiles=writeFiles,
230 raiseit=raiseit,
231 progress=progress,
232 start=start,
233 end=end,
234 singleFile=singleFile,
235 plottingImplementation=plottingImplementation)
236
237 self.hasPlotted=False
238 self.replotFrequency=replotFrequency
239
241 self.bakFreq=self.freq
242 if self.endTime!=None:
243 self.freq=1
244 else:
245 self.freq=self.replotFrequency
246
248 self.freq=self.bakFreq
249 self.oldtime=0
250
252 plotNow=True
253 if not self.hasPlotted and self.endTime!=None:
254 try:
255 if float(self.getTime())>self.endTime:
256 self.hasPlotted=True
257 except ValueError:
258 pass
259 elif self.hasPlotted:
260 plotNow=False
261 if plotNow:
262 for p in self.plots:
263 self.plots[p].redo()
264