source:
issm/oecreview/Archive/21724-22754/ISSM-22295-22296.diff@
22755
Last change on this file since 22755 was 22755, checked in by , 7 years ago | |
---|---|
File size: 23.9 KB |
-
../trunk-jpl/src/m/classes/settings.m
1 %SETTINGS class definition2 %3 % Usage:4 % settings=settings();5 6 classdef settings7 properties (SetAccess=public)8 results_on_nodes = 0;9 io_gather = 0;10 lowmem = 0;11 output_frequency = 0;12 recording_frequency = 0;13 waitonlock = 0;14 upload_server = '';15 upload_path = '';16 upload_login = '';17 upload_port = 0;18 upload_filename = '';19 solver_residue_threshold = 0;20 end21 methods22 function self = settings(varargin) % {{{23 switch nargin24 case 025 self=setdefaultparameters(self);26 otherwise27 error('constructor not supported');28 end29 end % }}}30 function self = setdefaultparameters(self) % {{{31 32 %are we short in memory ? (0 faster but requires more memory)33 self.lowmem=0;34 35 %i/o:36 self.io_gather=1;37 38 %results frequency by default every step39 self.output_frequency=1;40 41 %checkpoints frequency, by default never:42 self.recording_frequency=0;43 44 %this option can be activated to load automatically the results45 %onto the model after a parallel run by waiting for the lock file46 %N minutes that is generated once the solution has converged47 %0 to deactivate48 self.waitonlock=Inf;49 50 %upload options:51 self.upload_port = 0;52 53 %throw an error if solver residue exceeds this value54 self.solver_residue_threshold = 1e-6;55 56 end % }}}57 function md = checkconsistency(self,md,solution,analyses) % {{{58 59 md = checkfield(md,'fieldname','settings.results_on_nodes','numel',[1],'values',[0 1]);60 md = checkfield(md,'fieldname','settings.io_gather','numel',[1],'values',[0 1]);61 md = checkfield(md,'fieldname','settings.lowmem','numel',[1],'values',[0 1]);62 md = checkfield(md,'fieldname','settings.output_frequency','numel',[1],'>=',1);63 md = checkfield(md,'fieldname','settings.recording_frequency','numel',[1],'>=',0);64 md = checkfield(md,'fieldname','settings.waitonlock','numel',[1]);65 md = checkfield(md,'fieldname','settings.solver_residue_threshold','numel',[1],'>',0);66 67 end % }}}68 function disp(self) % {{{69 disp(sprintf(' general settings parameters:'));70 71 fielddisplay(self,'results_on_nodes','results are output for all the nodes of each element');72 fielddisplay(self,'io_gather','I/O gathering strategy for result outputs (default 1)');73 fielddisplay(self,'lowmem','is the memory limited ? (0 or 1)');74 fielddisplay(self,'output_frequency','frequency at which results are saved in all solutions with multiple time_steps');75 fielddisplay(self,'recording_frequency','frequency at which the runs are being recorded, allowing for a restart');76 fielddisplay(self,'waitonlock','maximum number of minutes to wait for batch results (NaN to deactivate)');77 fielddisplay(self,'upload_server','server hostname where model should be uploaded');78 fielddisplay(self,'upload_path','path on server where model should be uploaded');79 fielddisplay(self,'upload_login','server login');80 fielddisplay(self,'upload_port','port login (default is 0)');81 fielddisplay(self,'upload_filename','unique id generated when uploading the file to server');82 fielddisplay(self,'solver_residue_threshold','throw an error if solver residue exceeds this value (NaN to deactivate)');83 84 end % }}}85 function marshall(self,prefix,md,fid) % {{{86 WriteData(fid,prefix,'object',self,'fieldname','results_on_nodes','format','Boolean');87 WriteData(fid,prefix,'object',self,'fieldname','io_gather','format','Boolean');88 WriteData(fid,prefix,'object',self,'fieldname','lowmem','format','Boolean');89 WriteData(fid,prefix,'object',self,'fieldname','output_frequency','format','Integer');90 WriteData(fid,prefix,'object',self,'fieldname','recording_frequency','format','Integer');91 WriteData(fid,prefix,'object',self,'fieldname','waitonlock','data',self.waitonlock>0,'format','Boolean');92 WriteData(fid,prefix,'object',self,'fieldname','solver_residue_threshold','format','Double');93 end % }}}94 function savemodeljs(self,fid,modelname) % {{{95 96 writejsdouble(fid,[modelname '.settings.results_on_nodes'],self.results_on_nodes);97 writejsdouble(fid,[modelname '.settings.io_gather'],self.io_gather);98 writejsdouble(fid,[modelname '.settings.lowmem'],self.lowmem);99 writejsdouble(fid,[modelname '.settings.output_frequency'],self.output_frequency);100 writejsdouble(fid,[modelname '.settings.recording_frequency'],self.recording_frequency);101 writejsdouble(fid,[modelname '.settings.waitonlock'],self.waitonlock);102 writejsstring(fid,[modelname '.settings.upload_server'],self.upload_server);103 writejsstring(fid,[modelname '.settings.upload_path'],self.upload_path);104 writejsstring(fid,[modelname '.settings.upload_login'],self.upload_login);105 writejsdouble(fid,[modelname '.settings.upload_port'],self.upload_port);106 writejsstring(fid,[modelname '.settings.upload_filename'],self.upload_filename);107 writejsstring(fid,[modelname '.settings.solver_residue_threshold'],self.solver_residue_threshold);108 end % }}}109 end110 end -
../trunk-jpl/src/m/classes/qmu/continuous_design.m
30 30 % to foreign countries or providing access to foreign persons." 31 31 % 32 32 classdef continuous_design 33 34 35 36 37 38 39 40 33 properties 34 descriptor=''; 35 initpt = 0.; 36 lower =-Inf; 37 upper = Inf; 38 scale_type='none'; 39 scale = 1.; 40 end 41 41 42 43 42 methods 43 function [cdv]=continuous_design(varargin) 44 44 45 45 switch nargin 46 46 47 % create a default object47 % create a default object 48 48 49 49 case 0 50 50 51 % copy the object51 % copy the object 52 52 53 54 55 56 57 58 59 53 case 1 54 if isa(varargin{1},'continuous_design') 55 cdv=varargin{1}; 56 else 57 error('Object ''%s'' is a ''%s'' class object, not ''%s''.',... 58 inputname(1),class(varargin{1}),'continuous_design'); 59 end 60 60 61 % create the object from the input61 % create the object from the input 62 62 63 64 65 66 63 otherwise 64 asizec=num2cell(array_size(varargin{1:min(nargin,6)})); 65 cdv(asizec{:})=continuous_design; 66 clear asizec 67 67 68 69 70 71 72 73 74 75 76 77 68 if ischar(varargin{1}) 69 varargin{1}=cellstr(varargin{1}); 70 end 71 for i=1:numel(cdv) 72 if (numel(varargin{1}) > 1) 73 cdv(i).descriptor=varargin{1}{i}; 74 else 75 cdv(i).descriptor=[char(varargin{1}) string_dim(cdv,i,'vector')]; 76 end 77 end 78 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 79 if (nargin >= 2) 80 for i=1:numel(cdv) 81 if (numel(varargin{2}) > 1) 82 cdv(i).initpt =varargin{2}(i); 83 else 84 cdv(i).initpt =varargin{2}; 85 end 86 end 87 if (nargin >= 3) 88 for i=1:numel(cdv) 89 if (numel(varargin{3}) > 1) 90 cdv(i).lower =varargin{3}(i); 91 else 92 cdv(i).lower =varargin{3}; 93 end 94 end 95 if (nargin >= 4) 96 for i=1:numel(cdv) 97 if (numel(varargin{4}) > 1) 98 cdv(i).upper =varargin{4}(i); 99 else 100 cdv(i).upper =varargin{4}; 101 end 102 end 103 if (nargin >= 5) 104 if ischar(varargin{5}) 105 varargin{5}=cellstr(varargin{5}); 106 end 107 for i=1:numel(cdv) 108 if (numel(varargin{5}) > 1) 109 cdv(i).scale_type=varargin{5}{i}; 110 else 111 cdv(i).scale_type=char(varargin{5}); 112 end 113 end 114 if (nargin >= 6) 115 for i=1:numel(cdv) 116 if (numel(varargin{6}) > 1) 117 cdv(i).scale =varargin{6}(i); 118 else 119 cdv(i).scale =varargin{6}; 120 end 121 end 122 if (nargin > 6) 123 warning('continuous_design:extra_arg',... 124 'Extra arguments for object of class ''%s''.',... 125 class(cdv)); 126 end 127 end 128 end 129 end 130 end 131 end 132 end 133 133 134 134 end 135 135 136 136 function []=disp(cdv) 137 137 138 % display the object138 % display the object 139 139 140 141 142 143 144 145 146 147 148 149 150 140 disp(sprintf('\n')); 141 for i=1:numel(cdv) 142 disp(sprintf('class ''%s'' object ''%s%s'' = \n',... 143 class(cdv),inputname(1),string_dim(cdv,i))); 144 disp(sprintf(' descriptor: ''%s''' ,cdv(i).descriptor)); 145 disp(sprintf(' initpt: %g' ,cdv(i).initpt)); 146 disp(sprintf(' lower: %g' ,cdv(i).lower)); 147 disp(sprintf(' upper: %g' ,cdv(i).upper)); 148 disp(sprintf(' scale_type: ''%s''' ,cdv(i).scale_type)); 149 disp(sprintf(' scale: %g\n' ,cdv(i).scale)); 150 end 151 151 152 152 end 153 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 154 function [desc] =prop_desc(cdv,dstr) 155 desc=cell(1,numel(cdv)); 156 for i=1:numel(cdv) 157 if ~isempty(cdv(i).descriptor) 158 desc(i)=cellstr(cdv(i).descriptor); 159 elseif ~isempty(inputname(1)) 160 desc(i)=cellstr([inputname(1) string_dim(cdv,i,'vector')]); 161 elseif exist('dstr','var') 162 desc(i)=cellstr([dstr string_dim(cdv,i,'vector')]); 163 else 164 desc(i)=cellstr(['cdv' string_dim(cdv,i,'vector')]); 165 end 166 end 167 desc=allempty(desc); 168 end 169 function [initpt]=prop_initpt(cdv) 170 initpt=zeros(1,numel(cdv)); 171 for i=1:numel(cdv) 172 initpt(i)=cdv(i).initpt; 173 end 174 initpt=allequal(initpt,0.); 175 end 176 function [lower] =prop_lower(cdv) 177 lower=zeros(1,numel(cdv)); 178 for i=1:numel(cdv) 179 lower(i)=cdv(i).lower; 180 end 181 lower=allequal(lower,-Inf); 182 end 183 function [upper] =prop_upper(cdv) 184 upper=zeros(1,numel(cdv)); 185 for i=1:numel(cdv) 186 upper(i)=cdv(i).upper; 187 end 188 upper=allequal(upper, Inf); 189 end 190 function [mean] =prop_mean(cdv) 191 mean=[]; 192 end 193 function [stddev]=prop_stddev(cdv) 194 stddev=[]; 195 end 196 function [initst]=prop_initst(cdv) 197 initst=[]; 198 end 199 function [stype] =prop_stype(cdv) 200 stype=cell(1,numel(cdv)); 201 for i=1:numel(cdv) 202 stype(i)=cellstr(cdv(i).scale_type); 203 end 204 stype=allequal(stype,'none'); 205 end 206 function [scale] =prop_scale(cdv) 207 scale=zeros(1,numel(cdv)); 208 for i=1:numel(cdv) 209 scale(i)=cdv(i).scale; 210 end 211 scale=allequal(scale,1.); 212 end 213 end 214 214 215 216 215 methods (Static) 216 function []=dakota_write(fidi,dvar) 217 217 218 % collect only the variables of the appropriate class218 % collect only the variables of the appropriate class 219 219 220 220 cdv=struc_class(dvar,'continuous_design'); 221 221 222 % write variables222 % write variables 223 223 224 225 226 224 vlist_write(fidi,'continuous_design','cdv',cdv); 225 end 226 end 227 227 end -
../trunk-jpl/src/m/classes/model.m
127 127 if isa(md.slr,'double'); md.slr=slr(); end 128 128 %2016 October 11 129 129 if isa(md.esa,'double'); md.esa=esa(); end 130 %2017 Dec 21st (needs to be here) 131 if isempty(md.settings) 132 disp('Warning: md.settings had to be reset, make sure to adjust md.settings.output_frequency and other fields'); 133 md.settings = issmsettings(); 134 end 130 135 %2017 February 10th 131 136 if md.settings.solver_residue_threshold==0, 132 137 md.settings.solver_residue_threshold = 1e-6; … … 1145 1150 md.flowequation = flowequation(); 1146 1151 md.debug = debug(); 1147 1152 md.verbose = verbose(); 1148 md.settings = settings();1153 md.settings = issmsettings(); 1149 1154 md.toolkits = toolkits(); 1150 1155 md.cluster = generic(); 1151 1156 md.balancethickness = balancethickness(); -
../trunk-jpl/src/m/classes/issmsettings.m
1 %ISSMSETTINGS class definition 2 % 3 % Usage: 4 % issmsettings=issmsettings(); 5 6 classdef issmsettings 7 properties (SetAccess=public) 8 results_on_nodes = 0; 9 io_gather = 0; 10 lowmem = 0; 11 output_frequency = 0; 12 recording_frequency = 0; 13 waitonlock = 0; 14 upload_server = ''; 15 upload_path = ''; 16 upload_login = ''; 17 upload_port = 0; 18 upload_filename = ''; 19 solver_residue_threshold = 0; 20 end 21 methods 22 function self = issmsettings(varargin) % {{{ 23 switch nargin 24 case 0 25 self=setdefaultparameters(self); 26 otherwise 27 error('constructor not supported'); 28 end 29 end % }}} 30 function self = setdefaultparameters(self) % {{{ 31 32 %are we short in memory ? (0 faster but requires more memory) 33 self.lowmem=0; 34 35 %i/o: 36 self.io_gather=1; 37 38 %results frequency by default every step 39 self.output_frequency=1; 40 41 %checkpoints frequency, by default never: 42 self.recording_frequency=0; 43 44 %this option can be activated to load automatically the results 45 %onto the model after a parallel run by waiting for the lock file 46 %N minutes that is generated once the solution has converged 47 %0 to deactivate 48 self.waitonlock=Inf; 49 50 %upload options: 51 self.upload_port = 0; 52 53 %throw an error if solver residue exceeds this value 54 self.solver_residue_threshold = 1e-6; 55 56 end % }}} 57 function md = checkconsistency(self,md,solution,analyses) % {{{ 58 59 md = checkfield(md,'fieldname','issmsettings.results_on_nodes','numel',[1],'values',[0 1]); 60 md = checkfield(md,'fieldname','issmsettings.io_gather','numel',[1],'values',[0 1]); 61 md = checkfield(md,'fieldname','issmsettings.lowmem','numel',[1],'values',[0 1]); 62 md = checkfield(md,'fieldname','issmsettings.output_frequency','numel',[1],'>=',1); 63 md = checkfield(md,'fieldname','issmsettings.recording_frequency','numel',[1],'>=',0); 64 md = checkfield(md,'fieldname','issmsettings.waitonlock','numel',[1]); 65 md = checkfield(md,'fieldname','issmsettings.solver_residue_threshold','numel',[1],'>',0); 66 67 end % }}} 68 function disp(self) % {{{ 69 disp(sprintf(' general issmsettings parameters:')); 70 71 fielddisplay(self,'results_on_nodes','results are output for all the nodes of each element'); 72 fielddisplay(self,'io_gather','I/O gathering strategy for result outputs (default 1)'); 73 fielddisplay(self,'lowmem','is the memory limited ? (0 or 1)'); 74 fielddisplay(self,'output_frequency','frequency at which results are saved in all solutions with multiple time_steps'); 75 fielddisplay(self,'recording_frequency','frequency at which the runs are being recorded, allowing for a restart'); 76 fielddisplay(self,'waitonlock','maximum number of minutes to wait for batch results (NaN to deactivate)'); 77 fielddisplay(self,'upload_server','server hostname where model should be uploaded'); 78 fielddisplay(self,'upload_path','path on server where model should be uploaded'); 79 fielddisplay(self,'upload_login','server login'); 80 fielddisplay(self,'upload_port','port login (default is 0)'); 81 fielddisplay(self,'upload_filename','unique id generated when uploading the file to server'); 82 fielddisplay(self,'solver_residue_threshold','throw an error if solver residue exceeds this value (NaN to deactivate)'); 83 84 end % }}} 85 function marshall(self,prefix,md,fid) % {{{ 86 WriteData(fid,prefix,'object',self,'fieldname','results_on_nodes','format','Boolean'); 87 WriteData(fid,prefix,'object',self,'fieldname','io_gather','format','Boolean'); 88 WriteData(fid,prefix,'object',self,'fieldname','lowmem','format','Boolean'); 89 WriteData(fid,prefix,'object',self,'fieldname','output_frequency','format','Integer'); 90 WriteData(fid,prefix,'object',self,'fieldname','recording_frequency','format','Integer'); 91 WriteData(fid,prefix,'object',self,'fieldname','waitonlock','data',self.waitonlock>0,'format','Boolean'); 92 WriteData(fid,prefix,'object',self,'fieldname','solver_residue_threshold','format','Double'); 93 end % }}} 94 function savemodeljs(self,fid,modelname) % {{{ 95 96 writejsdouble(fid,[modelname '.issmsettings.results_on_nodes'],self.results_on_nodes); 97 writejsdouble(fid,[modelname '.issmsettings.io_gather'],self.io_gather); 98 writejsdouble(fid,[modelname '.issmsettings.lowmem'],self.lowmem); 99 writejsdouble(fid,[modelname '.issmsettings.output_frequency'],self.output_frequency); 100 writejsdouble(fid,[modelname '.issmsettings.recording_frequency'],self.recording_frequency); 101 writejsdouble(fid,[modelname '.issmsettings.waitonlock'],self.waitonlock); 102 writejsstring(fid,[modelname '.issmsettings.upload_server'],self.upload_server); 103 writejsstring(fid,[modelname '.issmsettings.upload_path'],self.upload_path); 104 writejsstring(fid,[modelname '.issmsettings.upload_login'],self.upload_login); 105 writejsdouble(fid,[modelname '.issmsettings.upload_port'],self.upload_port); 106 writejsstring(fid,[modelname '.issmsettings.upload_filename'],self.upload_filename); 107 writejsstring(fid,[modelname '.issmsettings.solver_residue_threshold'],self.solver_residue_threshold); 108 end % }}} 109 end 110 end
Note:
See TracBrowser
for help on using the repository browser.