Вы находитесь на странице: 1из 58

Universitat de Girona

INTRODUCTION TO FINITE ELEMENT


METHOD
Examples and Problems
A. Turon, D. Trias
September 2010
This document can be found at:
ftp://amade.udg.edu/amade/mme/FEmet/FEmet.pdf
Contents
1 Direct stiffness method 1
2 Strong form and weak form of Poissons equation 7
3 Bidimensional problems. Formulation of 2-D solid elements 17
4 Iso-parametric formulation of 2-D solid elements 25
5 Numerical Integration, Stress Recovery and Error Estimation 35
6 Formulation of 3-D solid elements 43
7 Axysimetric problems 47
8 Beam element formulation 49
iii
Chapter 1
Direct stiffness method
Examples
Example 1.1. The Hookes law applied in a truss (or bar) member with uniform properties along
its length gives the truss stiffness:
k =
EA
L
consequently the force-displacement equation is
F = kd =
EA
L
d
where F is the internal axial force and d the relative axial displacement (the bar elongation).
Obtain the matrix relation of force-displacement equation expressed in terms of the joint
forces and displacements as
F = f
xj
= f
xi
d = u
xj
u
xi
where f
x
k is the force at joint k in the x direction.
Solution to Example 1.1. Combining the above equations we obtain the matrix relation
_
f
xi
f
xj
_
=
EA
L
_
1 1
1 1
_ _
u
xi
u
xj
_
Expanding this relation to the y direction, in which the beam has no stiffness, we may write
in matrix form:
_

_
f
xi
f
yi
f
xj
f
yj
_

_
=
EA
L
_

_
1 0 1 0
0 0 0 0
1 0 1 0
0 0 0 0
_

_
_

_
u
xi
u
yi
u
xj
u
yj
_

_
1
2 Pre and post-process tools in nite element analysis
Example 1.2. Compute the element stiffness matrix and the equivalent nodal force vector of a
two-node element bar with the elemental coordinate system rotated an angle respect to the
global coordinate system.
Solution to Example 1.2. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 1.02
% J.A. Mayugo, 2006
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) %
% Two-nodes element bar T-C %
% %
%---------------------------------------------------%
clear all
syms c s k A E L q theta real
% a = [c s 0 ; -s c 0 ; 0 0 1 ]
T
_
with
_
rotZ = [c s 0 0 0 0 ; -s c 0 0 0 0 ; 0 0 1 0 0 0 ;
0 0 0 c s 0 ; 0 0 0 -s c 0 ; 0 0 0 0 0 1] % Transformation matrix
T = [T
_
with
_
rotZ(1:2,1:2),T
_
with
_
rotZ(1:2,4:5);
T
_
with
_
rotZ(1:2,4:5),T
_
with
_
rotZ(4:5,4:5)] % Eliminate z row and column
k
_
e = [k 0 -k 0 ; 0 0 0 0 ; -k 0 k 0 ; 0 0 0 0 ] % Stiffness matrix
k
_
eT = simplify(inv(T)
*
k
_
e
*
T)
k
_
eT = subs(k
_
eT,{k},{A
*
E/L})
k
_
eT = subs(k
_
eT,{c,s},{cos(theta),sin(theta)})
k
_
eT = simplify(k
_
eT)
pretty(k
_
eT)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex102.m
Something similar to the following should be obtained:
k
_
eT =
[ 2 2 ]
[cos(theta~) A~ E~ cos(theta~) A~ E~ ]
[------------------ , %1 , - ------------------ , -%1]
[ L~ L~ ]
[ ]
[ 2 2 ]
[ sin(theta~) A~ E~ sin(theta~) A~ E~]
[%1 , ------------------ , -%1 , - ------------------]
[ L~ L~ ]
[ ]
[ 2 2 ]
[ cos(theta~) A~ E~ cos(theta~) A~ E~ ]
[- ------------------ , -%1 , ------------------ , %1]
[ L~ L~ ]
[ ]
[ 2 2 ]
[ sin(theta~) A~ E~ sin(theta~) A~ E~]
[-%1 , - ------------------ , %1 , ------------------]
Chapter 1. Direct stiffness method 3
[ L~ L~ ]
cos(theta~) A~ E~ sin(theta~)
%1 := -----------------------------
L~
Example 1.3. Solve in Matlab the next structure using the direct stiffness method.
4 Pre and post-process tools in nite element analysis
Solution to Example 1.3. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 1.03
% J.A. Mayugo, A.Turon 2007
%---------------------------------------------------%
% %
% Frame Direct Stiffess Method %
% two-nodes element bar T-C %
% %
%---------------------------------------------------%
clear all
elem =[1 2; 2 3; 1 3] % Element conectivity
real =[1 1 1 ] % Cross Section Area
mat =[100 50 200
*
sqrt(2)] % Youngs modulus
lengt=[10 10 10
*
sqrt(2)] % Element length
angle=[0 90 45] % Element orientation
K
_
= zeros(6); % Inicialitation of global stiffness
for ielem = 1:3
A = real(ielem); % Element properties"
E = mat(ielem);
L = lengt(ielem);
c = cos(pi/180
*
angle(ielem));
s = sin(pi/180
*
angle(ielem));
T = [c s 0 0 ; -s c 0 0 ;
0 0 c s ; 0 0 -s c ]; % Rotation matrix
k
_
e = [ E
*
A/L 0 -E
*
A/L 0 ; 0 0 0 0 ;
-E
*
A/L 0 E
*
A/L 0 ; 0 0 0 0 ]; % Element matrix in local coordinates
k
_
ei = T
*
k
_
e
*
T % Element matrix in global coordinates
% assembly operation
i1=2
*
(elem(ielem,1)-1)+1; % degree of freedom X node i
i2=i1+1; % degree of freedom Y node i
j1=2
*
(elem(ielem,2)-1)+1; % degree of freedom X node j
j2=j1+1; % degree of freedom X node j
K
_
(i1:i2,i1:i2) = K
_
(i1:i2,i1:i2) + k
_
ei(1:2,1:2); %Assembly.
K
_
(i1:i2,j1:j2) = K
_
(i1:i2,j1:j2) + k
_
ei(1:2,3:4);
K
_
(j1:j2,i1:i2) = K
_
(j1:j2,i1:i2) + k
_
ei(3:4,1:2);
K
_
(j1:j2,j1:j2) = K
_
(j1:j2,j1:j2) + k
_
ei(3:4,3:4);
end
K
_
%Boundary conditions
%ux1=0 (position 1); uy1=0 (position 2); uy2=0 (position 4);
K
_
red = K
_
;
K
_
red(:,4)=[];K
_
red(4,:)=[]; % Eliminates row and column #4
K
_
red(:,2)=[];K
_
red(2,:)=[];
K
_
red(:,1)=[];K
_
red(1,:)=[]; % Reduced matrix
%fx2=0; fx3=2; fy3=1;
f
_
red = [0 2 1] % Reduced nodal force vector
u
_
red=inv(K
_
red)
*
f
_
red % Solve the system
u = [0 0 u
_
red(1) 0 u
_
red(2) u
_
red(3)]
f = (K
_
*
u) % Nodal force vector
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex103.m
The displacement and force vectors are obtained:
u = (0, 0, 0, 0, 0.4, 0.2) mm
Chapter 1. Direct stiffness method 5
f = (2.0, 2.0, 0, 1.0, 2.0, 1.0) N
Which, means for instance, that the displacement of node 3 in the x direction is 0.4 mm, and
the force at node 1 in y direction is -2 N.
Suggested Problems
Problem 1.1. Obtain the algebraical expression of stiffness matrix of Example 1.2 in function of
global coordinates of node i (x
i
, y
i
) and node j (x
j
, y
j
).
Problem 1.2. Obtain the axial forces for the truss elements of Example 1.3.
Problem 1.3. Using a similar code to that in Example 1.3 obtain the displacement, reactions and
elemental forces of
Chapter 2
Strong form and weak form of
Poissons equation
Examples
Example 2.1. The structural model shown in the Figure 2.1 is represented by the Poissons
equation
d
dx
_
EA
du
dx
_
+ q(x) = 0
and by the boundary conditions
u = u|
x=0
F = P|
x=l
= EA
du
dx
P = 0

x=l
Figure 2.1: Uniaxial structural problem.
Obtain the analytic solution and the numeric solution using nite difference method if l = 500
mm, E = 70 GPa, A = 100 mm
2
, q = 500 N/mm, P = 40 kN and u = 8 mm. Compare both results
7
8 Pre and post-process tools in nite element analysis
graphically.
Solution to Example 2.1. The analytic solution is
u(x) =
q
2EA
x
2
+
P + q l
EA
x + u;
Next, we present the numeric solution implemented using MATLAB
% FEmet. solution of Example 2.01
% J. Costa, 2007
%---------------------------------------------------%
% RESOLUCI DE LA DEFORMACI DUNA BARRA EMPOTRADA %
% EN UN EXTREM I SOTMESA A UNA FORA AXIAL, %
% PER DIFERNCIES FINITES %
%---------------------------------------------------%
clear all
L = 500; % longitud en mm
E = 70000; % mdul elstic en MPa
A = 100; % secci en mm^2
q = 500; % fora distribuida en N/mm
P = 40000; % fora puntual en lextrem en N
u0 = 8; % desplaament al primer node en mm
n
_
anal = 100; % nombre de punts per a la representaci analtica
n
_
disc = 15; % nombre de punts per a la resoluci discreta
Dx = L/(n
_
disc-1); % Delta X
x = [0:L/(n
_
anal-1):L]; % matriu de valors per a la representaci analtica
x
_
= [0:Dx:L]; % matriu de valors per a la representaci discreta
% Expressi analtica del camp de desplaaments
u = - (q
*
x.^2)/(2
*
E
*
A) + (P+q
*
L)
*
x/(E
*
A) + u0;
%%% RESOLUCI AMB DIFERNCIES FINITES
% construim la matriu K
K = zeros(n
_
disc,n
_
disc); % primer lomplim de zeros
K(1,1)=1; % primera fila fa referncia a la c.c. forada, u0
for i = 2:n
_
disc-1 % colloquem les sries -1 2 -1
K(i,i-1:i+1) = [-1 2 -1];
end
K(n
_
disc,i:i+1) = [-1 1] % ultima fila, fa referencia c.c. natural, P
% construim el vector de forces
f
_
(1) = u0
*
E
*
A; % Per fer complir la condici de contorn forada
f
_
(2:n
_
disc -1) = q
*
Dx^2; % equaci de diferncies finites
f
_
(n
_
disc) = P
*
Dx; % condici de contorn no forada
f
_
= f
_

% determinem els desplaaments a cada node


u
_
=(1/(E
*
A))
*
inv(K)
*
f
_
%%% Representaci grfica
plot(x,u,x
_
,u
_
,ks)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex201.m
Chapter 2. Strong form and weak form of Poissons equation 9
Example 2.2. With the same problem in Example 2.1, obtain the stiffness matrix and the equiv-
alent force vector using Galerkin method.
Solution to Example 2.2. The weighted residual method can be written as
_

W
i
(x)A( u)d +
_

W
i
(x)B( u)d = 0
i=1,2...p
(2.1)
where
A( u) =
d
dx
_
EA
d u
dx
_
+ q(x) = 0 over
B( u) =
_
_
_
u u = 0 over
u
EA
d u
dx
P = 0 over
P
Therefore,
_
x=l
x=0
W
i
(x)
d
dx
_
EA
d u
dx
_
dx +
_
x=l
x=0
W
i
(x)q(x)dx +

W
i
(x)
_
EA
d u
dx
P
_

x=l
= 0
i=1,2...p
(2.2)
where u(x) is the approximated solution that can be expressed using a set of shape functions
u(x)

= u(x) =
p

i=0
N
i
(x) u
i
The weak form of rst term in (2.2) is
_
W
i
(x)EA
d u
dx
_
x=l
x=0

_
x=l
x=0
dW
i
(x)
dx
EA
d u
dx
dx (2.3)
or
W
i
(x)EA
d u
dx

x=l
W
i
(x)EA
d u
dx

x=0

_
x=l
x=0
dW
i
(x)
dx
EA
d u
dx
dx (2.4)
Substituting (2.4) in (2.2)
_
x=l
x=0
dW
i
(x)
dx
EA
d u
dx
dx =
_
x=l
x=0
W
i
(x)q(x)dx+
+ W
i
(x)EA
d u
dx

x=l
W
i
(x)EA
d u
dx

x=0
+

W
i
(x)EA
d u
dx

x=l


W
i
(x)P

x=l
i=1,2...p
(2.5)
Using the Galerkin method W
i
(x) =

