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