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 CommonSafeTrigger import CommonSafeTrigger
22 from CommonWriteAllTrigger import CommonWriteAllTrigger
23 from CommonLibFunctionTrigger import CommonLibFunctionTrigger
24 from CommonServer import CommonServer
25 from CommonVCSCommit import CommonVCSCommit
26
27 from os import path
28
29 -class PlotRunner(PyFoamApplication,
30 CommonPlotOptions,
31 CommonPlotLines,
32 CommonSafeTrigger,
33 CommonWriteAllTrigger,
34 CommonLibFunctionTrigger,
35 CommonClearCase,
36 CommonServer,
37 CommonReportUsage,
38 CommonParallel,
39 CommonRestart,
40 CommonStandardOutput,
41 CommonVCSCommit):
43 description="""
44 runs an OpenFoam solver needs the usual 3 arguments (<solver>
45 <directory> <case>) and passes them on (plus additional arguments).
46 Output is sent to stdout and a logfile inside the case directory
47 (PyFoamSolver.logfile) Information about the residuals is output as
48 graphs
49
50 If the directory contains a file customRegexp this is automatically
51 read and the regular expressions in it are displayed
52 """
53 CommonPlotOptions.__init__(self,persist=True)
54 CommonPlotLines.__init__(self)
55 PyFoamApplication.__init__(self,
56 exactNr=False,
57 args=args,
58 description=description)
59
81
83 self.processPlotOptions()
84
85 cName=self.parser.casePath()
86 self.checkCase(cName)
87 self.addLocalConfig(cName)
88
89 self.processPlotLineOptions(autoPath=cName)
90
91 sol=SolutionDirectory(cName,archive=None)
92
93 self.clearCase(sol)
94
95 lam=self.getParallel(sol)
96
97 self.setLogname()
98
99 self.checkAndCommit(sol)
100
101 run=GnuplotRunner(argv=self.parser.getArgs(),
102 smallestFreq=self.opts.frequency,
103 persist=self.opts.persist,
104 plotLinear=self.opts.linear,
105 plotCont=self.opts.cont,
106 plotBound=self.opts.bound,
107 plotIterations=self.opts.iterations,
108 plotCourant=self.opts.courant,
109 plotExecution=self.opts.execution,
110 plotDeltaT=self.opts.deltaT,
111 customRegexp=self.plotLines(),
112 writeFiles=self.opts.writeFiles,
113 hardcopy=self.opts.hardcopy,
114 hardcopyPrefix=self.opts.hardcopyPrefix,
115 hardcopyFormat=self.opts.hardcopyformat,
116 server=self.opts.server,
117 lam=lam,
118 raiseit=self.opts.raiseit,
119 steady=self.opts.steady,
120 progress=self.opts.progress,
121 restart=self.opts.restart,
122 logname=self.opts.logname,
123 compressLog=self.opts.compress,
124 noLog=self.opts.noLog,
125 plottingImplementation=self.opts.implementation,
126 singleFile=self.opts.singleDataFilesOnly,
127 remark=self.opts.remark,
128 jobId=self.opts.jobId)
129
130 self.addSafeTrigger(run,sol,steady=self.opts.steady)
131 self.addWriteAllTrigger(run,sol)
132 self.addLibFunctionTrigger(run,sol)
133
134 self.addToCaseLog(cName,"Starting")
135
136 run.start()
137
138 self.addToCaseLog(cName,"Ending")
139
140 self.reportUsage(run)
141