1 """
2 Class that implements common functionality for plotting options
3 """
4
5 from optparse import OptionGroup
6
8 """ The class that adds plot options
9 """
10
12 self.persistDefault=persist
13
15 behaveGroup=OptionGroup(self.parser,
16 "Plot Behaviour",
17 "How the plots should behave (most of these options are passed to gnuplot)")
18
19 behaveGroup.add_option("--frequency",
20 type="float",
21 dest="frequency",
22 default=1.,
23 help="The frequency with which output should be generated (in seconds)")
24 behaveGroup.add_option("--persist",
25 action="store_true",
26 dest="persist",
27 default=self.persistDefault,
28 help="Gnuplot windows stay after interrupt")
29 behaveGroup.add_option("--non-persist",
30 action="store_false",
31 dest="persist",
32 help="Gnuplot windows close after interrupt")
33 behaveGroup.add_option("--raise",
34 action="store_true",
35 dest="raiseit",
36 help="Raise the Gnuplot windows after every replot")
37 self.parser.add_option_group(behaveGroup)
38
39 writeDGroup=OptionGroup(self.parser,
40 "Write plot data",
41 "How data and the plots themself should be written to disk")
42 writeDGroup.add_option("--write-files",
43 action="store_true",
44 default=False,
45 dest="writeFiles",
46 help="Writes the parsed data to files")
47 writeDGroup.add_option("--hardcopy",
48 action="store_true",
49 default=False,
50 dest="hardcopy",
51 help="Writes postscript hardcopies of the plot at the end of the run")
52 self.parser.add_option_group(writeDGroup)
53
54 plotItGroup=OptionGroup(self.parser,
55 "What to plot",
56 "Predefined quantities that the program looks for and plots")
57 plotItGroup.add_option("--no-default",
58 action="store_true",
59 default=False,
60 dest="nodefault",
61 help="Switch off the default plots (linear, continuity and bound)")
62 plotItGroup.add_option("--no-linear",
63 action="store_false",
64 default=True,
65 dest="linear",
66 help="Don't plot the linear solver convergence")
67 plotItGroup.add_option("--no-continuity",
68 action="store_false",
69 default=True,
70 dest="cont",
71 help="Don't plot the continuity info")
72 plotItGroup.add_option("--no-bound",
73 action="store_false",
74 default=True,
75 dest="bound",
76 help="Don't plot the bounding of variables")
77 plotItGroup.add_option("--with-iterations",
78 action="store_true",
79 default=False,
80 dest="iterations",
81 help="Plot the number of iterations of the linear solver")
82 plotItGroup.add_option("--with-courant",
83 action="store_true",
84 default=False,
85 dest="courant",
86 help="Plot the courant-numbers of the flow")
87 plotItGroup.add_option("--with-execution",
88 action="store_true",
89 default=False,
90 dest="execution",
91 help="Plot the execution time of each time-step")
92 plotItGroup.add_option("--with-deltat",
93 action="store_true",
94 default=False,
95 dest="deltaT",
96 help="'Plot the timestep-size time-step")
97 plotItGroup.add_option("--with-all",
98 action="store_true",
99 default=False,
100 dest="withAll",
101 help="Switch all possible plots on")
102 self.parser.add_option_group(plotItGroup)
103
105 if self.opts.nodefault:
106 self.opts.linear=False
107 self.opts.cont=False
108 self.opts.bound=False
109
110 if self.opts.withAll:
111 self.opts.linear=True
112 self.opts.cont=True
113 self.opts.bound=True
114 self.opts.iterations=True
115 self.opts.courant=True
116 self.opts.execution=True
117 self.opts.deltaT=True
118