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

Source Code for Module PyFoam.Applications.ClearCase

  1  """ 
  2  Application-class that implements pyFoamClearCase.py 
  3  """ 
  4  from optparse import OptionGroup 
  5   
  6  from PyFoamApplication import PyFoamApplication 
  7   
  8  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
  9   
10 -class ClearCase(PyFoamApplication):
11 - def __init__(self,args=None):
12 description=""" 13 Removes all timesteps but the first from a case-directory. 14 Also removes other data that is generated by sovers/utilities/PyFoam 15 """ 16 PyFoamApplication.__init__(self, 17 args=args, 18 description=description, 19 usage="%prog <caseDirectory>", 20 interspersed=True, 21 changeVersion=False, 22 nr=1, 23 exactNr=False)
24
25 - def addOptions(self):
26 what=OptionGroup(self.parser, 27 "What", 28 "Define what should be cleared") 29 self.parser.add_option_group(what) 30 31 what.add_option("--after", 32 type="float", 33 dest="after", 34 default=None, 35 help="Only remove timesteps after this time") 36 what.add_option("--processors-remove", 37 action="store_true", 38 dest="processor", 39 default=False, 40 help="Remove the processor directories") 41 what.add_option("--vtk-keep", 42 action="store_false", 43 dest="vtk", 44 default=True, 45 help="Keep the VTK directory") 46 what.add_option("--no-pyfoam", 47 action="store_false", 48 dest="pyfoam", 49 default=True, 50 help="Keep the PyFoam-specific directories and logfiles") 51 what.add_option("--keep-last", 52 action="store_true", 53 dest="latest", 54 default=False, 55 help="Keep the data from the last time-step") 56 what.add_option("--keep-regular", 57 action="store_true", 58 dest="keepRegular", 59 default=False, 60 help="Keep all the timesteps") 61 62 what.add_option("--clear-history", 63 action="store_true", 64 dest="clearHistory", 65 default=False, 66 help="Clear the PyFoamHistory-file") 67 what.add_option("--function-object-data", 68 action="store_true", 69 dest="functionObjectData", 70 default=False, 71 help="Clear the PyFoamHistory-file") 72 73 output=OptionGroup(self.parser, 74 "Output", 75 "What information should be given") 76 self.parser.add_option_group(output) 77 output.add_option("--fatal", 78 action="store_true", 79 dest="fatal", 80 default=False, 81 help="If non-cases are specified the program should abort") 82 output.add_option("--silent", 83 action="store_true", 84 dest="silent", 85 default=False, 86 help="Don't complain about non-case-files") 87 output.add_option("--verbose", 88 action="store_true", 89 dest="verbose", 90 default=False, 91 help="Print what cases are cleared")
92 93
94 - def run(self):
95 for cName in self.parser.getArgs(): 96 if self.checkCase(cName,fatal=self.opts.fatal,verbose=not self.opts.silent): 97 if self.opts.verbose: 98 print "Clearing",cName 99 sol=SolutionDirectory(cName,archive=None,paraviewLink=False) 100 sol.clear(after=self.parser.getOptions().after, 101 processor=self.parser.getOptions().processor, 102 pyfoam=self.parser.getOptions().pyfoam, 103 vtk=self.parser.getOptions().vtk, 104 keepRegular=self.parser.getOptions().keepRegular, 105 keepLast=self.parser.getOptions().latest, 106 clearHistory=self.parser.getOptions().clearHistory, 107 functionObjectData=self.parser.getOptions().functionObjectData) 108 109 self.addToCaseLog(cName)
110