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 7319 2011-03-03T23:10:51.400635Z 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  from CommonVCSCommit import CommonVCSCommit 
16   
17 -class MeshUtilityRunner(PyFoamApplication, 18 CommonServer, 19 CommonLibFunctionTrigger, 20 CommonVCSCommit):
21 - def __init__(self,args=None):
22 description=""" 23 Runs an OpenFoam utility that manipulates meshes. Needs the usual 3 24 arguments (<solver> <directory> <case>) and passes them on (plus additional arguments). 25 26 Output is sent to stdout and a logfile inside the case directory 27 (PyFoamMeshUtility.logfile) 28 29 Before running it clears all timesteps but the first. 30 31 After the utility ran it moves all the data from the polyMesh-directory 32 of the first time-step to the constant/polyMesh-directory 33 34 ATTENTION: This utility erases quite a lot of data without asking and 35 should therefor be used with care 36 """ 37 38 PyFoamApplication.__init__(self, 39 exactNr=False, 40 args=args, 41 description=description)
42
43 - def addOptions(self):
47
48 - def run(self):
49 cName=self.parser.casePath() 50 51 self.checkCase(cName) 52 53 sol=SolutionDirectory(cName,archive=None) 54 55 print "Clearing out old timesteps ...." 56 57 sol.clearResults() 58 59 self.checkAndCommit(SolutionDirectory(cName,archive=None)) 60 61 run=BasicRunner(argv=self.parser.getArgs(), 62 server=self.opts.server, 63 logname="PyFoamMeshUtility") 64 65 self.addLibFunctionTrigger(run,sol) 66 67 self.addToCaseLog(cName,"Starting") 68 69 run.start() 70 71 sol.reread(force=True) 72 73 self.addToCaseLog(cName,"Ending") 74 75 if sol.latestDir()!=sol.initialDir(): 76 for f in listdir(path.join(sol.latestDir(),"polyMesh")): 77 system("mv -f "+path.join(sol.latestDir(),"polyMesh",f)+" "+sol.polyMeshDir()) 78 79 print "\nClearing out new timesteps ...." 80 81 sol.clearResults() 82 else: 83 print "\n\n No new timestep. Utility propably failed"
84