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

Source Code for Module PyFoam.Applications.SteadyRunner

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