Changeset 27427 for issm/trunk-jpl/src/m/classes/toolkits.py
- Timestamp:
- 11/26/22 15:05:33 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/toolkits.py
r25169 r27427 8 8 9 9 class toolkits(object): 10 ''' 11 TOOLKITS class definition 10 """TOOLKITS class definition 12 11 13 14 15 '''12 Usage: 13 self = toolkits() 14 """ 16 15 17 16 def __init__(self): #{{{ 18 # default toolkits17 # Default toolkits 19 18 if IssmConfig('_HAVE_PETSC_')[0]: 20 # MUMPS is the default toolkits19 # MUMPS is the default toolkits 21 20 if IssmConfig('_HAVE_MUMPS_')[0]: 22 21 self.DefaultAnalysis = mumpsoptions() … … 31 30 raise IOError("ToolkitsFile error: need at least Mumps or Gsl to define issm solver type") 32 31 33 # Use same solver for Recovery mode32 # Use same solver for Recovery mode 34 33 self.RecoveryAnalysis = self.DefaultAnalysis 35 34 36 # The other properties are dynamic35 # The other properties are dynamic 37 36 #}}} 38 37 … … 50 49 # md.toolkits = addoptions(md.toolkits, 'StressbalanceAnalysis') 51 50 52 # Create dynamic property if property does not exist yet51 # Create dynamic property if property does not exist yet 53 52 if not hasattr(self, analysis): 54 53 setattr(self, analysis, None) 55 54 56 # Add toolkits options to analysis55 # Add toolkits options to analysis 57 56 if len(args) == 1: 58 57 setattr(self, analysis, args[0]) … … 62 61 63 62 def checkconsistency(self, md, solution, analyses): #{{{ 64 # TODO 63 # TODO: 65 64 # - Implement something closer to a switch as in 66 65 # src/m/classes/toolkits.m? … … 74 73 75 74 def ToolkitsFile(self, filename): #{{{ 76 ''' 77 TOOLKITSFILE - build toolkits file 75 """TOOLKITSFILE - build toolkits file 78 76 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 Build a PETSc compatible options file, from the toolkits model field + return options string. 78 This file will also be used when the toolkit used is 'issm' instead of 'petsc'. 83 79 84 85 86 '''80 Usage: 81 ToolkitsFile(toolkits, filename) 82 """ 87 83 88 # open file for writing84 # Open file for writing 89 85 try: 90 86 fid = open(filename, 'w') … … 92 88 raise IOError("ToolkitsFile error: could not open {}' for writing due to".format(filename), e) 93 89 94 # write header90 # Write header 95 91 fid.write("%s%s%s\n" % ('%Toolkits options file: ', filename, ' written from Python toolkits array')) 96 92 97 # start writing options93 # Start writing options 98 94 for analysis in list(vars(self).keys()): 99 95 options = getattr(self, analysis) 100 96 101 # first write analysis:102 fid.write("\n+{}\n".format(analysis)) # append a + to recognize it's an analysis enum103 # now, write options97 # First write analysis 98 fid.write("\n+{}\n".format(analysis)) # Append a + to recognize it's an analysis enum 99 # Now, write options 104 100 for optionname, optionvalue in list(options.items()): 105 101 106 102 if not optionvalue: 107 # this option has only one argument103 # This option has only one argument 108 104 fid.write("-{}\n".format(optionname)) 109 105 else: 110 # option with value. value can be string or scalar106 # Option with value. Value can be string or scalar. 111 107 if isinstance(optionvalue, (bool, int, float)): 112 108 fid.write("-{} {}\n".format(optionname, optionvalue))
Note:
See TracChangeset
for help on using the changeset viewer.