Professional Documents
Culture Documents
Figure E6-1 illustrates a two-dimensional region that is defined by an irregular boundary. A heat
transfer problem involving this type of geometry can most easily be addressed using the finite
element technique.
area of domain, A
q y + dy
q x q x + dx
dx
dy
q y
y
ds
x qn′′ boundary of domain, B
Figure E6-1: Two-dimensional region.
The governing differential equation is derived using an energy balance on a differential control
volume, shown in Figure E6-1. Assuming that the problem is steady state and there is no
generation of thermal energy, the energy balance is:
q x + q y = q x + dx + q y + dy (E6-1)
E6-1
E6: Section 2.7.2 The Galerkin Weighted Residual Method
∂q x ∂q y
q x + q y = q x + dx + q y + dy (E6-2)
∂x ∂y
and simplified:
∂q x ∂q y
dx + dy = 0 (E6-3)
∂x ∂y
∂⎛ ∂T ⎞ ∂ ⎛ ∂T ⎞
⎜ − k th dy ⎟ dx + ⎜ − k th dx ⎟ dy = 0 (E6-4)
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠
∂ ⎛ ∂T ⎞ ∂ ⎛ ∂T ⎞
⎜ −k ⎟ + ⎜ −k ⎟=0 (E6-5)
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠
∂ ⎛ ∂Tˆ ⎞ ∂ ⎛ ∂Tˆ ⎞
⎜ −k ⎟ + ⎜ −k ⎟ = residual (E6-6)
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠
The finite element technique does not attempt to make this residual equal to zero. Rather, the
finite element technique tries to make the weighted, average residual equal to zero. Equation
(E6-5) is multiplied by a weighting function, f(x,y), in order to define the weighted residual:
⎡ ∂ ⎛ ∂Tˆ ⎞ ∂ ⎛ ∂Tˆ ⎞ ⎤
f ⎢ ⎜ −k ⎟ + ⎜ −k ⎟ ⎥ = weighted residual (E6-7)
⎢⎣ ∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠ ⎥⎦
The weighted residual is integrated over the area of the computational domain:
⎡ ∂ ⎛ ∂Tˆ ⎞ ∂ ⎛ ∂Tˆ ⎞ ⎤
∫∫ f ⎢ ⎜ −k ⎟ + ⎜ −k ⎟ ⎥ dx dy = weighted average residual (E6-8)
A ⎣⎢ ∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠ ⎦⎥
E6-2
E6: Section 2.7.2 The Galerkin Weighted Residual Method
∂ ⎛ ∂Tˆ ⎞ ∂ ⎛ ∂Tˆ ⎞
∫∫A ∂x ⎝ ∂x ⎠
f ⎜ − k ⎟ dx dy + ∫∫A ∂y ⎜⎝ −k ∂y ⎟⎠ dx dy = weighted average residual
f (E6-9)
Integral 1 Integral 2
⎡ xmax ∂ ⎛ ∂Tˆ ⎞ ⎤
ymax
Integral 1= ∫ ⎢ ∫ f ⎜ −k ⎟ dx ⎥ dy (E6-10)
ymin ⎢
∂x
⎣
xmin ⎝ ∂x ⎠ ⎥⎦
x integral
where xmin and xmax are the lower and upper bounds, respectively, on the x-coordinate and ymin
and ymax are the lower and upper bounds, respectively, on the y-coordinate. The x integral in Eq.
(E6-10) can be integrated by parts. According to the chain rule:
∫ ∂x ⎢ ⎝ ∂x ⎠ ⎥ x∫ ∂x ⎝ ∂x ⎠ x∫ ∂x ⎜⎝ −k ∂x ⎟⎠ dx
⎢ f ⎜ − k ⎟ ⎥ dx = ⎜ − k ⎟ dx + f (E6-12)
xmin ⎣
⎦ min
min
The left side of Eq. (E6-12) is the integral of a derivative and the last term in Eq. (E6-12) is the
x-integral that is required by Eq. (E6-10):
x
∂ ⎛ ∂Tˆ ⎞ ⎡ ⎛ ∂Tˆ ⎞ ⎤ ∂f ⎛ ∂Tˆ ⎞
xmax max xmax
∫ ∂x ⎝ ∂x ⎠ ⎢ ⎝ ∂x ⎠ ⎥ x∫ ∂x ⎜⎝ −k ∂x ⎟⎠ dx
f ⎜ − k ⎟ dx = ⎢ f ⎜ − k ⎟ ⎥ − (E6-13)
xmin
⎣ ⎦ xmin min
x integral
E6-3
E6: Section 2.7.2 The Galerkin Weighted Residual Method
⎡ ⎛ ∂Tˆ ⎞ ⎤
ymax ymax
⎡ ⎛ ∂Tˆ ⎞ ⎤ ymax xmax
∂f ⎛ ∂Tˆ ⎞
Integral 1= ∫ ⎢ f ⎜ − k ⎟⎥ dy − ∫ ⎢ f ⎜ − k ⎟⎥ dy − ∫ ∫ ⎜ −k ⎟ dx dy
ymin ⎢
⎣ ⎝ ∂x ⎠ ⎥
⎦ x = xmax y ⎢
min ⎣ ⎝ ∂x ⎠ ⎥
⎦ x = xmin y x
min min
∂x ⎝ ∂x ⎠
(E6-15)
∂Tˆ
q ′′x = − k (E6-16)
∂x
∂f ⎛ ∂Tˆ ⎞
ymax ymax
∂f ⎛ ∂Tˆ ⎞
xmax xmax
Integral 2= ∫ ( f q′′ )
xmin
y y = ymax
dx − ∫ ( f q′′ )
xmin
y y = ymin
dx − ∫∫
A
⎜ −k
∂y ⎝
⎟ dA
∂y ⎠
(E6-18)
where q ′′y is the heat flux in the y-direction. Substituting Eqs. (E6-17) and (E6-18) into Eq.
(E6-9) leads to:
∂f ⎛ ∂Tˆ ⎞
ymax ymax
∫ (f
ymin
q ′′x ) x = x dy −
max
ymin
∫ (fmin
q ′′x ) x = x dy − ∫∫
A
⎜ −k
∂x ⎝
⎟ dA +
∂x ⎠
∂f ⎛ ∂Tˆ ⎞
xmax xmax
∫ ( f
q ′′ )
y y= y
max
dx − ∫ ( f
q ′′ )
y y= y
min
dx − ∫∫A ∂y ⎜⎝ −k ∂y ⎟⎠ dA (E6-19)
xmin xmin
The temperature distribution, T̂ , is adjusted numerically by the finite element solution method so
that the weighted average residual is zero. Therefore, Eq. (E6-19) can be rearranged:
⎡ ∂f ∂Tˆ ∂f ∂Tˆ ⎤
∫∫A ⎢⎣ ∂x ∂x ∂y ∂y ⎥⎦ dA =
k + k
weighted value of the net heat transfer into the region along the boundary
E6-4
E6: Section 2.7.2 The Galerkin Weighted Residual Method
The left side of Eq. (E6-20) is referred to as the weak form of the partial differential equation and
the right side of Eq. (E6-20) is the weighted value of the net rate of heat transfer into the
boundary of the computational domain. The first two terms on the right side of Eq. (E6-20) are
the x-projection of the conduction heat transfer into the left and right sides of the boundary,
respectively, and the last two terms are the y-projection of the conduction heat transfer into the
bottom and top sides of the boundary, respectively. Equation (E6-20) can be written more
concisely as:
⎡ ∂f ∂Tˆ ∂f ∂Tˆ ⎤
∫∫A ⎣ ∂x ∂x ∂y ∂y ⎥⎦ dA = ∫B f qn′′ ds
⎢ k + k (E6-21)
where qn′′ is the heat flux into the computational domain normal to the boundary and ds is the
differential length along the boundary (see Figure E6-1Error! Reference source not found.).
⎡Tˆ1 ⎤
⎢ ⎥
⎢Tˆ ⎥
Tˆ ( x, y ) = ⎡⎣ w1 ( x, y ) w2 ( x, y ) ... wN ( x, y ) ⎤⎦ ⎢ 2 ⎥ (E6-23)
...
wT ⎢ ⎥
⎢Tˆ ⎥
⎣N N⎦
Tˆ
or
Tˆ ( x, y ) = wT Tˆ (E6-24)
where the superscript T indicates the transpose of the vector w . The vector w contains
dimensionless functions of x and y:
⎡ w1 ( x, y ) ⎤
⎢ ⎥
⎢ w2 ( x, y ) ⎥
w=⎢ ⎥ (E6-25)
...
⎢ ⎥
⎢⎣ wN ( x, y ) ⎥⎦
E6-5
E6: Section 2.7.2 The Galerkin Weighted Residual Method
and T̂ is a vector of unknown temperatures (these are, eventually, the temperatures at each of the
nodes placed in the computational domain):
⎡Tˆ1 ⎤
⎢ ⎥
⎢Tˆ ⎥
Tˆ = ⎢ 2 ⎥ (E6-26)
⎢... ⎥
⎢Tˆ ⎥
⎣ N⎦
⎡ ∂f ∂ ∂f ∂ ⎤
∫∫ ⎢⎣ k ∂x ∂x ( w Tˆ ) + k ∂y ∂y ( w Tˆ )⎥⎦ dA = ∫ f qn′′ ds
T T
(E6-27)
A B
The partial derivative of the approximate temperature distribution with respect to x can be
evaluated according to:
⎛ ⎡Tˆ1 ⎤ ⎞ ⎡Tˆ1 ⎤
⎜ ⎢ ⎥ ⎟ ⎢ ⎥
∂ ⎜ ⎢Tˆ2 ⎥ ⎟ ⎡ ∂w1 ∂w2 ∂wN ⎤ ⎢Tˆ2 ⎥ ∂ w ˆ
T
∂ T ˆ
∂x
( )
w T = ⎜ [ w1 w2 ... wN ] ⎢ ⎥ ⎟ = ⎢
∂x ⎜ ... ⎣ ∂x ∂x
...
∂x ⎦⎢ ⎥
=
⎥ ⎢... ⎥ ∂x T (E6-28)
⎢ ⎥⎟
⎜ ⎢Tˆ ⎥ ⎟ ⎢Tˆ ⎥
⎝ ⎣ N ⎦⎠ ⎣ N⎦
T
∂ T ˆ ∂w ˆ
∂y
(w T = )
∂y
T (E6-29)
Substituting Eqs. (E6-28) and (E6-29) into Eq. (E6-27) leads to:
⎡ ∂f ∂ wT ˆ ∂f ∂ w ˆ ⎤
T
∫∫A ⎢⎣ ∂x ∂x
k T + k
∂y ∂y ⎦
T ⎥ dA = ∫ f qn′′ ds
B
(E6-30)
Note that the vector Tˆ is not a function of x or y since the temperatures in this vector are for
specified positions (see Eq. (E6-26)), and therefore T̂ may be removed from the integrand of
Eq. (E6-30):
⎡ ⎛ ∂f ∂ wT ∂f ∂ w ⎞ ⎤ ˆ
T
E6-6
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Given a single weighting function f, Eq. (E6-31) represents a single equation in the N unknown
temperatures T̂1 , Tˆ2 , ... , TˆN . To see this clearly, expand the vectors in Eq. (E6-31):
⎡Tˆ1 ⎤
⎢ ⎥
⎡ ⎛ ∂f ⎡ ∂w1 ∂w2 ∂wN ⎤ ∂f ⎡ ∂w1 ∂w2 ∂wN ⎤ ⎞ ⎤ ⎢Tˆ2 ⎥
⎢ ∫∫ ⎜ k ⎢
∂y ⎥⎦ ⎠ ⎦⎥ ⎢... ⎥ ∫B
... +k ⎢ ... ⎟ dA⎥ = f qn′′ ds (E6-32)
⎣⎢ A ⎝ ∂x ⎣ ∂x ∂x ∂x ⎥⎦ ∂y ⎣ ∂y ∂y
⎢ ⎥
⎢Tˆ ⎥
⎣ N⎦
The result of each of the integrations in square brackets in Eq. (E6-33) is a scalar and therefore
Eq. (E6-33) is a single, linear equation in N unknown temperatures Tˆ1 through TˆN .
Galerkin's Method
Equation (E6-33) is underspecified. In order to obtain N equations of the form of Eq. (E6-33),
we will write the equation for N different weighting functions, f1, f2, ..., fN :
⎡ ⎛ ∂f1 ∂w1 ∂f ∂w ⎞ ⎤ ⎡ ⎛ ∂f ∂w ∂f ∂w ⎞ ⎤
⎢ ∫∫ ⎜ k + k 1 1 ⎟ dA⎥ Tˆ1 + ⎢ ∫∫ ⎜ k 1 2 + k 1 2 ⎟ dA⎥ Tˆ2 + ...
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ ⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦
⎡ ⎛ ∂f ∂w ∂f ∂w ⎞ ⎤
+ ⎢ ∫∫ ⎜ k 1 N + k 1 N ⎟ dA⎥ TˆN = ∫ f1 qn′′ ds
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ B
⎡ ⎛ ∂f 2 ∂w1 ∂f ∂w ⎞ ⎤ ⎡ ⎛ ∂f ∂w ∂f ∂w ⎞ ⎤
⎢ ∫∫ ⎜ k + k 2 1 ⎟ dA⎥ Tˆ1 + ⎢ ∫∫ ⎜ k 2 2 + k 2 2 ⎟ dA⎥ Tˆ2 + ...
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ ⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦
(E6-34)
⎡ ⎛ ∂f ∂wN ∂f ∂wN ⎞ ⎤ ˆ
+ ⎢ ∫∫ ⎜ k 2 +k 2 ⎟ dA⎥ TN = ∫ f 2 qn′′ ds
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ B
...
E6-7
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Galerkin's method takes the weighting functions, fi, to be equal to the dimensionless functions
that are used to specify the approximate temperature distribution, wi:
⎡ ⎛ ∂w1 ∂w1 ∂w ∂w ⎞ ⎤ ⎡ ⎛ ∂w ∂w ∂w ∂w ⎞ ⎤
⎢ ∫∫ ⎜ k + k 1 1 ⎟ dA⎥ Tˆ1 + ⎢ ∫∫ ⎜ k 1 2 + k 1 2 ⎟ dA⎥ Tˆ2 + ...
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ ⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦
⎡ ⎛ ∂w ∂w ∂w ∂w ⎞ ⎤
+ ⎢ ∫∫ ⎜ k 1 N + k 1 N ⎟ dA⎥ TˆN = ∫ w1 qn′′ ds
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ B
⎡ ⎛ ∂w2 ∂w1 ∂w ∂w ⎞ ⎤ ⎡ ⎛ ∂w ∂w ∂w ∂w ⎞ ⎤
⎢ ∫∫ ⎜ k + k 2 1 ⎟ dA⎥ Tˆ1 + ⎢ ∫∫ ⎜ k 2 2 + k 2 2 ⎟ dA⎥ Tˆ2 + ...
⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ ⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎦
(E6-36)
⎡ ⎛ ∂w ∂wN ∂w ∂wN ⎞ ⎤ ˆ
+ ⎢ ∫∫ ⎜ k 2 +k 2 ⎟ dA⎥ TN = ∫ w2 qn′′ ds
⎣A⎝ ∂x ∂x ∂y ∂y ⎠ ⎦ B
...
Given the functions w1, w2, ... , wN, the area integrals in Eq. (E6-36) can be evaluated explicitly
in order to provide N linear equations in the unknown temperatures T̂1 , Tˆ2 , ... , TˆN . Equation
(E6-36) can be written more concisely in vector notation:
⎡ ⎛ ∂ w ∂ wT ∂ w ∂ wT ⎞ ⎤ ˆ
⎢ ∫∫ k ⎜ + ⎟ dA⎥ T = ∫ w qn′′ ds (E6-37)
⎢⎣ A ⎝ ∂x ∂x ∂y ∂y ⎠ ⎥⎦
B
K q
E6-8
E6: Section 2.7.2 The Galerkin Weighted Residual Method
The left side of Eq. (E6-37) is referred to as the conduction matrix K . The conduction matrix
has size N x N and multiplies a vector T̂ of unknown temperatures. The right side of Eq.
(E6-37) is a column vector, q . Therefore, Eq. (E6-37) is analogous to the matrix equation that
resulted from the finite difference solution to a steady-state two-dimensional conduction
problem, A X = b , although the structure of K and A are substantially different.
Interpolating Functions
In order to complete the finite element solution, it is necessary to specify the functions wi(x, y);
this process is guided by the discretization of the computational domain. In Error! Reference
source not found., a set of N nodes are distributed across the computational domain that was
shown in Error! Reference source not found.. The positioning of the nodes need not be
uniform, but nodes are placed in order to provide an approximation of the boundary. Lines
drawn between nodes form triangular elements. The element e in Figure E6-2 is defined by the
three nodes i, j, and k.
node k
node i
element e
node j
The temperatures Tˆ1 , Tˆ2 , ... , TˆN are the numerical prediction of the temperature at each of the
nodes in the domain and the functions w1, w2, ... , wN are interpolating functions. Recall the form
of our assumed temperature function, Eq. (E6-22):
The dimensionless functions wi are interpolating functions; these functions are used to predict the
temperature anywhere in the computational domain based the influence of the nodal
temperatures. The temperature within any element is assumed to be a linear function of the three
nodal temperatures that define that element. For example, the temperature at any location in
element e shown in Figure E6-2 is a linear function of the nodal temperatures Tˆi , Tˆj , and Tˆk .
This is equivalent to assuming that the temperature within element e lies on a plane that is
defined by the three points Tˆi at (xi, yi), Tˆj at (xj, yj), and Tˆk at (xk, yk) as shown in Figure E6-3.
E6-9
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Tˆi
Tˆk
Tˆj
(xj, yj)
T
y
x
Figure E6-3: Temperature distribution in element e is a plane passing through nodal temperatures.
The temperature at any point in element e is obtained by interpolating between the temperatures
Tˆi , Tˆj , and Tˆk . Clearly then, the interpolating function wi should be 1 at (xi, yi) and drop linearly
to 0 at (xj, yj) and (xk, yk). The value of wi should be between 0 and 1 everywhere inside element
e (or within any element that is adjacent to node i). Figure E6-4 illustrates the interpolating
function wi; the function is a pyramid with height 1 that is centered on node i. The interpolating
function wi is zero in any element that is not adjacent to node i because the value of Tˆi does not
influence the calculation of the temperature outside of those elements that are adjacent to node i.
wi
node i
T
y
x
Figure E6-4: Interpolating function wi.
Figure E6-5 illustrates the interpolating functions wi, wj, and wk within element e. Note that the
value of all of the other interpolating functions must be zero within element e. Therefore, the
temperature anywhere within element e ( Tˆe ) is given by:
E6-10
E6: Section 2.7.2 The Galerkin Weighted Residual Method
or
⎡Tˆ1 ⎤
⎢ ⎥
⎢Tˆ ⎥
Tˆe = ⎡⎣ 0 ... 0 wi 0 ... 0 w j 0 ... 0 wk 0 ... 0 ⎤⎦ ⎢ 2 ⎥ (E6-39)
⎢... ⎥
⎢Tˆ ⎥
⎣ N⎦
wi in element e
node i node k
element e
node j
T
y
x
(a)
wj in element e
node i node k
element e
node j
T
y
x
(b)
E6-11
E6: Section 2.7.2 The Galerkin Weighted Residual Method
wk in element e
node i node k
element e
node j
T
y
x
(c)
Figure E6-5: Interpolating functions (a) wi, (b) wj, and (c) wk within element e.
For the triangular elements considered here, the interpolating functions are referred to as a
triangular coordinates. The mathematical rules that govern triangular coordinates have been
worked out and are presented in various texts, including Myers (1987). The coordinates of nodes
i, j, and k that define element e are (xi, yi), (xj, yj), and (xk, yk). The distance between these nodes
in the x and y directions are abbreviated according to:
xij = x j − xi (E6-40)
xik = xk − xi (E6-41)
x jk = xk − x j (E6-42)
yij = y j − yi (E6-43)
yik = yk − yi (E6-44)
y jk = yk − y j (E6-45)
bijk
Ae = (E6-46)
2
Provided that nodes i, j, and k are defined in a counterclockwise fashion (as shown in Figure E6-
5), the value of bijk will be positive and therefore:
E6-12
E6: Section 2.7.2 The Galerkin Weighted Residual Method
bijk
Ae = (E6-48)
2
The partial derivative of the interpolating functions with respect to x and y are:
∂wi y
= − jk (E6-49)
∂x bijk
∂w j yik
= (E6-50)
∂x bijk
∂wk y
= − ij (E6-51)
∂x bijk
∂wi x
= − jk (E6-52)
∂y bijk
∂w j xik
= (E6-53)
∂y bijk
∂wk x
= − ij (E6-54)
∂y bijk
The general formula that provides the integral of the product of triangular coordinates to
arbitrary powers a, b, and c is:
a !b !c !
∫∫ w wbj wkc dA =
a
2A (E6-55)
Ae
i
( a + b + c + 2 )! e
⎛ ∂ w ∂ wT ∂ w ∂ wT ⎞ Ne
⎛ ∂ w ∂ wT ∂ w ∂ wT ⎞ Ne
K = ∫∫ k ⎜ + ⎟ dA = ∑ ke ∫∫ ⎜ + ⎟ dA = ∑ K e
A ⎝ ∂x ∂x ∂y ∂y ⎠ e =1 Ae ⎝
∂x ∂x
∂y ∂y ⎠
i =1
(E6-56)
E6-13
E6: Section 2.7.2 The Galerkin Weighted Residual Method
where Ne is the number of elements and ke is the thermal conductivity within element e. If we
can evaluate the integral over any element e then it is possible to calculate the element
conduction matrix K e and sum these element conduction matrices in order to obtain the global
conduction matrix K . The element conduction matrix is defined by:
⎛ ∂ w ∂ wT ∂ w ∂ wT ⎞
K e = ke ∫∫ ⎜ + ⎟ dA (E6-57)
Ae ⎝
∂x ∂x ∂y ∂y ⎠
Within element e, only weighting functions wi, wj, and wk are nonzero in the vector w (see
Figure E6-5):
T T
∂w ∂w ∂w ∂w
K e = ke ∫∫ dA + ke ∫∫ dA (E6-59)
Ae
∂x ∂x Ae
∂y ∂y
Integral 1 Integral 2
⎡0 ⎤
⎢ ⎥
⎢... ⎥
⎢0 ⎥
⎢ ⎥
⎢ wi ⎥
⎢0 ⎥
⎢ ⎥
⎢... ⎥
⎢0 ⎥
∂ ⎢ ⎥ ∂
T
∂w ∂w
Integral 1 = ke ∫∫ dA = ke ∫∫ ⎢ w j ⎥ ⎡⎣ 0 ... 0 wi 0 ... 0 w j 0 ... 0 wk 0 ... 0 ⎤⎦ dA
Ae
∂x ∂x Ae
∂x ⎢ ⎥ ∂x
⎢0 ⎥
⎢... ⎥
⎢ ⎥
⎢0 ⎥
⎢w ⎥
⎢ k⎥
⎢0 ⎥
⎢ ⎥
⎢... ⎥
⎢⎣0 ⎥⎦ (E6-60)
Substituting Eqs. (E6-49) through (E6-51) into Eq. (E6-60) leads to:
E6-14
E6: Section 2.7.2 The Galerkin Weighted Residual Method
⎡0 ⎤
⎢... ⎥
⎢ ⎥
⎢0 ⎥
⎢ ⎥
⎢ − y jk ⎥
⎢0 ⎥
⎢ ⎥
⎢... ⎥
⎢0 ⎥
k ⎢ ⎥
Integral 1 = 2e ∫∫ ⎢ yik ⎥ ⎡⎣0 ... 0 − y jk 0 ... 0 yik 0 ... 0 − yij 0 ... 0⎤⎦ dA
bijk Ae ⎢ ⎥
⎢0 ⎥
⎢... ⎥
⎢ ⎥
⎢0 ⎥
⎢− y ⎥
⎢ ij ⎥
⎢0 ⎥
⎢ ⎥
⎢... ⎥
⎢⎣0 ⎥⎦ (E6-61)
⎡. . . . . . .⎤
⎢. y 2jk . − y jk yik . y jk yik .⎥⎥
⎢
⎢. . . . . . .⎥
ke ⎢ ⎥
Integral 1 = 2 ∫∫ ⎢. − yik y jk . yik2 . − yik yij .⎥ dA (E6-62)
bijk Ae
⎢. . . . . . .⎥
⎢ ⎥
⎢. yij y jk . − yij yik . yij2 .⎥
⎢. .⎥⎦
⎣ . . . . .
Note that the matrix in the integrand of Eq. (E6-62) is independent of x and y and can be
removed from the integral:
⎡. . . . . . .⎤
⎢. y 2jk . − y jk yik . y jk yik .⎥⎥
⎢
⎢. . . . . . .⎥
ke ⎢ ⎥
Integral 1 = 2 ⎢. − yik y jk . yik2 . − yik yij .⎥ ∫∫ dA (E6-63)
bijk
⎢. . . . . . .⎥ NAe
⎢ ⎥ Ae
⎢. yij y jk . − yij yik . yij2 .⎥
⎢. .⎥⎦
⎣ . . . . .
E6-15
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Therefore:
⎡. . . . . . .⎤
⎢. y 2jk . − y jk yik . y jk yik .⎥⎥
⎢
⎢. . . . . . .⎥
Ae ke ⎢ ⎥
Integral 1 = 2 ⎢. − yik y jk . yik2 . − yik yij .⎥ (E6-64)
bijk
⎢. . . . . . .⎥
⎢ ⎥
⎢. yij y jk . − yij yik . yij2 .⎥
⎢. .⎥⎦
⎣ . . . . .
⎡. . . . . . .⎤
⎢. x 2jk . − x jk xik . x jk xik .⎥⎥
⎢
⎢. . . . . . .⎥
Ae ke ⎢ ⎥
Integral 2 = 2 ⎢. − xik x jk . xik2 . − xik xij .⎥ (E6-65)
bijk
⎢. . . . . . .⎥
⎢ ⎥
⎢. xij x jk . − xij xik . xij2 .⎥
⎢. .⎥⎦
⎣ . . . . .
Adding Eqs. (E6-64) and (E6-65) provides the element conduction matrix:
⎡. . . . . . .⎤
⎢ ⎥
(
x jk + y jk ) . − (x jk xik + y jk yik ) . (x xij + y jk yij )
2 2
⎢. jk .⎥ row i
⎢ ⎥
⎢. . . . . . .⎥
K e = 2 ⎢. − (xik x jk + yik y jk ) . − (xik xij + yik yijk )
Ae ke
(x + yik2 ) .⎥ row j
2
. ik
bijk ⎢ ⎥
⎢. . . . . . .⎥
⎢ ⎥
⎢. (xij x jk + yij y jk ) − (xij xik + yij yik ) . (x + yij2 )
2
. ij .⎥ row k
⎢ ⎥
⎣. . . . . . .⎦
Given the coordinates of the three nodes that define the element, Eq. (E6-66) can be used to
calculate the element conduction matrix. These element conduction matrices are summed
according to Eq. (E6-56) in order to assemble the global conduction matrix.
E6-16
E6: Section 2.7.2 The Galerkin Weighted Residual Method
q = ∫ w qn′′ ds (E6-67)
B
where qn′′ is the heat flux normal to the boundary, into the domain as shown in Error! Reference
source not found.. The heat flux may be a combination of a specified heat flux and a convective
heat flux:
(
qn′′ = q s′′ + h T∞ − Tˆ ) (E6-68)
where qs′′ is the specified heat flux, h is the local heat transfer coefficient, and T∞ is the local
ambient temperature. Substituting Eq. (E6-68) into Eq. (E6-67) leads to:
⎣ (
q = ∫ w ⎡ qs′′ + h T∞ − Tˆ ⎤ ds
⎦ ) (E6-69)
B
Just as the area integral over the computational domain was divided up by elements, the
boundary integral in Eq. (E6-69) is divided up by boundary segment:
Nb Nb
⎣ ( ) ⎦ b =1 Bb
⎣ ( ⎦ )
q = ∫ w ⎡ qs′′ + h T∞ − Tˆ ⎤ ds = ∑ ∫ w ⎡ qs′′,b + hb T∞ ,b − Tˆ ⎤ ds = ∑ qb
b =1
(E6-70)
B
where Nb is the number of boundary segments, q s′′,b , hb, and T∞ ,b are the specified heat flux, heat
transfer coefficient and ambient temperature, respectively, that exist for boundary segment b.
Boundary segment b is defined by two nodes, i and j, as shown in Figure E6-6.
E6-17
E6: Section 2.7.2 The Galerkin Weighted Residual Method
node j
boundary segment b
s sij
w
node i 1
wi
wj
0 s
0 sij
Figure E6-6: Boundary segment b.
Note that on boundary segment b between nodes i and j, the only weighting functions that are not
zero are wi and wj. Therefore, the temperature on boundary segment b ( Tˆb ) is given by:
or
⎡Tˆ1 ⎤
⎢ ⎥
⎢Tˆ ⎥
Tˆb = ⎡⎣ 0 ... 0 wi 0 ... 0 w j 0 ... 0 ⎤⎦ ⎢ 2 ⎥ (E6-72)
⎢... ⎥
⎢Tˆ ⎥
⎣ N⎦
As you move along the boundary segment in the s-direction, see Figure E6-6, the value of
interpolating function wi goes from 1 (at node i) to 0 (at node j) and wj goes from 0 (at node i) to
1 (at node j). The segment boundary vector, qb , is defined according to:
qb = ∫ w ⎡⎣q′′
s ,b (
+ hb T∞ ,b − Tˆ ⎤ ds
⎦ ) (E6-73)
Bb
qb = qs′′,b ∫ w ds + hb T∞ ,b ∫ w ds − h ∫ w Tˆ ds
b (E6-74)
Bb Bb Bb
E6-18
E6: Section 2.7.2 The Galerkin Weighted Residual Method
⎡0 ⎤
⎢ ⎥
⎢... ⎥
⎢0 ⎥
⎢ ⎥
⎢ wi ⎥
⎢0 ⎥
⎢ ⎥
Integral 1 = qs′′,b ∫ w ds = qs′′,b ∫ ⎢... ⎥ ds (E6-75)
Bb ⎢
Bb
0 ⎥
⎢ ⎥
⎢wj ⎥
⎢ ⎥
⎢0 ⎥
⎢... ⎥
⎢ ⎥
⎣⎢0 ⎦⎥
The integral of wi and wj over the boundary segment is equal to the area under the curves shown
in Figure E6-6:
sij
qs′′,b ∫ wi ds = q s′′,b (E6-76)
Bb
2
where sij is the length of the boundary segment. Therefore, Eq. (E6-75) can be written as:
⎡0⎤
⎢ ⎥
⎢...⎥
⎢0⎥
⎢ ⎥
⎢ 1 ⎥ row i
⎢0⎥
qs′′,b sij ⎢ ⎥
Integral 1 = ⎢...⎥
2 ⎢ ⎥
0
⎢ ⎥
⎢ 1 ⎥ row j
⎢0⎥
⎢ ⎥
⎢...⎥
⎢0⎥
⎣ ⎦ (E6-77)
E6-19
E6: Section 2.7.2 The Galerkin Weighted Residual Method
⎡0⎤
⎢ ⎥
⎢...⎥
⎢0⎥
⎢ ⎥
⎢ 1 ⎥ row i
⎢0⎥
hb T∞,b sij ⎢ ⎥
Integral 2 = ⎢...⎥
2 ⎢0⎥
⎢ ⎥
⎢ 1 ⎥ row j
⎢0⎥
⎢ ⎥
⎢...⎥
⎢0⎥
⎣ ⎦ (E6-78)
⎡0 ⎤
⎢ ⎥
⎢... ⎥
⎢0 ⎥
⎢ ⎥
⎢ wi ⎥ ⎡Tˆ1 ⎤
⎢0 ⎥ ⎢ ⎥
⎢ ⎥ ⎢Tˆ ⎥
Integral 3 = hb ∫ w Tˆ ds = hb Bb ∫ ⎢... ⎥ ⎡⎣0 ... 0 wi 0 ... 0 w j 0 ... 0 ⎤⎦ ⎢ 2 ⎥ ds (E6-79)
Bb ⎢
Bb
0 ⎥ ⎢... ⎥
⎢ ⎥ ⎢Tˆ ⎥
⎢wj ⎥ ⎣ N⎦
⎢ ⎥
⎢0 ⎥
⎢... ⎥
⎢ ⎥
⎣⎢0 ⎦⎥
⎛ ⎡. . . . .⎤ ⎞ ⎡ ˆ ⎤
⎜ ⎢ ⎟ T1
⎜ ⎢. wi
2
. wi w j .⎥⎥ ⎟ ⎢ ⎥
⎢Tˆ ⎥
Integral 3 = hb ⎜ ∫ ⎢. . . . .⎥ ds ⎟ ⎢ 2 ⎥ (E6-80)
⎜ Bb ⎢ ⎥ ⎟ ...
⎜ ⎢. w j wi . w 2
j .⎥ ⎟ ⎢ ⎥
⎢ˆ ⎥
⎜
⎝ ⎣⎢. . . . .⎦⎥ ⎠⎟ ⎣TN ⎦
The weighting functions wi and wj along the boundary element b can be written in terms of s as
(see Figure E6-6):
E6-20
E6: Section 2.7.2 The Galerkin Weighted Residual Method
s
wi = 1 − (E6-81)
sij
s
wj = (E6-82)
sij
Equations (E6-81) and (E6-82) allow each of the integrals in Eq. (E6-80) to be evaluated. For
example, the integral required by the entry in row j and column j in Eq. (E6-80) leads to:
sij
sij
s2 ⎡ s3 ⎤ hb sij
hb ∫w ds = hb ∫ ds = h ⎢ ⎥ =
2
j b (E6-83)
Bb 0
sij2 ⎣⎢ 3 sij ⎦⎥
2
3
0
The other integrals in Eq. (E6-80) are carried out in a similar manner, leading to:
⎡. . . . .⎤
⎢ ⎥
⎢. 1 1
. .⎥ row i
⎢ 3 6 ⎥
Integral 3 = hb sij ⎢. . . . .⎥ Tˆ
⎢ ⎥
⎢ 1 1 ⎥
⎢. . .⎥ row j
6 3
⎢ ⎥
⎣. . . . .⎦
column i
column j (E6-84)
Adding Eqs. (E6-77), (E6-78) and (E6-84) provides the segment boundary vector:
row i ⎡. . . . .⎤
⎡.⎤ ⎡.⎤ ⎢ ⎥
⎢. 1 1
⎢1⎥ ⎢1⎥ . .⎥ row i
qs′′,b sij ⎢ ⎥ hb T∞,b sij ⎢ ⎥ ⎢ 3 6 ⎥
qb = ⎢.⎥ + ⎢ . ⎥ − hb sij ⎢. . . . .⎥ Tˆ
2 ⎢⎥ 2 ⎢⎥ ⎢ ⎥
⎢⎥1 ⎢⎥1 ⎢. 1
.
1
.⎥ row j
⎢⎣ . ⎥⎦ ⎢⎣ . ⎥⎦ ⎢ 6 3 ⎥
row j ⎢ ⎥
⎣. . . . .⎦
Qb Hb column i
column j (E6-85)
E6-21
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Note that the segment boundary vector is composed of a column vector, Qb , and a matrix, H b ,
that multiplies the vector of unknown temperatures. Therefore, the global boundary vector is
given by:
q = Q − H Tˆ (E6-86)
Nb
Q = ∑ Qb (E6-87)
b =1
and
Nb
H = ∑ Hb (E6-88)
b =1
Substituting Eq. (E6-86) into Eq. (E6-37) leads to the matrix equation that must be solved to
obtain the solution to the finite element problem:
K Tˆ = Q − H Tˆ (E6-89)
or
( K + H ) Tˆ = Q (E6-90)
E6-22
E6: Section 2.7.2 The Galerkin Weighted Residual Method
ht = 100 W/m -K
2
T∞,t = 300 K
(0,0.75) (0.5,0.75)
k = 0.25 W/m-K
q ′′ = 100 W/m
2
(0.5,0.25)
hb = 50 W/m -K
2
(0,0) (0.25,0)
T∞,b = 350 K
Figure E6-7: Two-dimensional conduction problem used to illustrate the finite element solution. The
coordinates of points are shown in m.
The first step is to define the sub-domains and boundaries that specify the problem. The
information about the sub-domains is contained in matrix sd . The number of columns in the
matrix sd is equal to the number of sub-domains in the computational domain. The information
about each of the sub-domains is contained in the columns. For a more complex problem, the
volumetric generation and other parameters might be required. For the simple problem shown in
Error! Reference source not found. only the conductivity is required. There is only one sub-
domain for the problem, as shown in Figure E6-8, and therefore the matrix sd is setup in the
MATLAB script S2p7p2_script according to:
clear all;
The information about the boundary conditions is contained in matrix bc . The number of
columns in the matrix bc is equal to the number of boundaries (not boundary elements) in the
computational domain. The information about the boundaries is contained in each column: the
first row holds the heat transfer coefficient, the second row holds the adjacent fluid temperature,
and the third row holds the specified heat flux into the computational domain. There are five
boundaries for the problem shown in Figure E6-8 and therefore the matrix bc is setup according
to:
bcm=[0,0,0; 50,350,0; 0,0,0; 100,300,0; 0,0,100]'; % boundary condition for each boundary
>> bcm
bcm =
E6-23
E6: Section 2.7.2 The Galerkin Weighted Residual Method
0 50 0 100 0
0 350 0 300 0
0 0 0 0 100
ht = 100 W/m -K
2
T∞,t = 300 K
edge 4
k = 0.25 W/m-K
q ′′ = 100 W/m
2
sub-domain 1
hb = 50 W/m -K
2
edge 1
T∞,b = 350 K
Figure E6-8: Sub-domains and boundaries that define the problem.
The next step is to define a mesh of triangular elements. A very crude mesh is shown in Figure
E6-9.
n11 b6 n10 b5 n9
e8 e11
b7 b4
e9 e10
n6 n8
n7
b8 e6 e5 b3
e7 e4
n5 n3
n4
e1
b9 e3 n = node#
e2 b2 e = element #
n1 b1 n2 b = boundary segment #
Figure E6-9: A crude mesh.
The mesh shown in Figure E6-9 is defined by Nn = 11 nodes. Information about the nodes is
stored in the point matrix, p . There are Nn columns in the point matrix. The first row of each
column contains the x-coordinate of the corresponding node and the second row contains the y-
coordinate. The point matrix is setup for the grid shown in Figure E6-9 (refer to Figure E6-7 for
the dimensions of the problem):
>> pm
E6-24
E6: Section 2.7.2 The Galerkin Weighted Residual Method
pm =
The mesh is defined by Nb = 9 boundary segments. Information about the boundary segments is
stored in the edge matrix, e . There are Nb columns in the edge matrix. The first two rows of
each column contain the indices of the nodes that define the boundary segment. The third row
contains the index of the boundary that the boundary segment lies on (as seen in Figure E6-8).
The edge matrix is setup for the mesh shown in Figure E6-9:
>> em
em =
1 2 3 8 9 10 11 6 5
2 3 8 9 10 11 6 5 1
1 2 3 3 4 4 5 5 5
The mesh is defined by Ne = 11 elements. Information about the edge is stored in the triangle
matrix, t . There are Ne columns in the triangle matrix. The first three rows contain the indices
of the three nodes that define the elements, given in clockwise order. The fourth row contains
the number of the sub-domain that the element lies in. The triangle matrix is setup for the mesh
shown in Error! Reference source not found.:
>> tm
tm =
5 1 4 4 7 6 6 11 6 10 10
1 2 2 3 4 4 5 6 7 7 8
4 4 3 8 8 7 4 10 10 8 9
1 1 1 1 1 1 1 1 1 1 1
The element conduction matrix is derived in Eq. (E6-66), which is repeated below:
E6-25
E6: Section 2.7.2 The Galerkin Weighted Residual Method
⎡. . . . . . .⎤
⎢ ⎥
(
x jk + y jk ) . − (x jk xik + y jk yik ) . (x xij + y jk yij )
2 2
⎢. jk .⎥ row i
⎢ ⎥
⎢. . . . . . .⎥
K e = 2 ⎢. − (xik x jk + yik y jk ) . − (xik xij + yik yijk )
Ae ke
(x + yik2 ) .⎥ row j
2
. ik
bijk ⎢ ⎥
⎢. . . . . . .⎥
⎢ ⎥
⎢. (xij x jk + yij y jk ) − (xij xik + yij yik ) . (x + yij2 )
2
. ij .⎥ row k
⎢ ⎥
⎣. . . . . . .⎦
The elements associated with the element conduction matrix are added, element by element, to
the global conduction matrix according to Eq. (E6-56):
Ne
K = ∑ Ke (E6-91)
i =1
for e=1:N_e
The indices of the three nodes that define the element and the subdomain that the element
belongs to are obtained from the triangle matrix:
The x- and y-distances separating the nodes (xij, xik, etc.) are computed using Eqs. (E6-40)
through (E6-45); the coordinates of the nodes are obtained from the point matrix:
E6-26
E6: Section 2.7.2 The Galerkin Weighted Residual Method
The parameter bijk and the area of the element are computed using Eqs. (E6-47) and (E6-46),
respectively:
bijk=xij*yjk-xjk*yij;
Ae=abs(bijk)/2; % area of element e
The conductivity of the element is obtained from the matrix sd and the elements of the element
conduction matrix are added to the global conduction matrix according to Eq. (E6-66).
The vector Qb and matrix H b are derived in Eq. (E6-85), which is repeated below:
row i ⎡. . . . .⎤
⎡.⎤ ⎡.⎤ ⎢ ⎥
⎢. 1 1
⎢1⎥ ⎢1⎥ . .⎥ row i
qs′′,b sij ⎢ ⎥ hb T∞,b sij ⎢ ⎥ ⎢ 3 6 ⎥
qb = ⎢.⎥ + ⎢ . ⎥ − hb sij ⎢. . . . .⎥ Tˆ
2 ⎢⎥ 2 ⎢⎥ ⎢ ⎥
⎢⎥1 ⎢⎥1 ⎢. 1
.
1
.⎥ row j
⎢⎣ . ⎥⎦ ⎢⎣ . ⎥⎦ ⎢ 6 3 ⎥
row j ⎢ ⎥
⎣. . . . .⎦
Qb Hb column i
column j (E6-84)
for b=1:N_b
E6-27
E6: Section 2.7.2 The Galerkin Weighted Residual Method
The indices of the two nodes that define the boundary segment and the boundary that the
segment belongs to are obtained from the edge matrix:
The x- and y-distance separating the nodes and the linear distance between the nodes, sij, are
computed:
The specified heat flux, heat transfer coefficient, and ambient temperature associated with the
boundary segment is obtained from the matrix bc and the elements of Qb and H b are added to
the global vector Q and matrix H according to Eq. (E6-85).
>> T
T=
456.9587
353.6660
349.3872
381.2069
460.2514
421.6331
361.5230
343.2677
E6-28
E6: Section 2.7.2 The Galerkin Weighted Residual Method
300.6376
299.9842
303.2351
The organization of the mesh information is nearly the same as is used by the PDE toolbox in
MATLAB. Therefore, the tools and commands that are available in the PDE toolbox can be
used to manipulate and investigate this solution. If your version of MATLAB includes the PDE
toolbox, then the solution can be plotted using the pdeplot command:
pdeplot(pm,em,tm,'xydata',T,'contour','on');
The PDE toolbox has a graphical user interface that can be used to quickly setup a computational
domain and generate a mesh. From the command window, type:
>> pdetool
to open the graphical user interface. Specify the computational domain shown in Figure E6-7
using the polygon tool. Set the application to Heat Transfer from the Options menu. Select
Initialize Mesh and Refine Mesh from the Mesh menu (Figure E6-11).
E6-29
E6: Section 2.7.2 The Galerkin Weighted Residual Method
Select Export Mesh from the Mesh menu and the point matrix, edge matrix, and triangle matrix
associated with the mesh generated by the PDE toolbox are exported to the command space. The
refined mesh can be used in place of the coarse mesh that was generated manually by
commenting out the specified values of p , e , and t .
%clear all;
E6-30
E6: Section 2.7.2 The Galerkin Weighted Residual Method
The structure of the point matrix and triangle matrix is identical to the ones that were generated
manually:
The first two rows of the edge matrix generated by MATLAB's PDE toolbox are identical to
ours. The index of the boundary is contained in row five of the edge matrix generated by the
PDE toolbox:
Otherwise, the script S2p7p2_script remains unchanged. The solution generated with the more
refined mesh is shown in Figure E6-12.
Figure E6-12: Contour plot of the finite element solution with the refined mesh generated by the PDE
toolbox.
E6-31