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