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

Source Code for Module PyFoam.Applications.MeshUtilityRunner

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