Package PyFoam :: Package LogAnalysis :: Module TimeLineAnalyzer
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.LogAnalysis.TimeLineAnalyzer

 1  #  ICE Revision: $Id$ 
 2  """Analyze Line for Time""" 
 3   
 4  import re 
 5   
 6  from .LogLineAnalyzer import LogLineAnalyzer 
 7   
 8  from PyFoam import configuration as conf 
 9   
10 -class TimeLineAnalyzer(LogLineAnalyzer):
11 """Parses the line for the current time and makes it available to 12 the parent analyzer (who makes it available to all of his 13 children). This side-effect is important for all the other 14 line-analyzers that need the time""" 15
16 - def __init__(self,progress=False):
17 """ 18 Constructs the analyzer 19 20 @param progress: whether to print the time on the console 21 """ 22 LogLineAnalyzer.__init__(self) 23 self.exp=re.compile(conf().get("SolverOutput","timeRegExp")) 24 25 self.fallback=re.compile("^(Time =|Iteration:) (.+)$") 26 self.tryFallback=True 27 28 self.progress=progress
29
30 - def notifyNewTime(self,m):
31 try: 32 self.notify(float(m.group(2))) 33 if self.progress and type(self.parent.time)==float: 34 self.writeProgress("t = %10g" % self.parent.time) 35 36 except ValueError: 37 pass
38
39 - def doAnalysis(self,line):
40 m=self.exp.match(line) 41 if m!=None: 42 self.tryFallback=False 43 self.notifyNewTime(m) 44 45 if self.tryFallback: 46 # this is for cases that use a different regular expression for the time 47 m=self.fallback.match(line) 48 if m!=None: 49 self.notifyNewTime(m)
50 51 # Should work with Python3 and Python2 52