W
i
(x) = N
i
(x) and dening the reaction force R =
EA
d u
dx

x=0
, we obtain
_
x=l
x=0
dN
i
(x)
dx
EA
d u
dx
dx =
_
x=l
x=0
N
i
(x)q(x)dx N
i
(x)R|
x=0
+ N
i
(x)P|
x=l i=1,2...p
(2.6)
The approximate solution in function of nodal displacement is u(x) =

p
j=0
N
j
(x) u
j
. Substi-
tuting at previous equation and applying the distributive property in the integral,
p

j=0
__
x=l
x=0
dN
i
(x)
dx
EA
dN
j
(x)
dx
dx
_
uj =
_
x=l
x=0
N
i
(x)q(x)dx N
i
(x)R|
x=0
+ N
i
(x)P|
x=l i=1,2...p
(2.7)
In these case p = 2, where i = 1 or j = 1 is in x = 0 and i = 2 or j = 2 is in x = l, so
10 Pre and post-process tools in nite element analysis
k
ij
=
_
x=l
x=0
dN
i
(x)
dx
EA
dN
j
(x)
dx
dx (2.8)
and
f
1
=
_
x=l
x=0
N
1
(x)q(x)dx R (2.9)
f
2
=
_
x=l
x=0
N
2
(x)q(x)dx + N (2.10)
Example 2.3. Compute the element stiffness matrix and the equivalent nodal force vector of a
two-node spar nite element with
K
e
=
_
Ve
B
T
D B dV (2.11)
and
f
e
=
_
Ve
N
T
q dV +
_
Se
N
T
t dS (2.12)
Use the next shape functions
N
T
=
_
N
e
1
N
e
2
_
=
_
x
e+1
x
x
e+1
xe
xxe
x
e+1
xe
_
=
_
1 x/L
e
x/L
e
_
(2.13)
Implement the solution in a script of MAPLE, MATLAB or similar code.
Solution to Example 2.3. Let A
e
be the transverse area of the bar and L
e
the element length,
with x
e
= 0 and x
e+1
= L
e
.
Substituting these values in the linear Lagrange polynomial functions we obtain the shape
functions arrays
N
T
=
_
N
e
1
N
e
2
_
=
_
x
e+1
x
x
e+1
xe
xxe
x
e+1
xe
_
=
_
1 x/L
e
x/L
e
_
(2.14)
Differentiating we can calculate the the strain-displacement array as
B
T
= N
T
=
_
N
e
1
/x
N
e
2
/x
_
=
_
1/L
e
1/L
e
_
(2.15)
The bar element has one-dimensional strain-stress state with linear elastic behavior, therefore
D = E (2.16)
Then, using equation (2.11) we can write
K
e
=
_
Ve
B
T
D B dV =
_
Le
0
_
1/L
e
1/L
e
_
E
_
1/L
e
1/L
e

A
e
dx (2.17)
Integrating we obtain the element stiffness matrix
[K
e
] =
EA
e
L
e
_
1 1
1 1
_
(2.18)
To calculate the equivalent vector force we dene q
e
as the distributed force on the element,
P
e
1
the force at end x = 0 and P
e
2
the force at end x = L
e
. Substituting in equation (2.12) we
obtain
Chapter 2. Strong form and weak form of Poissons equation 11
f
e
=
_
Ve
N
T
q dV +
_
Se
N
T
t dS =
_
Le
0
_
1 x/L
e
x/L
e
_
q
e
dx +
_
P
e
1
P
e
2
_
(2.19)
Integrating we obtain the element equivalent force vector
f
e
=
q
e
L
e
2
_
1
1
_
+
_
P
e
1
P
e
2
_
(2.20)
Next, we present the solution implemented using the symbolic calculation capabilities of MAT-
LAB
% FEmet. solution of Example 2.03
% J.A. Mayugo, 2006
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) and %
% the nodal equival force (p
_
e) %
% %
% two-nodes element bar T-C %
% %
%---------------------------------------------------%
clear all
syms x x1 x2 L E A q real
% shape functions (linear lagrange polinomial)
N(1)=(x-x2)/(x1-x2)
N(2)=(x-x1)/(x2-x1)
N=subs(N,{x1,x2},{0,L})
% Strain-displacement matrix B
B=diff(N,x)
% Stiffness matrix
k
_
e = int(B
*
E
*
B,x,0,L)
*
A
% Equivalent nodal force vector
f
_
e=int(q
*
N,0,L)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex203.m
Example 2.4. Program a FE code using the element formulation obtained in Example 2.3 and
the assembly procedure. With this code, calculate a 1-D bar with distributed loads on elements.
Solution to Example 2.4. Next, we present the solution implemented on MATLAB
% FEmet. solution of Example 2.04
% J.A. Mayugo, 2006
%---------------------------------------------------%
% %
% Finite element analysis %
% %
% two-node element bar T-C %
% %
%---------------------------------------------------%
clear all;close all;
%---------------------------------------------------%
12 Pre and post-process tools in nite element analysis
% PRE-PROCESS: input data %
%---------------------------------------------------%
%% Material definition
mat = [1 60e3; % Material #1, E elastic modulus in MPa
2 50e3] % Material #2, E elastic modulus in MPa
%% Geometry real constants definition
real = [1 10; % Geometry 1, A area in mm^2
2 20] % Geometry 2, A area in mm^2
%% Definicio dels nodes
node = [1 0; % Node 1, coordenate x mm
2 500; % Node 2, coordenate x mm
3 1000; % Node 3, coordenate x mm
4 1500] % Node 4, coordenate x mm
[nnode,h] = size(node)
%% Element defintion,
%% element number, material, real constant, nodes connectivity
elem = [ 1 1 1 1 2;
2 1 1 2 3;
3 1 1 3 4 ]
[nelem,h] = size(elem)
%% Boundary conditions and loads
% Nodes with constraint displacements
dnode = [1 0.1]
[ndnode,h] = size(dnode)
% Nodes with concentrate load not equal 0
fnode = [3 100;
4 200]
[nfnode,h] = size(fnode)
% Distributed loads on elements
belem = [1 1e-4;
2 1e-4;
3 1]
[nbelem,h] = size(belem)
%---------------------------------------------------%
% SOLUTION %
%---------------------------------------------------%
%%% STIFFNESS MATRIX
K
_
= zeros(nnode);
for ielem = 1:nelem
A = real(elem(ielem,3),2);
E = mat(elem(ielem,2),2);
NODE1 = elem(ielem,4);
NODE2 = elem(ielem,5);
L = abs(node(NODE1,2)-node(NODE2,2));
k
_
e = [A
*
E/L -A
*
E/L; -A
*
E/L A
*
E/L] % element stiffness matrix
Chapter 2. Strong form and weak form of Poissons equation 13
% assembly operation
K
_
(NODE1,NODE1) = K
_
(NODE1,NODE1) + k
_
e(1,1);
K
_
(NODE1,NODE2) = K
_
(NODE1,NODE2) + k
_
e(1,2);
K
_
(NODE2,NODE1) = K
_
(NODE2,NODE1) + k
_
e(2,1);
K
_
(NODE2,NODE2) = K
_
(NODE2,NODE2) + k
_
e(2,2);
end
K
_
%%% DISPLACEMENT VECTOR
for inode = 1:nnode
U =sym([U,num2str(inode)],real);
U
_
(inode) = U;
end
U
_
= U
_
;
for idnode = 1:ndnode
U
_
(dnode(idnode,1))=dnode(idnode,2);
end
U
_
%%% EQUIVALENT FORCE VECTOR
syms F
_
zero real
for inode = 1:nnode
F
_
(inode)=F
_
zero;
for idnode = 1:ndnode
if dnode(idnode,1)==inode
F = sym([F,num2str(inode)],real);
F
_
(inode)=F;
end
end
for ifnode = 1:nfnode
if fnode(ifnode,1)==inode
F
_
(inode) = F
_
(inode) + fnode(ifnode,2);
end
end
end
F
_
= subs(F
_
,F
_
zero,0);
for ibelem = 1:nbelem
f = belem(ibelem,2); %
L = abs(node(elem(ibelem,4),2)-node(elem(ibelem,5),2)); % mm
f
_
e = (f
*
L)
*
[1/2;1/2];
F
_
(elem(ibelem,4)) = F
_
(elem(ibelem,4)) + f
_
e(1);
F
_
(elem(ibelem,5)) = F
_
(elem(ibelem,5)) + f
_
e(2);
end
F
_
%%% Define K
_
natural
K
_
n = ones(nnode);
F
_
n = ones(nnode,1);
ff = zeros(nnode,1);
for idnode = 1:ndnode
K
_
n(dnode(idnode,1),:)=0;
K
_
n(:,dnode(idnode,1))=0;
F
_
n(dnode(idnode,1))=0;
ff = ff + (K
_
(:,dnode(idnode,1))
*
U
_
(dnode(idnode,1)));
end
14 Pre and post-process tools in nite element analysis
K
_
n = K
_
n.
*
K
_
;
% Keep only rowns and columms not equal zero in K
_
n
K
_
nn = zeros (nnode-ndnode);
inoden = 0;
for inode = 1:nnode
jnoden = 0;
if (F
_
n(inode))~=0
inoden = inoden +1;
for jnode = 1:nnode
if (F
_
n(jnode))~=0
jnoden = jnoden +1;
K
_
nn(inoden,jnoden)=K
_
n(inode,jnode);
end
end
end
end
K
_
nn
% Keep rows not equal zero in F
_
n
F
_
nn = zeros (nnode-ndnode,1);
f
_
nn = zeros (nnode-ndnode,1);
inoden = 0;
for inode = 1:nnode
if (F
_
n(inode))~=0
inoden = inoden +1;
F
_
nn(inoden)=eval(F
_
(inode));
f
_
nn(inoden)=eval(ff(inode));
end
end
F
_
nn = F
_
nn - f
_
nn
U
_
nn = linsolve(K
_
nn,F
_
nn);
% Add known displacaments U
_
nn
U
_
solu = zeros (nnode,1);
inoden = 0;
for inode = 1:nnode
if (F
_
n(inode))~=0
inoden = inoden +1;
U
_
solu(inode)=U
_
nn(inoden);
else
U
_
solu(inode)=eval(U
_
(inode));
end
end
U
_
solu
% Compute external forces
F
_
solu = K
_
*
U
_
solu
% Compute nodals forces
for ielem = 1:nelem
disp([-------------- element ,num2str(ielem)])
A = real(elem(ielem,3),2);
E = mat(elem(ielem,2),2);
NODE1 = elem(ielem,4);
NODE2 = elem(ielem,5);
L = abs(node(NODE1,2)-node(NODE2,2)); % mm
k
_
e = [A
*
E/L -A
*
E/L; -A
*
E/L A
*
E/L]; % element stiffness
u
_
e = [U
_
solu(NODE1);U
_
solu(NODE2)] % nodal displacement
f
_
e = k
_
e
*
u
_
e % nodal reactions forces
Chapter 2. Strong form and weak form of Poissons equation 15
% Nodal displacement along (x)
x
_
x(:,ielem) = [0:L/10:L]; % nodal coordinates
N
_
x = [-(x
_
x(:,ielem)-L)/L , x
_
x(:,ielem)/L];
u
_
x(:,ielem) = N
_
x
*
u
_
e; % nodal displacements
X
_
x(:,ielem) = x
_
x(:,ielem)+node(NODE1,2);
% Derived results along (x)
% this part is not write yet
end
%---------------------------------------------------%
% POST-PROCESS: output data %
%---------------------------------------------------%
figure;
plot (node(:,2),U
_
solu,o,MarkerSize,10)
hold on
plot (X
_
x,u
_
x,--,LineWidth,1.5)
xlabel(x [mm], Coordinate)
ylabel(U
_
i [mm], Displacement)
legend(Nodal Displacement,Interpoled Displacement)
hold off
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex204.m
16 Pre and post-process tools in nite element analysis
Suggested Problems
Problem 2.1. Discuss if the next functions can be used as a shape functions.
N
T
=
_
N
e
1
N
e
2
_
=
_
_
sin
_

2
x
e+1
x
x
e+1
xe
_
sin
_

2
xxe
x
e+1
xe
_
_
_
=
_
sin
_

2
(1 x/L
e
)
_
sin
_

