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 parameters=None,
130 jobId=None):
131 """@param smallestFreq: smallest Frequency of output
132 @param persist: Gnuplot window persistst after run
133 @param steady: Is it a steady run? Then stop it after convergence"""
134 BasicRunner.__init__(self,
135 argv=argv,
136 silent=progress,
137 server=server,
138 lam=lam,
139 restart=restart,
140 logname=logname,
141 compressLog=compressLog,
142 noLog=noLog,
143 logTail=logTail,
144 remark=remark,
145 parameters=parameters,
146 jobId=jobId)
147 GnuplotCommon.__init__(self,
148 "Gnuplotting",
149 smallestFreq=smallestFreq,
150 persist=persist,
151 plotLinear=plotLinear,
152 plotCont=plotCont,
153 plotBound=plotBound,
154 plotIterations=plotIterations,
155 plotCourant=plotCourant,
156 plotExecution=plotExecution,
157 plotDeltaT=plotDeltaT,
158 customRegexp=customRegexp,
159 hardcopy=hardcopy,
160 hardcopyFormat=hardcopyFormat,
161 hardcopyPrefix=hardcopyPrefix,
162 writeFiles=writeFiles,
163 raiseit=raiseit,
164 progress=progress,
165 singleFile=singleFile,
166 writePickled=writePickled,
167 plottingImplementation=plottingImplementation)
168 self.steady=steady
169 if self.steady:
170 self.steadyAnalyzer=SteadyConvergedLineAnalyzer()
171 self.addAnalyzer("Convergence",self.steadyAnalyzer)
172
180
185
187 - def __init__(self,
188 logfile,
189 smallestFreq=0.,
190 persist=None,
191 silent=False,
192 tailLength=1000,
193 sleep=0.1,
194 replotFrequency=3600,
195 plotLinear=True,
196 plotCont=True,
197 plotBound=True,
198 plotIterations=False,
199 plotCourant=False,
200 plotExecution=False,
201 plotDeltaT=False,
202 customRegexp=None,
203 writeFiles=False,
204 hardcopy=False,
205 hardcopyFormat="png",
206 hardcopyPrefix=None,
207 raiseit=False,
208 progress=False,
209 start=None,
210 end=None,
211 singleFile=False,
212 writePickled=True,
213 plottingImplementation=None,
214 solverNotRunning=False):
215 """@param smallestFreq: smallest Frequency of output
216 @param persist: Gnuplot window persistst after run"""
217 BasicWatcher.__init__(self,
218 logfile,
219 silent=(silent or progress),
220 tailLength=tailLength,
221 sleep=sleep,
222 follow=not solverNotRunning)
223 GnuplotCommon.__init__(self,
224 logfile,
225 smallestFreq=smallestFreq,
226 persist=persist,
227 plotLinear=plotLinear,
228 plotCont=plotCont,
229 plotBound=plotBound,
230 plotIterations=plotIterations,
231 plotCourant=plotCourant,
232 plotExecution=plotExecution,
233 plotDeltaT=plotDeltaT,
234 customRegexp=customRegexp,
235 hardcopy=hardcopy,
236 hardcopyFormat=hardcopyFormat,
237 hardcopyPrefix=hardcopyPrefix,
238 writeFiles=writeFiles,
239 raiseit=raiseit,
240 progress=progress,
241 start=start,
242 end=end,
243 singleFile=singleFile,
244 writePickled=writePickled,
245 plottingImplementation=plottingImplementation)
246
247 self.hasPlotted=False
248 self.replotFrequency=replotFrequency
249
251 self.bakFreq=self.freq
252 if self.endTime!=None:
253 self.freq=1
254 else:
255 self.freq=self.replotFrequency
256
258 self.freq=self.bakFreq
259 self.oldtime=0
260
262 plotNow=True
263 if not self.hasPlotted and self.endTime!=None:
264 try:
265 if float(self.getTime())>self.endTime:
266 self.hasPlotted=True
267 except ValueError:
268 pass
269 elif self.hasPlotted:
270 plotNow=False
271 if plotNow:
272 for p in self.plots:
273 self.plots[p].redo()
274
275
276