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 5173 2009-06-28T17:25:28.283378Z 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 CommonStandardOutput import CommonStandardOutput 
10  from CommonServer import CommonServer 
11   
12  from PyFoam.Execution.UtilityRunner import UtilityRunner 
13  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
14   
15  import sys 
16  from os import path 
17   
18 -class RunAtMultipleTimes(PyFoamApplication, 19 CommonReportUsage, 20 CommonSelectTimesteps, 21 CommonServer, 22 CommonStandardOutput):
23 - def __init__(self,args=None):
24 description=""" 25 Runs a OpenFoam Utility that only supports being run for one or all times 26 to be run at multiple selected times 27 """ 28 PyFoamApplication.__init__(self, 29 exactNr=False, 30 args=args, 31 description=description)
32
33 - def addOptions(self):
34 CommonStandardOutput.addOptions(self,logname="RunAtMultipleTimes") 35 CommonServer.addOptions(self) 36 CommonSelectTimesteps.addOptions(self,defaultUnique=True) 37 CommonReportUsage.addOptions(self)
38
39 - def run(self):
40 cName=self.parser.casePath() 41 42 times=self.processTimestepOptions(SolutionDirectory(cName)) 43 if len(times)<1: 44 self.warning("Can't continue without time-steps") 45 return 46 47 for i,t in enumerate(times): 48 print " Running for t=",t 49 run=UtilityRunner(argv=self.parser.getArgs()+["-time",t], 50 silent=self.opts.progress, 51 server=self.opts.server, 52 logname="%s.%s.t=%s" % (self.opts.logname,self.parser.getApplication(),t), 53 compressLog=self.opts.compress, 54 noLog=self.opts.noLog) 55 56 self.addToCaseLog(cName,"Starting for t=%s",t) 57 58 run.start() 59 60 self.addToCaseLog(cName,"Ending") 61 62 self.reportUsage(run)
63