1 |
function showelem(fem_grid_struct,ie) |
---|
2 |
%SHOWELEM highlight and display statistics on selected element |
---|
3 |
% |
---|
4 |
% SHOWELEM highlights a user-specified element, either |
---|
5 |
% by mouse-click or by giving SHOWELEM an element number. |
---|
6 |
% The mesh must have been previously drawn by the OPNML/MATLAB |
---|
7 |
% routine DRAWELEMS for SHOWELEM to work. |
---|
8 |
% |
---|
9 |
% INPUT : fem_grid_struct - (from LOADGRID, see FEM_GRID_STRUCT) |
---|
10 |
% ie - element to highlight (OPT) |
---|
11 |
% If ie is not provided, SHOWELEM prompts the user to |
---|
12 |
% click on the FEM element drawing to specify an element. |
---|
13 |
% |
---|
14 |
% OUTPUTS : NONE (display to figure) |
---|
15 |
% |
---|
16 |
% CALL : >> showelem(fem_grid_struct,ie) |
---|
17 |
% or |
---|
18 |
% >> showelem(fem_grid_struct) |
---|
19 |
% |
---|
20 |
% Written by : Brian O. Blanton |
---|
21 |
% Fall 1997 |
---|
22 |
% |
---|
23 |
|
---|
24 |
% VERIFY INCOMING STRUCTURE |
---|
25 |
% |
---|
26 |
if ~is_valid_struct(fem_grid_struct) |
---|
27 |
error(' fem_grid_struct to SHOWELEM invalid.') |
---|
28 |
end |
---|
29 |
|
---|
30 |
|
---|
31 |
% determine if "drawelems" has been used to draw element picture |
---|
32 |
if isempty(findobj(gca,'Type','line','Tag','elements')) |
---|
33 |
disp('SHOWELEM will only work if DRAWELEMS drew the element picture'); |
---|
34 |
error; |
---|
35 |
end |
---|
36 |
|
---|
37 |
if ~exist('ie') |
---|
38 |
ie=findelem(fem_grid_struct); |
---|
39 |
end |
---|
40 |
|
---|
41 |
if ie==0,return,end |
---|
42 |
|
---|
43 |
currfig=gcf; |
---|
44 |
|
---|
45 |
x=fem_grid_struct.x; |
---|
46 |
y=fem_grid_struct.y; |
---|
47 |
e=fem_grid_struct.e; |
---|
48 |
z=fem_grid_struct.z; |
---|
49 |
|
---|
50 |
xc=(x(e(ie,1))+x(e(ie,2))+x(e(ie,3)))/3; |
---|
51 |
yc=(y(e(ie,1))+y(e(ie,2))+y(e(ie,3)))/3; |
---|
52 |
xe=[x(e(ie,1)) x(e(ie,2)) x(e(ie,3)) x(e(ie,1))]; |
---|
53 |
ye=[y(e(ie,1)) y(e(ie,2)) y(e(ie,3)) y(e(ie,1))]; |
---|
54 |
patch(xe,ye,'r'); |
---|
55 |
text(xc,yc,num2str(ie,6),'Color','g','HorizontalAlignment','Center'); |
---|
56 |
|
---|
57 |
|
---|
58 |
delete(findobj(0,'Type','figure','Tag','Element Info Fig')); |
---|
59 |
shfig=figure('Units','inches',... |
---|
60 |
'Position',[7 7 4 3],... |
---|
61 |
'NumberTitle','off',... |
---|
62 |
'Name',['Element ' int2str(ie) ' Information'],... |
---|
63 |
'Tag','Element Info Fig'); |
---|
64 |
set(shfig,'Units','Normalized'); |
---|
65 |
shax=axes('Position',[.1 .1 .8 .8],'Xlim',[-0.5 4.5],'Ylim',[-2.5 1.5]); |
---|
66 |
set(shax,'Visible','off'); |
---|
67 |
set(shax,'Box','on'); |
---|
68 |
xe=(xe-min(xe)); |
---|
69 |
xe=xe/max(xe); |
---|
70 |
ye=(ye-min(ye)); |
---|
71 |
ye=ye/max(ye); |
---|
72 |
line(xe,ye); |
---|
73 |
patch(xe,ye,'r'); |
---|
74 |
text(xe(1),ye(1),int2str(e(ie,1)),... |
---|
75 |
'HorizontalAlignment','Center','Color','g'); |
---|
76 |
text(xe(2),ye(2),int2str(e(ie,2)),... |
---|
77 |
'HorizontalAlignment','Center','Color','g'); |
---|
78 |
text(xe(3),ye(3),int2str(e(ie,3)),... |
---|
79 |
'HorizontalAlignment','Center','Color','g'); |
---|
80 |
|
---|
81 |
n1=e(ie,1); |
---|
82 |
n2=e(ie,2); |
---|
83 |
n3=e(ie,3); |
---|
84 |
|
---|
85 |
text(1.75,1.,['Nodes : ' int2str(n1) ]); |
---|
86 |
text(1.75,.7,[' ' int2str(n2)]) |
---|
87 |
text(1.75,.4,[' ' int2str(n3)]) |
---|
88 |
|
---|
89 |
text(-.5,-.5,['X = { ' num2str(x(n1)) ' ' num2str(x(n2)) ' ' num2str(x(n3)) ... |
---|
90 |
' }']) |
---|
91 |
text(-.5,-1.,['Y = { ' num2str(y(n1)) ' ' num2str(y(n2)) ' ' num2str(y(n3)) ... |
---|
92 |
' }']) |
---|
93 |
|
---|
94 |
if exist('z') |
---|
95 |
text(-.5,-1.5,['Z = { ' num2str(z(n1)) ' ' num2str(z(n2)) ' ' ... |
---|
96 |
num2str(z(n3)) ' }']) |
---|
97 |
end |
---|
98 |
|
---|
99 |
if ~isempty(fem_grid_struct.ar) |
---|
100 |
dy1=y(n2)-y(n3); |
---|
101 |
dy2=y(n3)-y(n1); |
---|
102 |
dy3=y(n1)-y(n2); |
---|
103 |
area=0.5d0*(x(n1)*dy1 + x(n2)*dy2 + x(n3)*dy3) |
---|
104 |
text(1.75,0,['Area = ' num2str(area)]) |
---|
105 |
end |
---|
106 |
|
---|
107 |
figure(currfig); |
---|
108 |
% |
---|
109 |
% Brian O. Blanton |
---|
110 |
% Department of Marine Sciences |
---|
111 |
% 15-1A Venable Hall |
---|
112 |
% CB# 3300 |
---|
113 |
% Uni. of North Carolina |
---|
114 |
% Chapel Hill, NC |
---|
115 |
% 27599-3300 |
---|
116 |
% |
---|
117 |
% 919-962-4466 |
---|
118 |
% blanton@marine.unc.edu |
---|
119 |
% |
---|
120 |
% Fall 1997 |
---|
121 |
|
---|