Changeset 9564
- Timestamp:
- 09/01/11 16:32:35 (14 years ago)
- Location:
- issm/trunk/src/m
- Files:
-
- 5 deleted
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/model/model.m
r9563 r9564 8 8 % {{{1 9 9 %Careful here: no other class should be used as default value this is a bug of matlab 10 %in what follows, any field is defined according to the following convention: 11 %field={defaultvalue,marshall?,data type,matrix type} 10 cluster = modelfield('default',0,'marshall',false); 11 verbose = modelfield('default',0,'marshall',true,'preprocess','marshallverbose','format','Integer'); 12 results = modelfield('default',0,'marshall',false); 13 solver = modelfield('default',0,'marshall',false); 14 15 %FIXME: all other fields should belong to other classes 12 16 13 17 %Model general information … … 195 199 requested_outputs = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',3); 196 200 %Debugging 197 verbose = modelfield('default',0,'marshall',true,'preprocess','marshallverbose','format','Integer');198 201 mem_debug = modelfield('default',0,'marshall',false); 199 202 gprof = modelfield('default',0,'marshall',false); … … 201 204 output_frequency = modelfield('default',0,'marshall',true,'format','Integer'); 202 205 results_on_vertices = modelfield('default',0,'marshall',true,'format','Boolean'); 203 results = modelfield('default',struct(),'marshall',false);204 206 vx = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',1); 205 207 vy = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',1); … … 223 225 224 226 %Parallelisation 225 cluster = modelfield('default',NaN,'marshall',false);226 227 outlog = modelfield('default','','marshall',false); 227 228 errlog = modelfield('default','','marshall',false); … … 230 231 %dummy 231 232 dummy = modelfield('default',NaN,'marshall',false); 232 233 %PETSc and MATLAB solver string234 petscoptions = modelfield('default',NaN,'marshall',false);235 233 236 234 %Analysis … … 534 532 end 535 533 534 %initialize subclasses 535 md.cluster=none; 536 md.solver=solver; 537 md.solver=addoptions(md.solver,DiagnosticVertAnalysisEnum,mumpsoptions); 538 md.results=struct(); 539 540 536 541 %Materials parameters 537 542 … … 712 717 713 718 %cluster set as none for serial 714 md.cluster=none;715 719 716 720 %this option can be activated to load automatically the results … … 727 731 md.hydro_kn=0; 728 732 729 %set petsc options for different analysis730 md.petscoptions=petscoptions;731 md.petscoptions=addoptions(md.petscoptions,DiagnosticVertAnalysisEnum,mumpsoptions);732 733 733 734 %Rheology law: what is the temperature dependence of B with T -
issm/trunk/src/m/classes/solver.m
r9530 r9564 1 % PETSCOPTIONSclass definition1 %SOLVER class definition 2 2 % 3 3 % Usage: 4 % o ptions=petscoptions();4 % obj=solver(); 5 5 6 classdef petscoptions6 classdef solver 7 7 properties (SetAccess=public) 8 % {{{19 8 options={NoneAnalysisEnum,mumpsoptions}; 10 %used when marshalling11 %}}}12 9 end 13 10 methods 14 function disp(o ) % {{{111 function disp(obj) % {{{1 15 12 % display the object 16 13 disp(sprintf('class ''%s'' object ''%s'' = \n',class(o),inputname(1))); 17 14 % display the options 18 for i=1:size(o .options,1),19 analysis=o .options{i,1};20 ioptions=o .options{i,2};21 string= petscoptiontostring(ioptions);15 for i=1:size(obj.options,1), 16 analysis=obj.options{i,1}; 17 ioptions=obj.options{i,2}; 18 string=PetscString(ioptions); 22 19 disp(sprintf(' %s -> ''%s''',EnumToString(analysis),string)); 23 20 end … … 25 22 end 26 23 %}}} 27 function o =addoptions(o,analysis,solveroptions) % {{{124 function obj=addoptions(obj,analysis,solveroptions) % {{{1 28 25 %first, find out if analysis has already been supplied 29 found= 0;30 for i=1:size(o .options,1),31 inanalysis=o .options{i,1};26 found=false; 27 for i=1:size(obj.options,1), 28 inanalysis=obj.options{i,1}; 32 29 if inanalysis==analysis, 33 found= 1;34 o .options{i,1}=analysis;35 o .options{i,2}=solveroptions;30 found=true; 31 obj.options{i,1}=analysis; 32 obj.options{i,2}=solveroptions; 36 33 break; 37 34 end 38 35 end 39 36 if ~found, 40 o .options{end+1,1}=analysis;41 o .options{end,2}=solveroptions;37 obj.options{end+1,1}=analysis; 38 obj.options{end,2}=solveroptions; 42 39 end 43 40 end 44 41 %}}} 45 end 46 end 42 function PetscFile(solver,filename) % {{{ 43 %PETSCFILE - build petsc file 44 % 45 % Build a Petsc compatible options file, from the solver model field + return options string 46 % 47 % Usage: PetscFile(solver,filename); 48 49 %open file for writing 50 fid=fopen(filename,'w'); 51 if fid==-1, 52 error(['PetscFile error: could not open ' filename ' for writing']); 53 end 54 55 %write header 56 fprintf(fid,'%s%s%s\n','%Petsc options file: ',filename,' written from Matlab solver array'); 57 58 %start writing options 59 for i=1:size(solver.options,1), 60 analysis=solver.options{i,1}; 61 options=solver.options{i,2}; 62 63 %first write analysis: 64 fprintf(fid,'\n+%s\n',EnumToString(analysis)); %append a + to recognize it's an analysis enum 65 66 %now, write options 67 for j=1:size(options,2), 68 option=options{j}; 69 if isempty(option), 70 %do nothing 71 elseif length(option)==1, 72 %this option has only one argument 73 fprintf(fid,'-%s\n',option{1}); 74 elseif length(option)==2, 75 %option with value. value can be string or scalar 76 if isscalar(option{2}), 77 fprintf(fid,'-%s %g\n',option{1},option{2}); 78 elseif ischar(option{2}), 79 fprintf(fid,'-%s %s\n',option{1},option{2}); 80 else 81 error(['PetscFile error: option #' num2str(j) ' is not well formatted']); 82 end 83 else 84 error(['PetscFile error: option #' num2str(j) ' is not well formatted']); 85 end 86 end 87 end 88 89 fclose(fid); 90 end %}}} 91 function string=PetscString(solver) % {{{ 92 93 %initialize string: 94 string=''; 95 96 %start writing options 97 for i=1:length(solver), 98 option=solver{i}; 99 if isempty(option), 100 %do nothing 101 elseif length(option)==1, 102 %this option has only one argument 103 string=[string ' -' option{1}]; 104 elseif length(option)==2, 105 %option with value. value can be string or scalar 106 if isscalar(option{2}), 107 string=[string ' -' option{1} ' ' num2str(option{2})]; 108 elseif ischar(option{2}), 109 string=[string ' -' option{1} ' ' option{2}]; 110 else 111 error(['PetscString error: option #' num2str(i) ' is not well formatted']); 112 end 113 else 114 error(['PetscString error: option #' num2str(i) ' is not well formatted']); 115 end 116 end 117 end % }}} 118 end 119 end -
issm/trunk/src/m/model/display/displayparallel.m
r6525 r9564 14 14 fielddisplay(md,'alloc_cleanup','allocation cleanup before starting a job, default 1'); 15 15 fielddisplay(md,'waitonlock','maximum number of minutes to wait for batch results, or return 0'); 16 disp('petsc options:');17 disp(md.petscoptions) -
issm/trunk/src/m/model/solve.m
r9561 r9564 61 61 62 62 %write a template file for issm to use, in parallel 63 Petsc Options2PetscFile(md.petscoptions,[md.name '.petsc']);63 PetscFile(md.solver,[md.name '.petsc']); 64 64 65 65 %If running in parallel, we have a different way of launching the solution
Note:
See TracChangeset
for help on using the changeset viewer.