ABSTRACT
function [S,T] = GLANT(Nn,Ne,n1L,n2L,n3L,xn,yn);
% Global Assembly two-dimensional node-based
% triangular elements
for e = 1:Ne;
n(1,e) = n1L(e);
n(2,e) = n2L(e);
n(3,e) = n3L(e);
end
% Initialization
S = zeros(Nn,Nn);
T = zeros(Nn,Nn);
% Loop through all elements
for e = 1: Ne;
% coordinates of the element nodes
for i = 1:3;
x(i) = xn(n(i,e));
y(i) = yn(n(i,e));
end
% compute the element matrix entries
b(1) = y(2) – y(3);
b(2) = y(3) – y(1);
b(3) = y(1) – y(2);
c(1) = x(3) – x(2);
c(2) = x(1) – x(3);
c(3) = x(2) – x(1);
Area = 0.5 * abs (b(2) * c(3) – b(3) * c(2));
% Compute the element matrix entries
for i = 1:3;
for j = 1:3;
Se(i,j) = (0.25/Area) * (b(i) * b(j) + c(i) * c(j));
if i == j
Te(i,j) = Area/6;
else
Te(i,j) = Area/12;
end
% Assemble the Element matrices into Global FEM System
S(n(i,e),n(j,e)) = S(n(i,e),n(j,e)) + Se(i,j);
T(n(i,e),n(j,e)) = T(n(i,e),n(j,e)) + Te(i,j);
end
end
end
252>> Ne = 2;
>> Nn = 4;
>> n1L =[1,2];
>> n2L =[2,3];
>> n3L =[4,4];
>> xn =[0.8,1.4,2.1,1.2];
>> yn =[1.8,1.4,2.1,2.7];
>> [S,T] = GLANT(Nn,Ne,n1L,n2L,n3L,xn,yn);
>> S
S =
1.2357 −0.7786 0 −0.4571
−0.7786 1.2500 −0.4571 −0.0143
0 −0.4571 0.8238 −0.3667
−0.4571 −0.0143 −0.3667 0.8381
>> T
T =
0.0583 0.0292 0 0.0292
0.0292 0.1458 0.0438 0.0729
0 0.0438 0.0875 0.0438
0.0292 0.0729 0.0438 0.1458
>> %frn: free node array
>> frn = [1,3];
>> %prn: prescribed node array
>> prn = [2,4];
>> %Vprn: potentials at the prescribed nodes
>> Vprn = [10,–10];
>> Sff = S(frn,frn)
Sff =
1.2357 0
0 0.8238
>> Sfp = S(frn,prn)
Sfp =
−0.7786 −0.4571
−0.4571 −0.3667
>> Vf = –inv(Sff)*Sfp*(Vprn)’
Vf =
2.6012
1.0983
>>