Changeset 11790
- Timestamp:
- 03/25/12 09:45:45 (13 years ago)
- Location:
- issm/trunk-jpl/src/py
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/py/classes/solver.py
r11788 r11790 1 #module imports 1 #module imports {{{ 2 2 import fielddisplay 3 3 import ismumps 4 4 from mumpsoptions import * 5 from iluasmoptions import * 6 #}}} 5 7 class solver: 6 8 #properties … … 8 10 # {{{ Properties 9 11 if ismumps: 10 self.options=[ 'NoneAnalysis',mumpsoptions]12 self.options=[["NoneAnalysis",mumpsoptions()]] 11 13 else: 12 self.options=[ 'NoneAnalysis',iluasmoptions]14 self.options=[["NoneAnalysis",iluasmoptions()]] 13 15 #}}} 14 16 def __repr__(obj): … … 36 38 elif isinstance(option[1],str): 37 39 string="%s%s%s%s%s"%(string," -",option[0]," ",option[1]) 40 elif isinstance(option[1],int): 41 string="%s%s%s%s%s"%(string," -",option[0]," ","%i"%(option[1])) 38 42 else: 39 43 raise RuntimeError("%s%s%s"%("PetscString error: option #","%i"%(i)," is not well formatted")) -
issm/trunk-jpl/src/py/model
-
Property svn:ignore
set to
__pycache__
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/py/model/solvers
-
Property svn:ignore
set to
__pycache__
-
Property svn:ignore
set to
-
issm/trunk-jpl/src/py/model/solvers/iluasmoptions.py
r11789 r11790 1 function options=iluasmoptions(varargin) 2 %ASMOPTIONS - return Additive Shwartz Method with ILU preconditioner petsc options 3 % 4 % Usage: 5 % options=iluasmoptions; 6 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 1 #module imports {{{ 2 from pairoptions import * 3 from petscversion import * 4 #}}} 5 def iluasmoptions(*args): 6 #ILUASMOPTIONS - return MUMPS direct solver petsc options 7 # 8 # Usage: 9 # options=iluasmoptions; 10 11 #retrieve options provided in varargin 12 arguments=pairoptions(*args) 13 14 options=[['mat_type','aij'],['ksp_type','gmres'],['pc_type','asm'],['sub_pc_type','ilu'],['pc_asm_overlap',5],['ksp_max_it',100],['ksp_rtol',1e-15]]; 9 15 10 %default iluasm options 11 options={{'mat_type','aij'},{'ksp_type','gmres'},{'pc_type','asm'},{'sub_pc_type','ilu'},{'pc_asm_overlap',5},{'ksp_max_it',100},{'ksp_rtol',1e-15'}}; 12 13 %now, go through our arguments, and write over default options. 14 for i=1:size(arguments.list,1), 15 arg1=arguments.list{i,1}; 16 arg2=arguments.list{i,2}; 17 found=0; 18 for j=1:size(options,2), 19 joption=options{j}; 20 if strcmpi(joption{1},arg1), 21 joption{2}=arg2; 22 options{j}=joption; 23 found=1; 24 break; 25 end 26 end 27 if ~found, 28 %this option did not exist, add it: 29 options{end+1}={arg1,arg2}; 30 end 31 end 16 #now, go through our arguments, and write over default options. 17 for i in range(len(arguments.list)): 18 arg1=arguments.list[i][0] 19 arg2=arguments.list[i][1] 20 found=0; 21 for j in range(len(options)): 22 joption=options[j][0] 23 if joption==arg1: 24 joption[1]=arg2; 25 options[j]=joption; 26 found=1; 27 break 28 if not found: 29 #this option did not exist, add it: 30 options.append([arg1,arg2]) 31 return options -
issm/trunk-jpl/src/py/model/solvers/mumpsoptions.py
r11789 r11790 1 function options=mumpsoptions(varargin) 2 %MUMPSOPTIONS - return MUMPS direct solver petsc options 3 % 4 % Usage: 5 % options=mumpsoptions; 1 #module imports {{{ 2 from pairoptions import * 3 from petscversion import * 4 #}}} 5 def mumpsoptions(*args): 6 #MUMPSOPTIONS - return MUMPS direct solver petsc options 7 # 8 # Usage: 9 # options=mumpsoptions; 10 11 #retrieve options provided in varargin 12 arguments=pairoptions(*args) 6 13 7 %retrieve options provided in varargin8 arguments=pairoptions(varargin{:});9 14 10 %default mumps options 11 PETSC_VERSION=petscversion(); 12 if PETSC_VERSION==2, 13 options={{'mat_type','aijmumps'},{'ksp_type','preonly'},{'pc_type','lu'},{'mat_mumps_icntl_14',120},{'pc_factor_shift_positive_definite','true'}}; 14 end 15 if PETSC_VERSION==3, 16 options={{'mat_type','mpiaij'},{'ksp_type','preonly'},{'pc_type','lu'},{'pc_factor_mat_solver_package','mumps'},{'mat_mumps_icntl_14',120},{'pc_factor_shift_positive_definite','true'}}; 15 #default mumps options 16 PETSC_VERSION=petscversion() 17 17 18 end 18 if PETSC_VERSION==2: 19 options=[['mat_type','aijmumps'],['ksp_type','preonly'],['pc_type','lu'],['mat_mumps_icntl_14',120],['pc_factor_shift_positive_definite','true']] 20 if PETSC_VERSION==3: 21 options=[['mat_type','mpiaij'],['ksp_type','preonly'],['pc_type','lu'],['pc_factor_mat_solver_package','mumps'],['mat_mumps_icntl_14',120],['pc_factor_shift_positive_definite','true']] 19 22 20 %now, go through our arguments, and write over default options. 21 for i=1:size(arguments.list,1), 22 arg1=arguments.list{i,1}; 23 arg2=arguments.list{i,2}; 24 found=0; 25 for j=1:size(options,2), 26 joption=options{j}; 27 if strcmpi(joption{1},arg1), 28 joption{2}=arg2; 29 options{j}=joption; 30 found=1; 31 break; 32 end 33 end 34 if ~found, 35 %this option did not exist, add it: 36 options{end+1}={arg1,arg2}; 37 end 38 end 23 #now, go through our arguments, and write over default options. 24 for i in range(len(arguments.list)): 25 arg1=arguments.list[i][0] 26 arg2=arguments.list[i][1] 27 found=0; 28 for j in range(len(options)): 29 joption=options[j][0] 30 if joption==arg1: 31 joption[1]=arg2; 32 options[j]=joption; 33 found=1; 34 break 35 if not found: 36 #this option did not exist, add it: 37 options.append([arg1,arg2]) 38 return options
Note:
See TracChangeset
for help on using the changeset viewer.