2
x/L
e
_
_
(2.21)
Let A
e
be the transverse area of the bar and L
e
the element length, with x
e
= 0 and x
e+1
= L
e
.
Problem 2.2. Compute the shape functions, the stiffness matrix, and the equivalent force vector
of a 2-node spar element assuming that the displacement eld over the element is approximated
with a function like:
u(x) = a + mx + nx
2
(2.22)
Problem 2.3. Using the same procedure in Ex. 2.3 calculate the element stiffness matrix and the
equivalent force vector of a three-node element bar with quadratic shape functions. The shape
functions are
N
e
1
=
xx
2
x
1
x
2
xx
3
x
1
x
3
N
e
2
=
xx
3
x
2
x
3
xx
1
x
2
x
1
N
e
3
=
xx
1
x
3
x
1
xx
2
x
3
x
2
(2.23)
where x
1
, x
2
and x
3
are the coordinate positions of node 1, 2 and 3 respectively. We can
choose x
1
= 0, x
2
= L/2 and x
3
= L where L is the element length. Show all work in a report.
Problem 2.4. Program a FE code using the element formulation obtained in Problem 2.3 and
the assembly procedure. With this code, calculate the same problem solved in Example 2.4.
Problem 2.5. Program a FE code using the element formulation obtained in Example 1.2 and
the assembly procedure. With this code, calculate a 2-D truss (a static structure consisting of
straight slender members inter-connected at joints into triangular units). Show all work in a
report. (Note: For help use the code ftp://amade.udg.es/amade/mme/FEmet/FEmet
_
Pb205.m).
Chapter 3
Bidimensional problems. Formulation
of 2-D solid elements
Examples
Example 3.1. Compute the element stiffness matrix and the equivalent nodal vector force of a
plane three-node triangular nite element.
Figure 3.1: 3-noded plane element.
Solution to Example 3.1. The gure shows a triangular element, with nodes 1, 2 and 3 in
an anticlockwise order. The displacement within the element can be represented by two linear
polynomials:
u = a
1
+ a
2
x + a
3
y
v = a
4
+ a
5
x + a
6
y
(3.1)
or in matrix form:
_
u
v
_
= [P
ik
]{a
k
} =
_
1 x y 0 0 0
0 0 0 1 x y
_
_

_
a
1
a
2
a
3
a
4
a
5
a
6
_

_
(3.2)
The six constants a
k
can be obtained through the nodal coordinates and the nodal displace-
ments, in matrix form:
17
18 Pre and post-process tools in nite element analysis
_

_
u
1
v
1
u
2
v
2
u
3
v
3
_

_
=
_

_
1 x
1
y
1
0 0 0
0 0 0 1 x
1
y
1
1 x
2
y
2
0 0 0
0 0 0 1 x
2
y
2
1 x
3
y
3
0 0 0
0 0 0 1 x
3
y
3
_

_
_

_
a
1
a
2
a
3
a
4
a
5
a
6
_

_
(3.3)
or in contracted form the above expression can be written as:
_
u
e
j
_
= [C
jk
]{a
k
} (3.4)
The constants a
k
can be computed by inversion of C
jk
as:
{a
k
} = [C
jk
]
1
{u
e
i
} (3.5)
The shape function in standard form can be obtained using equation:
(3.2) and (3.4)
_
u
v
_
= [P
ik
][C
jk
]
1
{u
e
j
} = [N
ij
]{u
e
j
} (3.6)
where
[N] =
_
N
1
0 N
2
0 N
3
0
0 N
1
0 N
2
0 N
3
_
(3.7)
The shape functions associated to the three nodes, N
1
, N
2
and N
3
, are respectively given by:
N
1
=
a
1
+ b
1
x + c
1
y
2A
N
2
=
a
2
+ b
2
x + c
2
y
2A
N
3
=
a
3
+ b
3
x + c
3
y
2A
(3.8)
where
a
1
= x
1
y
3
x
3
y
2
b
1
= y
2
y
3
c
1
= x
3
x
2
a
2
= x
2
y
1
x
1
y
3
b
2
= y
3
y
1
c
2
= x
1
x
3
a
3
= x
3
y
2
x
2
y
1
b
3
= y
1
y
2
c
3
= x
2
x
1
(3.9)
and A is the area of the element, that can be computed as:
A
e
=
1
2
det

1 x
1
y
1
1 x
2
y
2
1 x
3
y
3

(3.10)
The strain in the xy plane within the element can be dened by three components as:
_
_
_

xy
_
_
_
=
_

x
0
0

y

x
_

_
_
u
v
_
= [L]
_
u
v
_
= [L
mi
][N
ij
]{u
e
j
} (3.11)
with the standard [B] matrix denition given by:
Chapter 3. Bidimensional problems. Formulation of 2-D solid elements 19
[B] = [L][N] =
_

x
0
0

y

x
_

_
_
N
1
0 N
2
0 N
3
0
0 N
1
0 N
2
0 N
3
_
(3.12)
therefore,
[B] =
_

_
N
1
x
0
N
2
x
0
N
3
x
0
0
N
1
y
0
N
2
y
0
N
3
y
N
1
y
N
1
x
N
2
y
N
2
x
N
3
y
N
3
x
_

_
(3.13)
Using the interpolation functions in (3.8) the deformation matrix of the triangular element is
obtained:
[B] =
1
2A
_
_
y
2
y
3
0 y
3
y
1
0 y
2
y
1
0
0 x
3
x
2
0 x
1
x
3
0 x
2
x
1
x
3
x
2
y
2
y
3
x
1
x
3
y
3
y
1
x
2
x
1
y
1
y
2
_
_
(3.14)
It should be noted that in this element the [B] matrix is not dependent of the position and,
hence, the strains are constant through the element. For this reason, this element is also called
Constant Strain Triangular (CST) nite element.
The elasticity matrix [D] in a xy-plane takes the form:
_
_
_

xy
_
_
_
=
_
_
d
11
d
12
d
13
d
21
d
22
d
23
d
31
d
32
d
33
_
_
_
_
_

xy
_
_
_
= [D] {} (3.15)
Depending on the material (isotropic, orthotropic or anisotropic) and depending on the impo-
sition of plane stress or plane strain the [D] matrix takes a different expression.
For example, for a plane stress in a isotropic material, [D] matrix is given by:
[D] =
E
1
2
_
_
1 0
1 0
0 0 (1 )/2
_
_
(3.16)
The element stiffness matrix is dened by:
[K
e
] =
_
Ve
[B]
T
[D][B]dV (3.17)
When the thickness of the element t and the material properties are constant, the equation
(3.17) can be reduced to:
[K
e
] =
_
Ve
dV [B]
T
[D][B] = tA
e
[B]
T
[D][B] (3.18)
20 Pre and post-process tools in nite element analysis
To calculate the equivalent nodal force vector we dene P
e
1
, P
e
2
, P
e
3
as concentrated forces at
the nodes 1, 2 and 3, q
e
as a distributed force on the element, and p
e
12
, p
e
23
and p
e
31
as distributed
forces on the element edges 12, 23 and 31, respectively. Substituting in equation (2.12) we obtain
{f
e
} = {P
e
} +
_
Ve
[N]
T
{q
e
}dV +
+
_
L
12
[N]
T
{p
e
12
}tdL+
+
_
L
23
[N]
T
{p
e
23
}tdL+
+
_
L
31
[N]
T
{p
e
31
}tdL
(3.19)
or in the case that the distributed forces are constant we obtain
{f
e
} = {P
e
} + {q
e
}t
_
A
e
[N]
T
dA+
+ {p
e
12
}t
_
L
12
[N]
T
dL+
+ {p
e
23
}t
_
L
23
[N]
T
dL+
+ {p
e
31
}t
_
L
31
[N]
T
dL
(3.20)
where
_
A
e
[N]
T
dA = A
e
/3 and
_
L
ij
[N]
T
dL = L
ij
/2. Therefore, the nodal equivalent forces can
be reduced to:
{f
e
} = {P
e
} +
1
3
{q
e
}tA
e
+
+
1
2
{p
e
12
}tL
12
+
1
2
{p
e
23
}tL
23
+
1
2
{p
e
31
}tL
31
(3.21)
In expanded matrix form, the equivalent force vector can be written as
{f
e
} =
_

_
F
u1
F
v1
F
u2
F
v2
F
u3
F
v3
_

_
=
_

_
P
e
u1
P
e
v1
P
e
u2
P
e
v2
P
e
u3
P
e
v3
_

_
+
1
3
_

_
1 0
0 1
1 0
0 1
1 0
0 1
_

_
_
q
e
x
tA
q
e
y
tA
_
+
+
1
2
_

_
1 0 1 0 0 0
0 1 0 1 0 0
0 0 1 0 1 0
0 0 0 1 0 1
1 0 0 0 1 0
0 1 0 0 0 1
_

_
_

_
p
e
x12
tL
12
p
e
y12
tL
12
p
e
x23
tL
23
p
e
y23
tL
23
p
e
x31
tL
31
p
e
y31
tL
31
_

