Package PyFoam :: Package Applications :: Module CommonPlotOptions
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.CommonPlotOptions

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