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 from CommonParallel import CommonParallel
12
13 from PyFoam.Execution.UtilityRunner import UtilityRunner
14 from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory
15
16 import sys
17 from os import path
18
19 -class RunAtMultipleTimes(PyFoamApplication,
20 CommonReportUsage,
21 CommonSelectTimesteps,
22 CommonParallel,
23 CommonServer,
24 CommonStandardOutput):
34
41
43 cName=self.parser.casePath()
44
45 times=self.processTimestepOptions(SolutionDirectory(cName,archive=None))
46 if len(times)<1:
47 self.warning("Can't continue without time-steps")
48 return
49
50 lam=self.getParallel(SolutionDirectory(cName,archive=None))
51
52 for i,t in enumerate(times):
53 print " Running for t=",t
54 run=UtilityRunner(argv=self.parser.getArgs()+["-time",t],
55 silent=self.opts.progress,
56 server=self.opts.server,
57 logname="%s.%s.t=%s" % (self.opts.logname,self.parser.getApplication(),t),
58 compressLog=self.opts.compress,
59 noLog=self.opts.noLog,
60 lam=lam)
61
62 self.addToCaseLog(cName,"Starting for t=%s",t)
63
64 run.start()
65
66 self.addToCaseLog(cName,"Ending")
67
68 self.reportUsage(run)
69