1
2 """Base class for analyzing lines"""
3
4 from PyFoam.Error import error
5
7 """Base class for the analysis of all lines from a OpenFOAM-log
8
9 Lines are available one at a time"""
10
12 self.parent=None
13 self.eventListeners=[]
14
16 """Analyze a line
17
18 line - the line to be analyzed
19
20 This method carries the main functionality in the sub-classes"""
21 pass
22
24 """The value of the time has changed in the Log-file
25
26 For subclasses that need to know the current time"""
27 pass
28
30 """Introduces the LineAnalyzer to its supervisor
31
32 @param parent: The Analyzer class of which this is a part"""
33 self.parent=parent
34
36 """Let the parent write an additional progress message"""
37 if self.parent:
38 self.parent.writeProgress(msg)
39
41 """Set the directory to which output is to be written (if any
42 output is written)"""
43 pass
44
46 """If the analyzer thinks the simulation should be stopped
47 (for instance because of convergence) it returns false"""
48 return True
49
51 """@returns: current time"""
52 return self.parent.getTime()
53
55 """@param func: a new listener-function that gets notified every time
56 the line-analyzer encounters something interesting"""
57
58 self.eventListeners.append(func)
59
61 """Notifys the event listeners of an event
62 @param data: The data of the event. Everything is possible"""
63
64 for f in self.eventListeners:
65 f(*data)
66
68 """Hook to let every analyzer give its stuff back when the analysis has ended"""
69 pass
70
72 """Give back the current analyzed data in a dictionary
73
74 To be overwritten by subclasses"""
75
76 return {}
77