Package PyFoam :: Package Applications :: Module Runner
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.Runner

 1  """ 
 2  Application class that implements pyFoamRunner 
 3  """ 
 4   
 5  from PyFoamApplication import PyFoamApplication 
 6   
 7  from PyFoam.Execution.AnalyzedRunner import AnalyzedRunner 
 8  from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer 
 9  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
10   
11  from PyFoam.Execution.ParallelExecution import LAMMachine 
12   
13 -class Runner(PyFoamApplication):
14 - def __init__(self):
15 description=""" 16 Runs an OpenFoam solver. Needs the usual 3 arguments (<solver> 17 <directory> <case>) and passes them on (plus additional arguments). 18 Output is sent to stdout and a logfile inside the case directory 19 (PyFoamSolver.logfile) The Directory PyFoamSolver.analyzed contains 20 this information: a) Residuals and other information of the linear 21 solvers b Execution time c) continuity information d) bounding of 22 variables 23 """ 24 25 PyFoamApplication.__init__(self,description=description)
26
27 - def addOptions(self):
28 self.parser.add_option("--procnr",type="int",dest="procnr",default=None,help="The number of processors the run should be started on") 29 self.parser.add_option("--machinefile",dest="machinefile",default=None,help="The machinefile that specifies the parallel machine") 30 self.parser.add_option("--clear-case",action="store_true",default=False,dest="clearCase",help="Clear all timesteps except for the first before running")
31
32 - def run(self):
33 if self.opts.clearCase: 34 print "Clearing out old timesteps ...." 35 36 cName=self.parser.getArgs()[2] 37 sol=SolutionDirectory(cName) 38 sol.clearResults() 39 40 lam=None 41 if self.opts.procnr!=None or self.opts.machinefile!=None: 42 lam=LAMMachine(machines=self.opts.machinefile,nr=self.opts.procnr) 43 44 run=AnalyzedRunner(BoundingLogAnalyzer(),argv=self.parser.getArgs(),server=True,lam=lam) 45 46 run.start()
47