plot_segmentonneumann

PURPOSE ^

PLOT_SEGMENTONNEUMANN - plot segment on neumann BC

SYNOPSIS ^

function plot_segmentonneumann(md,options_structure,width,i,datai);

DESCRIPTION ^

PLOT_SEGMENTONNEUMANN - plot segment on neumann BC

   Usage:
      plot_segmentonneumann(md,options_structure,width,i);

   See also: PLOTMODEL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plot_segmentonneumann(md,options_structure,width,i,datai);
0002 %PLOT_SEGMENTONNEUMANN - plot segment on neumann BC
0003 %
0004 %   Usage:
0005 %      plot_segmentonneumann(md,options_structure,width,i);
0006 %
0007 %   See also: PLOTMODEL
0008 
0009 %plot mesh boundaries
0010 subplot(width,width,i); 
0011 
0012 %units
0013 if ~isnan(options_structure.unitmultiplier),
0014     md.x=md.x*options_structure.unitmultiplier;
0015     md.y=md.y*options_structure.unitmultiplier;
0016     md.z=md.z*options_structure.unitmultiplier;
0017 end
0018 
0019 if strcmp(datai,'segmentonneumann_diag') segmentonneumann=md.segmentonneumann_diag;end
0020 if strcmp(datai,'segmentonneumann_prog') segmentonneumann=md.segmentonneumann_prog;end
0021 
0022 %we are dealing with the loads.
0023 length_icefront=sqrt( (md.x(segmentonneumann(:,1))-md.x(segmentonneumann(:,2))).^2 + (md.y(segmentonneumann(:,1))-md.y(segmentonneumann(:,2))).^2 );
0024 normal_icefront(:,1)=cos(atan2( (md.x(segmentonneumann(:,1))-md.x(segmentonneumann(:,2))) , (md.y(segmentonneumann(:,2))-md.y(segmentonneumann(:,1))) ) );
0025 normal_icefront(:,2)=sin(atan2( (md.x(segmentonneumann(:,1))-md.x(segmentonneumann(:,2))) , (md.y(segmentonneumann(:,2))-md.y(segmentonneumann(:,1))) ) );
0026 
0027 if strcmpi(md.type,'2d'),
0028     for n=1:size(segmentonneumann,1),
0029 
0030         plot(md.x(segmentonneumann(n,1:2)),md.y(segmentonneumann(n,1:2)),'b-','linewidth',2);
0031         hold on
0032         plot(md.x(segmentonneumann(n,1:2)),md.y(segmentonneumann(n,1:2)),'r.','markersize',12);
0033 
0034         xstart=mean(md.x(segmentonneumann(n,1:2)));
0035         ystart=mean(md.y(segmentonneumann(n,1:2)));
0036 
0037         xend=xstart+length_icefront(n)*normal_icefront(n,1);
0038         yend=ystart+length_icefront(n)*normal_icefront(n,2);
0039 
0040         plot([xstart xend],[ystart yend],'r-')
0041         legend('element edges on ice front','grids on ice front','normal vectors')
0042     end
0043 else
0044     for n=1:size(segmentonneumann,1),
0045         hold on
0046 
0047         %Plot the two triangles of each quad (element edges on ice front)
0048         A=segmentonneumann(n,1);  B=segmentonneumann(n,2); C=segmentonneumann(n,3); D=segmentonneumann(n,4); E=md.numberofgrids+1;
0049         coordinates= [md.x md.y md.z; mean(md.x(segmentonneumann(n,1:4))) mean(md.y(segmentonneumann(n,1:4))) mean(md.z(segmentonneumann(n,1:4)))];
0050         p1=patch( 'Faces', [A B E A], 'Vertices',coordinates,'FaceVertexCData', [1 1 1],'FaceColor','flat','EdgeColor','blue','linewidth',2);
0051         patch( 'Faces', [A D E A], 'Vertices',coordinates,'FaceVertexCData', [1 1 1],'FaceColor','flat','EdgeColor','blue','linewidth',2);
0052         patch( 'Faces', [D C E D], 'Vertices',coordinates,'FaceVertexCData', [1 1 1],'FaceColor','flat','EdgeColor','blue','linewidth',2);
0053         patch( 'Faces', [C B E C], 'Vertices',coordinates,'FaceVertexCData', [1 1 1],'FaceColor','flat','EdgeColor','blue','linewidth',2);
0054 
0055         %Plot the nodes of each quad (grids on ice front)
0056         p2=plot3(md.x(segmentonneumann(n,1:4)),md.y(segmentonneumann(n,1:4)),md.z(segmentonneumann(n,1:4)),'r.','markersize',12);
0057         plot3(coordinates(end,1),coordinates(end,2),coordinates(end,3),'g.','markersize',12);
0058 
0059         %Retrieve coordinates of the four nodes of the Quad
0060         xyz1=[md.x(segmentonneumann(n,1));md.y(segmentonneumann(n,1));md.z(segmentonneumann(n,1));];
0061         xyz2=[md.x(segmentonneumann(n,2));md.y(segmentonneumann(n,2));md.z(segmentonneumann(n,2));];
0062         xyz3=[md.x(segmentonneumann(n,3));md.y(segmentonneumann(n,3));md.z(segmentonneumann(n,3));];
0063         xyz4=[md.x(segmentonneumann(n,4));md.y(segmentonneumann(n,4));md.z(segmentonneumann(n,4));];
0064         xyz5=coordinates(end,:)';
0065         
0066         %Build the norms of each triangle
0067         V1=cross(xyz5-xyz1,xyz5-xyz2); normal1=1/norm(V1)*V1';
0068         V2=cross(xyz5-xyz2,xyz5-xyz3); normal2=1/norm(V2)*V2';
0069         V3=cross(xyz5-xyz3,xyz5-xyz4); normal3=1/norm(V3)*V3';
0070         V4=cross(xyz5-xyz4,xyz5-xyz1); normal4=1/norm(V4)*V4';
0071 
0072         xstart1=mean([xyz1(1) xyz2(1) xyz5(1)]); ystart1=mean([xyz1(2) xyz2(2) xyz5(2)]); zstart1=mean([xyz1(3) xyz2(3) xyz5(3)]);
0073         xstart2=mean([xyz2(1) xyz3(1) xyz5(1)]); ystart2=mean([xyz2(2) xyz3(2) xyz5(2)]); zstart2=mean([xyz2(3) xyz3(3) xyz5(3)]);
0074         xstart3=mean([xyz3(1) xyz4(1) xyz5(1)]); ystart3=mean([xyz3(2) xyz4(2) xyz5(2)]); zstart3=mean([xyz3(3) xyz4(3) xyz5(3)]);
0075         xstart4=mean([xyz4(1) xyz1(1) xyz5(1)]); ystart4=mean([xyz4(2) xyz1(2) xyz5(2)]); zstart4=mean([xyz4(3) xyz1(3) xyz5(3)]);
0076 
0077         xend1=xstart1+length_icefront(n)*normal1(1);    yend1=ystart1+length_icefront(n)*normal1(2);    zend1=zstart1+length_icefront(n)*normal1(3);
0078         xend2=xstart2+length_icefront(n)*normal2(1);    yend2=ystart2+length_icefront(n)*normal2(2);    zend2=zstart2+length_icefront(n)*normal2(3);
0079         xend3=xstart3+length_icefront(n)*normal3(1);    yend3=ystart3+length_icefront(n)*normal3(2);    zend3=zstart3+length_icefront(n)*normal3(3);
0080         xend4=xstart4+length_icefront(n)*normal4(1);    yend4=ystart4+length_icefront(n)*normal4(2);    zend4=zstart4+length_icefront(n)*normal4(3);
0081         
0082         %plot the normals of each triangle (normal vectors)
0083         p3=plot3([xstart1 xend1],[ystart1 yend1],[zstart1 zend1],'r-');
0084         plot3([xstart2 xend2],[ystart2 yend2],[zstart2 zend2],'r-');
0085         plot3([xstart3 xend3],[ystart3 yend3],[zstart3 zend3],'r-');
0086         plot3([xstart4 xend4],[ystart4 yend4],[zstart4 zend4],'r-');
0087 
0088     end
0089     legend([p1,p2,p3],'element edges on ice front','grids on ice front','normal vectors');
0090 end
0091 
0092 %apply options
0093 if isnan(options_structure.title)
0094     options_structure.title='Neumann boundary conditions';
0095 end 
0096 if isnan(options_structure.colorbar)
0097     options_structure.colorbar=0;
0098 end
0099 applyoptions(md,[],options_structure);

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003