0% found this document useful (0 votes)
36 views1 page

Document 2

This document contains Matlab code that performs finite element analysis. It defines node coordinates and element connectivity arrays. It then assembles the stiffness matrix A and load vector b for the finite element system. Dirichlet boundary conditions are applied where specified. The linear system is solved for nodal solution values x, which are then used to plot the surface. Auxiliary functions u_D and B are defined to specify boundary conditions and calculate basis functions respectively.

Uploaded by

Thu Nguyen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Document 2

This document contains Matlab code that performs finite element analysis. It defines node coordinates and element connectivity arrays. It then assembles the stiffness matrix A and load vector b for the finite element system. Dirichlet boundary conditions are applied where specified. The linear system is solved for nodal solution values x, which are then used to plot the surface. Auxiliary functions u_D and B are defined to specify boundary conditions and calculate basis functions respectively.

Uploaded by

Thu Nguyen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

function P1FE1(epsilon)

c4n = [0 0;1 0;1 1;0 1]; n4e = [1 2 3;1 3 4];


Db = [2 3;3 4;4 1]; Nb = [1 2];
delta=0.000001;
%epsilon=0.00000001;
for j = 1 : 5
[c4n,n4e,Db,Nb] = red_refine(c4n,n4e,Db,Nb);
end
DiriNodes = unique(Db);
freeNodes = setdiff([1:size(c4n,1)],DiriNodes);
A = sparse(size(c4n,1),size(c4n,1));
b = sparse(size(c4n,1),1);
x = sparse(size(c4n,1),1);
for j = 1 : size(n4e,1)
grads_T = [1,1,1;c4n(n4e(j,:),:)'] \ [0,0;eye(2)];
area_T = det([1,1,1;c4n(n4e(j,:),:)'])/2;
mp_T = sum(c4n(n4e(j,:),:))/3;
delta_T = delta * area_T/ epsilon ;
for m = 1 : 3
for n = 1 : 3
A(n4e(j,m),n4e(j,n)) = A(n4e(j,m),n4e(j,n)) + ...
epsilon * area_T * grads_T(m,:) * grads_T(n,:)' + 1/3 * area_T * B(mp_T) * grads_T(n,:)' +...
delta_T * area_T * ( B(mp_T) * grads_T(m,:)') * ( B(mp_T) * grads_T(n,:)' ) ;
end
end
end
for j = 1 : size(DiriNodes,1)
x(DiriNodes(j)) = u_D(c4n(DiriNodes(j),:));
end
b = b - A * x;
x(freeNodes) = A(freeNodes,freeNodes) \ b(freeNodes);
trisurf(n4e,c4n(:,1),c4n(:,2),x);
function val = u_D(x)
val = 0;
if x(2)>=0 && x(2) <= 0.75 && x(1) == 0
val = 1;
end
function val = B(x)
val = [sin(atan(x(2)/x(1))),-cos(atan(x(2)/x(1)))];

You might also like