1
2 """Analyze Line for Time"""
3
4 import re
5
6 from .LogLineAnalyzer import LogLineAnalyzer
7
8 from PyFoam import configuration as conf
9
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
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
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
40 m=self.exp.match(line)
41 if m!=None:
42 self.tryFallback=False
43 self.notifyNewTime(m)
44
45 if self.tryFallback:
46
47 m=self.fallback.match(line)
48 if m!=None:
49 self.notifyNewTime(m)
50
51
52