Revision 495
(checked in by cbc, 12 years ago)
|
Initial import of Stark code.
|
Line | |
---|
1 |
% DRAWELEMS draw 2-D FEM element configuration |
---|
2 |
% |
---|
3 |
% DRAWELEMS draws element boundries given a valid grid structure. |
---|
4 |
% |
---|
5 |
% INPUT : fem_grid_struct - (from LOADGRID, see FEM_GRID_STRUCT) |
---|
6 |
% |
---|
7 |
% OUTPUT : hel - handle to the element object. |
---|
8 |
% |
---|
9 |
% CALL : hel=drawelems(fem_grid_struct); |
---|
10 |
% |
---|
11 |
% Written by: Brian O. Blanton |
---|
12 |
% Summer 1997 |
---|
13 |
% |
---|
14 |
function hel=drawelems(fem_grid_struct) |
---|
15 |
|
---|
16 |
% DEFINE ERROR STRINGS |
---|
17 |
err1=['Not enough input arguments; need a fem_grid_struct']; |
---|
18 |
|
---|
19 |
% check arguments |
---|
20 |
if nargin ==0 |
---|
21 |
error(err1); |
---|
22 |
end |
---|
23 |
|
---|
24 |
if ~is_valid_struct(fem_grid_struct) |
---|
25 |
error(' Argument to DRAWELEMS must be a valid fem_grid_struct.') |
---|
26 |
end |
---|
27 |
|
---|
28 |
% Extract grid fields from fem_grid_struct |
---|
29 |
% |
---|
30 |
elems=fem_grid_struct.e; |
---|
31 |
% COPY FIRST COLUMN TO LAST TO CLOSE ELEMENTS |
---|
32 |
% |
---|
33 |
elems=elems(:,[1 2 3 1]); |
---|
34 |
x=fem_grid_struct.x; |
---|
35 |
y=fem_grid_struct.y; |
---|
36 |
|
---|
37 |
elems=elems'; |
---|
38 |
[m,n]=size(elems); |
---|
39 |
xt=x(elems); |
---|
40 |
yt=y(elems); |
---|
41 |
if n~=1 |
---|
42 |
if m>n |
---|
43 |
xt=reshape(xt,n,m); |
---|
44 |
yt=reshape(yt,n,m); |
---|
45 |
else |
---|
46 |
xt=reshape(xt,m,n); |
---|
47 |
yt=reshape(yt,m,n); |
---|
48 |
end |
---|
49 |
xt=[xt |
---|
50 |
NaN*ones(size(1:length(xt)))]; |
---|
51 |
yt=[yt |
---|
52 |
NaN*ones(size(1:length(yt)))]; |
---|
53 |
end |
---|
54 |
xt=xt(:); |
---|
55 |
yt=yt(:); |
---|
56 |
% |
---|
57 |
% DRAW GRID |
---|
58 |
% |
---|
59 |
hel=line(xt,yt,'LineWidth',1,'LineStyle','-','Color',[.8 .8 .8]); |
---|
60 |
set(hel,'Tag','elements'); |
---|
61 |
|
---|
62 |
% |
---|
63 |
% Brian O. Blanton |
---|
64 |
% Curr. in Marine Sciences |
---|
65 |
% 15-1A Venable Hall |
---|
66 |
% CB# 3300 |
---|
67 |
% Uni. of North Carolina |
---|
68 |
% Chapel Hill, NC |
---|
69 |
% 27599-3300 |
---|
70 |
% |
---|
71 |
% 919-962-4466 |
---|
72 |
% blanton@cuda.chem.unc.edu |
---|
73 |
% |
---|
74 |
% Summer 1997 |
---|
75 |
% |
---|