1
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):
32
38
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