Changeset 25836 for issm/trunk/src/m/classes/toolkits.py
- Timestamp:
- 12/08/20 08:45:53 (4 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/classes/toolkits.py
r24313 r25836 8 8 9 9 class toolkits(object): 10 """10 ''' 11 11 TOOLKITS class definition 12 12 13 Usage:14 self = toolkits()15 """13 Usage: 14 self = toolkits() 15 ''' 16 16 17 def __init__(self): #{{{17 def __init__(self): #{{{ 18 18 #default toolkits 19 19 if IssmConfig('_HAVE_PETSC_')[0]: … … 34 34 self.RecoveryAnalysis = self.DefaultAnalysis 35 35 36 #The other properties are dynamic37 # 36 #The other properties are dynamic 37 #}}} 38 38 39 def __repr__(self): #{{{39 def __repr__(self): #{{{ 40 40 s = "List of toolkits options per analysis:\n\n" 41 41 for analysis in list(vars(self).keys()): 42 s += " %s\n" % fielddisplay(self, analysis, '')42 s += "{}\n".format(fielddisplay(self, analysis, '')) 43 43 44 45 # 44 return s 45 #}}} 46 46 47 def addoptions(self, analysis, *args): #{{{47 def addoptions(self, analysis, *args): #{{{ 48 48 # Usage example: 49 49 # md.toolkits = addoptions(md.toolkits, 'StressbalanceAnalysis', FSoptions()) … … 59 59 60 60 return self 61 # 61 #}}} 62 62 63 def checkconsistency(self, md, solution, analyses): # {{{ 63 def checkconsistency(self, md, solution, analyses): #{{{ 64 # TODO 65 # - Implement something closer to a switch as in 66 # src/m/classes/toolkits.m? 67 # 64 68 for analysis in list(vars(self).keys()): 65 69 if not getattr(self, analysis): 66 md.checkmessage("md.toolkits. %s is empty" % analysis)70 md.checkmessage("md.toolkits.{} is empty".format(analysis)) 67 71 68 72 return md 69 # 73 #}}} 70 74 71 def ToolkitsFile(self, filename): #{{{72 """75 def ToolkitsFile(self, filename): #{{{ 76 ''' 73 77 TOOLKITSFILE - build toolkits file 74 78 75 Build a Petsc compatible options file, from the toolkits model field + return options string 76 This file will also be used when the toolkit used is 'issm' instead of 'petsc' 79 Build a Petsc compatible options file, from the toolkits model 80 field + return options string. 81 This file will also be used when the toolkit used is 'issm' instead 82 of 'petsc'.s 77 83 84 Usage: 85 ToolkitsFile(toolkits, filename) 86 ''' 78 87 79 Usage: ToolkitsFile(toolkits, filename) 80 """ 81 82 #open file for writing 88 #open file for writing 83 89 try: 84 90 fid = open(filename, 'w') … … 86 92 raise IOError("ToolkitsFile error: could not open {}' for writing due to".format(filename), e) 87 93 88 #write header94 #write header 89 95 fid.write("%s%s%s\n" % ('%Toolkits options file: ', filename, ' written from Python toolkits array')) 90 96 91 #start writing options97 #start writing options 92 98 for analysis in list(vars(self).keys()): 93 99 options = getattr(self, analysis) 94 100 95 #first write analysis:101 #first write analysis: 96 102 fid.write("\n+{}\n".format(analysis)) #append a + to recognize it's an analysis enum 97 #now, write options103 #now, write options 98 104 for optionname, optionvalue in list(options.items()): 99 105 … … 111 117 112 118 fid.close() 113 # 119 #}}}
Note:
See TracChangeset
for help on using the changeset viewer.