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