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 .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 from PyFoam.ThirdParty.six import print_
18
19 -class RunAtMultipleTimes(PyFoamApplication,
20 CommonReportUsage,
21 CommonReportRunnerData,
22 CommonSelectTimesteps,
23 CommonParallel,
24 CommonServer,
25 CommonStandardOutput):
26 - def __init__(self,
27 args=None,
28 **kwargs):
38
46
48 cName=self.parser.casePath()
49
50 times=self.processTimestepOptions(SolutionDirectory(cName,archive=None))
51 if len(times)<1:
52 self.warning("Can't continue without time-steps")
53 return
54
55 lam=self.getParallel(SolutionDirectory(cName,archive=None))
56
57 data=[]
58
59 for i,t in enumerate(times):
60 print_(" Running for t=",t)
61 run=UtilityRunner(argv=self.parser.getArgs()+["-time",t],
62 silent=self.opts.progress or self.opts.silent,
63 server=self.opts.server,
64 logname="%s.%s.t=%s" % (self.opts.logname,self.parser.getApplication(),t),
65 compressLog=self.opts.compress,
66 logTail=self.opts.logTail,
67 noLog=self.opts.noLog,
68 echoCommandLine=self.opts.echoCommandPrefix,
69 lam=lam)
70
71 self.addToCaseLog(cName,"Starting for t=%s",t)
72
73 run.start()
74
75 self.setData({t:run.data})
76
77 self.addToCaseLog(cName,"Ending")
78
79 self.reportUsage(run)
80 self.reportRunnerData(run)
81
82 data.append(run.data)
83
84 return data
85
86
87