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

Source Code for Module PyFoam.Applications.Runner

  1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Applications/Runner.py 5717 2009-10-12T21:41:13.626022Z bgschaid  $  
  2  """ 
  3  Application class that implements pyFoamRunner 
  4  """ 
  5   
  6  from PyFoamApplication import PyFoamApplication 
  7   
  8  from PyFoam.Execution.AnalyzedRunner import AnalyzedRunner 
  9  from PyFoam.LogAnalysis.BoundingLogAnalyzer import BoundingLogAnalyzer 
 10  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 11  from PyFoam.RunDictionary.RegionCases import RegionCases 
 12   
 13  from PyFoam.Error import warning,error 
 14   
 15  from CommonMultiRegion import CommonMultiRegion 
 16  from CommonPlotLines import CommonPlotLines 
 17  from CommonClearCase import CommonClearCase 
 18  from CommonReportUsage import CommonReportUsage 
 19  from CommonWriteAllTrigger import CommonWriteAllTrigger 
 20  from CommonLibFunctionTrigger import CommonLibFunctionTrigger 
 21  from CommonStandardOutput import CommonStandardOutput 
 22  from CommonParallel import CommonParallel 
 23  from CommonRestart import CommonRestart 
 24  from CommonServer import CommonServer 
 25   
 26  from os import path 
 27   
28 -class Runner(PyFoamApplication, 29 CommonPlotLines, 30 CommonWriteAllTrigger, 31 CommonLibFunctionTrigger, 32 CommonClearCase, 33 CommonRestart, 34 CommonReportUsage, 35 CommonMultiRegion, 36 CommonParallel, 37 CommonServer, 38 CommonStandardOutput):
39 - def __init__(self,args=None):
40 description=""" 41 Runs an OpenFoam solver. Needs the usual 3 arguments (<solver> 42 <directory> <case>) and passes them on (plus additional arguments). 43 Output is sent to stdout and a logfile inside the case directory 44 (PyFoamSolver.logfile) The Directory PyFoamSolver.analyzed contains 45 this information: a) Residuals and other information of the linear 46 solvers b Execution time c) continuity information d) bounding of 47 variables 48 """ 49 50 CommonPlotLines.__init__(self) 51 PyFoamApplication.__init__(self, 52 exactNr=False, 53 args=args, 54 description=description)
55
56 - def addOptions(self):
67
68 - def run(self):
69 if self.opts.keeppseudo and (not self.opts.regions and self.opts.region==None): 70 warning("Option --keep-pseudocases only makes sense for multi-region-cases") 71 regionNames=[self.opts.region] 72 regions=None 73 74 casePath=self.parser.casePath() 75 self.checkCase(casePath) 76 77 self.addToCaseLog(casePath,"Starting") 78 79 if self.opts.regions or self.opts.region!=None: 80 print "Building Pseudocases" 81 sol=SolutionDirectory(casePath,archive=None) 82 regions=RegionCases(sol,clean=True) 83 84 if self.opts.regions: 85 regionNames=sol.getRegions() 86 87 self.processPlotLineOptions(autoPath=casePath) 88 89 self.clearCase(SolutionDirectory(casePath,archive=None)) 90 91 lam=self.getParallel() 92 93 for theRegion in regionNames: 94 args=self.buildRegionArgv(casePath,theRegion) 95 self.setLogname() 96 run=AnalyzedRunner(BoundingLogAnalyzer(progress=self.opts.progress, 97 singleFile=self.opts.singleDataFilesOnly, 98 doTimelines=True), 99 silent=self.opts.progress, 100 argv=args, 101 server=self.opts.server, 102 lam=lam, 103 restart=self.opts.restart, 104 logname=self.opts.logname, 105 compressLog=self.opts.compress, 106 noLog=self.opts.noLog, 107 remark=self.opts.remark, 108 jobId=self.opts.jobId) 109 110 run.createPlots(customRegexp=self.lines_) 111 112 self.addWriteAllTrigger(run,SolutionDirectory(casePath,archive=None)) 113 self.addLibFunctionTrigger(run,SolutionDirectory(casePath,archive=None)) 114 115 run.start() 116 117 self.reportUsage(run) 118 119 if theRegion!=None: 120 print "Syncing into master case" 121 regions.resync(theRegion) 122 123 124 if regions!=None: 125 if not self.opts.keeppseudo: 126 print "Removing pseudo-regions" 127 regions.cleanAll() 128 else: 129 for r in sol.getRegions(): 130 if r not in regionNames: 131 regions.clean(r) 132 133 self.addToCaseLog(casePath,"Ended")
134