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

Source Code for Module PyFoam.Applications.RunAtMultipleTimes

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Applications/RunAtMultipleTimes.py 7722 2012-01-18T17:50:53.943725Z bgschaid  $  
 2  """ 
 3  Application class that implements pyFoamRunAtMultipleTimes 
 4  """ 
 5   
 6  from PyFoamApplication import PyFoamApplication 
 7  from CommonSelectTimesteps import CommonSelectTimesteps 
 8  from CommonReportUsage import CommonReportUsage 
 9  from CommonReportRunnerData import CommonReportRunnerData 
10  from CommonStandardOutput import CommonStandardOutput 
11  from CommonServer import CommonServer 
12  from CommonParallel import CommonParallel 
13   
14  from PyFoam.Execution.UtilityRunner import UtilityRunner 
15  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
16   
17  import sys 
18  from os import path 
19   
20 -class RunAtMultipleTimes(PyFoamApplication, 21 CommonReportUsage, 22 CommonReportRunnerData, 23 CommonSelectTimesteps, 24 CommonParallel, 25 CommonServer, 26 CommonStandardOutput):
27 - def __init__(self,args=None):
28 description="""\ 29 Runs a OpenFoam Utility that only supports being run for one or all 30 times to be run at multiple selected times 31 """ 32 PyFoamApplication.__init__(self, 33 exactNr=False, 34 args=args, 35 description=description)
36
37 - def addOptions(self):
38 CommonStandardOutput.addOptions(self,logname="RunAtMultipleTimes") 39 CommonParallel.addOptions(self) 40 CommonServer.addOptions(self) 41 CommonSelectTimesteps.addOptions(self,defaultUnique=True) 42 CommonReportUsage.addOptions(self) 43 CommonReportRunnerData.addOptions(self)
44
45 - def run(self):
46 cName=self.parser.casePath() 47 48 times=self.processTimestepOptions(SolutionDirectory(cName,archive=None)) 49 if len(times)<1: 50 self.warning("Can't continue without time-steps") 51 return 52 53 lam=self.getParallel(SolutionDirectory(cName,archive=None)) 54 55 data=[] 56 57 for i,t in enumerate(times): 58 print " Running for t=",t 59 run=UtilityRunner(argv=self.parser.getArgs()+["-time",t], 60 silent=self.opts.progress or self.opts.silent, 61 server=self.opts.server, 62 logname="%s.%s.t=%s" % (self.opts.logname,self.parser.getApplication(),t), 63 compressLog=self.opts.compress, 64 logTail=self.opts.logTail, 65 noLog=self.opts.noLog, 66 lam=lam) 67 68 self.addToCaseLog(cName,"Starting for t=%s",t) 69 70 run.start() 71 72 self.setData({t:run.data}) 73 74 self.addToCaseLog(cName,"Ending") 75 76 self.reportUsage(run) 77 self.reportRunnerData(run) 78 79 data.append(run.data) 80 81 return data
82