0001 function md=setelementstype(md,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 if ((nargin<2) | (nargout~=1)),
0021 error('setelementstype error message');
0022 end
0023
0024 if md.counter<2,
0025 error('only fully parameterized 2d models can be setelementstyped');
0026 end
0027
0028 [hutterflag macayealflag pattynflag stokesflag filltype]=recover_areas(md,varargin);
0029
0030
0031 if strcmpi(filltype,'hutter'),
0032 hutterflag(find(~macayealflag & ~pattynflag))=1;
0033 elseif strcmpi(filltype,'macayeal'),
0034 macayealflag(find(~hutterflag & ~pattynflag))=1;
0035 elseif strcmpi(filltype,'pattyn'),
0036 pattynflag(find(~hutterflag & ~macayealflag))=1;
0037 end
0038
0039
0040 if any(hutterflag+ macayealflag+pattynflag==0),
0041 error('setelementstype error message: elements type not assigned, must be specified')
0042 end
0043
0044
0045 if any(hutterflag+ macayealflag+pattynflag>1),
0046 disp('setelementstype warning message: some elements have several types, higher order type is used for them')
0047 hutterflag(find(hutterflag & macayealflag))=0;
0048 macayealflag(find(macayealflag & pattynflag))=0;
0049 pattynflag(find(pattynflag & macayealflag))=0;
0050 end
0051
0052
0053 if strcmpi(md.type,'2d'),
0054 if any(stokesflag | pattynflag)
0055 error('setelementstype error message: stokes and pattyn elements no allowed in 2d mesh, extrude it first')
0056 end
0057 end
0058
0059
0060 nonstokesflag=find(~stokesflag);
0061 gridonstokes=ones(md.numberofgrids,1);
0062 gridonstokes(md.elements(nonstokesflag,:))=0;
0063 pos=find(md.gridondirichlet_diag);
0064 gridonstokes(pos)=0;
0065
0066
0067
0068 pos=find(stokesflag);
0069 constrained_list=pos(find(sum(gridonstokes(md.elements(pos,:)),2)==0));
0070 stokesflag(constrained_list)=0;
0071
0072
0073 md.elements_type=zeros(md.numberofelements,2);
0074
0075
0076 gridonhutter=zeros(md.numberofgrids,1);
0077 gridonhutter(md.elements(find(hutterflag),:))=1;
0078 md.gridonhutter=gridonhutter;
0079 md.elements_type(find(hutterflag),1)=hutterenum();
0080
0081
0082 gridonmacayeal=zeros(md.numberofgrids,1);
0083 gridonmacayeal(md.elements(find(macayealflag),:))=1;
0084 md.gridonmacayeal=gridonmacayeal;
0085 md.elements_type(find(macayealflag),1)=macayealenum();
0086
0087
0088 gridonpattyn=zeros(md.numberofgrids,1);
0089 gridonpattyn(md.elements(find(pattynflag),:))=1;
0090 md.gridonpattyn=gridonpattyn;
0091 md.elements_type(find(pattynflag),1)=pattynenum();
0092
0093
0094 md.gridonstokes=gridonstokes;
0095 md.elements_type(find(stokesflag),2)=stokesenum();
0096
0097
0098 md.elements_type(find(~stokesflag),2)=noneenum();
0099
0100
0101 numgrids2d=md.numberofgrids2d;
0102 numlayers=md.numlayers;
0103 bordergrids2d=find(gridonpattyn(1:numgrids2d) & gridonmacayeal(1:numgrids2d));
0104
0105
0106 md.penalties=[];
0107 if ~isnan(bordergrids2d),
0108 penalties=[];
0109 for i=1:numlayers,
0110 penalties=[penalties [bordergrids2d+md.numberofgrids2d*(i-1)]];
0111 end
0112 md.penalties=penalties;
0113 end
0114
0115
0116 nonmacayeal_el=find(~macayealflag);
0117 deadgrids=ones(md.numberofgrids,1);
0118 deadgrids(md.elements(nonmacayeal_el,:))=0;
0119 deadgrids(find(md.gridonbed))=0;
0120 md.deadgrids=deadgrids;
0121 end