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
26 -class SteadyRunner(PyFoamApplication,
27 CommonPlotLines,
28 CommonSafeTrigger,
29 CommonWriteAllTrigger,
30 CommonClearCase,
31 CommonServer,
32 CommonReportUsage,
33 CommonParallel,
34 CommonRestart,
35 CommonStandardOutput):
37 description="""
38 Runs an OpenFoam steady solver. Needs the usual 3 arguments (<solver>
39 <directory> <case>) and passes them on (plus additional arguments)
40 Output is sent to stdout and a logfile inside the case directory
41 (PyFoamSolver.logfile). The Directory PyFoamSolver.analyzed contains
42 this information a) Residuals and other information of the linear
43 solvers b) Execution time c) continuity information d) bounding of
44 variables
45
46 If the solver has converged (linear solvers below threshold) it is
47 stopped and the last simulation state is written to disk
48 """
49
50 CommonPlotLines.__init__(self)
51 PyFoamApplication.__init__(self,
52 args=args,
53 description=description)
54
65
67 cName=self.parser.casePath()
68 self.checkCase(cName)
69
70 self.processPlotLineOptions(autoPath=cName)
71
72 sol=SolutionDirectory(cName,archive=None)
73
74 self.clearCase(sol)
75
76 lam=self.getParallel()
77
78 self.setLogname()
79
80 run=ConvergenceRunner(BoundingLogAnalyzer(progress=self.opts.progress,
81 singleFile=self.opts.singleDataFilesOnly,
82 doTimelines=True),
83 silent=self.opts.progress,
84 argv=self.parser.getArgs(),
85 restart=self.opts.restart,
86 server=self.opts.server,
87 logname=self.opts.logname,
88 compressLog=self.opts.compress,
89 lam=lam,
90 noLog=self.opts.noLog,
91 remark=self.opts.remark,
92 jobId=self.opts.jobId)
93
94 run.createPlots(customRegexp=self.lines_)
95
96 self.addSafeTrigger(run,sol)
97 self.addWriteAllTrigger(run,sol)
98
99 self.addToCaseLog(cName,"Starting")
100
101 run.start()
102
103 self.addToCaseLog(cName,"Ending")
104
105 self.reportUsage(run)
106