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

Last change on this file since 13009 was 13009, checked in by Mathieu Morlighem, 13 years ago

CHG: moved mode/* to src/m

File size: 5.7 KB
Line 
1function plot_icefront(md,options,width,i,data);
2%PLOT_ICEFRONT - plot segment on neumann BC
3%
4% Usage:
5% plot_icefront(md,options,width,i);
6%
7% See also: PLOTMODEL
8
9%plot mesh boundaries
10subplot(width,width,i);
11
12%process mesh and data
13[x y z elements is2d isplanet]=processmesh(md,[],options);
14icefront=md.diagnostic.icefront;
15
16if (md.mesh.dimension==2),
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
23 %highlight elements on neumann
24 pos=find(icefront(:,end)==1);
25 pos=icefront(pos,end-1);
26 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
27 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');
32
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');
37
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*');
48else
49
50 %plot mesh
51 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
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');
57 hold on;
58
59 %highlight elements on neumann
60 pos=find(icefront(:,end)==1);
61 pos=icefront(pos,end-1);
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);
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');
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*');
96end
97
98%legend (disable warnings)
99warning off
100legend([h2,h3,h3bis,q],'element on ice front (Water)','element on ice front (Air)','element on ice front (Ice)','normal vectors')
101warning on
102
103%apply options
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.