source: issm/oecreview/Archive/15392-16133/ISSM-15611-15612.diff@ 16134

Last change on this file since 16134 was 16134, checked in by Mathieu Morlighem, 12 years ago

Added Archive/15392-16133

File size: 5.3 KB
  • ../trunk-jpl/src/m/plot/plot_icefront.m

     
    1111
    1212%process mesh and data
    1313[x y z elements is2d isplanet]=processmesh(md,[],options);
    14 icefront=md.diagnostic.icefront;
     14ice=(md.mask.icelevelset>0);
     15noice=(md.mask.icelevelset<=0);
     16zeroice=(md.mask.icelevelset==0);
     17elementice=sum(ice(md.mesh.elements),2);
     18elementnoice=sum(noice(md.mesh.elements),2);
     19elementzeroice=sum(zeroice(md.mesh.elements),2);
     20icefront=(elementice & elementnoice) & ~(elementice==2 & elementzeroice);
    1521
    1622if (md.mesh.dimension==2),
    1723
     
    2127        hold on;
    2228
    2329        %highlight elements on neumann
    24         pos=find(icefront(:,end)==1);
    25         pos=icefront(pos,end-1);
     30        pos=find(icefront);
    2631        A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
    2732        h2=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    28         pos=find(icefront(:,end)==0);
    29         pos=icefront(pos,end-1);
    30         A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
    31         h3=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
     33        hold on;
    3234
    33         pos=find(icefront(:,end)==2);
    34         pos=icefront(pos,end-1);
    35         A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
    36         h3bis=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
     35        %Plot zero icelevelset line
    3736
    38         %display arrows pointing outward
    39         xstart=mean(x(icefront(:,1:end-2)),2);
    40         ystart=mean(y(icefront(:,1:end-2)),2);
    41         length=sqrt((x(icefront(:,1))-x(icefront(:,2))).^2 + (y(icefront(:,1))-y(icefront(:,2))).^2 );
    42         normal(:,1)=cos(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
    43         normal(:,2)=sin(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
    44         xend=xstart+length.*normal(:,1);
    45         yend=ystart+length.*normal(:,2);
    46         q=quiver(xstart,ystart,xend-xstart,yend-ystart); hold on;
    47         h4=plot(xstart,ystart,'r*');
     37
    4838else
    4939
    5040        %plot mesh
     
    5747        hold on;
    5848
    5949        %highlight elements on neumann
    60         pos=find(icefront(:,end)==1);
    61         pos=icefront(pos,end-1);
     50        pos=find(icefront);
    6251        A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
    6352        h2=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    6453        patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    6554        patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    6655        patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    6756        patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
    68         pos=find(icefront(:,end)==0);
    69         pos=icefront(pos,end-1);
    70         A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
    71         h3=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
    72         patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
    73         patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
    74         patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
    75         patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','green','EdgeColor','black');
    76         pos=find(icefront(:,end)==2);
    77         pos=icefront(pos,end-1);
    78         A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
    79         h3bis=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
    80         patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
    81         patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
    82         patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
    83         patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','cyan','EdgeColor','black');
    84 
    85         %display arrows pointing outward
    86         xstart=mean(x(icefront(:,1:end-2)),2);
    87         ystart=mean(y(icefront(:,1:end-2)),2);
    88         zstart=mean(z(icefront(:,1:end-2)),2);
    89         length=sqrt((x(icefront(:,1))-x(icefront(:,2))).^2 + (y(icefront(:,1))-y(icefront(:,2))).^2 );
    90         normal(:,1)=cos(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
    91         normal(:,2)=sin(atan2((x(icefront(:,1))-x(icefront(:,2))) , (y(icefront(:,2))-y(icefront(:,1)))));
    92         xend=xstart+length.*normal(:,1);
    93         yend=ystart+length.*normal(:,2);
    94         q=quiver3(xstart,ystart,zstart,xend-xstart,yend-ystart,zeros(numel(xstart),1)); hold on;
    95         h4=plot3(xstart,ystart,zstart,'r*');
    9657end
    9758
    9859%legend (disable warnings)
    9960warning off
    100 legend([h2,h3,h3bis,q],'element on ice front (Water)','element on ice front (Air)','element on ice front (Ice)','normal vectors')
     61legend([h2],'element on ice front')
    10162warning on
    10263
    10364%apply options
Note: See TracBrowser for help on using the repository browser.