Changeset 11870
- Timestamp:
- 04/03/12 09:32:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/solver.m
r11869 r11870 4 4 % obj=solver(); 5 5 6 classdef solver 6 classdef solver < dynamicprops 7 7 properties (SetAccess=public) 8 options=cell(0,0); 8 NoneAnalysis 9 %The other properties are dynamic 9 10 end 10 11 methods … … 21 22 %MUMPS is the default solver 22 23 if ismumps, 23 obj. options={'NoneAnalysis',mumpsoptions};24 obj.NoneAnalysis=mumpsoptions; 24 25 else 25 obj. options={'NoneAnalysis',iluasmoptions};26 obj.NoneAnalysis=iluasmoptions; 26 27 end 27 28 … … 32 33 analysis=EnumToString(analysis); 33 34 34 %first, find out if analysis has already been supplied 35 found=false; 36 for i=1:size(obj.options,1), 37 inanalysis=obj.options{i,1}; 38 if strcmp(inanalysis,analysis), 39 found=true; 40 obj.options{i,1} = analysis; 41 obj.options{i,2} = solveroptions; 42 break; 43 end 35 %Create dynamic property if property does not exist yet 36 if ~ismember(analysis,properties(obj)), 37 obj.addprop(analysis); 44 38 end 45 39 46 if ~found, 47 obj.options{end+1,1}= analysis; 48 obj.options{end,2} = solveroptions; 49 end 40 %Add solver options to analysis 41 obj.(analysis) = solveroptions; 50 42 end 51 43 %}}} 52 44 function checkconsistency(obj,md,solution,analyses) % {{{ 53 for i=1:size(obj.options,1), 54 if ~ischar(obj.options{i,1}), 55 checkmessage('solver is not well formatted: Analyses are not strings'); 56 end 57 end 45 %Nothing checked 58 46 end % }}} 59 47 function PetscFile(solver,filename) % {{{ 60 61 62 63 64 48 %PETSCFILE - build petsc file 49 % 50 % Build a Petsc compatible options file, from the solver model field + return options string 51 % 52 % Usage: PetscFile(solver,filename); 65 53 66 54 %open file for writing … … 74 62 75 63 %start writing options 76 for i=1:size(solver.options,1), 77 analysis=solver.options{i,1}; 78 options=solver.options{i,2}; 64 analyses=properties(solver); 65 for i=1:numel(analyses), 66 analysis=analyses{i}; 67 options=solver.(analysis); 79 68 80 69 %first write analysis: … … 106 95 fclose(fid); 107 96 end %}}} 108 function disp(obj) % {{{1109 disp(sprintf(' solver parameters:'));110 111 for i=1:size(obj.options,1),112 analysis=obj.options{i,1};113 ioptions=obj.options{i,2};114 115 string='';116 for i=1:length(ioptions),117 option=ioptions{i};118 if isempty(option),119 %do nothing120 elseif length(option)==1,121 %this option has only one argument122 string=[string ' -' option{1}];123 elseif length(option)==2,124 %option with value. value can be string or scalar125 if isscalar(option{2}),126 string=[string ' -' option{1} ' ' num2str(option{2})];127 elseif ischar(option{2}),128 string=[string ' -' option{1} ' ' option{2}];129 else130 error(['PetscString error: option #' num2str(i) ' is not well formatted']);131 end132 else133 error(['PetscString error: option #' num2str(i) ' is not well formatted']);134 end135 end136 137 disp(sprintf(' %s -> ''%s''',analysis,string));138 end139 end140 %}}}141 97 end 142 98 end
Note:
See TracChangeset
for help on using the changeset viewer.