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 7722 2012-01-18T17:50:53.943725Z 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 CommonReportRunnerData import CommonReportRunnerData 
 20  from CommonWriteAllTrigger import CommonWriteAllTrigger 
 21  from CommonLibFunctionTrigger import CommonLibFunctionTrigger 
 22  from CommonStandardOutput import CommonStandardOutput 
 23  from CommonParallel import CommonParallel 
 24  from CommonRestart import CommonRestart 
 25  from CommonServer import CommonServer 
 26  from CommonVCSCommit import CommonVCSCommit 
 27   
 28  from os import path 
 29   
30 -class Runner(PyFoamApplication, 31 CommonPlotLines, 32 CommonWriteAllTrigger, 33 CommonLibFunctionTrigger, 34 CommonClearCase, 35 CommonRestart, 36 CommonReportUsage, 37 CommonReportRunnerData, 38 CommonMultiRegion, 39 CommonParallel, 40 CommonServer, 41 CommonStandardOutput, 42 CommonVCSCommit):
43 - def __init__(self,args=None):
44 description="""\ 45 Runs an OpenFoam solver. Needs the usual 3 arguments (<solver> 46 <directory> <case>) and passes them on (plus additional arguments). 47 Output is sent to stdout and a logfile inside the case directory 48 (PyFoamSolver.logfile) The Directory PyFoamSolver.analyzed contains 49 this information: a) Residuals and other information of the linear 50 solvers b Execution time c) continuity information d) bounding of 51 variables 52 """ 53 54 CommonPlotLines.__init__(self) 55 PyFoamApplication.__init__(self, 56 exactNr=False, 57 args=args, 58 description=description)
59
60 - def addOptions(self):
73
74 - def run(self):
75 if self.opts.keeppseudo and (not self.opts.regions and self.opts.region==None): 76 warning("Option --keep-pseudocases only makes sense for multi-region-cases") 77 regionNames=[self.opts.region] 78 regions=None 79 80 casePath=self.parser.casePath() 81 self.checkCase(casePath) 82 self.addLocalConfig(casePath) 83 84 self.addToCaseLog(casePath,"Starting") 85 86 if self.opts.regions or self.opts.region!=None: 87 print "Building Pseudocases" 88 sol=SolutionDirectory(casePath,archive=None) 89 regions=RegionCases(sol,clean=True) 90 91 if self.opts.regions: 92 regionNames=sol.getRegions() 93 94 self.processPlotLineOptions(autoPath=casePath) 95 96 self.clearCase(SolutionDirectory(casePath,archive=None)) 97 98 lam=self.getParallel(SolutionDirectory(casePath,archive=None)) 99 100 self.checkAndCommit(SolutionDirectory(casePath,archive=None)) 101 102 for theRegion in regionNames: 103 args=self.buildRegionArgv(casePath,theRegion) 104 self.setLogname() 105 run=AnalyzedRunner(BoundingLogAnalyzer(progress=self.opts.progress, 106 doFiles=self.opts.writeFiles, 107 singleFile=self.opts.singleDataFilesOnly, 108 doTimelines=True), 109 silent=self.opts.progress or self.opts.silent, 110 argv=args, 111 server=self.opts.server, 112 lam=lam, 113 restart=self.opts.restart, 114 logname=self.opts.logname, 115 compressLog=self.opts.compress, 116 logTail=self.opts.logTail, 117 noLog=self.opts.noLog, 118 remark=self.opts.remark, 119 jobId=self.opts.jobId) 120 121 run.createPlots(customRegexp=self.lines_, 122 writeFiles=self.opts.writeFiles) 123 124 self.addWriteAllTrigger(run,SolutionDirectory(casePath,archive=None)) 125 self.addLibFunctionTrigger(run,SolutionDirectory(casePath,archive=None)) 126 127 run.start() 128 129 if len(regionNames)>1: 130 self.setData({theRegion:run.data}) 131 else: 132 self.setData(run.data) 133 134 self.reportUsage(run) 135 self.reportRunnerData(run) 136 137 if theRegion!=None: 138 print "Syncing into master case" 139 regions.resync(theRegion) 140 141 if regions!=None: 142 if not self.opts.keeppseudo: 143 print "Removing pseudo-regions" 144 regions.cleanAll() 145 else: 146 for r in sol.getRegions(): 147 if r not in regionNames: 148 regions.clean(r) 149 150 self.addToCaseLog(casePath,"Ended")
151