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 writePickled=True,
40 plottingImplementation=None):
41 """
42 TODO: Docu
43 """
44 StepAnalyzedCommon.__init__(self,
45 fname,
46 BoundingLogAnalyzer(doTimelines=True,
47 doFiles=writeFiles,
48 progress=progress,
49 singleFile=singleFile,
50 startTime=start,
51 endTime=end),
52 writePickled=writePickled,
53 smallestFreq=smallestFreq)
54
55 self.startTime=start
56 self.endTime=end
57
58 self.plots=self.createPlots(persist=persist,
59 raiseit=raiseit,
60 start=start,
61 end=end,
62 writeFiles=writeFiles,
63 splitThres=splitThres,
64 plotLinear=plotLinear,
65 plotCont=plotCont,
66 plotBound=plotBound,
67 plotIterations=plotIterations,
68 plotCourant=plotCourant,
69 plotExecution=plotExecution,
70 plotDeltaT=plotDeltaT,
71 customRegexp=customRegexp,
72 plottingImplementation=plottingImplementation)
73
74 self.hardcopy=hardcopy
75 self.hardcopyFormat=hardcopyFormat
76 self.hardcopyPrefix=hardcopyPrefix
77
83
97
99 - def __init__(self,
100 argv=None,
101 smallestFreq=0.,
102 persist=None,
103 plotLinear=True,
104 plotCont=True,
105 plotBound=True,
106 plotIterations=False,
107 plotCourant=False,
108 plotExecution=False,
109 plotDeltaT=False,
110 customRegexp=None,
111 hardcopy=False,
112 hardcopyFormat="png",
113 hardcopyPrefix=None,
114 writeFiles=False,
115 server=False,
116 lam=None,
117 raiseit=False,
118 steady=False,
119 progress=False,
120 restart=False,
121 logname=None,
122 compressLog=False,
123 noLog=False,
124 logTail=None,
125 singleFile=False,
126 writePickled=True,
127 plottingImplementation=None,
128 remark=None,
129 jobId=None):
130 """@param smallestFreq: smallest Frequency of output
131 @param persist: Gnuplot window persistst after run
132 @param steady: Is it a steady run? Then stop it after convergence"""
133 BasicRunner.__init__(self,
134 argv=argv,
135 silent=progress,
136 server=server,
137 lam=lam,
138 restart=restart,
139 logname=logname,
140 compressLog=compressLog,
141 noLog=noLog,
142 logTail=logTail,
143 remark=remark,
144 jobId=jobId)
145 GnuplotCommon.__init__(self,
146 "Gnuplotting",
147 smallestFreq=smallestFreq,
148 persist=persist,
149 plotLinear=plotLinear,
150 plotCont=plotCont,
151 plotBound=plotBound,
152 plotIterations=plotIterations,
153 plotCourant=plotCourant,
154 plotExecution=plotExecution,
155 plotDeltaT=plotDeltaT,
156 customRegexp=customRegexp,
157 hardcopy=hardcopy,
158 hardcopyFormat=hardcopyFormat,
159 hardcopyPrefix=hardcopyPrefix,
160 writeFiles=writeFiles,
161 raiseit=raiseit,
162 progress=progress,
163 singleFile=singleFile,
164 writePickled=writePickled,
165 plottingImplementation=plottingImplementation)
166 self.steady=steady
167 if self.steady:
168 self.steadyAnalyzer=SteadyConvergedLineAnalyzer()
169 self.addAnalyzer("Convergence",self.steadyAnalyzer)
170
178
183
185 - def __init__(self,
186 logfile,
187 smallestFreq=0.,
188 persist=None,
189 silent=False,
190 tailLength=1000,
191 sleep=0.1,
192 replotFrequency=3600,
193 plotLinear=True,
194 plotCont=True,
195 plotBound=True,
196 plotIterations=False,
197 plotCourant=False,
198 plotExecution=False,
199 plotDeltaT=False,
200 customRegexp=None,
201 writeFiles=False,
202 hardcopy=False,
203 hardcopyFormat="png",
204 hardcopyPrefix=None,
205 raiseit=False,
206 progress=False,
207 start=None,
208 end=None,
209 singleFile=False,
210 writePickled=True,
211 plottingImplementation=None,
212 solverNotRunning=False):
213 """@param smallestFreq: smallest Frequency of output
214 @param persist: Gnuplot window persistst after run"""
215 BasicWatcher.__init__(self,
216 logfile,
217 silent=(silent or progress),
218 tailLength=tailLength,
219 sleep=sleep,
220 follow=not solverNotRunning)
221 GnuplotCommon.__init__(self,
222 logfile,
223 smallestFreq=smallestFreq,
224 persist=persist,
225 plotLinear=plotLinear,
226 plotCont=plotCont,
227 plotBound=plotBound,
228 plotIterations=plotIterations,
229 plotCourant=plotCourant,
230 plotExecution=plotExecution,
231 plotDeltaT=plotDeltaT,
232 customRegexp=customRegexp,
233 hardcopy=hardcopy,
234 hardcopyFormat=hardcopyFormat,
235 hardcopyPrefix=hardcopyPrefix,
236 writeFiles=writeFiles,
237 raiseit=raiseit,
238 progress=progress,
239 start=start,
240 end=end,
241 singleFile=singleFile,
242 writePickled=writePickled,
243 plottingImplementation=plottingImplementation)
244
245 self.hasPlotted=False
246 self.replotFrequency=replotFrequency
247
249 self.bakFreq=self.freq
250 if self.endTime!=None:
251 self.freq=1
252 else:
253 self.freq=self.replotFrequency
254
256 self.freq=self.bakFreq
257 self.oldtime=0
258
260 plotNow=True
261 if not self.hasPlotted and self.endTime!=None:
262 try:
263 if float(self.getTime())>self.endTime:
264 self.hasPlotted=True
265 except ValueError:
266 pass
267 elif self.hasPlotted:
268 plotNow=False
269 if plotNow:
270 for p in self.plots:
271 self.plots[p].redo()
272