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 sol.addLocalConfig()
89
90 self.clearCase(sol)
91
92 lam=self.getParallel()
93
94 self.setLogname()
95
96 run=GnuplotRunner(argv=self.parser.getArgs(),
97 smallestFreq=self.opts.frequency,
98 persist=self.opts.persist,
99 plotLinear=self.opts.linear,
100 plotCont=self.opts.cont,
101 plotBound=self.opts.bound,
102 plotIterations=self.opts.iterations,
103 plotCourant=self.opts.courant,
104 plotExecution=self.opts.execution,
105 plotDeltaT=self.opts.deltaT,
106 customRegexp=self.plotLines(),
107 writeFiles=self.opts.writeFiles,
108 hardcopy=self.opts.hardcopy,
109 hardcopyPrefix=self.opts.hardcopyPrefix,
110 hardcopyFormat=self.opts.hardcopyformat,
111 server=self.opts.server,
112 lam=lam,
113 raiseit=self.opts.raiseit,
114 steady=self.opts.steady,
115 progress=self.opts.progress,
116 restart=self.opts.restart,
117 logname=self.opts.logname,
118 compressLog=self.opts.compress,
119 noLog=self.opts.noLog,
120 plottingImplementation=self.opts.implementation,
121 singleFile=self.opts.singleDataFilesOnly,
122 remark=self.opts.remark,
123 jobId=self.opts.jobId)
124
125 self.addSafeTrigger(run,sol,steady=self.opts.steady)
126 self.addWriteAllTrigger(run,sol)
127 self.addLibFunctionTrigger(run,sol)
128
129 self.addToCaseLog(cName,"Starting")
130
131 run.start()
132
133 self.addToCaseLog(cName,"Ending")
134
135 self.reportUsage(run)
136