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

Source Code for Module PyFoam.Applications.MeshUtilityRunner

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Applications/MeshUtilityRunner.py 5103 2009-05-21T13:38:11.860189Z bgschaid  $  
 2  """ 
 3  Application class that implements pyFoamMeshUtilityRunner 
 4  """ 
 5   
 6  from os import listdir,path,system 
 7   
 8  from PyFoamApplication import PyFoamApplication 
 9   
10  from PyFoam.Execution.BasicRunner import BasicRunner 
11  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
12   
13  from CommonLibFunctionTrigger import CommonLibFunctionTrigger 
14  from CommonServer import CommonServer 
15   
16 -class MeshUtilityRunner(PyFoamApplication, 17 CommonServer, 18 CommonLibFunctionTrigger):
19 - def __init__(self,args=None):
20 description=""" 21 Runs an OpenFoam utility that manipulates meshes. Needs the usual 3 22 arguments (<solver> <directory> <case>) and passes them on (plus additional arguments). 23 24 Output is sent to stdout and a logfile inside the case directory 25 (PyFoamMeshUtility.logfile) 26 27 Before running it clears all timesteps but the first. 28 29 After the utility ran it moves all the data from the polyMesh-directory 30 of the first time-step to the constant/polyMesh-directory 31 32 ATTENTION: This utility erases quite a lot of data without asking and 33 should therefor be used with care 34 """ 35 36 PyFoamApplication.__init__(self, 37 exactNr=False, 38 args=args, 39 description=description)
40
41 - def addOptions(self):
44
45 - def run(self):
46 cName=self.parser.casePath() 47 48 self.checkCase(cName) 49 50 sol=SolutionDirectory(cName,archive=None) 51 52 print "Clearing out old timesteps ...." 53 54 sol.clearResults() 55 56 run=BasicRunner(argv=self.parser.getArgs(), 57 server=self.opts.server, 58 logname="PyFoamMeshUtility") 59 60 self.addLibFunctionTrigger(run,sol) 61 62 self.addToCaseLog(cName,"Starting") 63 64 run.start() 65 66 sol.reread(force=True) 67 68 self.addToCaseLog(cName,"Ending") 69 70 if sol.latestDir()!=sol.initialDir(): 71 for f in listdir(path.join(sol.latestDir(),"polyMesh")): 72 system("mv -f "+path.join(sol.latestDir(),"polyMesh",f)+" "+sol.polyMeshDir()) 73 74 print "\nClearing out new timesteps ...." 75 76 sol.clearResults() 77 else: 78 print "\n\n No new timestep. Utility propably failed"
79