Changeset 11003


Ignore:
Timestamp:
12/01/11 14:03:21 (13 years ago)
Author:
Mathieu Morlighem
Message:

cleaning up setflowequations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/model/setflowequation.m

    r9733 r11003  
    6767end
    6868
    69 %add in model who is who
    70 md.flowequation.element_equation=zeros(md.mesh.numberofelements,1);
    71 
    7269%1: Hutter elements
    7370nodeonhutter=zeros(md.mesh.numberofvertices,1);
    7471nodeonhutter(md.mesh.elements(find(hutterflag),:))=1;
    75 md.flowequation.element_equation(find(hutterflag))=1;
    7672
    7773%2: MacAyeal elements
    7874nodeonmacayeal=zeros(md.mesh.numberofvertices,1);
    7975nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
    80 md.flowequation.bordermacayeal=nodeonmacayeal;
    81 md.flowequation.element_equation(find(macayealflag))=2;
    8276
    8377%3: Pattyn elements
    8478nodeonpattyn=zeros(md.mesh.numberofvertices,1);
    8579nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
    86 md.flowequation.borderpattyn=nodeonpattyn;
    87 md.flowequation.element_equation(find(pattynflag))=3;
    8880
    8981%4: Stokes elements
     
    9890nodeonstokes=zeros(md.mesh.numberofvertices,1);
    9991nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
    100 md.flowequation.borderstokes=nodeonstokes;
    101 md.flowequation.element_equation(find(stokesflag))=4;
     92
     93%5: None elements
     94noneflag=zeros(md.mesh.numberofelements,1);
    10295
    10396%Then complete with NoneApproximation or the other model used if there is no stokes
     
    10699                pattynflag(~stokesflag)=1;
    107100                nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
    108                 md.flowequation.borderpattyn=nodeonpattyn;
    109                 md.flowequation.element_equation(find(~stokesflag))=3;
    110101        elseif any(macayealflag), %fill with macayeal
    111102                macayealflag(~stokesflag)=1;
    112103                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
    113                 md.flowequation.bordermacayeal=nodeonmacayeal;
    114                 md.flowequation.element_equation(find(~stokesflag))=2;
    115104        else %fill with none
    116         %5: None elements (non Stokes)
    117                 md.flowequation.element_equation(find(~stokesflag))=0;
     105                noneflag(find(~stokesflag))=1;
    118106        end
    119107end
     
    124112nodeonpattynstokes=zeros(md.mesh.numberofvertices,1);
    125113nodeonmacayealstokes=zeros(md.mesh.numberofvertices,1);
     114macayealpattynflag=zeros(md.mesh.numberofelements,1);
     115macayealstokesflag=zeros(md.mesh.numberofelements,1);
     116pattynstokesflag=zeros(md.mesh.numberofelements,1);
    126117if strcmpi(coupling_method,'penalties'),
    127118        %Create the border nodes between Pattyn and MacAyeal and extrude them
     
    147138                commonelements(find(pattynflag))=0; %only one layer: the elements previously in macayeal
    148139                macayealflag(find(commonelements))=0; %these elements are now macayealpattynelements
    149                 macayealpattynflag=zeros(md.mesh.numberofelements,1);
    150140                macayealpattynflag(find(commonelements))=1;
    151141                nodeonmacayeal=zeros(md.mesh.numberofvertices,1);
    152142                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
    153                 md.flowequation.bordermacayeal=nodeonmacayeal;
    154 
    155                 %Create MacaAyealPattynApproximation where needed
    156                 md.flowequation.element_equation(find(macayealpattynflag))=5;
    157 
    158                 %Now recreate nodeonmacayeal and nodeonmacayealpattyn
     143
     144                %rule out elements that don't touch the 2 boundaries
     145                pos=find(macayealpattynflag);
     146                list=zeros(length(pos),1);
     147                list = list + any(sum(nodeonmacayeal(md.mesh.elements(pos,:)),2),2);
     148                list = list - any(sum(nodeonpattyn(md.mesh.elements(pos,:))  ,2),2);
     149                pos1=find(list==1);
     150                pattynflag(pos(pos1))=0;
     151                macayealflag(pos(pos1))=1;
     152                macayealpattynflag(pos(pos1))=0;
     153                pos2=find(list==-1);
     154                pattynflag(pos(pos2))=1;
     155                macayealflag(pos(pos2))=0;
     156                macayealpattynflag(pos(pos2))=0;
     157
     158                nodeonmacayeal(:)=0;
     159                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
     160                nodeonpattyn(:)=0;
     161                nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
     162                nodeonmacayealpattyn(:)=0;
    159163                nodeonmacayealpattyn(md.mesh.elements(find(macayealpattynflag),:))=1;
     164
    160165        elseif any(pattynflag) & any(stokesflag), %coupling pattyn stokes
    161166                %Find node at the border
     
    166171                commonelements(find(pattynflag))=0; %only one layer: the elements previously in macayeal
    167172                stokesflag(find(commonelements))=0; %these elements are now macayealpattynelements
    168                 pattynstokesflag=zeros(md.mesh.numberofelements,1);
    169173                pattynstokesflag(find(commonelements))=1;
    170174                nodeonstokes=zeros(md.mesh.numberofvertices,1);
    171175                nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
    172                 md.flowequation.borderstokes=nodeonstokes;
    173 
    174                 %Create MacaAyealPattynApproximation where needed
    175                 md.flowequation.element_equation(find(pattynstokesflag))=7;
    176176
    177177                %Now recreate nodeonpattynstokes
     
    186186                commonelements(find(macayealflag))=0; %only one layer: the elements previously in macayeal
    187187                stokesflag(find(commonelements))=0; %these elements are now macayealmacayealelements
    188                 macayealstokesflag=zeros(md.mesh.numberofelements,1);
    189188                macayealstokesflag(find(commonelements))=1;
    190189                nodeonstokes=zeros(md.mesh.numberofvertices,1);
    191190                nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
    192                 md.flowequation.borderstokes=nodeonstokes;
    193 
    194                 %Create MacaAyeal Approximation where needed
    195                 md.flowequation.element_equation(find(macayealstokesflag))=6;
    196191
    197192                %Now recreate nodeonmacayealstokes
     
    202197        end
    203198end
     199
     200%Create MacaAyealPattynApproximation where needed
     201md.flowequation.element_equation=zeros(md.mesh.numberofelements,1);
     202md.flowequation.element_equation(find(noneflag))=0;
     203md.flowequation.element_equation(find(hutterflag))=1;
     204md.flowequation.element_equation(find(macayealflag))=2;
     205md.flowequation.element_equation(find(pattynflag))=3;
     206md.flowequation.element_equation(find(stokesflag))=4;
     207md.flowequation.element_equation(find(macayealpattynflag))=5;
     208md.flowequation.element_equation(find(macayealstokesflag))=6;
     209md.flowequation.element_equation(find(pattynstokesflag))=7;
     210
     211%border
     212md.flowequation.borderpattyn=nodeonpattyn;
     213md.flowequation.bordermacayeal=nodeonmacayeal;
     214md.flowequation.borderstokes=nodeonstokes;
    204215
    205216%Create vertices_type
     
    213224pos=find(nodeonhutter);
    214225md.flowequation.vertex_equation(pos)=1;
    215 pos=find(nodeonpattyn & nodeonmacayeal);
    216 md.flowequation.vertex_equation(pos)=3;
    217226pos=find(nodeonmacayealpattyn);
    218227md.flowequation.vertex_equation(pos)=5;
     
    235244md.flowequation.isstokes=double(any(md.flowequation.element_equation==4));
    236245
    237 end
     246return
     247
     248%Check that tiling can work:
     249if any(md.flowequation.bordermacayeal) & any(md.flowequation.borderpattyn) & any(md.flowequation.borderpattyn + md.flowequation.bordermacayeal ~=1),
     250        error('error coupling domain too irregular');
     251end
     252if any(md.flowequation.bordermacayeal) & any(md.flowequation.borderstokes) & any(md.flowequation.borderstokes + md.flowequation.bordermacayeal ~=1),
     253        error('error coupling domain too irregular');
     254end
     255if any(md.flowequation.borderstokes) & any(md.flowequation.borderpattyn) & any(md.flowequation.borderpattyn + md.flowequation.borderstokes~=1),
     256        error('error coupling domain too irregular');
     257end
Note: See TracChangeset for help on using the changeset viewer.