1
2 """
3 Class that implements pyFoamPlotRunner
4 """
5
6 from .PyFoamApplication import PyFoamApplication
7
8 from PyFoam.Execution.GnuplotRunner import GnuplotRunner
9
10 from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory
11
12 from PyFoam.Error import warning
13
14 from .CommonStandardOutput import CommonStandardOutput
15 from .CommonPlotLines import CommonPlotLines
16 from .CommonParallel import CommonParallel
17 from .CommonRestart import CommonRestart
18 from .CommonPlotOptions import CommonPlotOptions
19 from .CommonClearCase import CommonClearCase
20 from .CommonReportUsage import CommonReportUsage
21 from .CommonReportRunnerData import CommonReportRunnerData
22 from .CommonSafeTrigger import CommonSafeTrigger
23 from .CommonWriteAllTrigger import CommonWriteAllTrigger
24 from .CommonLibFunctionTrigger import CommonLibFunctionTrigger
25 from .CommonServer import CommonServer
26 from .CommonVCSCommit import CommonVCSCommit
27
28 from os import path
29
30 -class PlotRunner(PyFoamApplication,
31 CommonPlotOptions,
32 CommonPlotLines,
33 CommonSafeTrigger,
34 CommonWriteAllTrigger,
35 CommonLibFunctionTrigger,
36 CommonClearCase,
37 CommonServer,
38 CommonReportUsage,
39 CommonReportRunnerData,
40 CommonParallel,
41 CommonRestart,
42 CommonStandardOutput,
43 CommonVCSCommit):
45 description="""\
46 Runs an OpenFoam solver needs the usual 3 arguments (<solver>
47 <directory> <case>) and passes them on (plus additional arguments).
48 Output is sent to stdout and a logfile inside the case directory
49 (PyFoamSolver.logfile) Information about the residuals is output as
50 graphs
51
52 If the directory contains a file customRegexp this is automatically
53 read and the regular expressions in it are displayed
54 """
55 CommonPlotOptions.__init__(self,persist=True)
56 CommonPlotLines.__init__(self)
57 PyFoamApplication.__init__(self,
58 exactNr=False,
59 args=args,
60 description=description)
61
84
86 self.processPlotOptions()
87
88 cName=self.parser.casePath()
89 self.checkCase(cName)
90 self.addLocalConfig(cName)
91
92 self.processPlotLineOptions(autoPath=cName)
93
94 sol=SolutionDirectory(cName,archive=None)
95
96 self.clearCase(sol)
97
98 lam=self.getParallel(sol)
99
100 self.setLogname()
101
102 self.checkAndCommit(sol)
103
104 run=GnuplotRunner(argv=self.parser.getArgs(),
105 smallestFreq=self.opts.frequency,
106 persist=self.opts.persist,
107 plotLinear=self.opts.linear,
108 plotCont=self.opts.cont,
109 plotBound=self.opts.bound,
110 plotIterations=self.opts.iterations,
111 plotCourant=self.opts.courant,
112 plotExecution=self.opts.execution,
113 plotDeltaT=self.opts.deltaT,
114 customRegexp=self.plotLines(),
115 writeFiles=self.opts.writeFiles,
116 hardcopy=self.opts.hardcopy,
117 hardcopyPrefix=self.opts.hardcopyPrefix,
118 hardcopyFormat=self.opts.hardcopyformat,
119 server=self.opts.server,
120 lam=lam,
121 raiseit=self.opts.raiseit,
122 steady=self.opts.steady,
123 progress=self.opts.progress or self.opts.silent,
124 restart=self.opts.restart,
125 logname=self.opts.logname,
126 compressLog=self.opts.compress,
127 noLog=self.opts.noLog,
128 logTail=self.opts.logTail,
129 plottingImplementation=self.opts.implementation,
130 writePickled=self.opts.writePickled,
131 singleFile=self.opts.singleDataFilesOnly,
132 remark=self.opts.remark,
133 parameters=self.getRunParameters(),
134 jobId=self.opts.jobId)
135
136 self.addSafeTrigger(run,sol,steady=self.opts.steady)
137 self.addWriteAllTrigger(run,sol)
138 self.addLibFunctionTrigger(run,sol)
139
140 self.addToCaseLog(cName,"Starting")
141
142 run.start()
143
144 self.setData(run.data)
145
146 self.addToCaseLog(cName,"Ending")
147
148 self.reportUsage(run)
149 self.reportRunnerData(run)
150
151 return run.data
152
153
154