1
2 """
3 Application class that implements pyFoamSteadyRunner
4 """
5
6 from os import path
7
8 from PyFoamApplication import PyFoamApplication
9
10 from PyFoam.Execution.ConvergenceRunner import ConvergenceRunner
11 from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer
12 from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory
13
14 from PyFoam.Error import warning
15
16 from CommonParallel import CommonParallel
17 from CommonRestart import CommonRestart
18 from CommonPlotLines import CommonPlotLines
19 from CommonClearCase import CommonClearCase
20 from CommonReportUsage import CommonReportUsage
21 from CommonSafeTrigger import CommonSafeTrigger
22 from CommonWriteAllTrigger import CommonWriteAllTrigger
23 from CommonStandardOutput import CommonStandardOutput
24 from CommonServer import CommonServer
25 from CommonVCSCommit import CommonVCSCommit
26
27 -class SteadyRunner(PyFoamApplication,
28 CommonPlotLines,
29 CommonSafeTrigger,
30 CommonWriteAllTrigger,
31 CommonClearCase,
32 CommonServer,
33 CommonReportUsage,
34 CommonParallel,
35 CommonRestart,
36 CommonStandardOutput,
37 CommonVCSCommit):
39 description="""
40 Runs an OpenFoam steady solver. Needs the usual 3 arguments (<solver>
41 <directory> <case>) and passes them on (plus additional arguments)
42 Output is sent to stdout and a logfile inside the case directory
43 (PyFoamSolver.logfile). The Directory PyFoamSolver.analyzed contains
44 this information a) Residuals and other information of the linear
45 solvers b) Execution time c) continuity information d) bounding of
46 variables
47
48 If the solver has converged (linear solvers below threshold) it is
49 stopped and the last simulation state is written to disk
50 """
51
52 CommonPlotLines.__init__(self)
53 PyFoamApplication.__init__(self,
54 args=args,
55 description=description)
56
68
70 cName=self.parser.casePath()
71 self.checkCase(cName)
72
73 self.processPlotLineOptions(autoPath=cName)
74
75 sol=SolutionDirectory(cName,archive=None)
76
77 self.clearCase(sol)
78
79 lam=self.getParallel(sol)
80
81 self.setLogname()
82
83 self.checkAndCommit(sol)
84
85 run=ConvergenceRunner(BoundingLogAnalyzer(progress=self.opts.progress,
86 doFiles=self.opts.writeFiles,
87 singleFile=self.opts.singleDataFilesOnly,
88 doTimelines=True),
89 silent=self.opts.progress,
90 argv=self.parser.getArgs(),
91 restart=self.opts.restart,
92 server=self.opts.server,
93 logname=self.opts.logname,
94 compressLog=self.opts.compress,
95 lam=lam,
96 noLog=self.opts.noLog,
97 remark=self.opts.remark,
98 jobId=self.opts.jobId)
99
100 run.createPlots(customRegexp=self.lines_,
101 writeFiles=self.opts.writeFiles)
102
103 self.addSafeTrigger(run,sol)
104 self.addWriteAllTrigger(run,sol)
105
106 self.addToCaseLog(cName,"Starting")
107
108 run.start()
109
110 self.addToCaseLog(cName,"Ending")
111
112 self.reportUsage(run)
113