_
(3.22)
The next box shows the solution implemented using the symbolic calculation capabilities of
MATLAB.
% FEmet. solution of Example 3.01
% J.A. Mayugo, 2006, D. Trias 2010
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) and %
% the nodal equival force (p
_
e) %
% %
% three-node element CTS %
% %
%---------------------------------------------------%
clear all
syms x y x1 y1 x2 y2 x3 y3 t A
_
e real % geometry
syms E nu d11 d12 d22 d33 real % material
syms N
_
1 N
_
2 N
_
3 diff
_
x diff
_
y
Chapter 3. Bidimensional problems. Formulation of 2-D solid elements 21
%% shape functions
% linear polinomial
P=[1 x y 0 0 0; 0 0 0 1 x y]
% evaluate P on node1, node2 and node3 coordinates
C=[subs(P,{x,y},{x1,y1});
subs(P,{x,y},{x2,y2});
subs(P,{x,y},{x3,y3})]
% element area
A
_
e=1/2
*
det([1 x1 y1;1 x2 y2; 1 x3 y3])
% Shape functions
N = simplify(P
*
inv(C))
N1 = N(1,1);N2 = N(1,3);N3 = N(1,5);
N
_
=[N
_
1 0 N
_
2 0 N
_
3 0 ;
0 N
_
1 0 N
_
2 0 N
_
3]
%% Strain-displacement matrix B
L = [diff
_
x 0; 0 diff
_
y; diff
_
y diff
_
x]
B = L
*
N
_
B = subs(char(B),{diff
_
x
*
N
_
1,diff
_
y
*
N
_
1,diff
_
x
*
N
_
2,diff
_
y
*
N
_
2,diff
_
x
*
N
_
3,diff
_
y
*
N
_
3},...
{char(diff(N1,x)),char(diff(N1,y)),char(diff(N2,x)),char(diff(N2,y)),char(diff(N3,x)),char(diff(N3,y))})
B = subs(B)
% Constitutive Matriz
%D=[d11 d12 0; d12 d22 0; 0 0 d33 ] % isotropic or orthotropic material
D=E/(1-nu^2)
*
[1 nu 0;nu 1 0; 0 0 (1-nu)/2] % plane stress
%D=E/(1+nu)/(1-2
*
nu)
*
[1-nu nu 0;nu 1-nu 0; 0 0 (1-2
*
nu)/2] % plane stress
% Stiffness matrix
k
_
= simplify (t
*
A
_
e
*
B
*
D
*
B)
% Example
k
_
exemple=subs(k
_
,{E,nu,t,x1,x2,x3,y1,y2,y3},{2e6,0.2,1,0,30,0,0,0,40})
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex301
_
solids.m
Example 3.2. Using the formulation presented in Example 3.1 solve the structure presented in
Figure 3.2 where the thickness is 0.5 mm. The material properties are E = 210GPa and = 0.2.
Figure 3.2: 4-noded plane element.
Solve the same problem with a commercial nite element code and compare results.
Solution to Example 3.2. The solution implemented using the symbolic calculation capabilities
of MATLAB is shown bellow:
%---------------------------------------------------%
% %
% A. Turon, J.A. Mayugo, 2007 %
22 Pre and post-process tools in nite element analysis
% %
% Element triangular bidimensional 3 nodes %
% %
%---------------------------------------------------%
clear all
syms x y x1 y1 x2 y2 x3 y3 t A
_
e E nu d11 d12 d22 d33 real
syms u3 v3 u4 v4 H1 H2 R1 R2
P=[1 x y 0 0 0; 0 0 0 1 x y];
C=[subs(P,{x,y},{x1,y1});
subs(P,{x,y},{x2,y2});
subs(P,{x,y},{x3,y3})]
A
_
e=1/2
*
det([1 x1 y1;1 x2 y2; 1 x3 y3]);
N = simplify(P
*
inv(C));
N1=N(1,1);
N2=N(1,3);
N3=N(1,5);
dN1
_
x=diff(N1,x);
dN1
_
y=diff(N1,y);
dN2
_
x=diff(N2,x);
dN2
_
y=diff(N2,y);
dN3
_
x=diff(N3,x);
dN3
_
y=diff(N3,y);
B=[ dN1
_
x 0 dN2
_
x 0 dN3
_
x 0 ;
0 dN1
_
y 0 dN2
_
y 0 dN3
_
y ;
dN1
_
y dN1
_
x dN2
_
y dN2
_
x dN3
_
y dN3
_
x ];
D=E/(1-nu^2)
*
[1 nu 0;nu 1 0; 0 0 (1-nu)/2]; % tensio plana
%D=E/(1+nu)/(1-2
*
nu)
*
[1-nu nu 0;nu 1-nu 0; 0 0 (1-2
*
nu)/2] % deformacio plana
k
_
= simplify (t
*
A
_
e
*
B
*
D
*
B);
% Mesh (a)
k
_
1=subs(k
_
,{E,nu,t,x1,x2,x3,y1,y2,y3},{2.1e5,0.2,0.5,0,2000.0,0,0,0,1000.0})
k
_
2=subs(k
_
,{E,nu,t,x1,x2,x3,y1,y2,y3},{2.1e5,0.2,0.5,2000.,2000.,0,0,1000,1000})
%Permute rows and columns 3-4 and 5-6
i=[1 0 0 0 0 0 ; 0 1 0 0 0 0 ;0 0 0 0 1 0; 0 0 0 0 0 1; 0 0 1 0 0 0;0 0 0 1 0 0];
k
_
2p=i
*
k
_
2
*
i
%Initialize global K and F
K(1:8,1:8)=0;
Fq(1:8,1)=0;
%Assembly
K(1:6,1:6)=k
_
1(1:6,1:6)
K(3:8,3:8)=K(3:8,3:8)+k
_
2p(1:6,1:6)
%Solve
F=[H1;R1;H2;R2;0;0;600000.0;0]
K
_
red(1:4,1:4)=K(5:8,5:8)
F
_
red(1:4,1)=F(5:8,1)
u
_
red=(inv(K
_
red)
*
F
_
red)
u
_
m1(5:8,1)=double(u
_
red(1:4,1)) %Nodal displacements
F
_
m1=double(K
*
u
_
m1) %Nodal forces
%%%%%%%%%%%%%%%%%%%%%
%Mesh (b)
k
_
1=subs(k
_
,{E,nu,t,x1,x2,x3,y1,y2,y3},{2.1e5,0.2,0.5,0,2000.0,2000,0,0,1000.0})
k
_
2=subs(k
_
,{E,nu,t,x1,x2,x3,y1,y2,y3},{2.1e5,0.2,0.5,0,2000.,0.,0,1000.,1000.})
%insert 2 rows/columns in k
_
2 relative to u2,v2
i=[1 0 0 0 0 0; 0 1 0 0 0 0 ; 0 0 0 0 0 0;0 0 0 0 0 0;0 0 1 0 0 0; 0 0 0 1 0 0; 0 0 0 0 1 0;0 0 0 0 0 1]
k
_
2e=i
*
k
_
2
*
i
%Assembly
K(1:8,1:8)=k
_
2e(1:8,1:8)
K(1:6,1:6)=K(1:6,1:6)+k
_
1(1:6,1:6)
%Solve
F=[H1;R1;H2;R2;600000;0;0.0;0]
K
_
red(1:4,1:4)=K(5:8,5:8)
F
_
red(1:4,1)=F(5:8,1)
u
_
red=double(inv(K
_
red)
*
F
_
red)
u
_
m2(5:8,1)=double(u
_
red(1:4,1)) %Nodal displacements
F
_
m2=double(K
*
u
_
m2) %Nodal forces
Chapter 3. Bidimensional problems. Formulation of 2-D solid elements 23
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex302
_
solids.m
The solution of the problem using ANSYS
TM
for mesh (a) is shown bellow:
FINISH
/CLEAR
/PREP7
ET,1,PLANE42
KEYOPT,1,3,3
R,1,.5, ! Real constant set #1: 0.5 mm
MP,EX,1,210000 ! Material #1
MP,PRXY,1,0.2
n,1,0,0,0
n,2,2000,0,0
n,3,2000,1000,0
n,4,0,1000,0
e,1,2,4,4
e,2,3,4,4
FINISH
/SOLU
ANTYPE,static
d,1,all
d,2,all
f,3,fx,600000
SOLVE
FINISH
/POST1
PLDISP,1
PRNSOL,u,x
PRNSOL,u,y
PRRSOL,
PLNSOL, EPEL,X, 0,1.0
PLESOL, EPEL,X, 0,1.0
/GRAPHICS,FULL
!PLESOL, SERR,, 0,1.0
PRERR
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex302a
_
solids.dat
The solution of the problem using ANSYS
TM
for mesh (b) is shown bellow:
FINISH
/CLEAR
/PREP7
ET,1,PLANE42
KEYOPT,1,3,3
R,1,.5, ! Real constant set #1: 0.5 mm
MP,EX,1,210000 ! Material #1
MP,PRXY,1,0.2
n,1,0,0,0
n,2,2000,0,0
n,3,2000,1000,0
n,4,0,1000,0
e,1,2,3,3
e,1,3,4,4
FINISH
/SOLU
ANTYPE,static
d,1,all
24 Pre and post-process tools in nite element analysis
d,2,all
f,3,fx,600000
SOLVE
FINISH
/POST1
PLDISP,1
PRNSOL,u,x
PRNSOL,u,y
PRRSOL,
PLNSOL, EPEL,X, 0,1.0
PLESOL, EPEL,X, 0,1.0
/GRAPHICS,FULL
!PLESOL, SERR,, 0,1.0
PRERR
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex302b
_
solids.dat
Suggested Problems
Problem 3.1. Solve the following plane problem using the formulation of Example 3.1. Use
two or more 3-noded plane elements and compare the results obtained by at least two different
meshes. Show all work in a report.
Figure 3.3: 2D structural problem.
Problem 3.2. Program a FE code using the element formulation obtained in Example 3.1 and
the assembly procedure. To do so you may adapt the code of Problem 2.5 (also with a model
dened in 2-D space with translations in-plane). With this code, compute the model shown in
Figure 3.4. Show all work in a report.
Problem 3.3. Using the same procedure in Ex. 3.1, calculate the element stiffness matrix of
a four-node rectangular element 2-D with dimensions 2a and 2b (shown in the Figure 3.5) with
shape functions dened by the next displacement functions
u(x, y) =
1
+
2
x +
3
y +
4
xy
u(x, y) =
5
+
6
x +
7
y +
8
xy
Show all work in a report.
Chapter 3. Bidimensional problems. Formulation of 2-D solid elements 25
Figure 3.4: 2D structural problem.
Figure 3.5: 4-noded plane element.
Chapter 4
Iso-parametric formulation of 2-D
solid elements
Examples
Hint 1: Numerical integration
The stiffness matrix can be evaluated numerically using Gauss quadrature:
K =
_
V
e
B
T
DBdV =
_
1
1
_
1
1
tB
T
DBdet(J)dd =
p

k
q

l
tB
T
(
k
,
l
)DB(
k
,
l
) det (J(
k
,
l
)) W
k
W
l
for k = 1..p, l = 1..q, where p is the number of Gauss points in direction and q in direction.
The position and the weights W of the Gauss points are shown in the next Table for 1, 2, and 3
Gauss points.
Number of Gauss Points Position Weight W
i
1 0 2
2
1

3
,
+1

3
1,1
3
_
3
5
, 0, +
_
3
5
5
9
,
8
9
,
5
9
Example 4.1. Using iso-parametric formulation obtain the position of the Gauss points in a four-
node quadrilateral bilinear element. The nodes 1, 2, 3 and 4 of the element have de coordinates
(1,1.5), (2,1.8), (2.5, 3) and (0.5,2.5) respectively. The coordinates of the nodes 1, 2, 3 and 4 in
natural coordinates are (-1,-1), (-1,1), (1,1) and (-1,1) and the shape functions associated to each
node are
N
1
=
1
4
(1 )(1 ) N
2
=
1
4
(1 + )(1 )
N
3
=
1
4
(1 + )(1 + ) N
4
=
1
4
(1 )(1 + )
(4.1)
Also obtain the representation of the lines between: node 1 and node 3, node 4 and node 2, and
node 4 and node 3.
Solution to Example 4.1. The solution implemented using MATLAB
TM
is shown below
27
28 Pre and post-process tools in nite element analysis
% FEmet. solution of Example 4.01
% J.A. Mayugo, 2007. D. Trias, 2009
%---------------------------------------------------%
% %
% Isoparametric formulation: %
% Quadrilateral bilineal element %
% %
%---------------------------------------------------%
clear all, close all
syms xi eta x y real
% Shape function in natural space
N(1)=1/4
*
(1-xi)
*
(1-eta);
N(2)=1/4
*
(1+xi)
*
(1-eta);
N(3)=1/4
*
(1+xi)
*
(1+eta);
N(4)=1/4
*
(1-xi)
*
(1+eta);
N
sumN=simplify(N(1)+N(2)+N(3)+N(4)) %check of completness property
% in natural coordinates: [node1, node2, node3, node 4]
xi
_
i =[-1,+1,+1,-1];
eta
_
i =[-1,-1,+1,+1];
% in geometrical coordinates: [node1, node2, node3, node 4]
x
_
i = [1.0,2.0,2.5,0.5];
y
_
i = [1.5,1.8,3.0,2.5];
%% geometrical coordinates as a function of natural coordinates
x = x
_
i(1)
*
N(1)+x
_
i(2)
*
N(2)+x
_
i(3)
*
N(3)+x
_
i(4)
*
N(4);
y = y
_
i(1)
*
N(1)+y
_
i(2)
*
N(2)+y
_
i(3)
*
N(3)+y
_
i(4)
*
N(4);
%% Gauss Points g and associated weights w in natural coordinates (xi,eta)
g1=[0];w1=[2]; % p = 1
g2=[-1/sqrt(3) 1/sqrt(3)];w2=[1 1]; % p = 2
g3=[-sqrt(3/5) 0 sqrt(3/5)];w3=[5/9 8/9 5/9]; % p = 3
g4=[-sqrt(3+2
*
sqrt(6/5)/7) -sqrt(3-2
*
sqrt(6/5)/7) ...
sqrt(3-2
*
sqrt(6/5)/7) sqrt(3+2
*
sqrt(6/5)/7)];
w4=[1/2-1/6
*
sqrt(5/6) 1/2+1/6
*
sqrt(5/6)...
1/2+1/6
*
sqrt(5/6) 1/2-1/6
*
sqrt(5/6)]; % p = 4
% Gauss points for p=2;
xi
_
g=[g2(1),g2(2),g2(1),g2(2)];
eta
_
g=[g2(1),g2(1),g2(2),g2(2)];
x
_
g=double(subs(x,{xi,eta},{xi
_
g,eta
_
g}));
y
_
g=double(subs(y,{xi,eta},{xi
_
g,eta
_
g}));
% centre
xi
_
centre=0;
eta
_
centre=0;
x
_
centre=double(subs(x,{xi,eta},{xi
_
centre,eta
_
centre}));
y
_
centre=double(subs(y,{xi,eta},{xi
_
centre,eta
_
centre}));
% Random inner points
xi
_
t =rand(1,50)
*
2-1; % 50 points
eta
_
t =rand(1,50)
*
2-1;
x
_
t =double(subs(x,{xi,eta},{xi
_
t,eta
_
t}));
y
_
t =double(subs(y,{xi,eta},{xi
_
t,eta
_
t}));
% Points for line "eta=+1": line between node 4 and node 3
xi
_
c =[-1:1/25:+1]; % 51 points
eta
_
c =+ones(1,51);
x
_
c =double(subs(x,{xi,eta},{xi
_
c,eta
_
c}));
y
_
c =double(subs(y,{xi,eta},{xi
_
c,eta
_
c}));
% Points for line "eta=xi": line between node 1 and node 3
xi
_
l =[-1:1/25:+1]; % 51 points
eta
_
l =xi
_
l;
Chapter 4. Iso-parametric formulation of 2-D solid elements 29
x
_
l =double(subs(x,{xi,eta},{xi
_
l,eta
_
l}));
y
_
l =double(subs(y,{xi,eta},{xi
_
l,eta
_
l}));
% Points for line "eta=-xi": line between node 4 and node 2
xi
_
le =[-1:1/25:+1]; % 51 points
eta
_
le=-xi
_
le;
x
_
le =double(subs(x,{xi,eta},{xi
_
le,eta
_
le}));
y
_
le =double(subs(y,{xi,eta},{xi
_
le,eta
_
le}));
%% Plot of natural and geometrical spaces
figure1=figure;
subplot(1,2,1); % Plot in natural space
title(Natural Space,Fontsize,16);
xlabel(\xi,Fontsize,16);ylabel(\eta,Fontsize,16);
hold on;
plot(xi
_
g,eta
_
g,sr,LineWidth,1.8,MarkerSize,10);
plot(xi
_
i,eta
_
i,xk,LineWidth,1.8,MarkerSize,10);
plot(xi
_
centre,eta
_
centre,ok,LineWidth,1.8,MarkerSize,10);
plot(xi
_
l,eta
_
l,--b,LineWidth,1.8); % diagonal line
plot(xi
_
le,eta
_
le,--b,LineWidth,1.8); % diagonal line
plot(xi
_
c,eta
_
c,-c,LineWidth,1.8); % upper line
plot(xi
_
t,eta
_
t,.k); % random points
axis([-1.1,1.1,-1.1,1.1]);axis equal
legend(Gauss points,Nodal points,Center point,Location,NorthEast);legend(boxoff);
set(gca,Fontsize,16);
subplot(1,2,2); % Plot in real space
title(Actual Space,Fontsize,16);
xlabel(x,Fontsize,16);ylabel(y,Fontsize,16);
hold on;
plot(x
_
g,y
_
g,sr,LineWidth,1.8,MarkerSize,10);
plot(x
_
i,y
_
i,xk,LineWidth,1.8,MarkerSize,10);
plot(x
_
centre,y
_
centre,ok,LineWidth,1.8,MarkerSize,10);
plot(x
_
l,y
_
l,--b,LineWidth,1.8) % diagonal line
plot(x
_
le,y
_
le,--b,LineWidth,1.8) % diagonal line
plot(x
_
c,y
_
c,-c,LineWidth,1.8); % upper line
plot(x
_
t,y
_
t,.k); % random points
axis equal
legend(Gauss points,Nodal points,Center point,Location,NorthEast);legend(boxoff);
set(gca,Fontsize,16);
hold off;
saveas(figure1,[fig
_
FEmet
_
Ex501],eps);
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex401.m
Example 4.2. Calculate the jacobian matrix of the element dened in Example 3.2. By numeric
integration, compute the area of the element and the the volume if the thickness on the nodes 1,
2, 3 and 4 respectively are 0.2, 0.22, 0.24 and 0.21.
Solution to Example 4.2. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 4.02
% J.A. Mayugo, 2007. D. Trias, 2009
%---------------------------------------------------%
% %
% Isoparametric formulation %
% Quadrilateral bilineal element %
% %
%---------------------------------------------------%
clear all, close all
syms xi eta x y %real
% Shape function in natural space
N(1)=1/4
*
(1-xi)
*
(1-eta);
N(2)=1/4
*
(1+xi)
*
(1-eta);
N(3)=1/4
*
(1+xi)
*
(1+eta);
30 Pre and post-process tools in nite element analysis
1 0 1
2
1.5
1
0.5
0
0.5
1
1.5
2
Natural Space

