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

Source Code for Module PyFoam.Applications.SteadyRunner

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