[9664] | 1 | function md=setflowequation(md,varargin)
|
---|
[18301] | 2 | %SETFLOWEQUATION - associate a solution type to each element
|
---|
[1] | 3 | %
|
---|
| 4 | % This routine works like plotmodel: it works with an even number of inputs
|
---|
[27035] | 5 | % 'SIA','SSA','L1L2','MOLHO','HO','FS' and 'fill' are the possible options
|
---|
[1] | 6 | % that must be followed by the corresponding exp file or flags list
|
---|
| 7 | % It can either be a domain file (argus type, .exp extension), or an array of element flags.
|
---|
| 8 | % If user wants every element outside the domain to be
|
---|
[16137] | 9 | % setflowequationd, add '~' to the name of the domain file (ex: '~HO.exp');
|
---|
[1] | 10 | % an empty string '' will be considered as an empty domain
|
---|
| 11 | % a string 'all' will be considered as the entire domain
|
---|
[5379] | 12 | % You can specify the type of coupling, 'penalties' or 'tiling', to use with the input 'coupling'
|
---|
[27035] | 13 | % NB: L1L2 and MOLHO cannot currently be coupled to any other ice flow model
|
---|
[1] | 14 | %
|
---|
| 15 | % Usage:
|
---|
[9664] | 16 | % md=setflowequation(md,varargin)
|
---|
[1] | 17 | %
|
---|
| 18 | % Example:
|
---|
[16137] | 19 | % md=setflowequation(md,'HO','HO.exp',fill','SIA','coupling','tiling');
|
---|
[1] | 20 |
|
---|
| 21 | %some checks on list of arguments
|
---|
| 22 | if ((nargin<2) | (nargout~=1)),
|
---|
[9664] | 23 | error('setflowequation error message');
|
---|
[1] | 24 | end
|
---|
| 25 |
|
---|
[13028] | 26 | %Process options
|
---|
| 27 | options=pairoptions(varargin{:});
|
---|
| 28 | options=deleteduplicates(options,1);
|
---|
| 29 |
|
---|
[5379] | 30 | %Find_out what kind of coupling to use
|
---|
| 31 | coupling_method=getfieldvalue(options,'coupling','tiling');
|
---|
| 32 | if (~strcmpi(coupling_method,'tiling') & ~strcmpi(coupling_method,'penalties')),
|
---|
| 33 | error('coupling type can only be: tiling or penalties');
|
---|
| 34 | end
|
---|
| 35 |
|
---|
[13028] | 36 | %recover elements distribution
|
---|
[16137] | 37 | SIAflag = FlagElements(md,getfieldvalue(options,'SIA',''));
|
---|
| 38 | SSAflag = FlagElements(md,getfieldvalue(options,'SSA',''));
|
---|
| 39 | HOflag = FlagElements(md,getfieldvalue(options,'HO',''));
|
---|
| 40 | L1L2flag = FlagElements(md,getfieldvalue(options,'L1L2',''));
|
---|
[27035] | 41 | MOLHOflag = FlagElements(md,getfieldvalue(options,'MOLHO',''));
|
---|
[16137] | 42 | FSflag = FlagElements(md,getfieldvalue(options,'FS',''));
|
---|
| 43 | filltype = getfieldvalue(options,'fill','none');
|
---|
| 44 | displayunused(options);
|
---|
[1] | 45 |
|
---|
[12888] | 46 | %Flag the elements that have not been flagged as filltype
|
---|
[16137] | 47 | if strcmpi(filltype,'SIA'),
|
---|
| 48 | SIAflag(find(~(SSAflag | HOflag)))=1;
|
---|
| 49 | elseif strcmpi(filltype,'SSA'),
|
---|
| 50 | SSAflag(find(~(SIAflag | HOflag | FSflag)))=1;
|
---|
| 51 | elseif strcmpi(filltype,'HO'),
|
---|
| 52 | HOflag(find(~(SIAflag | SSAflag | FSflag)))=1;
|
---|
[1] | 53 | end
|
---|
| 54 |
|
---|
| 55 | %check that each element has at least one flag
|
---|
[27035] | 56 | if any(SIAflag+SSAflag+HOflag+L1L2flag+MOLHOflag+FSflag==0),
|
---|
[27232] | 57 | error('elements type not assigned, supported models are ''SIA'',''SSA'',''HO'',''MOLHO'' and ''FS''')
|
---|
[1] | 58 | end
|
---|
| 59 |
|
---|
| 60 | %check that each element has only one flag
|
---|
[27035] | 61 | if any(SIAflag+SSAflag+HOflag+L1L2flag+MOLHOflag+FSflag>1),
|
---|
[26744] | 62 | disp('setflowequation.m: Warning: some elements have several types, higher order type is used for them')
|
---|
[16137] | 63 | SIAflag(find(SIAflag & SSAflag))=0;
|
---|
| 64 | SIAflag(find(SIAflag & HOflag))=0;
|
---|
| 65 | SSAflag(find(SSAflag & HOflag))=0;
|
---|
[1] | 66 | end
|
---|
| 67 |
|
---|
[16137] | 68 | %check that L1L2 is not coupled to any other model for now
|
---|
| 69 | if any(L1L2flag) & any(SIAflag | SSAflag | HOflag | FSflag)
|
---|
| 70 | error('L1L2 cannot be coupled to any other model');
|
---|
[13048] | 71 | end
|
---|
[27035] | 72 | if any(MOLHOflag) & any(SIAflag | SSAflag | HOflag | FSflag)
|
---|
| 73 | error('MOLHO cannot be coupled to any other model');
|
---|
[25836] | 74 | end
|
---|
[13048] | 75 |
|
---|
[18301] | 76 | %Check that no HO or FS for 2d mesh
|
---|
[17806] | 77 | if strcmp(domaintype(md.mesh),'2Dhorizontal')
|
---|
[18301] | 78 | if any(FSflag | HOflag)
|
---|
[16137] | 79 | error('FS and HO elements not allowed in 2d mesh, extrude it first')
|
---|
[1] | 80 | end
|
---|
| 81 | end
|
---|
| 82 |
|
---|
[16137] | 83 | %FS can only be used alone for now:
|
---|
| 84 | if any(FSflag) &any(SIAflag),
|
---|
| 85 | error('FS cannot be used with any other model for now, put FS everywhere')
|
---|
[5433] | 86 | end
|
---|
[1] | 87 |
|
---|
[11004] | 88 | %Initialize node fields
|
---|
[25836] | 89 | nodeonSIA=zeros(md.mesh.numberofvertices,1); nodeonSIA(md.mesh.elements(find(SIAflag),:))=1;
|
---|
| 90 | nodeonSSA=zeros(md.mesh.numberofvertices,1); nodeonSSA(md.mesh.elements(find(SSAflag),:))=1;
|
---|
| 91 | nodeonHO=zeros(md.mesh.numberofvertices,1); nodeonHO(md.mesh.elements(find(HOflag),:))=1;
|
---|
| 92 | nodeonL1L2=zeros(md.mesh.numberofvertices,1); nodeonL1L2(md.mesh.elements(find(L1L2flag),:))=1;
|
---|
[27035] | 93 | nodeonMOLHO=zeros(md.mesh.numberofvertices,1); nodeonMOLHO(md.mesh.elements(find(MOLHOflag),:))=1;
|
---|
[16137] | 94 | nodeonFS=zeros(md.mesh.numberofvertices,1);
|
---|
[11004] | 95 | noneflag=zeros(md.mesh.numberofelements,1);
|
---|
[1] | 96 |
|
---|
[16137] | 97 | %First modify FSflag to get rid of elements contrained everywhere (spc + border with HO or SSA)
|
---|
| 98 | if any(FSflag),
|
---|
| 99 | fullspcnodes=double((~isnan(md.stressbalance.spcvx)+~isnan(md.stressbalance.spcvy)+~isnan(md.stressbalance.spcvz))==3 | (nodeonHO & nodeonFS)); %find all the nodes on the boundary of the domain without icefront
|
---|
[9733] | 100 | fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6); %find all the nodes on the boundary of the domain without icefront
|
---|
[16137] | 101 | FSflag(find(fullspcelems))=0;
|
---|
| 102 | nodeonFS(md.mesh.elements(find(FSflag),:))=1;
|
---|
[5613] | 103 | end
|
---|
[1] | 104 |
|
---|
[16137] | 105 | %Then complete with NoneApproximation or the other model used if there is no FS
|
---|
| 106 | if any(FSflag),
|
---|
| 107 | if any(HOflag), %fill with HO
|
---|
| 108 | HOflag(~FSflag)=1;
|
---|
| 109 | nodeonHO(md.mesh.elements(find(HOflag),:))=1;
|
---|
| 110 | elseif any(SSAflag), %fill with SSA
|
---|
| 111 | SSAflag(~FSflag)=1;
|
---|
| 112 | nodeonSSA(md.mesh.elements(find(SSAflag),:))=1;
|
---|
[5613] | 113 | else %fill with none
|
---|
[16137] | 114 | noneflag(find(~FSflag))=1;
|
---|
[5613] | 115 | end
|
---|
[5433] | 116 | end
|
---|
[1] | 117 |
|
---|
[16137] | 118 | %Now take care of the coupling between SSA and HO
|
---|
[24313] | 119 | if strcmpi(coupling_method,'penalties'),
|
---|
| 120 | md.stressbalance.vertex_pairing=[];
|
---|
| 121 | end
|
---|
[16137] | 122 | nodeonSSAHO=zeros(md.mesh.numberofvertices,1);
|
---|
| 123 | nodeonHOFS=zeros(md.mesh.numberofvertices,1);
|
---|
| 124 | nodeonSSAFS=zeros(md.mesh.numberofvertices,1);
|
---|
| 125 | SSAHOflag=zeros(md.mesh.numberofelements,1);
|
---|
| 126 | SSAFSflag=zeros(md.mesh.numberofelements,1);
|
---|
| 127 | HOFSflag=zeros(md.mesh.numberofelements,1);
|
---|
[5379] | 128 | if strcmpi(coupling_method,'penalties'),
|
---|
[16137] | 129 | %Create the border nodes between HO and SSA and extrude them
|
---|
[9725] | 130 | numnodes2d=md.mesh.numberofvertices2d;
|
---|
| 131 | numlayers=md.mesh.numberoflayers;
|
---|
[16137] | 132 | bordernodes2d=find(nodeonHO(1:numnodes2d) & nodeonSSA(1:numnodes2d)); %Nodes connected to two different types of elements
|
---|
[5379] | 133 |
|
---|
| 134 | %initialize and fill in penalties structure
|
---|
[8298] | 135 | if ~isnan(bordernodes2d),
|
---|
[5379] | 136 | penalties=[];
|
---|
| 137 | for i=1:numlayers-1,
|
---|
[9725] | 138 | penalties=[penalties; [bordernodes2d bordernodes2d+md.mesh.numberofvertices2d*(i)]];
|
---|
[5379] | 139 | end
|
---|
[16137] | 140 | md.stressbalance.vertex_pairing=penalties;
|
---|
[5379] | 141 | end
|
---|
| 142 | elseif strcmpi(coupling_method,'tiling'),
|
---|
[16137] | 143 | if any(SSAflag) & any(HOflag), %coupling SSA HO
|
---|
[8298] | 144 | %Find node at the border
|
---|
[16137] | 145 | nodeonSSAHO(find(nodeonSSA & nodeonHO))=1;
|
---|
| 146 | %SSA elements in contact with this layer become SSAHO elements
|
---|
| 147 | matrixelements=ismember(md.mesh.elements,find(nodeonSSAHO));
|
---|
[5613] | 148 | commonelements=sum(matrixelements,2)~=0;
|
---|
[16137] | 149 | commonelements(find(HOflag))=0; %only one layer: the elements previously in SSA
|
---|
| 150 | SSAflag(find(commonelements))=0; %these elements are now SSAHOelements
|
---|
| 151 | SSAHOflag(find(commonelements))=1;
|
---|
| 152 | nodeonSSA(:)=0;
|
---|
| 153 | nodeonSSA(md.mesh.elements(find(SSAflag),:))=1;
|
---|
[5379] | 154 |
|
---|
[11003] | 155 | %rule out elements that don't touch the 2 boundaries
|
---|
[16137] | 156 | pos=find(SSAHOflag);
|
---|
[12959] | 157 | elist=zeros(length(pos),1);
|
---|
[16137] | 158 | elist = elist + any(sum(nodeonSSA(md.mesh.elements(pos,:)),2),2);
|
---|
| 159 | elist = elist - any(sum(nodeonHO(md.mesh.elements(pos,:)) ,2),2);
|
---|
[12959] | 160 | pos1=find(elist==1);
|
---|
[16137] | 161 | SSAflag(pos(pos1))=1;
|
---|
| 162 | SSAHOflag(pos(pos1))=0;
|
---|
[12959] | 163 | pos2=find(elist==-1);
|
---|
[16137] | 164 | HOflag(pos(pos2))=1;
|
---|
| 165 | SSAHOflag(pos(pos2))=0;
|
---|
[5379] | 166 |
|
---|
[11004] | 167 | %Recompute nodes associated to these elements
|
---|
[16137] | 168 | nodeonSSA(:)=0;
|
---|
| 169 | nodeonSSA(md.mesh.elements(find(SSAflag),:))=1;
|
---|
| 170 | nodeonHO(:)=0;
|
---|
| 171 | nodeonHO(md.mesh.elements(find(HOflag),:))=1;
|
---|
| 172 | nodeonSSAHO(:)=0;
|
---|
| 173 | nodeonSSAHO(md.mesh.elements(find(SSAHOflag),:))=1;
|
---|
[11003] | 174 |
|
---|
[16137] | 175 | elseif any(HOflag) & any(FSflag), %coupling HO FS
|
---|
[8298] | 176 | %Find node at the border
|
---|
[16137] | 177 | nodeonHOFS(find(nodeonHO & nodeonFS))=1;
|
---|
| 178 | %FS elements in contact with this layer become HOFS elements
|
---|
| 179 | matrixelements=ismember(md.mesh.elements,find(nodeonHOFS));
|
---|
[5613] | 180 | commonelements=sum(matrixelements,2)~=0;
|
---|
[16137] | 181 | commonelements(find(HOflag))=0; %only one layer: the elements previously in SSA
|
---|
| 182 | FSflag(find(commonelements))=0; %these elements are now SSAHOelements
|
---|
| 183 | HOFSflag(find(commonelements))=1;
|
---|
| 184 | nodeonFS=zeros(md.mesh.numberofvertices,1);
|
---|
| 185 | nodeonFS(md.mesh.elements(find(FSflag),:))=1;
|
---|
[5613] | 186 |
|
---|
[11004] | 187 | %rule out elements that don't touch the 2 boundaries
|
---|
[16137] | 188 | pos=find(HOFSflag);
|
---|
[12959] | 189 | elist=zeros(length(pos),1);
|
---|
[16137] | 190 | elist = elist + any(sum(nodeonFS(md.mesh.elements(pos,:)),2),2);
|
---|
| 191 | elist = elist - any(sum(nodeonHO(md.mesh.elements(pos,:)),2),2);
|
---|
[12959] | 192 | pos1=find(elist==1);
|
---|
[16137] | 193 | FSflag(pos(pos1))=1;
|
---|
| 194 | HOFSflag(pos(pos1))=0;
|
---|
[12959] | 195 | pos2=find(elist==-1);
|
---|
[16137] | 196 | HOflag(pos(pos2))=1;
|
---|
| 197 | HOFSflag(pos(pos2))=0;
|
---|
[11004] | 198 |
|
---|
| 199 | %Recompute nodes associated to these elements
|
---|
[16137] | 200 | nodeonFS(:)=0;
|
---|
| 201 | nodeonFS(md.mesh.elements(find(FSflag),:))=1;
|
---|
| 202 | nodeonHO(:)=0;
|
---|
| 203 | nodeonHO(md.mesh.elements(find(HOflag),:))=1;
|
---|
| 204 | nodeonHOFS(:)=0;
|
---|
| 205 | nodeonHOFS(md.mesh.elements(find(HOFSflag),:))=1;
|
---|
[11004] | 206 |
|
---|
[16137] | 207 | elseif any(FSflag) & any(SSAflag),
|
---|
[8298] | 208 | %Find node at the border
|
---|
[16137] | 209 | nodeonSSAFS(find(nodeonSSA & nodeonFS))=1;
|
---|
| 210 | %FS elements in contact with this layer become SSAFS elements
|
---|
| 211 | matrixelements=ismember(md.mesh.elements,find(nodeonSSAFS));
|
---|
[6705] | 212 | commonelements=sum(matrixelements,2)~=0;
|
---|
[16137] | 213 | commonelements(find(SSAflag))=0; %only one layer: the elements previously in SSA
|
---|
| 214 | FSflag(find(commonelements))=0; %these elements are now SSASSAelements
|
---|
| 215 | SSAFSflag(find(commonelements))=1;
|
---|
| 216 | nodeonFS=zeros(md.mesh.numberofvertices,1);
|
---|
| 217 | nodeonFS(md.mesh.elements(find(FSflag),:))=1;
|
---|
[6705] | 218 |
|
---|
[11004] | 219 | %rule out elements that don't touch the 2 boundaries
|
---|
[16137] | 220 | pos=find(SSAFSflag);
|
---|
[12959] | 221 | elist=zeros(length(pos),1);
|
---|
[16137] | 222 | elist = elist + any(sum(nodeonSSA(md.mesh.elements(pos,:)),2),2);
|
---|
| 223 | elist = elist - any(sum(nodeonFS(md.mesh.elements(pos,:)) ,2),2);
|
---|
[12959] | 224 | pos1=find(elist==1);
|
---|
[16137] | 225 | SSAflag(pos(pos1))=1;
|
---|
| 226 | SSAFSflag(pos(pos1))=0;
|
---|
[12959] | 227 | pos2=find(elist==-1);
|
---|
[16137] | 228 | FSflag(pos(pos2))=1;
|
---|
| 229 | SSAFSflag(pos(pos2))=0;
|
---|
[11004] | 230 |
|
---|
| 231 | %Recompute nodes associated to these elements
|
---|
[16137] | 232 | nodeonSSA(:)=0;
|
---|
| 233 | nodeonSSA(md.mesh.elements(find(SSAflag),:))=1;
|
---|
| 234 | nodeonFS(:)=0;
|
---|
| 235 | nodeonFS(md.mesh.elements(find(FSflag),:))=1;
|
---|
| 236 | nodeonSSAFS(:)=0;
|
---|
| 237 | nodeonSSAFS(md.mesh.elements(find(SSAFSflag),:))=1;
|
---|
[11004] | 238 |
|
---|
[16137] | 239 | elseif any(FSflag) & any(SIAflag),
|
---|
[5613] | 240 | error('type of coupling not supported yet');
|
---|
| 241 | end
|
---|
[5379] | 242 | end
|
---|
| 243 |
|
---|
[18301] | 244 | %Create element equations
|
---|
[11003] | 245 | md.flowequation.element_equation=zeros(md.mesh.numberofelements,1);
|
---|
| 246 | md.flowequation.element_equation(find(noneflag))=0;
|
---|
[16137] | 247 | md.flowequation.element_equation(find(SIAflag))=1;
|
---|
| 248 | md.flowequation.element_equation(find(SSAflag))=2;
|
---|
[18301] | 249 | md.flowequation.element_equation(find(L1L2flag))=3;
|
---|
[27035] | 250 | md.flowequation.element_equation(find(MOLHOflag))=4;
|
---|
[25836] | 251 | md.flowequation.element_equation(find(HOflag))=5;
|
---|
| 252 | md.flowequation.element_equation(find(FSflag))=6;
|
---|
| 253 | md.flowequation.element_equation(find(SSAHOflag))=7;
|
---|
| 254 | md.flowequation.element_equation(find(SSAFSflag))=8;
|
---|
| 255 | md.flowequation.element_equation(find(HOFSflag))=9;
|
---|
[11003] | 256 |
|
---|
| 257 | %border
|
---|
[16137] | 258 | md.flowequation.borderHO=nodeonHO;
|
---|
| 259 | md.flowequation.borderSSA=nodeonSSA;
|
---|
| 260 | md.flowequation.borderFS=nodeonFS;
|
---|
[11003] | 261 |
|
---|
[5071] | 262 | %Create vertices_type
|
---|
[9725] | 263 | md.flowequation.vertex_equation=zeros(md.mesh.numberofvertices,1);
|
---|
[25836] | 264 | pos=find(nodeonSSA); md.flowequation.vertex_equation(pos)=2;
|
---|
| 265 | pos=find(nodeonL1L2); md.flowequation.vertex_equation(pos)=3;
|
---|
[27035] | 266 | pos=find(nodeonMOLHO); md.flowequation.vertex_equation(pos)=4;
|
---|
[25836] | 267 | pos=find(nodeonHO); md.flowequation.vertex_equation(pos)=5;
|
---|
| 268 | pos=find(nodeonFS); md.flowequation.vertex_equation(pos)=6;
|
---|
[20500] | 269 | %DO SIA LAST! Otherwise spcs might not be set up correctly (SIA should have priority)
|
---|
| 270 | pos=find(nodeonSIA);
|
---|
| 271 | md.flowequation.vertex_equation(pos)=1;
|
---|
[16137] | 272 | if any(FSflag),
|
---|
| 273 | pos=find(~nodeonFS);
|
---|
| 274 | if(~any(HOflag) & ~any(SSAflag)),
|
---|
[9661] | 275 | md.flowequation.vertex_equation(pos)=0;
|
---|
[5969] | 276 | end
|
---|
[5433] | 277 | end
|
---|
[18301] | 278 | pos=find(nodeonSSAHO);
|
---|
[25836] | 279 | md.flowequation.vertex_equation(pos)=7;
|
---|
[16137] | 280 | pos=find(nodeonHOFS);
|
---|
[25836] | 281 | md.flowequation.vertex_equation(pos)=8;
|
---|
[16137] | 282 | pos=find(nodeonSSAFS);
|
---|
[25836] | 283 | md.flowequation.vertex_equation(pos)=9;
|
---|
[5071] | 284 |
|
---|
[202] | 285 | %figure out solution types
|
---|
[16137] | 286 | md.flowequation.isSIA = double(any(md.flowequation.element_equation == 1));
|
---|
| 287 | md.flowequation.isSSA = double(any(md.flowequation.element_equation == 2));
|
---|
[18301] | 288 | md.flowequation.isL1L2 = double(any(md.flowequation.element_equation == 3));
|
---|
[27035] | 289 | md.flowequation.isMOLHO = double(any(md.flowequation.element_equation == 4));
|
---|
[25836] | 290 | md.flowequation.isHO = double(any(md.flowequation.element_equation == 5));
|
---|
| 291 | md.flowequation.isFS = double(any(md.flowequation.element_equation == 6));
|
---|
[202] | 292 |
|
---|
[11003] | 293 | return
|
---|
| 294 |
|
---|
| 295 | %Check that tiling can work:
|
---|
[16137] | 296 | if any(md.flowequation.borderSSA) & any(md.flowequation.borderHO) & any(md.flowequation.borderHO + md.flowequation.borderSSA ~=1),
|
---|
[11003] | 297 | error('error coupling domain too irregular');
|
---|
[1] | 298 | end
|
---|
[16137] | 299 | if any(md.flowequation.borderSSA) & any(md.flowequation.borderFS) & any(md.flowequation.borderFS + md.flowequation.borderSSA ~=1),
|
---|
[11003] | 300 | error('error coupling domain too irregular');
|
---|
| 301 | end
|
---|
[16137] | 302 | if any(md.flowequation.borderFS) & any(md.flowequation.borderHO) & any(md.flowequation.borderHO + md.flowequation.borderFS~=1),
|
---|
[11003] | 303 | error('error coupling domain too irregular');
|
---|
| 304 | end
|
---|