Gauss points
Nodal points
Center point
0.5 1 1.5 2 2.5
0.5
1
1.5
2
2.5
3
3.5
4
Actual Space
x
y
Gauss points
Nodal points
Center point
Figure 4.1: 4-noded plane element.
N(4)=1/4
*
(1-xi)
*
(1+eta);
N
sumN=simplify(N(1)+N(2)+N(3)+N(4)) %completeness check property
% in natural coordinates: [node1, node2, node3, node 4]
xi
_
i =[-1,+1,+1,-1];
eta
_
i =[-1,-1,+1,+1];
% in geometrical coordinates: [node1, node2, node3, node 4]
x
_
i = [1.0,2.0,2.5,0.5];
y
_
i = [1.5,1.8,3.0,2.5];
% thickness associated to each node: [node1, node2, node3, node 4]
th
_
i = [0.20,0.22,0.24,0.21];
X = [x
_
i;y
_
i];
%% geometrical coordinates as a function of natural coordinates
for j=1:4
x = x
_
i(1)
*
N(1)+x
_
i(2)
*
N(2)+x
_
i(3)
*
N(3)+x
_
i(4)
*
N(4);
y = y
_
i(1)
*
N(1)+y
_
i(2)
*
N(2)+y
_
i(3)
*
N(3)+y
_
i(4)
*
N(4);
end
%% thickness as a function of natural coordinates
for j=1:4
th = th
_
i(1)
*
N(1)+th
_
i(2)
*
N(2)+th
_
i(3)
*
N(3)+th
_
i(4)
*
N(4);
end
%% Gauss Points g and associated weights w in natural coordinates
%% (xi,eta)
g1=[0];w1=[2]; % p = 1
g2=[-1/sqrt(3) 1/sqrt(3)];w2=[1 1]; % p = 2
g3=[-sqrt(3/5) 0 sqrt(3/5)];w3=[5/9 8/9 5/9]; % p = 3
g4=[-sqrt(3+2
*
sqrt(6/5)/7) -sqrt(3-2
*
sqrt(6/5)/7) ...
sqrt(3-2
*
sqrt(6/5)/7) sqrt(3+2
*
sqrt(6/5)/7)];
w4=[1/2-1/6
*
sqrt(5/6) 1/2+1/6
*
sqrt(5/6)...
1/2+1/6
*
sqrt(5/6) 1/2-1/6
*
sqrt(5/6)]; % p = 4
Chapter 4. Iso-parametric formulation of 2-D solid elements 31
% Gauss points for p=2;
xi
_
g=[g2(1),g2(2),g2(1),g2(2)];
eta
_
g=[g2(1),g2(1),g2(2),g2(2)];
x
_
g=double(subs(x,{xi,eta},{xi
_
g,eta
_
g}));
y
_
g=double(subs(y,{xi,eta},{xi
_
g,eta
_
g}));
%% Jacobian matrix (alternative computation)
%for j=1:4
% P(1,j)=diff(N(j),xi);
% P(2,j)=diff(N(j),eta);
%end
%J=P
*
X % Jacobian
J=[diff(x,xi) diff(y,xi); % Jacobian
diff(x,eta) diff(y,eta)]
invJ=inv(J) % Inverse jacobian
detJ=det(J) % det of jacobian
%% Computation of Element Area
Area=0;Area
_
n=0;
for i=1:2
for j=1:2
Area
_
n = Area
_
n + w2(i)
*
w2(j);
Area = Area + w2(i)
*
w2(j)
*
double(subs(detJ,{xi,eta},{g2(i),g2(j)}));
end
end
Area
_
n
Area
%% Computation of Element Volume
Volume=0;Volume
_
n=0;
for i=1:2
for j=1:2
Volume
_
n = Volume
_
n + w2(i)
*
w2(j)
*
double(subs(th,{xi,eta},{g2(i),g2(j)}));
Volume = Volume + w2(i)
*
w2(j)
*
double(subs(th,{xi,eta},{g2(i),g2(j)}))...
*
double(subs(detJ,{xi,eta},{g2(i),g2(j)}));
end
end
Volume
_
n
Volume
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex402.m
The computed area is 1.65 and the computed volume is 0.36.
Example 4.3. Calculate the stiffness matrix of the 4-noded element shown in Figure 4.2. Thick-
ness is 1 mm and the material is steel (E = 210 GPa and = 0.3).
Figure 4.2: 4-noded plane element.
Solution to Example 4.3. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 4.03
% A. Turon, 2007
32 Pre and post-process tools in nite element analysis
%---------------------------------------------------%
% %
% ISO-P %
% 4-noded element %
% %
%---------------------------------------------------%
clear all, close all
syms x y x1 xi eta real
% geometric coordeninates : [node1, node2, node3, node 4]
x
_
i = [0.0,1.0,1.0,0.0];
y
_
i = [0.0,0.0,1.0,1.0];
t=1 % constant thickness
E=210000 % Elastic modulus MPa
nu=0.3 % Poisson coefficient
N1=1/4
*
(1-xi)
*
(1-eta); % Shape functions
N2=1/4
*
(1+xi)
*
(1-eta);
N3=1/4
*
(1+xi)
*
(1+eta);
N4=1/4
*
(1-xi)
*
(1+eta);
x=simplify(N1
*
x
_
i(1)+N2
*
x
_
i(2)+N3
*
x
_
i(3)+N4
*
x
_
i(4))
y=simplify(N1
*
y
_
i(1)+N2
*
y
_
i(2)+N3
*
y
_
i(3)+N4
*
y
_
i(4))
J=[diff(x,xi) diff(y,xi); % Jacobian
diff(x,eta) diff(y,eta)]
J1=inv(J)
dN1
_
x=diff(N1,xi)
*
J1(1,1) + diff(N1,eta)
*
J1(2,1);
dN1
_
y=diff(N1,xi)
*
J1(1,2) + diff(N1,eta)
*
J1(2,2);
dN2
_
x=diff(N2,xi)
*
J1(1,1) + diff(N2,eta)
*
J1(2,1);
dN2
_
y=diff(N2,xi)
*
J1(1,2) + diff(N2,eta)
*
J1(2,2);
dN3
_
x=diff(N3,xi)
*
J1(1,1) + diff(N3,eta)
*
J1(2,1);
dN3
_
y=diff(N3,xi)
*
J1(1,2) + diff(N3,eta)
*
J1(2,2);
dN4
_
x=diff(N4,xi)
*
J1(1,1) + diff(N4,eta)
*
J1(2,1);
dN4
_
y=diff(N4,xi)
*
J1(1,2) + diff(N4,eta)
*
J1(2,2);
B=[ dN1
_
x 0 dN2
_
x 0 dN3
_
x 0 dN4
_
x 0;
0 dN1
_
y 0 dN2
_
y 0 dN3
_
y 0 dN4
_
y;
dN1
_
y dN1
_
x dN2
_
y dN2
_
x dN3
_
y dN3
_
x dN4
_
y dN4
_
x];
D=E/(1-nu^2)
*
[1 nu 0;nu 1 0; 0 0 (1-nu)/2]; % Plane stress
% Numerical integration: 2 Gauss points in each direction, p = 2
% G1(-1/sqrt(3),-1/sqrt(3)) 4 o----------o 3
% G2( 1/sqrt(3),-1/sqrt(3)) | G4 G3 |
% G3( 1/sqrt(3), 1/sqrt(3)) | |
% G4(-1/sqrt(3), 1/sqrt(3)) | G1 G2 |
% 1 o----------o 2
f
_
= simplify (t
*
det(J)
*
B
*
D
*
B); % Gauss function
kG1=subs(1
*
1
*
f
_
,{xi,eta},{-1/sqrt(3),-1/sqrt(3)}); % Evaluation of Gauss function at G1
kG2=subs(1
*
1
*
f
_
,{xi,eta},{ 1/sqrt(3),-1/sqrt(3)});
kG3=subs(1
*
1
*
f
_
,{xi,eta},{ 1/sqrt(3), 1/sqrt(3)});
kG4=subs(1
*
1
*
f
_
,{xi,eta},{-1/sqrt(3), 1/sqrt(3)});
k
_
=kG1+kG2+kG3+kG4 % Stiffness matrix
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex403
_
4nodes.m
Example 4.4. Calculate the nodal displacements of the 4-noded element shown in Figure 4.3a.
The nodal forces are:
Verify that the reaction forces are equal that appear in Figure 4.3b. So the nodal vector force
Chapter 4. Iso-parametric formulation of 2-D solid elements 33
Figure 4.3: 4-noded plane element.
must be:
_

_
Fu
1
Fv
1
Fu
2
Fv
2
Fu
3
Fv
3
Fu
4
Fv
4
_

_
=
_

_
20
1
10
1
10
0
0
0
_

