1
2 """
3 Application class that implements pyFoamSteadyRunner
4 """
5
6 from .PyFoamApplication import PyFoamApplication
7
8 from PyFoam.Execution.ConvergenceRunner import ConvergenceRunner
9 from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer
10 from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory
11
12 from .CommonParallel import CommonParallel
13 from .CommonRestart import CommonRestart
14 from .CommonPlotLines import CommonPlotLines
15 from .CommonClearCase import CommonClearCase
16 from .CommonReportUsage import CommonReportUsage
17 from .CommonReportRunnerData import CommonReportRunnerData
18 from .CommonSafeTrigger import CommonSafeTrigger
19 from .CommonWriteAllTrigger import CommonWriteAllTrigger
20 from .CommonStandardOutput import CommonStandardOutput
21 from .CommonServer import CommonServer
22 from .CommonVCSCommit import CommonVCSCommit
23
24 -class SteadyRunner(PyFoamApplication,
25 CommonPlotLines,
26 CommonSafeTrigger,
27 CommonWriteAllTrigger,
28 CommonClearCase,
29 CommonServer,
30 CommonReportUsage,
31 CommonReportRunnerData,
32 CommonParallel,
33 CommonRestart,
34 CommonStandardOutput,
35 CommonVCSCommit):
36 - def __init__(self,
37 args=None,
38 **kwargs):
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 **kwargs)
57
70
72 cName=self.parser.casePath()
73 self.checkCase(cName)
74
75 self.processPlotLineOptions(autoPath=cName)
76
77 sol=SolutionDirectory(cName,archive=None)
78
79 self.clearCase(sol)
80
81 lam=self.getParallel(sol)
82
83 self.setLogname()
84
85 self.checkAndCommit(sol)
86
87 run=ConvergenceRunner(BoundingLogAnalyzer(progress=self.opts.progress,
88 doFiles=self.opts.writeFiles,
89 singleFile=self.opts.singleDataFilesOnly,
90 doTimelines=True),
91 silent=self.opts.progress or self.opts.silent,
92 argv=self.parser.getArgs(),
93 restart=self.opts.restart,
94 server=self.opts.server,
95 logname=self.opts.logname,
96 compressLog=self.opts.compress,
97 lam=lam,
98 logTail=self.opts.logTail,
99 noLog=self.opts.noLog,
100 remark=self.opts.remark,
101 parameters=self.getRunParameters(),
102 echoCommandLine=self.opts.echoCommandPrefix,
103 jobId=self.opts.jobId)
104
105 run.createPlots(customRegexp=self.lines_,
106 writeFiles=self.opts.writeFiles)
107
108 self.addSafeTrigger(run,sol)
109 self.addWriteAllTrigger(run,sol)
110
111 self.addToCaseLog(cName,"Starting")
112
113 run.start()
114
115 self.addToCaseLog(cName,"Ending")
116
117 self.setData(run.data)
118
119 self.reportUsage(run)
120 self.reportRunnerData(run)
121
122 return run.data
123
124
125