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