_
N (4.2)
Solution to Example 4.4. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 4.04
% A. Turon, 2007
%---------------------------------------------------%
% %
% ISO-P %
% 4-noded element %
% %
%---------------------------------------------------%
clear all, close all
syms x y x1 xi eta real
% geometric coordeninates : [node1, node2, node3, node 4]
x
_
i = [0.0,10.0,1.0,0.0];
y
_
i = [0.0,0.0,1.0,10.0];
t=1 % constant thickness
E=210000 % Elastic modulus MPa
nu=0.3 % Poisson coefficient
N1=1/4
*
(1-xi)
*
(1-eta); % Shape functions
N2=1/4
*
(1+xi)
*
(1-eta);
N3=1/4
*
(1+xi)
*
(1+eta);
N4=1/4
*
(1-xi)
*
(1+eta);
x=simplify(N1
*
x
_
i(1)+N2
*
x
_
i(2)+N3
*
x
_
i(3)+N4
*
x
_
i(4))
y=simplify(N1
*
y
_
i(1)+N2
*
y
_
i(2)+N3
*
y
_
i(3)+N4
*
y
_
i(4))
J=[diff(x,xi) diff(y,xi); % Jacobian
diff(x,eta) diff(y,eta)]
J1=inv(J)
dN1
_
x=diff(N1,xi)
*
J1(1,1) + diff(N1,eta)
*
J1(2,1);
dN1
_
y=diff(N1,xi)
*
J1(1,2) + diff(N1,eta)
*
J1(2,2);
dN2
_
x=diff(N2,xi)
*
J1(1,1) + diff(N2,eta)
*
J1(2,1);
dN2
_
y=diff(N2,xi)
*
J1(1,2) + diff(N2,eta)
*
J1(2,2);
dN3
_
x=diff(N3,xi)
*
J1(1,1) + diff(N3,eta)
*
J1(2,1);
dN3
_
y=diff(N3,xi)
*
J1(1,2) + diff(N3,eta)
*
J1(2,2);
dN4
_
x=diff(N4,xi)
*
J1(1,1) + diff(N4,eta)
*
J1(2,1);
34 Pre and post-process tools in nite element analysis
dN4
_
y=diff(N4,xi)
*
J1(1,2) + diff(N4,eta)
*
J1(2,2);
B=[ dN1
_
x 0 dN2
_
x 0 dN3
_
x 0 dN4
_
x 0;
0 dN1
_
y 0 dN2
_
y 0 dN3
_
y 0 dN4
_
y;
dN1
_
y dN1
_
x dN2
_
y dN2
_
x dN3
_
y dN3
_
x dN4
_
y dN4
_
x];
D=E/(1-nu^2)
*
[1 nu 0;nu 1 0; 0 0 (1-nu)/2]; % Plane stress
% Numerical integration: 2 Gauss points in each direction, p = 2
% G1(-1/sqrt(3),-1/sqrt(3)) 4 o----------o 3
% G2( 1/sqrt(3),-1/sqrt(3)) | G4 G3 |
% G3( 1/sqrt(3), 1/sqrt(3)) | |
% G4(-1/sqrt(3), 1/sqrt(3)) | G1 G2 |
% 1 o----------o 2
f
_
= simplify (t
*
det(J)
*
B
*
D
*
B); % Gauss function
kG1=subs(1
*
1
*
f
_
,{xi,eta},{-1/sqrt(3),-1/sqrt(3)}); % Evaluation of Gauss function at G1
kG2=subs(1
*
1
*
f
_
,{xi,eta},{ 1/sqrt(3),-1/sqrt(3)});
kG3=subs(1
*
1
*
f
_
,{xi,eta},{ 1/sqrt(3), 1/sqrt(3)});
kG4=subs(1
*
1
*
f
_
,{xi,eta},{-1/sqrt(3), 1/sqrt(3)});
k
_
=kG1+kG2+kG3+kG4 % Stiffness matrix
% u=[0 0 u2x 0 u3x u3y u4x u4y]
k
_
red=k
_
;
k
_
red(:,4)=[];k
_
red(4,:)=[];
k
_
red(:,1:2)=[];k
_
red(1:2,:)=[];
f
_
red = [10 10 0 0 0];
u
_
red = inv(k
_
red)
*
f
_
red;
u
_
= [0 0 u
_
red(1) 0 u
_
red(2) u
_
red(3) u
_
red(4) u
_
red(5)] % Nodal displacements
f
_
=k
_
*
u
_
% Nodal equivalent forces
% %% Plot nodal displacements
% u
_
i = [u
_
(1) u
_
(3) u
_
(5) u
_
(7)];
% v
_
i = [u
_
(2) u
_
(4) u
_
(6) u
_
(8)];
% factor=1e3;
% figure1 = figure;
% hold on
% plot(x
_
i,y
_
i,x)
% plot(x
_
i+factor
*
u
_
i,y
_
i+factor
*
v
_
i,xk,LineWidth,2)
% hold off
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex404
_
4nodes
_
distorted.m
The execution of the previous script in MATLAB
TM
gives different solutions for reaction force.
The nodal forces obtained from execution of previous script returns:
_

_
Fu
1
Fv
1
Fu
2
Fv
2
Fu
3
Fv
3
Fu
4
Fv
4
_

_
=
_

_
20
5.78
10
5.78
10
0
0
0
_

_
N (4.3)
That is, the element do not satisfy the global equilibrium. It is obvious that this solution is erro-
neous. This is a consequence of the high distortion of the element that results in an inaccurate
stiffness matrix.
Suggested Problems
Problem 4.1. Calculate the stiffness matrix of the element dened in Example 4.1 and 4.2 (val-
ues are in mm). Use plane stress and isotropic properties for the material (E =70000 MPa and
Chapter 4. Iso-parametric formulation of 2-D solid elements 35
=0.29).
Problem 4.2. Using the iso-parametric formulation of the bilinear quadrilateral element, calcu-
late the expression of the stiffness element matrix for a rectangular element with dimensions 2a
and 2b. Compare the obtained results with the solution of Problem 8.2. Show all work in a report.
Problem 4.3. Calculate the stiffness element matrix of an eight-node serendipity element under
plane strain. Obtain the general expression function of the nodes position and material proper-
ties. Show all work in a report.
Figure 4.4: 8-noded plane serendipity element.
Hint 2: Shape functions eight-node serendipity element
The shape functions are computed using similar procedure that in lagrangian elements.
The shape functions for middle edge nodes are obtained by product of one-dimensional
shape function in each direction. For example, the node #2 in Figure 4.4 have a quadratic
function in direction (3 nodes) and a linear function in direction (2 nodes), so the two-
dimensional shape function is
N
2
() = (1
2
)
N
2
() =
1
2
(1 )
_
N
2
(, ) = N
2
()N
2
() = (1
2
)
1
2
(1 )
The shape function for corners nodes needs a algebraic addition. For example to obtain the
shape functions of node #1:
1) A two-dimensional lineal function

N
1
(, ) is dened between the considered node #1
and the adjacent corner nodes (nodes #3 and #7). Therefore, in the nodes #2 and #8 the
value is 1/2 (see Figure 4.5).

N
1
() =
1
2
(1 )

N
1
() =
1
2
(1 )
_

N
1
(, ) =

N
1
()

N
1
() =
1
4
(1 )(1 )
2) The shape functions of nodes #2 and #8 divided by 2 are subtracted to

N
1
(, ), and the
shape function for the node #1 is obtained as
N
1
(, ) =

N
1
(, )
1
2
(N
2
(, ) + N
8
(, ))
36 Pre and post-process tools in nite element analysis
Figure 4.5: Shape function of node #1 of 8-noded plane serendipity element.
Chapter 5
Numerical Integration, Stress
Recovery and Error Estimation
Examples
Hint 3: Gauss quadrature
General one-dimensional Gauss quadrature formula:
_
1
1
f(x) dx =
ng

i=1
w
i
f(x
i
)
In one dimension, quadrature of order n
g
(which means n
g
quadrature points) is able to
integrate exactly a polynomial of degree 2n
g
1
In two dimensions, the same rule stands for each natural coordinate direction
Example 5.1. Obtain the quadrature rule for n
g
= 2, considering the gauss points are symmetric.
Solution to Example 5.1. The solution implemented using MATLAB
TM
is shown below
% Example 6.1. Gauss Quadrature
% D. Trias, 2008
syms a0 a1 a2 a3 x x1 x2 w1 w2 real
alpha=[a0 a1 a2 a3];
pol=[1 x x^2 x^3]
f=alpha
*
pol
fint=int(f,-1,1)
% 2 point quadrature
ng=2;
w=[w1 w2];
xg=[x1 x2];
intg=0;
for i=1:ng,
intg=intg+w(i)
*
subs(f,{x},{xg(i)})
end
intg2=subs(intg,{w2,x2},{w1,-x1})
37
38 Pre and post-process tools in nite element analysis
intg2=simplify(intg2)
syms solu
solu=fint-intg2
[x1,w1]=solve(solu=0)
% We cannot solve yet so we impose w1=1
intg3=subs(intg2,{w1},{1})
x1=solve(fint-intg3)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex501-gauss.m
You may verify that these points are the same given in the hint-box Numerical integration of
Chapter 4.
Example 5.2. Show that Gauss points are optimal for stress estimation. Assume that the real
stress solution is given by f(x) = 1 + x + x
2
Solution to Example 5.2. The solution implemented using MATLAB
TM
is shown below
% Example 6.2 - Optimal stress points
% D. Trias, 2008
clear all
syms x a b real
f=1 +x +x^2; % Real stress distribution
g = a+b
*
x; % FEM approximation of Stress for quadratic shape functions
error = int((f-g)^2,x,-1,1);
a=solve(diff(error,a))
b=solve(diff(error,b))
g=eval(g);
optimal=solve(f-g);
optimal=simplify(optimal)
x
_
=-1:0.1:1;
y
_
=subs(f,x,x
_
);
g
_
=subs(g,x,x
_
);
plot(x
_
,y
_
,red)
hold on
plot(x
_
,g
_
,blue)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex502-optimal.m
Check that optimal points for stress evaluation are those obtained in the previous example.
Hint 4: Nodal stress recovery
The stress distribution at an element e may be obtained directly from the nodal displace-
ments:

(e)
(, ) = D B u
(e)
where Dis the constitutive matrix, B is the shape function derivatives matrix and u
(e)
is the
displacement vector at the nodes of the element. So substituting the natural coordinates (, )
of each node, the stresses at the nodes might be obtained.
Chapter 5. Numerical Integration, Stress Recovery and Error Estimation 39
Example 5.3. Consider an element with nodes located at (0, 0), (1.0, 0.5) (1.5, 1.5) and (0, 1.0)
(in mm). The displacement solution at this nodes is given by the vector: (0.0, 0.0, 1.5 10
3
, 3.0
10
3
, 1.5 10
3
, 1.0 10
3
, 0.0, 2.3 10
3
) mm. Find the stress distribution on this element from
the nodal displacements. The material is steel (E = 210 GPa and = 0.3) and plane stress may
be assumed.
Solution to Example 5.3. The solution implemented using MATLAB
TM
is shown below
%function [s]=local
_
extrapol[u,x
_
i,y
_
i]
% Stress recovery for a 4 node lagrangian element
% Stress from nodal values - Wrong method!!!
% D. Trias, 2008
u=1.0e-3
*
[0.0 0.0 1.5 3.0 1.5 -1.0 0.0 -2.3];
x
_
i=[0 1 1.5 0];
y
_
i=[0 -0.5 1.5 1];
E=210000.0 % Elastic modulus MPa
nu=0.3 % Poisson coefficient
syms N
_
N eta xi eta
_
xi
_
p M temp ug S xg eg real
N
_
=1/4
*
(1+xi
*
xi
_
)
*
(1+eta
*
eta
_
)
xin=[ -1 1 1 -1];
etan=[-1 -1 1 1];
for i=1:4,
N(i)=subs(N
_
,{xi
_
,eta
_
},{xin(i),etan(i)})
end
x=N
*
x
_
i; % Geometric aproximation
y=N
*
y
_
i;
J=[diff(x,xi) diff(y,xi); % Jacobian
diff(x,eta) diff(y,eta)]
J1=inv(J)
for i=1:4,
dN
_
x(i)=diff(N(i),xi)
*
J1(1,1) + diff(N(i),eta)
*
J1(1,2);
dN
_
y(i)=diff(N(i),xi)
*
J1(2,1) + diff(N(i),eta)
*
J1(2,2);
end
for i=1:4,
B(1:3,2
*
i-1:2
*
i)=[dN
_
x(i) 0; 0 dN
_
y(i);dN
_
y(i) dN
_
x(i)]
end
B=simplify(B)
D=E/(1.0-nu^2)
*
[1.0 nu 0.0;nu 1.0 0.0; 0.0 0.0 (1.0-nu)/2.0];
eps=B
*
u;
S=D
*
eps; % Stress field from displacements at Gauss points
% Strains at nodes
for i=1:4,
en(i,1:3)=subs(eps,{xi,eta},{xin(i),etan(i)})
end
% Stresses at nodes
for i=1:4,
Snn(i,1:3)=subs(S,{xi,eta},{xin(i),etan(i)});
end
Snn
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex503
_
nodal
_
stress.m
40 Pre and post-process tools in nite element analysis
Compare the solution with the one given by of ANSYS, which can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet504
_
stress-recovery.dat
Hint 5: Nodal stress recovery from Gauss points. Local extrapolation (Direct method).
The stress distribution at an element e may be obtained directly from the nodal displace-
ments:

