-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawElement.m
114 lines (93 loc) · 3.94 KB
/
drawElement.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function drawElement(coordmat, elementmat, flag_text)
% HAKAI - A 3-dimensional finite element program
% Copyright (c) 2024 Yozo Yugen
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see http://www.gnu.org/licenses/.
coordmat = coordmat'; % row major
elementmat = elementmat'; % row major
figure
nNode = size(coordmat,1);
%plot3(coordmat(:,1), coordmat(:,2), coordmat(:,3), 'bo' );
xlabel('X');
ylabel('Y');
zlabel('Z');
axis equal;
hold on;
if flag_text == 1
plot3(coordmat(:,1), coordmat(:,2), coordmat(:,3), 'bo' );
for i = 1 : nNode
text(coordmat(i,1), coordmat(i,2), coordmat(i,3), sprintf('#%d', i) );
end
end
nElement = size(elementmat,1);
nEN = size(elementmat,2);
drawMat1x = zeros(5,nElement*2);
drawMat1y = zeros(5,nElement*2);
drawMat1z = zeros(5,nElement*2);
drawMat2x = zeros(2,nElement*4);
drawMat2y = zeros(2,nElement*4);
drawMat2z = zeros(2,nElement*4);
if nEN == 8
% for i = 1 : nElement
% nd = elementmat(i,:);
% ii = nd([1 2 3 4 1]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color', 'b' )
% ii = nd([5 6 7 8 5]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color','b' )
% ii = nd([1 5]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color','b' )
% ii = nd([2 6]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color','b' )
% ii = nd([3 7]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color','b' )
% ii = nd([4 8]);
% line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color','b' )
% end
for i = 1 : nElement
nd = elementmat(i,:);
ii = nd([1 2 3 4 1]);
drawMat1x(:,i*2-1) = coordmat(ii,1);
drawMat1y(:,i*2-1) = coordmat(ii,2);
drawMat1z(:,i*2-1) = coordmat(ii,3);
ii = nd([5 6 7 8 5]);
drawMat1x(:,i*2) = coordmat(ii,1);
drawMat1y(:,i*2) = coordmat(ii,2);
drawMat1z(:,i*2) = coordmat(ii,3);
ii = nd([1 5]);
drawMat2x(:,i*4-3) = coordmat(ii,1);
drawMat2y(:,i*4-3) = coordmat(ii,2);
drawMat2z(:,i*4-3) = coordmat(ii,3);
ii = nd([2 6]);
drawMat2x(:,i*4-2) = coordmat(ii,1);
drawMat2y(:,i*4-2) = coordmat(ii,2);
drawMat2z(:,i*4-2) = coordmat(ii,3);
ii = nd([3 7]);
drawMat2x(:,i*4-1) = coordmat(ii,1);
drawMat2y(:,i*4-1) = coordmat(ii,2);
drawMat2z(:,i*4-1) = coordmat(ii,3);
ii = nd([4 8]);
drawMat2x(:,i*4) = coordmat(ii,1);
drawMat2y(:,i*4) = coordmat(ii,2);
drawMat2z(:,i*4) = coordmat(ii,3);
end
line( drawMat1x, drawMat1y, drawMat1z, 'color', 'b' )
line( drawMat2x, drawMat2y, drawMat2z, 'color', 'b' )
elseif nEN == 4
for i = 1 : nElement
nd = elementmat(i,:);
ii = nd([1 2 3 4 1]);
line( coordmat( ii,1), coordmat( ii,2), coordmat( ii,3), 'color', 'b' )
end
end
end