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 """Set the directory to which output is to be written (if any
37 output is written)"""
38 pass
39
41 """If the analyzer thinks the simulation should be stopped
42 (for instance because of convergence) it returns false"""
43 return True
44
46 """@returns: current time"""
47 return self.parent.getTime()
48
50 """@param func: a new listener-function that gets notified every time
51 the line-analyzer encounters something interesting"""
52
53 self.eventListeners.append(func)
54
56 """Notifys the event listeners of an event
57 @param data: The data of the event. Everything is possible"""
58
59 for f in self.eventListeners:
60 f(*data)
61
63 """Hook to let every analyzer give its stuff back when the analysis has ended"""
64 pass
65