Changeset 11871
- Timestamp:
- 04/03/12 10:11:50 (13 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/classes/solver.m ¶
r11870 r11871 6 6 classdef solver < dynamicprops 7 7 properties (SetAccess=public) 8 NoneAnalysis 8 NoneAnalysis = struct(); 9 9 %The other properties are dynamic 10 10 end … … 18 18 end 19 19 end % }}} 20 function obj = setdefaultparameters(obj) % {{{21 22 %MUMPS is the default solver23 if ismumps,24 obj.NoneAnalysis=mumpsoptions;25 else26 obj.NoneAnalysis=iluasmoptions;27 end28 29 end % }}}30 20 function obj = addoptions(obj,analysis,solveroptions) % {{{1 31 21 … … 42 32 end 43 33 %}}} 34 function obj = setdefaultparameters(obj) % {{{ 35 36 %MUMPS is the default solver 37 if ismumps, 38 obj.NoneAnalysis=mumpsoptions; 39 else 40 obj.NoneAnalysis=iluasmoptions; 41 end 42 43 end % }}} 44 function disp(obj) % {{{ 45 analyses=properties(obj); 46 disp(sprintf('List of solver options per analysis:\n')); 47 for i=1:numel(analyses), 48 analysis=analyses{i}; 49 disp([analysis ':']); 50 disp(obj.(analysis)); 51 end 52 end % }}} 44 53 function checkconsistency(obj,md,solution,analyses) % {{{ 45 54 %Nothing checked … … 71 80 72 81 %now, write options 73 for j=1:size(options,2), 74 option=options{j}; 75 if isempty(option), 76 %do nothing 77 elseif length(option)==1, 82 optionslist=fieldnames(options); 83 for j=1:numel(optionslist), 84 optionname=optionslist{j}; 85 optionvalue=options.(optionname); 86 87 if isempty(optionvalue), 78 88 %this option has only one argument 79 fprintf(fid,'-%s\n',option {1});80 else if length(option)==2,89 fprintf(fid,'-%s\n',optionname); 90 else 81 91 %option with value. value can be string or scalar 82 if isscalar(option {2}),83 fprintf(fid,'-%s %g\n',option {1},option{2});84 elseif ischar(option {2}),85 fprintf(fid,'-%s %s\n',option {1},option{2});92 if isscalar(optionvalue), 93 fprintf(fid,'-%s %g\n',optionname,optionvalue); 94 elseif ischar(optionvalue), 95 fprintf(fid,'-%s %s\n',optionname,optionvalue); 86 96 else 87 error(['PetscFile error: option #' num2str(j)' is not well formatted']);97 error(['PetscFile error: option ' optionname ' is not well formatted']); 88 98 end 89 else90 error(['PetscFile error: option #' num2str(j) ' is not well formatted']);91 99 end 92 100 end -
TabularUnified issm/trunk-jpl/src/m/model/solvers/asmoptions.m ¶
r6005 r11871 1 function options=asmoptions(varargin)1 function asm=asmoptions(varargin) 2 2 %ASMOPTIONS - return Additive Shwartz Method petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 asm=struct(); 9 10 10 11 %default asm options 11 options={{'mat_type','aij'},{'ksp_type','gmres'},{'pc_type','asm'},{'sub_pc_type','lu'},{'pc_asm_overlap',3},{'ksp_max_it',100},{'ksp_rtol',1e-30'}}; 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 12 asm.mat_type=getfieldvalue(options,'mat_type','aij'); 13 asm.ksp_type=getfieldvalue(options,'ksp_type','gmres'); 14 asm.pc_type=getfieldvalue(options,'pc_type','asm'); 15 asm.sub_pc_type=getfieldvalue(options,'sub_pc_type','lu'); 16 asm.pc_asm_overlap=getfieldvalue(options,'pc_asm_overlap',3); 17 asm.ksp_max_it=getfieldvalue(options,'ksp_max_it',100); 18 asm.ksp_rtol=getfieldvalue(options,'ksp_rtol',1e-30); -
TabularUnified issm/trunk-jpl/src/m/model/solvers/iluasmoptions.m ¶
r6671 r11871 1 function options=iluasmoptions(varargin)2 % ASMOPTIONS - return Additive Shwartz Method with ILU preconditioner petsc options1 function iluasm=iluasmoptions(varargin) 2 %ILUASMOPTIONS - 3 3 % 4 4 % Usage: … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 iluasm=struct(); 9 10 10 11 %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 12 iluasm.mat_type=getfieldvalue(options,'mat_type''','aij'); 13 iluasm.ksp_type=getfieldvalue(options,'ksp_type''','gmres'); 14 iluasm.pc_type=getfieldvalue(options,'pc_type''','asm'); 15 iluasm.sub_pc_type=getfieldvalue(options,'sub_pc_type''','ilu'); 16 iluasm.pc_asm_overlap=getfieldvalue(options,'pc_asm_overlap',5); 17 iluasm.ksp_max_it=getfieldvalue(options,'ksp_max_it',100); 18 iluasm.ksp_rtol=getfieldvalue(options,'ksp_rtol',1e-15); -
TabularUnified issm/trunk-jpl/src/m/model/solvers/jacobiasmoptions.m ¶
r6098 r11871 1 function options=jacobiasmoptions(varargin)1 function jacobiasm=jacobiasmoptions(varargin) 2 2 %ASMOPTIONS - return Additive Shwartz Method with Jacobi preconditioner petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 jacobiasm=struct(); 9 10 10 11 %default jacobiasm options 11 options={{'mat_type','aij'},{'ksp_type','gmres'},{'pc_type','asm'},{'sub_pc_type','jacobi'},{'pc_asm_overlap',3},{'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 12 jacobiasm.mat_type=getfieldvalue(options,'mat_type','aij'); 13 jacobiasm.ksp_type=getfieldvalue(options,'ksp_type','gmres'); 14 jacobiasm.pc_type=getfieldvalue(options,'pc_type','asm'); 15 jacobiasm.sub_pc_type=getfieldvalue(options,'sub_pc_type','jacobi'); 16 jacobiasm.pc_asm_overlap=getfieldvalue(options,'pc_asm_overlap',3); 17 jacobiasm.ksp_max_it=getfieldvalue(options,'ksp_max_it',100); 18 jacobiasm.ksp_rtol=getfieldvalue(options,'ksp_rtol',1e-15); -
TabularUnified issm/trunk-jpl/src/m/model/solvers/jacobicgoptions.m ¶
r10565 r11871 1 function options=jacobiasmoptions(varargin)1 function jacobicg=jacobiacgoptions(varargin) 2 2 %ASMOPTIONS - return Additive Shwartz Method with Jacobi preconditioner petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 jacobicg=struct(); 9 10 10 11 %default jacobiasm options 11 options={{'mat_type','aij'},{'ksp_type','cg'},{'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 12 jacobicg.mat_type=getfieldvalue(options,'mat_type','aij'); 13 jacobicg.ksp_type=getfieldvalue(options,'ksp_type','cg'); 14 jacobicg.ksp_max_it=getfieldvalue(options,'ksp_max_it',100); 15 jacobicg.ksp_rtol=getfieldvalue(options,'ksp_rtol',1e-15); -
TabularUnified issm/trunk-jpl/src/m/model/solvers/matlaboptions.m ¶
r6014 r11871 1 function options=matlaboptions(varargin)1 function maltab=matlaboptions(varargin) 2 2 %MATLABOPTIONS - return Matlab petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 maltab=struct(); 9 10 10 11 %default matlab options 11 options={{'ksp_type','matlab'}}; 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 12 maltab.ksp_type='matlab'; -
TabularUnified issm/trunk-jpl/src/m/model/solvers/mumpsoptions.m ¶
r7046 r11871 1 function options=mumpsoptions(varargin)1 function mumps=mumpsoptions(varargin) 2 2 %MUMPSOPTIONS - return MUMPS direct solver petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 mumps=struct(); 9 10 10 11 %default mumps options 11 12 PETSC_VERSION=petscversion(); 12 13 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 mumps.mat_type=getfieldvalue(options,'mat_type','aijmumps'); 15 mumps.ksp_type=getfieldvalue(options,'ksp_type','preonly'); 16 mumps.pc_type=getfieldvalue(options,'pc_type','lu'); 17 mumps.mat_mumps_icntl_14=getfieldvalue(options,'mat_mumps_icntl_14',120); 18 mumps.pc_factor_shift_positive_definite=getfieldvalue(options,'pc_factor_shift_positive_definite','true'); 14 19 end 15 20 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'}}; 17 21 mumps.mat_type=getfieldvalue(options,'mat_type','mpiaij'); 22 mumps.ksp_type=getfieldvalue(options,'ksp_type','preonly'); 23 mumps.pc_type=getfieldvalue(options,'pc_type','lu'); 24 mumps.pc_factor_mat_solver_package=getfieldvalue(options,'pc_factor_mat_solver_package','mumps'); 25 mumps.mat_mumps_icntl_14=getfieldvalue(options,'mat_mumps_icntl_14',120); 26 mumps.pc_factor_shift_positive_definite=getfieldvalue(options,'pc_factor_shift_positive_definite','true'); 18 27 end 19 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 end33 end34 if ~found,35 %this option did not exist, add it:36 options{end+1}={arg1,arg2};37 end38 end -
TabularUnified issm/trunk-jpl/src/m/model/solvers/soroptions.m ¶
r6014 r11871 1 function options=soroptions(varargin)1 function sor=soroptions(varargin) 2 2 %SOROPTIONS - return Relaxation Solver petsc options 3 3 % … … 6 6 7 7 %retrieve options provided in varargin 8 arguments=pairoptions(varargin{:}); 8 options=pairoptions(varargin{:}); 9 sor=struct(); 9 10 10 11 %default sor options 11 options={{'mat_type','aij'},{'ksp_type','cg'},{'pc_type','sor'},{'pc_sor_omega',1.1},{'pc_sor_its',2}}; 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 12 sor.mat_type=getfieldvalue(options,'mat_type','aij'); 13 sor.ksp_type=getfieldvalue(options,'ksp_type','cg'); 14 sor.pc_type=getfieldvalue(options,'pc_type','sor'); 15 sor.pc_sor_omega=getfieldvalue(options,'pc_sor_omega',1.1); 16 sor.pc_sor_its=getfieldvalue(options,'pc_sor_its',2); -
TabularUnified issm/trunk-jpl/src/m/model/solvers/stokesoptions.m ¶
r8110 r11871 1 function options=stokesoptions(varargin)1 function stokes=stokesoptions(varargin) 2 2 %STOKESOPTIONS - return STOKES multi-physics solver petsc options 3 3 % … … 7 7 %retrieve options provided in varargin 8 8 arguments=pairoptions(varargin{:}); 9 stokes=struct(); 9 10 10 11 %default stokes options … … 14 15 end 15 16 if PETSC_VERSION==3, 16 options={{'mat_type','mpiaij'},{'ksp_max_it',1000},{'ksp_type','gmres'},{'pc_type','fieldsplit'},{'pc_field_split_type','schur'},... 17 {'fieldsplit_0_pc_type','hypre'},{'fieldsplit_0_ksp_type','gmres'},{'fieldsplit_0_pc_hypre_type','boomerang'},... 18 {'fieldsplit_1_pc_type','jacobi'},{'fieldsplit_1_ksp_type','preonly'},{'issm_option_solver','stokes'}}; 17 stokes.mat_type=getfieldvalue(options,'mat_type','mpiaij'); 18 stokes.ksp_max_it=getfieldvalue(options,'ksp_max_it',1000); 19 stokes.ksp_type=getfieldvalue(options,'ksp_type','gmres'); 20 stokes.pc_type=getfieldvalue(options,'pc_type','fieldsplit'); 21 stokes.pc_field_split_type=getfieldvalue(options,'pc_field_split_type','schur'); 22 stokes.fieldsplit_0_pc_type=getfieldvalue(options,'fieldsplit_0_pc_type','hypre'); 23 stokes.fieldsplit_0_ksp_type=getfieldvalue(options,'fieldsplit_0_ksp_type','gmres'); 24 stokes.fieldsplit_0_pc_hypre_type=getfieldvalue(options,'fieldsplit_0_pc_hypre_type','boomerang'); 25 stokes.fieldsplit_1_pc_type=getfieldvalue(options,'fieldsplit_1_pc_type','jacobi'); 26 stokes.fieldsplit_1_ksp_type=getfieldvalue(options,'fieldsplit_1_ksp_type','preonly'); 27 stokes.issm_option_solver=getfieldvalue(options,'issm_option_solver','stokes'); 19 28 end 20 21 %now, go through our arguments, and write over default options.22 for i=1:size(arguments.list,1),23 arg1=arguments.list{i,1};24 arg2=arguments.list{i,2};25 found=0;26 for j=1:size(options,2),27 joption=options{j};28 if strcmpi(joption{1},arg1),29 joption{2}=arg2;30 options{j}=joption;31 found=1;32 break;33 end34 end35 if ~found,36 %this option did not exist, add it:37 options{end+1}={arg1,arg2};38 end39 end
Note:
See TracChangeset
for help on using the changeset viewer.