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

Source Code for Module PyFoam.Applications.PlotRunner

  1  #  ICE Revision: $Id$ 
  2  """ 
  3  Class that implements pyFoamPlotRunner 
  4  """ 
  5   
  6  from .PyFoamApplication import PyFoamApplication 
  7   
  8  from PyFoam.Execution.GnuplotRunner import GnuplotRunner 
  9   
 10  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 11   
 12  from .CommonStandardOutput import CommonStandardOutput 
 13  from .CommonPlotLines import CommonPlotLines 
 14  from .CommonParallel import CommonParallel 
 15  from .CommonRestart import CommonRestart 
 16  from .CommonPlotOptions import CommonPlotOptions 
 17  from .CommonClearCase import CommonClearCase 
 18  from .CommonReportUsage import CommonReportUsage 
 19  from .CommonReportRunnerData import CommonReportRunnerData 
 20  from .CommonSafeTrigger import CommonSafeTrigger 
 21  from .CommonWriteAllTrigger import CommonWriteAllTrigger 
 22  from .CommonLibFunctionTrigger import CommonLibFunctionTrigger 
 23  from .CommonServer import CommonServer 
 24  from .CommonVCSCommit import CommonVCSCommit 
 25   
26 -class PlotRunner(PyFoamApplication, 27 CommonPlotOptions, 28 CommonPlotLines, 29 CommonSafeTrigger, 30 CommonWriteAllTrigger, 31 CommonLibFunctionTrigger, 32 CommonClearCase, 33 CommonServer, 34 CommonReportUsage, 35 CommonReportRunnerData, 36 CommonParallel, 37 CommonRestart, 38 CommonStandardOutput, 39 CommonVCSCommit):
40 - def __init__(self, 41 args=None, 42 **kwargs):
43 description="""\ 44 Runs an OpenFoam solver needs the usual 3 arguments (<solver> 45 <directory> <case>) and passes them on (plus additional arguments). 46 Output is sent to stdout and a logfile inside the case directory 47 (PyFoamSolver.logfile) Information about the residuals is output as 48 graphs 49 50 If the directory contains a file customRegexp this is automatically 51 read and the regular expressions in it are displayed 52 """ 53 CommonPlotOptions.__init__(self,persist=True) 54 CommonPlotLines.__init__(self) 55 PyFoamApplication.__init__(self, 56 exactNr=False, 57 args=args, 58 description=description, 59 **kwargs)
60
61 - def addOptions(self):
62 CommonClearCase.addOptions(self) 63 64 CommonPlotOptions.addOptions(self) 65 66 self.parser.add_option("--steady-run", 67 action="store_true", 68 default=False, 69 dest="steady", 70 help="This is a steady run. Stop it after convergence") 71 72 CommonReportUsage.addOptions(self) 73 CommonReportRunnerData.addOptions(self) 74 CommonStandardOutput.addOptions(self) 75 CommonParallel.addOptions(self) 76 CommonRestart.addOptions(self) 77 CommonPlotLines.addOptions(self) 78 CommonSafeTrigger.addOptions(self) 79 CommonWriteAllTrigger.addOptions(self) 80 CommonLibFunctionTrigger.addOptions(self) 81 CommonServer.addOptions(self) 82 CommonVCSCommit.addOptions(self)
83
84 - def run(self):
85 self.processPlotOptions() 86 87 cName=self.parser.casePath() 88 self.checkCase(cName) 89 self.addLocalConfig(cName) 90 91 self.processPlotLineOptions(autoPath=cName) 92 93 sol=SolutionDirectory(cName,archive=None) 94 95 self.clearCase(sol) 96 97 lam=self.getParallel(sol) 98 99 self.setLogname() 100 101 self.checkAndCommit(sol) 102 103 run=GnuplotRunner(argv=self.parser.getArgs(), 104 smallestFreq=self.opts.frequency, 105 persist=self.opts.persist, 106 plotLinear=self.opts.linear, 107 plotCont=self.opts.cont, 108 plotBound=self.opts.bound, 109 plotIterations=self.opts.iterations, 110 plotCourant=self.opts.courant, 111 plotExecution=self.opts.execution, 112 plotDeltaT=self.opts.deltaT, 113 customRegexp=self.plotLines(), 114 writeFiles=self.opts.writeFiles, 115 hardcopy=self.opts.hardcopy, 116 hardcopyPrefix=self.opts.hardcopyPrefix, 117 hardcopyFormat=self.opts.hardcopyformat, 118 server=self.opts.server, 119 lam=lam, 120 raiseit=self.opts.raiseit, 121 steady=self.opts.steady, 122 progress=self.opts.progress or self.opts.silent, 123 restart=self.opts.restart, 124 logname=self.opts.logname, 125 compressLog=self.opts.compress, 126 noLog=self.opts.noLog, 127 logTail=self.opts.logTail, 128 plottingImplementation=self.opts.implementation, 129 writePickled=self.opts.writePickled, 130 singleFile=self.opts.singleDataFilesOnly, 131 remark=self.opts.remark, 132 parameters=self.getRunParameters(), 133 echoCommandLine=self.opts.echoCommandPrefix, 134 jobId=self.opts.jobId) 135 136 self.addSafeTrigger(run,sol,steady=self.opts.steady) 137 self.addWriteAllTrigger(run,sol) 138 self.addLibFunctionTrigger(run,sol) 139 140 self.addToCaseLog(cName,"Starting") 141 142 run.start() 143 144 self.setData(run.data) 145 146 self.addToCaseLog(cName,"Ending") 147 148 self.reportUsage(run) 149 self.reportRunnerData(run) 150 151 return run.data
152 153 # Should work with Python3 and Python2 154