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 hardcopyFormat=self.opts.hardcopyformat,
109 server=self.opts.server,
110 lam=lam,
111 raiseit=self.opts.raiseit,
112 steady=self.opts.steady,
113 progress=self.opts.progress,
114 restart=self.opts.restart,
115 logname=self.opts.logname,
116 noLog=self.opts.noLog)
117
118 self.addSafeTrigger(run,sol,steady=self.opts.steady)
119 self.addWriteAllTrigger(run,sol)
120 self.addLibFunctionTrigger(run,sol)
121
122 run.start()
123
124 self.reportUsage(run)
125