Linear Interpolation Shape Functions: Element Node 1 2 1 2
Linear Interpolation Shape Functions: Element Node 1 2 1 2
In the finite element method for one-dimensional problems, the region of interest is
divided into elements connecting nodes. The elements and nodes are identified by a
numbering system. The elements are numbered 1, 2, , Ne. The nodes of an element are
identified by 1 and 2 in the local node numbering system. A connectivity table relates
the local node numbers to the global numbers.
Element Node
Element numbers
1 2 3 4 e 1 2 local
1 1 2
1 2 3 4 5
Global numbering 2 2 3 global
3 3 4
4 4 5
Local numbering 1 2
+X
Assume that the solution to a problem is the unknown function u(x). The aim of the finite
element method is to find an approximate solution v(x) by calculating its values at the
nodes from an interpolation function ve(x) defined between two nodes.
u v ve(x)
ve1 ve2
e
+X 1 2 +X
Unknown solution u(x)
Approximate solution
v(x) = ve(x)
Fig. 2. Linear interpolation ve(x) used within each element to give the
approximate solution v(x). ve1 and ve2 are the nodal values of the
approximation function in local coordinates.
To specify the location along the X-axis of a point, both global and local coordinate
systems are used, as shown in figure 3. The global coordinates of the nodes are xi (i = 1,
2, , Ne+1. The local coordinate system is often referred to as a natural or instrinsic
coordinate system, denoted by where
for the ith element of length hi = xi+1 xi. At node 1 of an element, = -1 and at node 2,
= +1.
ith element
1 2
x=0
xi +X
xi+1
x
= -1 = +1
hi
d 2 hi
and dx d (2)
dx hi 2
The natural coordinate system is used to define the linear interpolation shape functions,
N1 and N2 used for the interpolation within the ith element
where ve1 and ve2 are the local nodal values of the function v(x) and
1
N1 ( ) (4a)
2
1
N 2 ( ) (4b)
2
The interpolation functions are straight lines, with N1(-1) = 1, N1(+1) = 0, N2(-1) = 0 and
N2(+1) = 1 as shown in figure 4.
1 N1 N2
ve2
ve1
0
1 2 1 2
= -1 =0 = +1 = -1 = +1
The derivates of the element interpolation function vi and the shape functions N1 and N2
with respect to and x are
dN1 1 dN 2 1
(5a)
d 2 d 2
dN1 dN1 d 1 2 1 dN 2 1
(5b)
dx d dx 2 hi hi dx hi
dvi 1 1
ve1 ve 2 (6a)
d 2 2
dvi dvi d 1 1 1
ve1 ve 2 ve1 ve 2 (6b)
dx d dx hi hi hi
The interpolation function and its first derivative can be written in matrix form as
vi [N]{v e } (7)
dvi 1 1 dvi 1 1
[ ]{v e } [ ]{v e } (8)
d 2 2 dx hi hi
where
ve1
[N] = [N1 N2] and {v e } (9)
ve 2
xe1
x = [N] {xe} = [N1 N2] (10)
xe 2
where xe1 and xe2 are the local nodal X coordinates. When both the approximation
function v and coordinate x are interpolated using the same shape functions, the
formulation is called isoparametric.
We can calculate the integrals of the shape function with respect to x over an element by
calculating the area under the curves for N1 and N2,
hi hi hi
o
N1 dx N 2 dx
o 2
(11a)
and
hi dN1 dN1 hi dN dN 1
0 dx dx
dx
0 dx
2
dx
2
dx
hi
(11b)
hi dN1 dN 2 hi dN dN 1
0 dx dx
dx
0 dx
2
dx
1
dx
hi
(11c)
In the steady-state heat transfer in one direction, our goal is to find the temperature
distribution. A heat flux occurs and a temperature gradient exists along only one
coordinate axis and the temperature at each point is independent of time. Many actual
situations involving heat transfer can be modeled based upon the one-dimensional steady-
state transfer of heat.
dT ( x )
q( x ) ( x ) (12)
dx
There is convective transfer of heat between a fluid and a solid surface as a result of a
temperature difference. The equation for heat transfer by convection is
q hc Ts T (13)
Where q is the convective heat flux (W.m-2), hc is the convection heat transfer coefficient
(W.m-2.K-1), Ts is the surface temperature of the material and T is the fluid temperature.
Heat transfer can also occur by radiation where the heat flux is proportional to the fourth
power of the absolute temperature. This method of heat heat transfer will not be
considered in our models.
Consider the heat conduction through a wall as shown in figure ? The cross section area
of the wall is A and assume a uniform internal generation of heat per unit volume QV
(W.m-3), for example, a wire of resistance R with a current I (QV = I2R/V). QV is usually
called a source when QV > 0 and a sink when QV < 0. For a steady-state situation, the heat
flux and the internal heat generation for a volume element must equal the heat flux
leaving an element for the temperature to remain independent of time, therefore,
dq
q A QV Adx q A (14)
dx
Using Fouriers law and rearranging the equations gives a simple differential equation
governing the one-dimensional steady state conduction of heat through the material
d dT ( x )
( x) QV 0 (15)
dx dx
where T(x) is the temperature along the material which can be determined by solving
equation (15) given the boundary conditions.
1. Dirichlet condition: the nodal values are specified by the boundary conditions. For
example, the temperatures at the ends of the material are specified
2. Neumann condition: the heat fluxes are specified at the boundaries. For example,
where the inside surface is insulated and the flux is zero and the outside surface is a
convection surface
3. Cauchy or mixed condition: Both field values and the field gradients are specified
by the boundary conditions. For example, the inside wall is maintained at a constant
temperature and convective occurs at the outside surface
Galerkins approach
To find the approximate temperature distribution (T v) along the material using the
finite element method, we first define for each element, as in equation (7)
vi [N]{v e } (17)
L d dv
0 dx dx QV [N] dx 0
(18)
Apply integration by parts to the left hand side of equation (18) to give
L
dv L d [ N ] dv L
N 0 dx QV N dx 0
(19)
dx 0
dx dx o
The first term is determined by the boundary conditions at the ends of the material and
can be assigned the values Q1 and QNe+1 which corresponds to the heat flux into the first
element and the heat flux out of the last element.
We can use the isoparametric representation with equation (19), so that for the ith element
we can write
hi
hi d [ N ] dvi dv hi
i dx i N QVi N dx
0 dx dx dx 0
o (20)
Using equations (5) and (6), the right hand side of equation (20) can be expressed as
hi
dv hi
i N2 i QV i N 2 dx qe 2 (21b)
dx o
0
qe1
q (22)
qe 2
e
where the column vector {ve} gives the local nodal values of the unknown function
ve1
ve (24)
ve 2
hi dN j dN1 dN 2
[k e ] i 0 dx dx dx
dx (25a)
hi dN 2 dN1 i hi dN 2 dN 2
ke21 i 0 dx dx
dx
hi
ke 22 i 0
k
dx dx
dx i
hi
(25c)
i 1 1
[ke ] 1 1 (25d)
hi
Assembly Procedure
We need to assemble the global matrices [K], [V] and [Q] from the element matrices [ke],
{ve} and {qe}. For a three element model, the assembly process involves:
1. Construction of the global column matrix for the unknown nodal temperatures {V}
V1 v11
V v1 v 2
V 2
2 1
(27)
V 3 v 22 v 31
V 4 v 32
where terms such as v21 is the unknown value for element 2 and local node 1. The
values of V1 and V4 may be determined by the boundary conditions at the external
nodes.
Q1 q11
Q q1 q2
Q 2
2 1
(28)
Q 3 q22 q31
Q 4 q32
where terms such as q32 is the heat flux across the local node 2 for element 3. If all
quantities are measured in their S.I. unit, then the Qs are measured in watts in this
problem on heat conduction. The Qs represent the rate of heat transfer or heat flux
across each node and the values Q1 and Q4 represent the heat fluxes at the external
boundaries, into and out of the material respectively.
3. Construction of the global thermal coefficient matrix [K] of (Ne +1) rows and
(Ne+1) columns
k111 k112 0 0
k1 k122 k 211 k 212 0
K 21 (29)
0 k 221 k 222 k 311 k 312
0 0 0 k 321 k 322
Each term in the matrix [K] has the S.I. units of W.K-1 (W.C-1). The thermal
coefficient matrix [K] is a banded and sparse matrix because the nonzero terms are
clustered about its main diagonal, and outside this band all the terms are zero. The
The integration by parts of equation (18) has two important implications: (1) it gives
information of the boundary values and (2) it lowered the order of the highest order
derivative appearing in the integrals of the thermal coefficient matrix [K]. The generality
of this assembly process for the finite element method is very advantageous, since a
computer code developed for the solution of one class of problem can be applied to other
classes of problems. The complete system of equations solved by the finite element
method is always of the form
where {V} is the column matrix of nodal values for the assemblage.
Regardless of the type of problem, the system of equation to be solved after the assembly
process will have the form
The physics of the problem determines the boundary conditions that apply. We require at
every node that we know either the Vi or Qi. There are a variety of ways to apply the
boundary conditions.
V1 = 1 and V3 = 2
Again, the system of simultaneous equations can be solved to find the unknown nodal
values.
Parameters
L1 = 0.100 m L2 = 0.050 m 1 = 20 W.m-1.C-1 2 = 50 W.m-1.C-1
T1 = 100 C T2 = 0C
In the steady-state, the heat flux through both materials must be the same. Therefore, q1 =
q2 and we can write
Tx T1 T2 Tx
1 2
L1 L2
And rearranging
Tx
2 / L2 T2 1 / L1 T1
2 / L2 1 / L1
Results of calculation
Tx = 16.6667 C
q = 1.66667104 W.m-2
Matlab Code
% example_xxx.m
clear
clc
% Calculations ***********************************
c = s./L;
% Temperature at interface Tx = T(3)
T(3) = (c(1)*T(1) + c(2)*T(2))/(c(1)+c(2));
Solution: fem
Results of calculation
Nodal positions
x=
0
0.0500
0.1000
0.1250
0.1500
V1 =
100.0000
58.3333
16.6667
8.3333
0
V2 =
100.0000
58.3333
16.6667
8.3334
0.0000
The results are identical to the exact solution, because the temperature gradient within
each material is a linear function and a linear interpolation function is used.
90
80
70
Temperature T ( C)
o
60
50
40
30
20
10
0
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16
Position x (m)
Matlab Code
% example_xxx1.m
clear
clc
% Setup *****************************************
% Coefficients c = sigma/h
h = zeros(1,Ne);
c = zeros(1,Ne);
h(1:Ne/2) = L(1)/2;
h(Ne/2+1:Ne) = L(2)/2;
sigma(1:Ne/2) = s(1);
Ke = [1 -1;-1 1];
x = zeros(Ne+1,1);
for cc = 2 : Ne+1
x(cc) = x(cc-1) + h(cc-1);
end
% Q matrix
Q = zeros(Ne+1,1);
Q1(1) = T(1);
Q1(5) = T(2);
Q1(2) = Q(2) - K(2,1)*T(1) - K(2,5)*T(2);
Q1(3) = Q(3) - K(3,1)*T(1) - K(3,5)*T(2);
Q1(4) = Q(4) - K(4,1)*T(1) - K(4,5)*T(2);
V1 = K1\Q1;
Kmax = max(max(K))*1e5;
V2 = K2\Q2;
% GRAPHICS **************************************
figure(1)
plot(x,V1,'o-','LineWidth',2)
xlabel('Position x (m)');
ylabel('Temperature T ( {^o} C)');
% OUTPUTS ***************************************
% Heat Flux density
I = - s(1)*(V1(2)-V1(1))/h(1);
disp(' ')
disp('Nodal positions')
x
disp(' ')
disp('Nodal temperatures - Method 1: Modification of [K] and {Q} matrices')
V1
disp('Nodal temperatures - Method 2: Penalty approach')
V2
Solution: fem
x = 0 q(0) hc T (0) T
where T(0) is the unknown temperature V1, hc = 25 W.m-2.C-1 and T = 800 C
x = L T(L) = V4 = 20 C
Consider a 3 element model with 4 nodes. The matrix equation can be written as
We can solve this set of simultaneous equations to find the unknown temperatures.