Ignore:
Timestamp:
12/09/11 20:36:51 (13 years ago)
Author:
Eric.Larour
Message:

merged trunk-jpl and trunk for revision 11026

Location:
issm/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src/m/model/setflowequation.m

    r9733 r11027  
    6767end
    6868
    69 %add in model who is who
    70 md.flowequation.element_equation=zeros(md.mesh.numberofelements,1);
    71 
    72 %1: Hutter elements
     69%Initialize node fields
    7370nodeonhutter=zeros(md.mesh.numberofvertices,1);
    7471nodeonhutter(md.mesh.elements(find(hutterflag),:))=1;
    75 md.flowequation.element_equation(find(hutterflag))=1;
    76 
    77 %2: MacAyeal elements
    7872nodeonmacayeal=zeros(md.mesh.numberofvertices,1);
    7973nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
    80 md.flowequation.bordermacayeal=nodeonmacayeal;
    81 md.flowequation.element_equation(find(macayealflag))=2;
    82 
    83 %3: Pattyn elements
    8474nodeonpattyn=zeros(md.mesh.numberofvertices,1);
    8575nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
    86 md.flowequation.borderpattyn=nodeonpattyn;
    87 md.flowequation.element_equation(find(pattynflag))=3;
    88 
    89 %4: Stokes elements
     76nodeonstokes=zeros(md.mesh.numberofvertices,1);
     77noneflag=zeros(md.mesh.numberofelements,1);
     78
    9079%First modify stokesflag to get rid of elements contrained everywhere (spc + border with pattyn or macayeal)
    9180if any(stokesflag),
    92         nodeonstokes=zeros(md.mesh.numberofvertices,1);
    93         nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
    9481        fullspcnodes=double((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy)+~isnan(md.diagnostic.spcvz))==3 | (nodeonpattyn & nodeonstokes));         %find all the nodes on the boundary of the domain without icefront
    9582        fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6);         %find all the nodes on the boundary of the domain without icefront
    9683        stokesflag(find(fullspcelems))=0;
    97 end
    98 nodeonstokes=zeros(md.mesh.numberofvertices,1);
    99 nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
    100 md.flowequation.borderstokes=nodeonstokes;
    101 md.flowequation.element_equation(find(stokesflag))=4;
     84        nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
     85end
    10286
    10387%Then complete with NoneApproximation or the other model used if there is no stokes
     
    10690                pattynflag(~stokesflag)=1;
    10791                nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
    108                 md.flowequation.borderpattyn=nodeonpattyn;
    109                 md.flowequation.element_equation(find(~stokesflag))=3;
    11092        elseif any(macayealflag), %fill with macayeal
    11193                macayealflag(~stokesflag)=1;
    11294                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
    113                 md.flowequation.bordermacayeal=nodeonmacayeal;
    114                 md.flowequation.element_equation(find(~stokesflag))=2;
    11595        else %fill with none
    116         %5: None elements (non Stokes)
    117                 md.flowequation.element_equation(find(~stokesflag))=0;
     96                noneflag(find(~stokesflag))=1;
    11897        end
    11998end
     
    124103nodeonpattynstokes=zeros(md.mesh.numberofvertices,1);
    125104nodeonmacayealstokes=zeros(md.mesh.numberofvertices,1);
     105macayealpattynflag=zeros(md.mesh.numberofelements,1);
     106macayealstokesflag=zeros(md.mesh.numberofelements,1);
     107pattynstokesflag=zeros(md.mesh.numberofelements,1);
    126108if strcmpi(coupling_method,'penalties'),
    127109        %Create the border nodes between Pattyn and MacAyeal and extrude them
     
    147129                commonelements(find(pattynflag))=0; %only one layer: the elements previously in macayeal
    148130                macayealflag(find(commonelements))=0; %these elements are now macayealpattynelements
    149                 macayealpattynflag=zeros(md.mesh.numberofelements,1);
    150131                macayealpattynflag(find(commonelements))=1;
    151                 nodeonmacayeal=zeros(md.mesh.numberofvertices,1);
    152                 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
     132                nodeonmacayeal(:)=0;
     133                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
     134
     135                %rule out elements that don't touch the 2 boundaries
     136                pos=find(macayealpattynflag);
     137                list=zeros(length(pos),1);
     138                list = list + any(sum(nodeonmacayeal(md.mesh.elements(pos,:)),2),2);
     139                list = list - any(sum(nodeonpattyn(md.mesh.elements(pos,:))  ,2),2);
     140                pos1=find(list==1);
     141                macayealflag(pos(pos1))=1;
     142                macayealpattynflag(pos(pos1))=0;
     143                pos2=find(list==-1);
     144                pattynflag(pos(pos2))=1;
     145                macayealpattynflag(pos(pos2))=0;
     146
     147                %Recompute nodes associated to these elements
     148                nodeonmacayeal(:)=0;
     149                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
     150                nodeonpattyn(:)=0;
     151                nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
     152                nodeonmacayealpattyn(:)=0;
    159153                nodeonmacayealpattyn(md.mesh.elements(find(macayealpattynflag),:))=1;
     154
    160155        elseif any(pattynflag) & any(stokesflag), %coupling pattyn stokes
    161156                %Find node at the border
     
    166161                commonelements(find(pattynflag))=0; %only one layer: the elements previously in macayeal
    167162                stokesflag(find(commonelements))=0; %these elements are now macayealpattynelements
    168                 pattynstokesflag=zeros(md.mesh.numberofelements,1);
    169163                pattynstokesflag(find(commonelements))=1;
    170164                nodeonstokes=zeros(md.mesh.numberofvertices,1);
    171165                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;
    176 
    177                 %Now recreate nodeonpattynstokes
    178                 nodeonpattynstokes=zeros(md.mesh.numberofvertices,1);
     166
     167                %rule out elements that don't touch the 2 boundaries
     168                pos=find(pattynstokesflag);
     169                list=zeros(length(pos),1);
     170                list = list + any(sum(nodeonstokes(md.mesh.elements(pos,:)),2),2);
     171                list = list - any(sum(nodeonpattyn(md.mesh.elements(pos,:)),2),2);
     172                pos1=find(list==1);
     173                stokesflag(pos(pos1))=1;
     174                pattynstokesflag(pos(pos1))=0;
     175                pos2=find(list==-1);
     176                pattynflag(pos(pos2))=1;
     177                pattynstokesflag(pos(pos2))=0;
     178
     179                %Recompute nodes associated to these elements
     180                nodeonstokes(:)=0;
     181                nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
     182                nodeonpattyn(:)=0;
     183                nodeonpattyn(md.mesh.elements(find(pattynflag),:))=1;
     184                nodeonpattynstokes(:)=0;
    179185                nodeonpattynstokes(md.mesh.elements(find(pattynstokesflag),:))=1;
     186
    180187        elseif any(stokesflag) & any(macayealflag),
    181188                %Find node at the border
     
    186193                commonelements(find(macayealflag))=0; %only one layer: the elements previously in macayeal
    187194                stokesflag(find(commonelements))=0; %these elements are now macayealmacayealelements
    188                 macayealstokesflag=zeros(md.mesh.numberofelements,1);
    189195                macayealstokesflag(find(commonelements))=1;
    190196                nodeonstokes=zeros(md.mesh.numberofvertices,1);
    191197                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;
    196 
    197                 %Now recreate nodeonmacayealstokes
    198                 nodeonmacayealstokes=zeros(md.mesh.numberofvertices,1);
     198
     199                %rule out elements that don't touch the 2 boundaries
     200                pos=find(macayealstokesflag);
     201                list=zeros(length(pos),1);
     202                list = list + any(sum(nodeonmacayeal(md.mesh.elements(pos,:)),2),2);
     203                list = list - any(sum(nodeonstokes(md.mesh.elements(pos,:))  ,2),2);
     204                pos1=find(list==1);
     205                macayealflag(pos(pos1))=1;
     206                macayealstokesflag(pos(pos1))=0;
     207                pos2=find(list==-1);
     208                stokesflag(pos(pos2))=1;
     209                macayealstokesflag(pos(pos2))=0;
     210
     211                %Recompute nodes associated to these elements
     212                nodeonmacayeal(:)=0;
     213                nodeonmacayeal(md.mesh.elements(find(macayealflag),:))=1;
     214                nodeonstokes(:)=0;
     215                nodeonstokes(md.mesh.elements(find(stokesflag),:))=1;
     216                nodeonmacayealstokes(:)=0;
    199217                nodeonmacayealstokes(md.mesh.elements(find(macayealstokesflag),:))=1;
     218
    200219        elseif any(stokesflag) & any(hutterflag),
    201220                error('type of coupling not supported yet');
    202221        end
    203222end
     223
     224%Create MacaAyealPattynApproximation where needed
     225md.flowequation.element_equation=zeros(md.mesh.numberofelements,1);
     226md.flowequation.element_equation(find(noneflag))=0;
     227md.flowequation.element_equation(find(hutterflag))=1;
     228md.flowequation.element_equation(find(macayealflag))=2;
     229md.flowequation.element_equation(find(pattynflag))=3;
     230md.flowequation.element_equation(find(stokesflag))=4;
     231md.flowequation.element_equation(find(macayealpattynflag))=5;
     232md.flowequation.element_equation(find(macayealstokesflag))=6;
     233md.flowequation.element_equation(find(pattynstokesflag))=7;
     234
     235%border
     236md.flowequation.borderpattyn=nodeonpattyn;
     237md.flowequation.bordermacayeal=nodeonmacayeal;
     238md.flowequation.borderstokes=nodeonstokes;
    204239
    205240%Create vertices_type
     
    213248pos=find(nodeonhutter);
    214249md.flowequation.vertex_equation(pos)=1;
    215 pos=find(nodeonpattyn & nodeonmacayeal);
    216 md.flowequation.vertex_equation(pos)=3;
    217250pos=find(nodeonmacayealpattyn);
    218251md.flowequation.vertex_equation(pos)=5;
     
    235268md.flowequation.isstokes=double(any(md.flowequation.element_equation==4));
    236269
    237 end
     270return
     271
     272%Check that tiling can work:
     273if any(md.flowequation.bordermacayeal) & any(md.flowequation.borderpattyn) & any(md.flowequation.borderpattyn + md.flowequation.bordermacayeal ~=1),
     274        error('error coupling domain too irregular');
     275end
     276if any(md.flowequation.bordermacayeal) & any(md.flowequation.borderstokes) & any(md.flowequation.borderstokes + md.flowequation.bordermacayeal ~=1),
     277        error('error coupling domain too irregular');
     278end
     279if any(md.flowequation.borderstokes) & any(md.flowequation.borderpattyn) & any(md.flowequation.borderpattyn + md.flowequation.borderstokes~=1),
     280        error('error coupling domain too irregular');
     281end
Note: See TracChangeset for help on using the changeset viewer.