source: issm/trunk-jpl/src/m/plot/plot_icefront.m@ 13730

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

CHG: per matlab's request, removed all unnecessary semicolon

File size: 5.7 KB
RevLine 
[13730]1function plot_icefront(md,options,width,i,data)
[11249]2%PLOT_ICEFRONT - plot segment on neumann BC
[1758]3%
4% Usage:
[11249]5% plot_icefront(md,options,width,i);
[1758]6%
7% See also: PLOTMODEL
8
9%plot mesh boundaries
10subplot(width,width,i);
11
12%process mesh and data
[8472]13[x y z elements is2d isplanet]=processmesh(md,[],options);
[11249]14icefront=md.diagnostic.icefront;
[1758]15
[9719]16if (md.mesh.dimension==2),
[1758]17
18 %plot mesh
19 A=elements(:,1); B=elements(:,2); C=elements(:,3);
20 h1=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
21 hold on;
22
[3103]23 %highlight elements on neumann
[11249]24 pos=find(icefront(:,end)==1);
25 pos=icefront(pos,end-1);
[1758]26 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
[3103]27 h2=patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
[11249]28 pos=find(icefront(:,end)==0);
29 pos=icefront(pos,end-1);
[3103]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');
[1758]32
[11249]33 pos=find(icefront(:,end)==2);
34 pos=icefront(pos,end-1);
[7315]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');
37
[1758]38 %display arrows pointing outward
[11249]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)))));
[1758]44 xend=xstart+length.*normal(:,1);
45 yend=ystart+length.*normal(:,2);
46 q=quiver(xstart,ystart,xend-xstart,yend-ystart); hold on;
[3103]47 h4=plot(xstart,ystart,'r*');
[1758]48else
49
50 %plot mesh
51 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
[5617]52 h1=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
53 patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
54 patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
55 patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
56 patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
[1758]57 hold on;
58
[3103]59 %highlight elements on neumann
[11249]60 pos=find(icefront(:,end)==1);
61 pos=icefront(pos,end-1);
[1758]62 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
[5617]63 h2=patch( 'Faces', [A B C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
64 patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
65 patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
66 patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
67 patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','blue','EdgeColor','black');
[11249]68 pos=find(icefront(:,end)==0);
69 pos=icefront(pos,end-1);
[3103]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);
[5617]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');
[11249]76 pos=find(icefront(:,end)==2);
77 pos=icefront(pos,end-1);
[7315]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');
[1758]84
85 %display arrows pointing outward
[11249]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)))));
[1758]92 xend=xstart+length.*normal(:,1);
93 yend=ystart+length.*normal(:,2);
[7545]94 q=quiver3(xstart,ystart,zstart,xend-xstart,yend-ystart,zeros(numel(xstart),1)); hold on;
[3235]95 h4=plot3(xstart,ystart,zstart,'r*');
[1758]96end
97
[2513]98%legend (disable warnings)
99warning off
[7315]100legend([h2,h3,h3bis,q],'element on ice front (Water)','element on ice front (Air)','element on ice front (Ice)','normal vectors')
[2513]101warning on
[1758]102
103%apply options
[2439]104options=addfielddefault(options,'title','Neumann boundary conditions');
105options=addfielddefault(options,'colorbar',0);
106applyoptions(md,[],options);
Note: See TracBrowser for help on using the repository browser.