Changeset 22758 for issm/trunk/src/m/classes/amr.m
- Timestamp:
- 05/10/18 10:24:27 (7 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/classes/amr.m
r21729 r22758 2 2 % 3 3 % Usage: 4 % amr=amr();4 % md.amr=amr(); 5 5 6 6 classdef amr 7 7 properties (SetAccess=public) 8 level_max = 0; 9 region_level_1 = 0; 10 region_level_max = 0; 8 hmin = 0.; 9 hmax = 0.; 10 fieldname = ''; 11 err = 0.; 12 keepmetric = 0; 13 gradation = 0.; 14 groundingline_resolution = 0.; 15 groundingline_distance = 0.; 16 icefront_resolution = 0.; 17 icefront_distance = 0.; 18 thicknesserror_resolution = 0.; 19 thicknesserror_threshold = 0.; 20 thicknesserror_groupthreshold = 0.; 21 thicknesserror_maximum = 0.; 22 deviatoricerror_resolution = 0.; 23 deviatoricerror_threshold = 0.; 24 deviatoricerror_groupthreshold = 0.; 25 deviatoricerror_maximum = 0.; 26 restart=0.; 27 end 28 methods (Static) 29 function self = loadobj(self) % {{{ 30 % This function is directly called by matlab when a model object is 31 % loaded. Update old properties here 32 33 if verLessThan('matlab','7.9'), 34 disp('Warning: your matlab version is old and there is a risk that load does not work correctly'); 35 disp(' if the model is not loaded correctly, rename temporarily loadobj so that matlab does not use it'); 36 37 % This is a Matlab bug: all the fields of md have their default value 38 % Example of error message: 39 % Warning: Error loading an object of class 'model': 40 % Undefined function or method 'exist' for input arguments of type 'cell' 41 % 42 % This has been fixed in MATLAB 7.9 (R2009b) and later versions 43 end 44 45 %2017 September 15th 46 if isstruct(self), 47 disp('WARNING: updating amr. Now the default is amr with bamg'); 48 disp(' some old fields were not converted'); 49 disp(' see the new fields typing md.amr and modify them properly'); 50 obj2 = self; 51 self = amr(); 52 %Converting region_level_max to groundingline_distance 53 if(obj2.region_level_max>0 && obj2.region_level_1>obj2.region_level_max) 54 self.groundingline_distance = obj2.region_level_max; 55 self.keepmetric = 0; 56 self.fieldname = 'None'; 57 end 58 end 59 end% }}} 11 60 end 12 61 methods … … 21 70 function self = setdefaultparameters(self) % {{{ 22 71 23 %level_max: 2 to 4 24 self.level_max=2; 72 %hmin and hmax 73 self.hmin=100.; 74 self.hmax=100.e3; 25 75 26 %region_level_1: region around (m) the discontinuity (grounding line or ice front) where the mesh will be refined once (h=1). 27 self.region_level_1=20000.; 76 %fields 77 self.fieldname ='Vel'; 78 self.err=3.; 79 80 %keep metric? 81 self.keepmetric=1; 82 83 %control of element lengths 84 self.gradation=1.5; 85 86 %other criterias 87 self.groundingline_resolution=500.; 88 self.groundingline_distance=0.; 89 self.icefront_resolution=500.; 90 self.icefront_distance=0.; 91 self.thicknesserror_resolution=500.; 92 self.thicknesserror_threshold=0.; 93 self.thicknesserror_groupthreshold=0.; 94 self.thicknesserror_maximum=0.; 95 self.deviatoricerror_resolution=500.; 96 self.deviatoricerror_threshold=0.; 97 self.deviatoricerror_groupthreshold=0.; 98 self.deviatoricerror_maximum=0.; 28 99 29 % region_level_max: region around (m) the discontinuity (grounding line or ice front) where the mesh will be refined with max level of refinement (h=level_max).30 self.re gion_level_max=15000.;100 %is restart? This calls femmodel->ReMesh() before first time step. 101 self.restart=0; 31 102 32 103 end % }}} 33 104 function md = checkconsistency(self,md,solution,analyses) % {{{ 34 105 35 md = checkfield(md,'fieldname','amr.level_max','numel',[1],'>=',0,'<=',4); 36 md = checkfield(md,'fieldname','amr.region_level_1','numel',[1],'>',0,'NaN',1,'Inf',1); 37 md = checkfield(md,'fieldname','amr.region_level_max','numel',[1],'>',0,'NaN',1,'Inf',1); 38 if self.region_level_1-self.region_level_max<0.2*self.region_level_1, %it was adopted 20% of the region_level_1 39 md = checkmessage(md,'region_level_max should be lower than 80% of region_level_1'); 40 end 106 md = checkfield(md,'fieldname','amr.hmax','numel',[1],'>',0,'NaN',1); 107 md = checkfield(md,'fieldname','amr.hmin','numel',[1],'>',0,'<',self.hmax,'NaN',1); 108 %md = checkfield(md,'fieldname','amr.fieldname','string',[1]); 109 md = checkfield(md,'fieldname','amr.keepmetric','numel',[1],'>=',0,'<=',1,'NaN',1); 110 md = checkfield(md,'fieldname','amr.gradation','numel',[1],'>=',1.1,'<=',5,'NaN',1); 111 md = checkfield(md,'fieldname','amr.groundingline_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1); 112 md = checkfield(md,'fieldname','amr.groundingline_distance','numel',[1],'>=',0,'NaN',1,'Inf',1); 113 md = checkfield(md,'fieldname','amr.icefront_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1); 114 md = checkfield(md,'fieldname','amr.icefront_distance','numel',[1],'>=',0,'NaN',1,'Inf',1); 115 md = checkfield(md,'fieldname','amr.thicknesserror_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1); 116 md = checkfield(md,'fieldname','amr.thicknesserror_threshold','numel',[1],'>=',0,'<=',1,'NaN',1); 117 md = checkfield(md,'fieldname','amr.thicknesserror_groupthreshold','numel',[1],'>=',0,'<=',1,'NaN',1); 118 md = checkfield(md,'fieldname','amr.thicknesserror_maximum','numel',[1],'>=',0,'NaN',1,'Inf',1); 119 md = checkfield(md,'fieldname','amr.deviatoricerror_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1); 120 md = checkfield(md,'fieldname','amr.deviatoricerror_threshold','numel',[1],'>=',0,'<=',1,'NaN',1); 121 md = checkfield(md,'fieldname','amr.deviatoricerror_groupthreshold','numel',[1],'>=',0,'<=',1,'NaN',1); 122 md = checkfield(md,'fieldname','amr.deviatoricerror_maximum','numel',[1],'>=',0,'NaN',1,'Inf',1); 123 md = checkfield(md,'fieldname','amr.restart','numel',[1],'>=',0,'<=',1,'NaN',1); 41 124 end % }}} 42 125 function disp(self) % {{{ 43 126 disp(sprintf(' amr parameters:')); 44 127 45 fielddisplay(self,'level_max',['maximum refinement level (1, 2, 3 or 4)']); 46 fielddisplay(self,'region_level_1',['region which will be refined once (level 1) [ m ]']); 47 fielddisplay(self,'region_level_max',['region which will be refined with level_max [ m ]']); 48 128 fielddisplay(self,'hmin',['minimum element length']); 129 fielddisplay(self,'hmax',['maximum element length']); 130 fielddisplay(self,'fieldname',['name of input that will be used to compute the metric (should be an input of FemModel)']); 131 fielddisplay(self,'keepmetric',['indicates whether the metric should be kept every remeshing time']); 132 fielddisplay(self,'gradation',['maximum ratio between two adjacent edges']); 133 fielddisplay(self,'groundingline_resolution',['element length near the grounding line']); 134 fielddisplay(self,'groundingline_distance',['distance around the grounding line which elements will be refined']); 135 fielddisplay(self,'icefront_resolution',['element length near the ice front']); 136 fielddisplay(self,'icefront_distance',['distance around the ice front which elements will be refined']); 137 fielddisplay(self,'thicknesserror_resolution',['element length when thickness error estimator is used']); 138 fielddisplay(self,'thicknesserror_threshold',['maximum threshold thickness error permitted']); 139 fielddisplay(self,'thicknesserror_groupthreshold',['maximum group threshold thickness error permitted']); 140 fielddisplay(self,'thicknesserror_maximum',['maximum thickness error permitted']); 141 fielddisplay(self,'deviatoricerror_resolution',['element length when deviatoric stress error estimator is used']); 142 fielddisplay(self,'deviatoricerror_threshold',['maximum threshold deviatoricstress error permitted']); 143 fielddisplay(self,'deviatoricerror_groupthreshold',['maximum group threshold deviatoricstress error permitted']); 144 fielddisplay(self,'deviatoricerror_maximum',['maximum deviatoricstress error permitted']); 145 fielddisplay(self,'restart',['indicates if ReMesh() will call before first time step']); 49 146 end % }}} 50 147 function marshall(self,prefix,md,fid) % {{{ 51 148 52 scale = md.constants.yts; 53 WriteData(fid,prefix,'object',self,'fieldname','level_max','format','Integer'); 54 WriteData(fid,prefix,'object',self,'fieldname','region_level_1','format','Double'); 55 WriteData(fid,prefix,'object',self,'fieldname','region_level_max','format','Double'); 56 end % }}} 57 function savemodeljs(self,fid,modelname) % {{{ 58 59 writejsdouble(fid,[modelname '.amr.level_max'],self.level_max); 60 writejsdouble(fid,[modelname '.amr.region_level_1'],self.region_level_1); 61 writejsdouble(fid,[modelname '.amr.region_level_max'],self.region_level_max); 149 WriteData(fid,prefix,'name','md.amr.type','data',1,'format','Integer'); 150 WriteData(fid,prefix,'object',self,'class','amr','fieldname','hmin','format','Double'); 151 WriteData(fid,prefix,'object',self,'class','amr','fieldname','hmax','format','Double'); 152 WriteData(fid,prefix,'object',self,'class','amr','fieldname','fieldname','format','String'); 153 WriteData(fid,prefix,'object',self,'class','amr','fieldname','err','format','Double'); 154 WriteData(fid,prefix,'object',self,'class','amr','fieldname','keepmetric','format','Integer'); 155 WriteData(fid,prefix,'object',self,'class','amr','fieldname','gradation','format','Double'); 156 WriteData(fid,prefix,'object',self,'class','amr','fieldname','groundingline_resolution','format','Double'); 157 WriteData(fid,prefix,'object',self,'class','amr','fieldname','groundingline_distance','format','Double'); 158 WriteData(fid,prefix,'object',self,'class','amr','fieldname','icefront_resolution','format','Double'); 159 WriteData(fid,prefix,'object',self,'class','amr','fieldname','icefront_distance','format','Double'); 160 WriteData(fid,prefix,'object',self,'class','amr','fieldname','thicknesserror_resolution','format','Double'); 161 WriteData(fid,prefix,'object',self,'class','amr','fieldname','thicknesserror_threshold','format','Double'); 162 WriteData(fid,prefix,'object',self,'class','amr','fieldname','thicknesserror_groupthreshold','format','Double'); 163 WriteData(fid,prefix,'object',self,'class','amr','fieldname','thicknesserror_maximum','format','Double'); 164 WriteData(fid,prefix,'object',self,'class','amr','fieldname','deviatoricerror_resolution','format','Double'); 165 WriteData(fid,prefix,'object',self,'class','amr','fieldname','deviatoricerror_threshold','format','Double'); 166 WriteData(fid,prefix,'object',self,'class','amr','fieldname','deviatoricerror_groupthreshold','format','Double'); 167 WriteData(fid,prefix,'object',self,'class','amr','fieldname','deviatoricerror_maximum','format','Double'); 168 WriteData(fid,prefix,'object',self,'class','amr','fieldname','restart','format','Integer'); 62 169 63 170 end % }}}
Note:
See TracChangeset
for help on using the changeset viewer.