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

Source Code for Module PyFoam.Applications.CommonClearCase

 1  """ 
 2  Class that implements the common functionality for clearing the cases 
 3  """ 
 4   
 5  from PyFoam.ThirdParty.six import print_ 
 6   
7 -class CommonClearCase(object):
8 """ The class that clears the case 9 """ 10
11 - def addOptions(self):
12 self.ensureGeneralOptions() 13 self.generalOpts.add_option("--clear-case", 14 action="store_true", 15 default=False, 16 dest="clearCase", 17 help="Clear all timesteps except for the first before running") 18 self.generalOpts.add_option("--complete-clear", 19 action="store_true", 20 default=False, 21 dest="clearComplete", 22 help="Like clear-case but removes the function-object data as well") 23 self.generalOpts.add_option("--pyfoam-stuff-clear", 24 action="store_true", 25 dest="pyfoam", 26 default=False, 27 help="Keep the PyFoam-specific directories and logfiles. Will only be used with '--clear-case'") 28 self.generalOpts.add_option("--additional-clear", 29 action="append", 30 dest="additionalClear", 31 default=[], 32 help="Glob-pattern with additional files to be removes. Can be used more than once. Will only be used with '--clear-case'") 33 self.generalOpts.add_option("--history-clear", 34 action="store_true", 35 dest="clearHistory", 36 default=False, 37 help="Clear the PyFoamHistory-file. Will only be used with '--clear-case'") 38 self.generalOpts.add_option("--remove-processor-dirs", 39 action="store_true", 40 dest="removeProcessorDirs", 41 default=False, 42 help="Remove the whole processor directories") 43 self.generalOpts.add_option("--keep-postprocessing", 44 action="store_true", 45 dest="keepPostprocessing", 46 default=False, 47 help="Keep the directory 'postProcessing' where functionObjects write their stuff")
48
49 - def clearCase(self,sol):
50 if not self.opts.keepPostprocessing: 51 self.opts.additionalClear.append("postProcessing") 52 if self.opts.clearComplete: 53 self.opts.clearCase=True 54 if self.opts.clearCase: 55 print_("Clearing out old timesteps ....") 56 sol.clear(additional=self.parser.getOptions().additionalClear, 57 processor=self.parser.getOptions().removeProcessorDirs, 58 pyfoam=self.parser.getOptions().pyfoam, 59 clearHistory=self.parser.getOptions().clearHistory, 60 functionObjectData=self.opts.clearComplete)
61 62 # Should work with Python3 and Python2 63