(e)
(, ) = D B u
(e)
where D is the constitutive matrix, B is the shape function derivatives matrix and u
(e)
is
the displacement vector at the nodes of the element. So substituting the natural coordinates
(, ) of each integration point, the stresses at the integration points (
G
) might be obtained.
As seen in Example 5.2 the stress estimation at these points is optimal. So, if the nodal stresses
are to be obtained, they may be extrapolated from the values at the integration points (
G
) by
writting the shape functions in Gaussian-element coordinates (

):

(e)
(, ) =
ng

i=1
N
i
(

)
G
For a 2 point quadrature, if Gauss points are located at (1/p) and (1/p), the conversion
from natural coordinates to Gaussian element coordinates may be written:

= p

= p
So, considering the Gauss points located at 1/

3 and 1/

3 at each natural direction, the


location of the nodes in Gaussian-element coordinates is

3 and

3 the following matrix


relation may be obtained:
_
_
_
_

4
_
_
_
_
=
_
_
_
_
_
_
1 +

3
2

1
2
1

3
2

1
2

1
2
1 +

3
2

1
2
1

3
2
1

3
2

1
2
1 +

3
2

1
2

1
2
1

3
2

1
2
1 +

3
2
_
_
_
_
_
_
_
_
_
_

II

III

IV
_
_
_
_
where (
1
. . .
4
) are a stress component at nodes 1 to 4 and (
I
. . .
IV
) are that stress com-
ponent at integration points I to IV.
Remarks:
You may see the former expression as a weighted mean
Check that since the sum of shape functions equals 1, the sum of the coefcients at each
row equals 1.
This method gives a discontinuous stress from element to element, so some averaging
should be applied at nodes belonging to more than one element. This would provide a
smoothed solution.
Chapter 5. Numerical Integration, Stress Recovery and Error Estimation 41
Example 5.4. Compute the nodal stresses on the element of Example by extrapolation of the
stresses at the Gauss points.
Solution to Example 5.4. The solution implemented using MATLAB
TM
is shown below
%function [s]=local
_
extrapol[u,x
_
i,y
_
i]
% Stress recovery for a 4 node lagrangian element
% Direct method
% Simple case for verification
%u=1.0e-3
*
[0.0 0.0 1 0.0 1 -0.3 0 -0.3 ];
%x
_
i=[0 1 1 0];
%y
_
i=[0 0 1 1];
u=1.0e-3
*
[0.0 0.0 1.5 3.0 1.5 -1.0 0.0 -2.3];
x
_
i=[0 1 1.5 0];
y
_
i=[0 -0.5 1.5 1];
E=210000 % Elastic modulus MPa
nu=0.3 % Poisson coefficient
syms N
_
N eta xi eta
_
xi
_
p M temp S xg eg real
N
_
=1/4
*
(1+xi
*
xi
_
)
*
(1+eta
*
eta
_
)
xig=[ -1 1 1 -1]; % Nodal natural coordinates
etag=[-1 -1 1 1];
p=sqrt(3.0);
xg=[-1/p 1/p 1/p -1/p]; % Gauss points natural coordinates
eg=[-1/p -1/p 1/p 1/p];
for i=1:4,
N(i)=subs(N
_
,{xi
_
,eta
_
},{xig(i),etag(i)})
end
x=simplify(N
*
x
_
i); % Geometric aproximation
y=simplify(N
*
y
_
i);
J=[diff(x,xi) diff(y,xi); % Jacobian
diff(x,eta) diff(y,eta)]
detJ=det(J);
dxxi=diff(x,xi);
dxeta=diff(x,eta);
dyxi=diff(y,xi);
dyeta=diff(y,eta);
for i=1:4,
dNxi=diff(N(i),xi);
dNeta=diff(N(i),eta);
b(i)=dyeta
*
dNxi-dyxi
*
dNeta;
c(i)=dxxi
*
dNeta-dxeta
*
dNxi;
B(1:3,2
*
i-1:2
*
i)=[b(i) 0
0 c(i)
c(i) b(i)];
end
B=simplify(B/detJ)
D=E/(1-nu^2)
*
[1 nu 0;nu 1 0; 0 0 (1-nu)/2];
eps=B
*
u; % Stresses and strains at gauss points
S=D
*
eps;
for i=1:4,
Sg(i,1:3)=subs(S,{xi,eta},{xg(i),eg(i)});
epsg(i,1:3)=subs(eps,{xi,eta},{xg(i),eg(i)});
end
% Nodes in Gauss-element coordinates
xigg=xig.
*
p;
42 Pre and post-process tools in nite element analysis
etagg=etag.
*
p;
% Extrapolation matrix
for i=1:4,
for j=1:4,
M(i,j)=subs(N(j),{xi,eta},{xigg(i),etagg(i)})
end
end
M=eval(M)
% Stresses and strains at nodes extrapolated from Gauss points
Sn=[]
for i=1:3,
Sn(:,i)=M
*
Sg(:,i);
epsn(:,i)=M
*
epsg(:,i);
end
Sn
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex504
_
local
_
extrapol.m
Compare the solution with the one given by of ANSYS, which can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet504
_
stress-recovery.dat
Hint 6: Error estimation
The error of the stress or strain at any location may be dened as:
e

=
e

=
where and are the exact or analytical solution of the problem and and are the
numerical solution. However, generally the analytical solution for most engineering problems
is not available, so to compute the stress error we may use the stress extrapolated from the
Gauss points as the more accurate solution and the stress derived from the nodal displacements
as the less accurate solution:
e

=
G

N
we can compute then the energy norm of the error as:
e

=
__

[
G

N
]
T
D
1
[
G

N
] d
_
1/2
where D is the constitutive matrix. Note there is no need for squaring e

The analogous
expression may be written for e

. For a linear elastic material e

= e

.
Chapter 5. Numerical Integration, Stress Recovery and Error Estimation 43
Hint 7: Remarks in error estimation:
Generally the error is computed:
e

=
s

n
where
n
are the stress nodal values, extrapolated from the stresses at the Gauss points
and
s
are locally or globally smoothed stresses, computed considering that the nodal
stresses may be extrapolated from each element the node belongs to.
In a nite element environment the above norm may be computed as the sum of the norm
at each element.
The energy norm may be compared with the total strain energy dened as:
U =
__


T
G
D
1

G
d
_
1/2
Some programs usually compute a the percent energy error as:
error(%) =
e

U
Hint 8: Norms in nite elements
The above norms have the following property:
e =
N
el

