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

Source Code for Module PyFoam.Applications.Runner

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