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

Source Code for Module PyFoam.Applications.MeshUtilityRunner

 1  #  ICE Revision: $Id: MeshUtilityRunner.py 7832 2007-08-28 13:07:26Z 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.FoamInformation import changeFoamVersion 
11   
12  from PyFoam.Execution.BasicRunner import BasicRunner 
13  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
14   
15 -class MeshUtilityRunner(PyFoamApplication):
16 - def __init__(self):
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,description=description)
34
35 - def addOptions(self):
36 self.parser.add_option("--foamVersion",dest="foamVersion",default=None,help="Change the OpenFOAM-version that is to be used")
37
38 - def run(self):
39 if self.opts.foamVersion!=None: 40 changeFoamVersion(self.opts.foamVersion) 41 42 cName=self.parser.getArgs()[2] 43 sol=SolutionDirectory(cName) 44 45 print "Clearing out old timesteps ...." 46 47 sol.clearResults() 48 49 50 run=BasicRunner(argv=self.parser.getArgs(),server=False,logname="PyFoamMeshUtility") 51 52 run.start() 53 54 if sol.latestDir()!=sol.initialDir(): 55 for f in listdir(path.join(sol.latestDir(),"polyMesh")): 56 system("mv -f "+path.join(sol.latestDir(),"polyMesh",f)+" "+sol.polyMeshDir()) 57 58 print "\nClearing out new timesteps ...." 59 60 sol.clearResults() 61 else: 62 print "\n\n No new timestep. Utility propably failed"
63