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

Source Code for Module PyFoam.Applications.SteadyRunner

  1  #  ICE Revision: $Id: SteadyRunner.py 9161 2008-08-04 08:01:05Z bgschaid $  
  2  """ 
  3  Application class that implements pyFoamSteadyRunner 
  4  """ 
  5   
  6  from os import path 
  7   
  8  from PyFoamApplication import PyFoamApplication 
  9   
 10  from PyFoam.Execution.ConvergenceRunner import ConvergenceRunner 
 11  from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer 
 12  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 13   
 14  from PyFoam.Execution.ParallelExecution import LAMMachine 
 15  from PyFoam.Error import warning 
 16   
 17  from CommonPlotLines import CommonPlotLines 
 18  from CommonClearCase import CommonClearCase 
 19  from CommonSafeTrigger import CommonSafeTrigger 
 20  from CommonWriteAllTrigger import CommonWriteAllTrigger 
 21   
22 -class SteadyRunner(PyFoamApplication, 23 CommonPlotLines, 24 CommonSafeTrigger, 25 CommonWriteAllTrigger, 26 CommonClearCase):
27 - def __init__(self,args=None):
28 description=""" 29 Runs an OpenFoam steady solver. Needs the usual 3 arguments (<solver> 30 <directory> <case>) and passes them on (plus additional arguments) 31 Output is sent to stdout and a logfile inside the case directory 32 (PyFoamSolver.logfile). The Directory PyFoamSolver.analyzed contains 33 this information a) Residuals and other information of the linear 34 solvers b) Execution time c) continuity information d) bounding of 35 variables 36 37 If the solver has converged (linear solvers below threshold) it is 38 stopped and the last simulation state is written to disk 39 """ 40 41 CommonPlotLines.__init__(self) 42 PyFoamApplication.__init__(self, 43 args=args, 44 description=description)
45
46 - def addOptions(self):
47 self.parser.add_option("--procnr", 48 type="int", 49 dest="procnr", 50 default=None, 51 help="The number of processors the run should be started on") 52 self.parser.add_option("--machinefile", 53 dest="machinefile", 54 default=None, 55 help="The machinefile that specifies the parallel machine") 56 self.parser.add_option("--restart", 57 action="store_true", 58 default=False, 59 dest="restart", 60 help="Restart the simulation from the last time-step") 61 self.parser.add_option("--progress", 62 action="store_true", 63 default=False, 64 dest="progress", 65 help="Only prints the progress of the simulation, but swallows all the other output") 66 self.parser.add_option("--report-usage", 67 action="store_true", 68 default=False, 69 dest="reportUsage", 70 help="After the execution the maximum memory usage is printed to the screen") 71 72 CommonPlotLines.addOptions(self) 73 CommonClearCase.addOptions(self) 74 CommonSafeTrigger.addOptions(self) 75 CommonWriteAllTrigger.addOptions(self)
76
77 - def run(self):
78 cName=self.parser.casePath() 79 self.checkCase(cName) 80 81 self.processPlotLineOptions(autoPath=cName) 82 83 sol=SolutionDirectory(cName,archive=None) 84 85 self.clearCase(sol) 86 87 lam=None 88 if self.opts.procnr!=None or self.opts.machinefile!=None: 89 lam=LAMMachine(machines=self.opts.machinefile,nr=self.opts.procnr) 90 91 92 run=ConvergenceRunner(BoundingLogAnalyzer(progress=self.opts.progress),silent=self.opts.progress,argv=self.parser.getArgs(),restart=self.opts.restart,server=True,lam=lam) 93 94 self.addPlotLineAnalyzers(run) 95 96 self.addSafeTrigger(run,sol) 97 self.addWriteAllTrigger(run,sol) 98 99 run.start() 100 101 if self.opts.reportUsage: 102 print "\n Used Memory: ",run.run.usedMemory(),"MB"
103