Line | |
---|
1 | |
---|
2 | class Operator: |
---|
3 | """Operator - generic structure for a fractional operator |
---|
4 | |
---|
5 | This is the base class for all fractional step operators |
---|
6 | """ |
---|
7 | |
---|
8 | def __init__(self, domain): |
---|
9 | |
---|
10 | self.domain = domain |
---|
11 | self.domain.set_fractional_step_operator(self) |
---|
12 | |
---|
13 | if domain.numproc > 1: |
---|
14 | msg = 'Not implemented to run in parallel' |
---|
15 | assert self.__parallel_safe(), msg |
---|
16 | |
---|
17 | self.logging = False |
---|
18 | self.logging_file = '' |
---|
19 | |
---|
20 | def __call__(self): |
---|
21 | |
---|
22 | #timestep = self.domain.get_timestep() |
---|
23 | raise Exception('Need to implement __call__ for your operator') |
---|
24 | |
---|
25 | def get_timestep(self): |
---|
26 | |
---|
27 | return self.domain.get_timestep() |
---|
28 | |
---|
29 | def __parallel_safe(self): |
---|
30 | |
---|
31 | return True |
---|
32 | |
---|
33 | def statistics(self): |
---|
34 | |
---|
35 | message = 'You need to implement operator statistics for your operator' |
---|
36 | return message |
---|
37 | |
---|
38 | def print_statistics(self): |
---|
39 | |
---|
40 | print self.statistics() |
---|
41 | |
---|
42 | |
---|
43 | def timestepping_statistics(self): |
---|
44 | |
---|
45 | message = 'You need to implement timestepping statistics for your operator' |
---|
46 | return message |
---|
47 | |
---|
48 | def print_timestepping_statistics(self): |
---|
49 | |
---|
50 | print self.timestepping_statistics() |
---|
51 | |
---|
52 | |
---|
53 | def log_timestepping_statistics(self): |
---|
54 | |
---|
55 | from anuga.utilities.system_tools import log_to_file |
---|
56 | if self.logging: |
---|
57 | log_to_file(self.log_filename, self.timestepping_statistics()) |
---|
58 | |
---|
Note: See
TracBrowser
for help on using the repository browser.