i=1
e
2
i
where i = 1, . . . , N
el
are the elements in the mesh. So, the squared norm on the whole
model can be computed as the summation of the square of the norm at each element.
Example 5.5. Compute the error estimation for the element of the former Examples. Find the
relative error as the relation of the error and the strain energy.
Solution to Example 5.5. The solution implemented using MATLAB
TM
is shown below
% Error estimation
% D. Trias, 2008
% Energetic norm
Dinv=inv(D);
error = 0;
% Compute this loop for each element:
for i=1:4,
44 Pre and post-process tools in nite element analysis
er=Sn(i,1:3)-Snn(i,1:3);
er=er;
error = error+(er
*
Dinv
*
er)/4; % The energy in the element is about
% the mean energy of the nodal values
end
error=sqrt(error)
% Total strain energy
energy = 0;
for i=1:4,
stress=Sn(i,1:3);
energy = energy +(stress
*
Dinv
*
stress)/4; % The energy in the element is about
% the mean energy of the nodal values
end
energy=sqrt(energy);
err
_
rel=(error/energy)
*
100
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex505
_
error
_
estimation.m
Suggested Problems
Problem 5.1. Assume you have solved the nite element mesh given in the Figure 5.1. The
solution displacements are given in Figure 5.2. The material is steel and plane stress may be
assumed.
Figure 5.1: Mesh
Compute:
1. The stresses at each element separately, from the nodal displacement (wrong method).
2. The smoothed stress solution by averaging the obtained nodal stresses.
Chapter 5. Numerical Integration, Stress Recovery and Error Estimation 45
Figure 5.2: Displacement solution
3. The stresses at each element separately, from the stresses at the integration points.
4. The smoothed stress solution by averaging nodal stresses obtained in (3).
5. An error estimation using the results obtained at (3) and (4), being this last result the most
accurate solution.
Show all this work on a report.
Chapter 6
Formulation of 3-D solid elements
Examples
Example 6.1. Calculate the stiffness matrix of a 4-noded tetrahedron element.
Solution to Example 6.1. The solution implemented using MATLAB
TM
is shown below
% FEmet.
% A.Turon 2007
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) and %
% the nodal equival force (p
_
e) %
% %
% 4-noded tetrahedron element CTS %
% %
%---------------------------------------------------%
clear all
syms x y z x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 real % geometry
syms E nu real % material
syms N
_
1 N
_
2 N
_
3 N
_
4
% element volume
V
_
e=1/6
*
det([1 x1 y1 z1;1 x2 y2 z2; 1 x3 y3 z3;1 x4 y4 z4])
% Shape functions
N
_
1=det([1 x y z;1 x2 y2 z2; 1 x3 y3 z3;1 x4 y4 z4])/(6
*
V
_
e)
N
_
2=det([1 x1 y1 z1;1 x y z; 1 x3 y3 z3;1 x4 y4 z4])/(6
*
V
_
e)
N
_
3=det([1 x1 y1 z1;1 x2 y2 z2; 1 x y z;1 x4 y4 z4])/(6
*
V
_
e)
N
_
4=det([1 x1 y1 z1;1 x2 y2 z2; 1 x3 y3 z3;1 x y z])/(6
*
V
_
e)
N
_
=[N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4 0 0;
0 N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4 0;
0 0 N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4;]
%% Strain-displacement matrix B
dN1
_
x=diff(N
_
1,x);
dN1
_
y=diff(N
_
1,y);
dN1
_
z=diff(N
_
1,z);
dN2
_
x=diff(N
_
2,x);
dN2
_
y=diff(N
_
2,y);
dN2
_
z=diff(N
_
2,z);
dN3
_
x=diff(N
_
3,x);
dN3
_
y=diff(N
_
3,y);
dN3
_
z=diff(N
_
3,z);
dN4
_
x=diff(N
_
4,x);
dN4
_
y=diff(N
_
4,y);
dN4
_
z=diff(N
_
4,z);
B=[ dN1
_
x 0 0 dN2
_
x 0 0 dN3
_
x 0 0 dN4
_
x 0 0;
0 dN1
_
y 0 0 dN2
_
y 0 0 dN3
_
y 0 0 dN4
_
x 0;
47
48 Pre and post-process tools in nite element analysis
0 0 dN1
_
z 0 0 dN2
_
z 0 0 dN3
_
z 0 0 dN4
_
z;
dN1
_
y dN1
_
x 0 dN2
_
y dN2
_
x 0 dN3
_
y dN3
_
x 0 dN4
_
y dN4
_
x 0;
0 dN1
_
z dN1
_
y 0 dN2
_
z dN2
_
y 0 dN3
_
z dN3
_
y 0 dN4
_
z dN4
_
y;
dN1
_
z 0 dN1
_
x dN2
_
z 0 dN2
_
x dN3
_
z 0 dN3
_
x dN4
_
z 0 dN4
_
x];
% Constitutive matrix
D=E/(1+nu)/(1-2
*
nu)
*
[1-nu nu nu 0 0 0;nu 1-nu nu 0 0 0; nu nu 1-nu 0 0 0;
0 0 0 (1-2
*
nu)/2 0 0;0 0 0 0 (1-2
*
nu)/2 0 ;0 0 0 0 0 (1-2
*
nu)/2;]
% Stiffness matrix
k
_
= simplify (V
_
e
*
B
*
D
*
B)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex701.m
Example 6.2. Using the formulation derived in previous exercise, calculate the nodal force vec-
tor, the nodal stresses and nodal strains of the 4-noded element with the following nodal coordi-
nates:
node
1
(0, 40, 0)
node
2
(30, 0, 0)
node
3
(0, 0, 50)
node
4
(0, 0, 0)
all nodal displacements are 0 except:
u
x3
= 1mm
u
y4
= 2mm
E = 2.110
6
, = 0.2.
Solution to Example 6.2. The solution implemented using MATLAB
TM
is shown below
% FEmet.
% A.Turon 2007
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) and %
% the nodal equival force (p
_
e) %
% %
% 4-noded tetrahedron element CTS %
% %
%---------------------------------------------------%
clear all
syms x y z real
% Material properties
E=2e6
nu=0.2
% Nodal coordinates
x1=0;y1=40;z1=0;
x2=30;y2=0;z2=0;
x3=0;y3=0;z3=50;
x4=0;y4=0;z4=0
% element volume
V
_
e=1/6
*
det([1 x1 y1 z1;1 x2 y2 z2; 1 x3 y3 z3;1 x4 y4 z4])
% Shape functions
N
_
1=det([1 x y z;1 x2 y2 z2; 1 x3 y3 z3;1 x4 y4 z4])/(6
*
V
_
e)
N
_
2=det([1 x1 y1 z1;1 x y z; 1 x3 y3 z3;1 x4 y4 z4])/(6
*
V
_
e)
N
_
3=det([1 x1 y1 z1;1 x2 y2 z2; 1 x y z;1 x4 y4 z4])/(6
*
V
_
e)
N
_
4=det([1 x1 y1 z1;1 x2 y2 z2; 1 x3 y3 z3;1 x y z])/(6
*
V
_
e)
N
_
=[N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4 0 0;
0 N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4 0;
0 0 N
_
1 0 0 N
_
2 0 0 N
_
3 0 0 N
_
4;]
%% Strain-displacement matrix B
dN1
_
x=diff(N
_
1,x);
Chapter 6. Formulation of 3-D solid elements 49
dN1
_
y=diff(N
_
1,y);
dN1
_
z=diff(N
_
1,z);
dN2
_
x=diff(N
_
2,x);
dN2
_
y=diff(N
_
2,y);
dN2
_
z=diff(N
_
2,z);
dN3
_
x=diff(N
_
3,x);
dN3
_
y=diff(N
_
3,y);
dN3
_
z=diff(N
_
3,z);
dN4
_
x=diff(N
_
4,x);
dN4
_
y=diff(N
_
4,y);
dN4
_
z=diff(N
_
4,z);
B=[ dN1
_
x 0 0 dN2
_
x 0 0 dN3
_
x 0 0 dN4
_
x 0 0;
0 dN1
_
y 0 0 dN2
_
y 0 0 dN3
_
y 0 0 dN4
_
x 0;
0 0 dN1
_
z 0 0 dN2
_
z 0 0 dN3
_
z 0 0 dN4
_
z;
dN1
_
y dN1
_
x 0 dN2
_
y dN2
_
x 0 dN3
_
y dN3
_
x 0 dN4
_
y dN4
_
x 0;
0 dN1
_
z dN1
_
y 0 dN2
_
z dN2
_
y 0 dN3
_
z dN3
_
y 0 dN4
_
z dN4
_
y;
dN1
_
z 0 dN1
_
x dN2
_
z 0 dN2
_
x dN3
_
z 0 dN3
_
x dN4
_
z 0 dN4
_
x];
% Constitutive matrix
D=E/(1+nu)/(1-2
*
nu)
*
[1-nu nu nu 0 0 0;nu 1-nu nu 0 0 0; nu nu 1-nu 0 0 0;
0 0 0 (1-2
*
nu)/2 0 0;0 0 0 0 (1-2
*
nu)/2 0 ;0 0 0 0 0 (1-2
*
nu)/2;]
% Stiffness matrix
k
_
= eval(V
_
e
*
B
*
D
*
B)
% Nodal displacement vector
u
_
e=[0;0;0;0;0;0;1;0;0;0;2;0]
% Nodal forces
f
_
e=(k
_
*
u
_
e)
% Nodal strains
eval(B
*
u
_
e)
% Nodal stresses
eval(D
*
B
*
u
_
e)
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex702.m
Suggested Problems
Problem6.1. Program an eight-node 3-D solid element using iso-parametric formulation. Obtain
the general expression function of the stiffness element matrix. Show all work in a report.
Problem 6.2. Using the formulation derived in previous problem, calculate the nodal force vec-
tor, the nodal stresses and nodal strains of the 4-noded element with the following nodal coordi-
nates:
node
1
(10, 0, 0) node
2
(10, 10, 0) node
3
(0, 10, 0) node
4
(0, 0, 0)
node
5
(10, 0, 5) node
6
(10, 10, 5) node
7
(0, 10, 5) node
8
(0, 0, 5)
all nodal displacements are 0 except
u
x3
= 1mm
u
y4
= 2mm
u
x7
= 1mm
u
y8
= 2mm
E = 2.110
6
, = 0.2
Chapter 7
Axysimetric problems
Examples
Hint 9: Stiffness matrix for axysimetric problems
For solving axysimetric problems the same formulation used for 2D plane elements can be
used, updating the kinematic relations and the constitutive matrix to axysimetric problems.
The stiffness matrix reads:
K =
_
V
e
B
T
DBdV =
_
1
1
_
1
1
2B
T
DBdet(J)dd
Example 7.1. Calculate the nodal forces and the nodal displacements of the cylindrical shaft
shown in Figure 7.1. Use the formulation given in Example 3.1 and adapt it for an axysimetric
problem. Check that the B matrix is not constant, oppositely to the 3-noded element for 2D plane
problems.
Figure 7.1: Axysimetric problem.
Solution to Example 7.1. The solution implemented using MATLAB
TM
is shown below
% FEmet. solution of Example 6.01
% A. Turon, 2007
%---------------------------------------------------%
% %
% AXYMETRIC %
51
52 Pre and post-process tools in nite element analysis
% Element triangular bidimensional 3 nodes %
% %
%---------------------------------------------------%
clear all
syms r z r1 z1 r2 z2 r3 z3 t A
_
e E nu d11 d12 d22 d33 real
syms r3 z3 r4 z4 H1 H2 R1 R2
A
_
e=det([1 r1 z1;1 r2 z2; 1 r3 z3])/2;
N1=det([1 r z;1 r2 z2; 1 r3 z3])/2/A
_
e;
N2=det([1 r1 z1;1 r z; 1 r3 z3])/2/A
_
e;
N3=det([1 r1 z1;1 r2 z2; 1 r z])/2/A
_
e;
dN1
_
r=diff(N1,r);
dN1
_
z=diff(N1,z);
dN2
_
r=diff(N2,r);
dN2
_
z=diff(N2,z);
dN3
_
r=diff(N3,r);
dN3
_
z=diff(N3,z);
B=[ 0 dN1
_
z 0 dN2
_
z 0 dN3
_
z;
dN1
_
r 0 dN2
_
r 0 dN3
_
r 0 ;
N1/r 0 N2/r 0 N3/r 0 ;
dN1
_
z dN1
_
r dN2
_
z dN2
_
r dN3
_
z dN3
_
r ];
D=E
*
(1-nu)/(1+nu)/(1-2
*
nu)
*
[1 nu/(1-nu) nu/(1-nu) 0;...
nu/(1-nu) 1 nu/(1-nu) 0; nu/(1-nu) nu/(1-nu) 1 0;...
0 0 0 (1-2
*
nu)/2]; % plane strain
k
_
= simplify (2
*
pi
*
r
*
A
_
e
*
B
*
D
*
B);
% Mesh (a)
D=(subs(D,{E,nu},{2.1e5,0.2}))
B
_
1=(subs(B,{E,nu,r1,r2,r3,z1,z2,z3,r,z},{2.1e5,0.2,40,40,60,10,0,10,1/3
*
(40+60+40),1/3
*
(10+0+10)}))
k
_
1=2
*
(subs(k
_
,{E,nu,r1,r2,r3,z1,z2,z3,r,z},{2.1e5,0.2,40,40,60,10,0,10,1/3
*
(40+60+40),1/3
*
(10+0+10)}))
B
_
2=(subs(B,{E,nu,r1,r2,r3,z1,z2,z3,r,z},{2.1e5,0.2,40,60,60,0,0,10,1/3
*
(40+60+60),1/3
*
(0+0+10)}))
k
_
2=2
*
(subs(k
_
,{E,nu,r1,r2,r3,z1,z2,z3,r,z},{2.1e5,0.2,40,60,60,0,0,10,1/3
*
(40+60+60),1/3
*
(0+0+10)}))
%insert 2 rows/columns in k
_
1 relative to u3,v3
i=[1 0 0 0 0 0; 0 1 0 0 0 0 ; 0 0 1 0 0 0; 0 0 0 1 0 0;0 0 0 0 0 0;0 0 0 0 0 0; 0 0 0 0 1 0;0 0 0 0 0 1];
k
_
1e=i
*
k
_
1
*
i
%insert 2 rows/columns in k
_
2 relative to u1,v1
i=[0 0 0 0 0 0;0 0 0 0 0 0;1 0 0 0 0 0; 0 1 0 0 0 0 ; 0 0 1 0 0 0; 0 0 0 1 0 0; 0 0 0 0 1 0;0 0 0 0 0 1];
k
_
2e=i
*
k
_
2
*
i
%Assembly
K=k
_
1e+k
_
2e
%Solve v1=0,v2=0,v3=0,v4=0,r3=0,r4=0
K
_
red(1,1)=K(1,1);
K
_
red(1,2)=K(1,3);
K
_
red(2,1)=K(3,1);
K
_
red(2,2)=K(3,3);
F
_
red=[2514;2514];
K
_
red
F
_
red
u
_
red=single(inv(K
_
red)
*
F
_
red)
u
_
tot(1:8,1)=0;
u
_
tot(1,1)=u
_
red(1);
u
_
tot(3,1)=u
_
red(2);
u
_
tot % Nodal displacements
F=(K
*
u
_
tot) % Nodal forces
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex601.m
Suggested Problems
Problem 7.1. Solve the Example 7.1 using a 4-noded iso-parametric element instead of 3-noded
elements. Show all work in a report.
Chapter 8
Beam element formulation
Examples
Example 8.1. Using a similar procedure as in Example 2.3, calculate the element stiffness matrix
and the equivalent force vector of a two-node Bernoulli beam element with cubic shape functions.
Solution to Example 8.1. The solution implemented using MATLAB is shown below.
% FEmet. solution of Example 3.01. Bernoulli beam
%---------------------------------------------------%
% %
% Compute the element stiffness (k
_
e) and %
% the nodal equival force (p
_
e) %
% %
% two-node element beam (bending) %
% %
%---------------------------------------------------%
clear all
syms x y a0 a1 a2 a3 L E I q real
% shape functions (cubic polinomial)
alpha = [a0 a1 a2 a3]
coef
_
v = [1 x x^2 x^3]
coef
_
theta = diff(coef
_
v,x)
A1=subs(coef
_
v,{x},{0}) % boundary condition v(x=0)
A2=subs(coef
_
theta,{x},{0}) % boundary condition theta(x=0)
A3=subs(coef
_
v,{x},{L}) % boundary condition v(x=L)
A4=subs(coef
_
theta,{x},{L}) % boundary condition theta(x=L)
C = [A1;A2;A3;A4]
N = coef
_
v
*
inv(C)
diff
_
N =coef
_
theta
*
inv(C)
figure(1)
subplot(2,2,1);ezplot(subs(N(1),L,1),[0,1]);title(N
_
1)
subplot(2,2,2);ezplot(subs(N(3),L,1),[0,1]);title(N
_
3)
subplot(2,2,3);ezplot(subs(diff(N(2)),L,1),[0,1]);title(dN
_
2/dx)
subplot(2,2,4);ezplot(subs(diff(N(4)),L,1),[0,1]);title(dN
_
4/dx)
% Strain-displacement matrix B
B=-y
*
diff(diff(N,x),x)
B
_
=diff(diff(N,x),x)
% Stiffness matrix
k
_
e = int(B
_

*
B
_
,x,0,L)
*
E
*
I
% Equivalent nodal force vector
f
_
e=int(N
*
q,0,L)
53
54 Pre and post-process tools in nite element analysis
This le can be found at:
ftp://amade.udg.edu/mme/FEmet/m
_
files/FEmet
_
Ex301.m
Suggested Problems
Problem 8.1. Using the results of Examples 2.3 and 8.1 obtain the element stiffness matrix and
the equivalent force vector of a two-node beam element with axial tensile-compression capability.
Obtain the shape function diagrams along the element length for the six degree of freedom of the
element (three degrees of freedom in each node, in-plane displacements and rotation).
Problem 8.2. With the formulation obtained in Problem 8.1 calculate the displaced position of
the following structure. One only element of two nodes can be used. Choose an appropriate
transversal section geometry and material to achieve a maximum displacement smaller than
100/L.
Problem 8.3. Program a FE code using the element formulation obtained in Problem 8.1 and
the assembly procedure. With this code, calculate a 2-D rigid frame. Show all work in a report.
Problem 8.4. Solve the Problem 8.2 with a FE code using an iso-parametric Bernoulli beam
element formulation with the following shape functions.
N
1
=
1
4
(1 )
2
(2 + ) (8.1)
N
2
=
l
e
8
(1 )
2
(1 + ) (8.2)
N
3
=
1
4
(1 + )
2
(2 ) (8.3)
N
4
=
l
e
8
(1 + )
2
(1 + ) (8.4)

Вам также может понравиться