1
METU Mechanical Engineering Department ME 582 Finite Element Analysis in Thermofluids
Spring 2018 (Dr. Sert) Handout 3 β Examples of Chapter 2
Example 2.1:
Weβll solve the following advection diffusion equation
π’ππ
ππ₯β πΌ
π2π
ππ₯2= π over 0 β€ π₯ β€ 1
with π’ = 3, πΌ = 1, π = 1. The DE is supported by the following EBCs
π(0) = 0 , π(1) = 0
Letβs use Galerkin FEM on a mesh of 5 equal-sized elements as shown below
Elemental stiffness matrices can be evaluated using the following equation as derived previously
πΎπππ = β« ( ππ
π π’ πππ
π
ππ 1
π½π+ πΌ
ππππ
ππ 1
π½π πππ
π
ππ 1
π½π) π½π ππ
1
β1
Each element has the length of βπ = 0.2 and has the same Jacobian π½π = βπ/2 = 0.1. π’ and πΌ are
given as constants. Therefore [πΎπ] will be the same for all elements. Using previously derived shape
functions of
π1π =
1
2(1 β π) , π2
π =1
2(1 + π)
and their derivatives
ππ1π
ππ= β
1
2 ,
ππ2π
ππ=1
2
entries of the 2x2 [πΎπ] matrix can be calculated as follows (no need to use GQ integration here. As an
exercise you can try to evaluate the integrals using for example 2 point GQ)
πΎ11π = β« [
1
2(1 β π)(3) (β
1
2) (
1
0.1) + (1) (β
1
2) (
1
0.1) (β
1
2) (
1
0.1)] (0.1) ππ
1
β1
= 3.5
e=1
x
e=2 e=3 e=4 e=5
1 2 3 4 5 6
2
πΎ12π = β« [
1
2(1 β π)(3) (
1
2) (
1
0.1) + (1) (β
1
2) (
1
0.1) (1
2) (
1
0.1)] (0.1) ππ
1
β1
= β3.5
πΎ21π = β« [
1
2(1 + π)(3) (β
1
2) (
1
0.1) + (1) (
1
2) (
1
0.1) (β
1
2) (
1
0.1)] (0.1) ππ
1
β1
= β6.5
πΎ22π = β« [
1
2(1 + π)(3) (
1
2) (
1
0.1) + (1) (
1
2) (
1
0.1) (1
2) (
1
0.1)] (0.1) ππ
1
β1
= 6.5
Therefore, for all elements
πΎπ = [3.5 β3.5β6.5 6.5
]
Entries of the elemental force vector are given by
πΉππ = β« ππ
π π π½π ππ
1
β1
Function π is constant and the same for each element. Therefore, elemental force vectors will also be
the same for all elements. Their components can be evaluated as
πΉ1π = β«
1
2(1 β π) (1) (0.1) ππ
1
β1
= 0.1
πΉ2π = β«
1
2(1 + π) (1) (0.1) ππ
1
β1
= 0.1
Combining these two entries we get
πΉπ = {0.10.1}
Local to global mapping of the mesh is given by
πΏπ‘ππΊ =
[ 1 22 33 44 55 6]
Using the assembly rule, following 6x6 global system can be assembled
[ 3.5 β3.5 0 0 0 0β6.5 6.5 + 3.5 β3.5 0 0 00 β6.5 6.5 + 3.5 β3.5 0 00 0 β6.5 6.5 + 3.5 β3.5 00 0 0 β6.5 6.5 + 3.5 β3.50 0 0 0 β6.5 6.5 ]
{
π1π2π3π4π5π6}
=
{
0.10.1 + 0.10.1 + 0.10.1 + 0.10.1 + 0.10.1 }
+
{
π΅10000π΅6}
3
Due to the EBCs provided at π₯ = 0 and π₯ = 1, π1 and π6 are actually known and we can perform
reduction as explained in the previous section to remove the first and last equation resulting in the
following 4x4 system.
[
10 β3.5 0 0β6.5 10 β3.5 00 β6.5 10 β3.50 0 β6.5 10
]{
π2π3π4π5
} = {
0.20.20.20.2
}
Note that the reduction of the system did not result any change in the right hand side vector, because
of the special zero EBCs. Solving this system, we get the following nodal unknowns as
{
π2π3π4π5
} = {
0.05310.09460.11460.0945
}
Exact solution can be found using MATLAB as follows.
dsolve('3*Dy-D2y=1', 'y(0)=0', 'y(1)=0')
which can be simplified using MATLABβs simplify command to get
πππ₯πππ‘ = βπ3π₯ β π₯π3 + π₯ β 1
3(π3 β 1)
Comparison of FEM and exact solutions is given below. Except the boundary nodes, nodal values are
not exact, but they are close to the exact solution.
4
Example 2.2:
Remember that one disadvantage of variational solutions we performed in the previous chapter was
the dependency of approximation function selection on the boundary conditions. To appreciate that
this is not the case for FEM, letβs solve the previous problem with the following different EBCs
π(0) = 1 , π(1) = 10
Change in BCs will not bring any change to the elemental system calculation or to the assembly process.
Therefore, the same 6x6 global system, given below, will be obtained.
[ 3.5 β3.5 0 0 0 0β6.5 10 β3.5 0 0 00 β6.5 10 β3.5 0 00 0 β6.5 10 β3.5 00 0 0 β6.5 10 β3.50 0 0 0 β6.5 6.5 ]
{
π1π2π3π4π5π6}
=
{
0.10.20.20.20.20.1}
+
{
π΅10000π΅6}
π1 and π6 are known. Therefore, letβs reduce the system to a 4x4 system by deleting the first and the
last rows and columns. In the meantime, the right hand side vector will also change.
[
10 β3.5 0 0β6.5 10 β3.5 00 β6.5 10 β3.50 0 β6.5 10
]{
π2π3π4π5
} = {
0.2 β (β6.5)(1)0.20.2
0.2 β (β3.5)(10)
}
The solution is
{
π2π3π4π5
} = {
1.41892.13963.42115.7437
}
Comparison of FEM and exact solutions is as follows.
5
Example 2.3:
To experiment with NBCs, letβs solve the same problem with the following BCs
π(0) = 0 , ππ
ππ₯|π₯=1
= β1
The 6x6 global system is again the same as before. Reduction will be applied for the EBC. After deleting
the first row and the first column weβll be left with the following 5x5 system
[ 10 β3.5 0 0 0β6.5 10 β3.5 0 00 β6.5 10 β3.5 00 0 β6.5 10 β3.50 0 0 β6.5 6.5 ]
{
π2π3π4π5π6}
=
{
0.20.20.20.20.1}
+
{
0000π΅6}
First derivative is given at π₯ = 1. This is related to π΅6 of the last equation.
π΅6 = (ππ)π₯=1 = (πΌππ
ππ₯ππ₯)
π₯=1= β1
Warning: Do not include the effect of πΌ and ππ₯ . In this case they are both equal to one, but in general
this is not the case.
Use this π΅6 value in the reduced global system and solve it to get
Now this is a solvable system with 5 equations and 5 unknowns. The solution gives the following nodal
values
{
π2π3π4π5π6}
=
{
0.04940.08410.09130.0475β0.0910}
FEM solution is very close to the exact one. At the right boundary, where NBC is specified, the value of
π6 is not exact, athough it looks so on the graph. The exact value at the right boundary is -0.089, but
we calculated it to be -0.091. As a general rule, unknown nodal values at the NBC boundaries cannot
be calculated as exact.
6
Example 2.4:
To experiment with MBCs, letβs solve the same problem with the following BCs
(π + 2ππ
ππ₯)|π₯=0
= 5 , π(1) = β10
The 6x6 global system is the same as before. We apply reduction for the EBC given at π₯ = 1 to get the
following 5x5 reduced system.
[ 3.5 β3.5 0 0 0β6.5 10 β3.5 0 00 β6.5 10 β3.5 00 0 β6.5 10 β3.50 0 0 β6.5 10 ]
{
π1π2π3π4π5}
=
{
0.10.20.20.2
0.2 β (β3.5)(β10)}
+
{
π΅10000 }
SV at the first node is
π΅1 = (ππ)1 = (πΌππ
ππ₯ππ₯)
π₯=0= (β
ππ
ππ₯)π₯=0
Letβs write the given MBC in the standard ππ = π½ ππ + πΎ form
π΅1 = 0.5π1 β 2.5
And use it in the right hand side of the global system
[ 3.5 β3.5 0 0 0β6.5 10 β3.5 0 00 β6.5 10 β3.5 00 0 β6.5 10 β3.50 0 0 β6.5 10 ]
{
π1π2π3π4π5}
=
{
0.10.20.20.2β34.8}
+
{
0.5π1 β 2.5
0000 }
Transfer 0.5π1 from the right hand side to the left hand side
[ 3.5 β 0.5 β3.5 0 0 0β6.5 10 β3.5 0 00 β6.5 10 β3.5 00 0 β6.5 10 β3.50 0 0 β6.5 10 ]
{
π1π2π3π4π5}
=
{
β2.40.20.20.2β34.8}
And solve this system to get
{
π2π3π4π5π6}
=
{
10.16449.39817.91775.1113β0.1576}
Comparison of exact and approximate solutions is given below. As seen clearly, at the MBC boundary
FEM solution deviates from the exact solution. More elements are required for a better solution.
7
Example 2.5:
Letβs solve Example 2.3 again using the following mesh of 2 equi-sized quadratic elements.
Elemental stiffness matrices can be evaluated using the same equation that we used previously for
linear elements
πΎπππ = β« ( ππ
π π’ πππ
π
ππ 1
π½π+ πΌ
ππππ
ππ 1
π½π πππ
π
ππ 1
π½π) π½π ππ
1
β1
Both elements has a length of βπ = 0.5 and a Jacobian of π½π = βπ/2 = 1/4. Similar to the previous
solution [πΎπ] will be the same for both elements. Using the shape functions of quadratic elements,
entries of the 3x3 [πΎπ] can be calculated as
πΎ11π = β« (
1
2π(π β 1)(3) (
1
2(2π β 1)) (4) + (1) (
1
2(2π β 1)) (4) (
1
2(2π β 1)) (4)) (
1
4) ππ
1
β1
=19
6
πΎ12π = β« (
1
2π(π β 1)(3)(β2π) (4) + (1) (
1
2(2π β 1)) (4)(β2π) (4)) (
1
4) ππ
1
β1
= β10
3
πΎ13π = β« (
1
2π(π β 1)(3) (
1
2(2π + 1)) (4) + (1) (
1
2(2π β 1)) (4) (
1
2(2π + 1)) (4)) (
1
4) ππ
1
β1
=1
6
e=1
π₯
e=2
1 2 3 4 5
8
πΎ21π = β« ((1 β π2)(3) (
1
2(2π β 1)) (4) + (1) (β2π) (4) (
1
2(2π β 1)) (4)) (
1
4) ππ
1
β1
= β22
3
πΎ22π = β«((1 β π2)(3)(β2π) (4) + (1) (β2π) (4)(β2π) (4)) (
1
4) ππ
1
β1
=32
3
πΎ23π = β« ((1 β π2)(3) (
1
2(2π + 1)) (4) + (1) (β2π) (4) (
1
2(2π + 1)) (4)) (
1
4) ππ
1
β1
= β10
3
πΎ31π = β« (
1
2π(π + 1)(3) (
1
2(2π β 1)) (4) + (1) (
1
2(2π + 1)) (4) (
1
2(2π β 1)) (4)) (
1
4) ππ
1
β1
=7
6
πΎ32π = β« (
1
2π(π + 1)(3)(β2π) (4) + (1) (
1
2(2π + 1)) (4)(β2π) (4)) (
1
4) ππ
1
β1
= β22
3
πΎ33π = β« (
1
2π(π + 1)(3) (
1
2(2π + 1)) (4) + (1) (
1
2(2π + 1)) (4) (
1
2(2π + 1)) (4)) (
1
4) ππ
1
β1
=37
6
Therefore, for both elements
πΎπ = [
19/6 β10/3 1/6β22/3 32/3 β10/37/6 β22/3 37/6
]
Remembering the following general form of the elemental force vector
πΉππ = β« ππ
π π π½π ππ
1
β1
and noticing that the source function π is constant and the same for each element, elemental force
vectors will also be the same for both elements. Its entries can be evaluated as
πΉ1π = β«
1
2π(π β 1) (1) (
1
4) ππ
1
β1
= 1
12
πΉ2π = β«(1 β π2) (1) (
1
4) ππ
1
β1
= 1
3
πΉ3π = β«
1
2π(π + 1) (1) (
1
4) ππ
1
β1
= 1
12
Combining these three entries we get
πΉπ = {
1/121/31/12
}
9
Local to global mapping of the mesh is πΏπ‘ππΊ = [1 2 33 4 5
]
Using the assembly rule, global system can be obtained as
[ 19
6 β
10
3
1
6 0 0
β22
3
32
3 β
10
3 0 0
7
6 β
22
3 37
6+19
6 β
10
3
1
6
0 0 β22
3
32
3 β
10
3
0 0 7
6 β
22
3
37
6 ]
{
π1 π2 π3 π4 π5}
=
{
1
121
31
12+1
121
31
12 }
+
{
π΅1 0 0 0 π΅5}
π1 = 0 is given as an EBC. Applying reduction for the first equation and using π΅5 = β1 we are left with
the following 4x4 system
[ 32
3 β
10
3 0 0
β22
3
56
6 β
10
3
1
6
0 β22
3
32
3 β
10
3
0 7
6 β
22
3
37
6 ]
{
π2 π3 π4 π5}
=
{
13β
16β
13β
112β }
+
{
0 0 0 β1}
Solving this system we get {
π2π3π4π5
} = {
0.05910.08900.0648β0.0884
}
The following figure compares the GFEM solution with the approximate solution. The solution
obtained in Example 2.3 with 5 linear elements is also given. As seen, the linear solution with 5
elements and the quadratic solution with 2 elements provide a comparable performance.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.1
-0.05
0
0.05
0.1
x
T
Comparison of Linear and Quadratic GFEM Solutions
Exact
Linear GFEM
Quadratic GFEM
10
Example 2.6:
Letβs work on a different, more physical problem, which has a different DE. Consider the following steady, heat transfer problem in a 1D fin with constant circular cross-section. πβ = 25 β , β = 100 W/m
2K π = 140 W/mK π· = 0.1 m (fin diameter) πΏ = 1 m (fin length) At π₯ = 0 π = 100 β
At π₯ = πΏ ππ΄π (ππ
ππ₯) + βπ΄π(π β πβ) = 0
The governing DE is
βπ
ππ₯(ππ΄π
ππ
ππ₯) + βπ(π β πβ) = 0
where π΄π = ππ·
2/4 is the cross-sectional area and π = ππ· is the perimeter of the fin. Warning: ππ΄π is constant. We can divide the whole equation by ππ΄π, but we prefer not to this because if we keep the equation in the given form, the secondary variable will have a more physical meaning, i.e. amount of heat passing through the boundary. Also studying the ODE in this form is better because it can be extended to cases where π and/or π΄π is not constant, as weβll see in the next example. Note that the minus sign in front of the first term is there for a purpose. Itβll disappear after integration by parts. Letβs obtain the temperature distribution π(π₯) on the fin using GFEM using a mesh of 4 linear elements of the same length. Compared to the previous examples, now the DE is not the advection-diffusion equation. We need to obtain its weak form.
Residual: π (π₯) = βπ
ππ₯(ππ΄π
ππ
ππ₯) + βπ(π β πβ)
Weighted integral statement: β«π€π ππ₯
Ξ©
= β« [βπ€π
ππ₯(ππ΄π
ππ
ππ₯) + π€βπ(π β πβ)] ππ₯
Ξ©
= 0
Apply int. by parts: β« [ππ΄πππ€
ππ₯
ππ
ππ₯+ βππ€π] ππ₯
Ξ©
= β«π€βππβ ππ₯
Ξ©
+ (π€ ππ)0 + (π€ ππ)πΏ
where the secondary variable is the following term, which is conductive heat transfer rate in Watts.
ππ = ππ΄πππ
ππ₯ππ₯
Primary variable of the problem is the temperature, π. We wrote the πβ term on the right hand side because it is known. We can get πΎππ
π and πΉππ entries of the elemental system by replacing the unknown
π with ππ and the weight function π€ with ππ.
πΎπππ = β« [ππ΄π
πππππ₯
πππ
ππ₯+ βπππππ] ππ₯
Ξ©e
, πΉππ = β« ππβππβ ππ₯
Ξ©e
π₯
11
To be able to use the master element and the shape functions defined using the π coordinate, letβs change the variable of integration from π₯ to π.
πΎπππ = β« (ππ΄π
ππππ
ππ
1
π½π πππ
π
ππ
1
π½π+ βπππ
ππππ) π½πππ
1
β1
, πΉππ = β« ππβππβ π½
πππ1
β1
where the shape functions are now functions of π and π½π = βπ/2 is the Jacobian of element π. To get
this form,
we converted each πππ
ππ₯ to
πππ
ππ
1
π½π, i.e. we included an extra
1
π½π,
we changed the integral limits to [-1,1],
we changed the last ππ₯ to π½πππ.
π, β, π΄π and π are the same for all elements. Also element lengths and therefore π½πβs are the same for
all elements. It means that [πΎπ]βs and {πΉπ}βs are the same for all elements. Substituting the shape function details and other numerical values, we can calculate (using GQ integration or not) the following
[πΎπ] = [7.0162 β3.0892β3.0892 7.0162
] , {πΉπ} = {98.174898.1748
}
Important: As seen, [πΎπ] is symmetric. Actually it can be seen from the πΎππ
π equation. As we
interchange the indices π and π, nothing changes in the integrand. In earlier examples, there was no such symmetry because of the existence of the first derivative term in the DE. Assembled 5x5 system is
[ 7.0162 β3.0892 0 0 0β3.0892 14.0324 β3.0892 0 0
0 β3.0892 14.0324 β3.0892 00 0 β3.0892 14.0324 β3.08920 0 0 β3.0892 7.0162 ]
{
π1π2π3π4π5}
=
{
98.1748196.3495196.3495196.349598.1748 }
+
{
π΅1000π΅5}
π1 is given as 100
oC. Apply reduction for this and get rid of the first equation.
[
14.0324 β3.0892 0 0β3.0892 14.0324 β3.0892 0
0 β3.0892 14.0324 β3.08920 0 β3.0892 7.0162
]{
π2π3π4π5
} = {
196.3495196.3495196.349598.1748
} + {
0 β (β3.0892)(100)00π΅5
}
MBC is provided at the last node as
π΅5 = (ππ΄πππ
ππ₯ππ₯)
πΏ= ππ΄π
ππ
ππ₯|πΏ= ββπ΄π(π5 β πβ)
Put this in the standard form of
π΅5 = (ππ)5 = π½π5 + πΎ where π½ = ββπ΄π = β0.7854 and πΎ = βπ΄ππβ = 19.6350. Use these in the reduced system
12
[
14.0324 β3.0892 0 0β3.0892 14.0324 β3.0892 0
0 β3.0892 14.0324 β3.08920 0 β3.0892 7.0162 + 0.7854
]{
π2π3π4π5
} = {
196.3495196.3495196.349598.1748
} + {
308.9200
19.6350
}
Solving this system, we get
{
π2π3π4π5
} = {
42.401929.045825.975725.3864
} β
Comparison of the known exact solution and the FEM solution is as follows.
As a post processing calculation the amount of heat that goes through the fin base (π₯ = 0), which is
important in evaluating the finβs performance, can be calculated. The value we want is given by
ππππ π = (ππ΄πππ
ππ₯ππ₯)
π₯=0
where ππ₯ = β1 at the left boundary of the domain. ππππ π is nothing but the SV at node 1, i.e. π΅1. It
can be calculated in two different ways. First one is to use the first equation of the original 5x5 system
that we had before reduction. Substituting the already calculated temperature values we can obtain
π΅1.
ππππ π = π΅1 = (7.0162)(100) + (β3.0892)(42.4019) = 570.6 W
In an alternative way we can use the calculated nodal temperatures to determine the slope of
temperature at the fin base and use it to calculate ππππ π. Over the first element the temperature varies
linearly as seen above and the slope of this linear variation is
ππ
ππ₯|π₯=0
= π2 β π1βπ
=42.4019 β 100
0.25= β230.4 K/m
Multiplying this slope with ππ΄πππ₯ will give the required ππππ π
ππππ π = (ππ΄πππ
ππ₯ππ₯)
π₯=0= (140) (
π 0.12
4)(β230.4)(β1) = 253.3 W
13
Important: The two values calculated are quite different. The reason of this is the extra derivative
approximation involved in the second approach. Differentiation is always a risky operation that
amplifies the already existing errors. Here, the calculated temperature values already have some error
in them, and these errors amplify when we approximate the first derivative at the fin base. Although
the first approach gives a better estimate (exact value of ππππ π is 440.8 W), the second approach is
usually used in an FEM code due to practical reasons. As expected, as the mesh is refined, the values
estimated by the two approaches converge to the same value, which is the exact value. This can be
seen below
π΅π¬ πΈππππ calculated with the second approach (W)
4 253.3
10 344.6
100 429.3
1000 439.6
ππππ π is positive, meaning that heat is coming into the domain at the base of the fin. Because we
included ππ₯ in the SV definition, regardless of which boundary we calculate π at (fin base or fin tip), a
positive value means βheat is coming inβ, and a negative value means βheat is going outβ.
Example 2.7:
Letβs modify the previous fin problem a bit, by making the diameter of the fin variable. It is larger at the base and decreases linearly towards the tip. πΏ = 1 m
π·πππ π = 0.1 m , π·π‘ππ = 0.05 m
π·(π₯) = β0.05π₯ + 0.1 Governing DE is the same as before, but now the cross sectional area and the perimeter of the fin are not constant. They are functions of π₯. πΎππ
π and πΉππ integrals are expressed same as before, also given
below.
πΎπππ = β« (ππ΄π
ππππ
ππ
1
π½π πππ
π
ππ
1
π½π+ βπππ
ππππ) π½πππ
1
β1
, πΉππ = β« ππβππβ π½
πππ1
β1
Important: Now [πΎπ] and {πΉπ} of each element is different because π΄π and π changes from element
to element. To evaluate the above integrals we need to write π΄π and π as functions of π.
π΄π =ππ·2
4=π
4(β0.05π₯ + 0.1)2, π = ππ· = π(β0.05π₯ + 0.1)
For element βeβ, π₯ β π relation is given by
π₯ =βπ
2π +
π₯1π + π₯2
π
2
π₯
14
which needs to be substituted in the π΄π and π expressions to get
π΄π =ππ·2
4=π
4[β0.05(
βπ
2π +
π₯1π + π₯2
π
2) + 0.1]
2
, π = ππ· = π [β0.05(βπ
2π +
π₯1π + π₯2
π
2) + 0.1]
As you see, things can get pretty involved and it becomes very difficult to perform a hand solution. But
this will not create any difficulty in a FEM code that makes use of GQ integration, as weβll see later.
Example 2.8:
Letβs solve Example 2.1, DE of which is given below, using the Finite Difference Method (FDM) and
compare the solution with the FEM solution.
3ππ
ππ₯βπ2π
ππ₯2= 1 π(0) = 0 , π(1) = 0
FDM has no concept of elements, but it has nodes. Weβll perform a 6 node solution using a node
spacing of Ξπ₯ = 1/5 = 0.2.
Letβs write the ODE for an inner node π, with neighbors π β 1 and π + 1.
Node π: 3ππ
ππ₯|πβπ2π
ππ₯2|π
= 1
The first and the second derivatives can be approximated in many different ways, such as backward,
central and forward. Also approximations of various orders, such as first-order or second-order can be
used. Weβll use the following second-order central approximations
ππ
ππ₯|πβ ππ+1 β ππβ1
2Ξπ₯ ,
π2π
ππ₯2|π
β ππ+1 β 2ππ + ππβ1
(Ξπ₯)2
Substitute these into the ODE to get
Node π: 3 (ππ+1 β ππβ1
2Ξπ₯) β (
ππ+1 β 2ππ + ππβ1(Ξπ₯)2
) = 1
Use Ξπ₯ = 0.2 and arrange into
Node π: 32.5ππβ1 + 50ππ + 17.5ππ+1 = 1
To see the similarity of this equation with that obtained earlier by FEM, multiply the equation by
Ξπ₯ = 0.2
Node π: 6.5ππβ1 + 10ππ + 3.5ππ+1 = 0.2
This is exactly the same equation as those obtained for the inner nodes of the FE solution. Look at the
global system obtained in Example 2.1 to see it.
x
1 2 3 4 5 6
Ξπ₯
15
Important: Therefore, our FEM solution is practically the same as using FDM with second-order central
derivative approximations. But FDM seems to be much simpler than FEM. So why should anyone prefer
FEM? For this 1D problem, FEM has no advantage over FDM. FDM is just OK here. But FDM cannot be
extended to 2D and 3D problems over complicated geometries, where unstructured grids are required.
On the other hand, FEM is naturally suitable for those problems.
Important: Here we worked only on the inner nodes. For the boundary nodes, derivatives need to be
approximated not as central, but as a one-sided, such as forward differencing for node 1, and backward
differencing for node 6.
Example 2.9:
Letβs solve Example 2.6, DE of which is given below, using the Finite Volume Method (FVM) and
compare the solution with the FEM solution.
βπ
ππ₯(πππ
ππ₯) +
βπ
π΄π(π β πβ) = 0 , 0 < π₯ < πΏ
Note that both terms are divided by π΄π, because this form is more suitable to FVM. A FVM mesh has
cells and nodes. Cells are similar to the elements of FEM. Nodes are where we store the discrete
unknown values, and typically they are at the midpoints of the cells. Following mesh has 4 cells and 4
nodes. Different than FEM or FDM, there are no nodes at the boundaries. In FVM one can use other
storage schemes too.
Consider each cell to have a length of Ξπ₯ = πΏ/4.
FVM uses integral form of the given DE. We integrate the DE over cell π.
Cell π βΆ ββ«π
ππ₯(πππ
ππ₯) πβ
Ξ©π
+β«βπ
π΄π(π β πβ) πβ
Ξ©π
= 0
where Ξ©π denotes the domain (line segment in 1D) of cell π and πβ is used for volume integration (line
integral in 1D). FVM is based on the accounting of incoming and outgoing amounts of the conserved
quantity at the faces of a cell. To see it this way we apply Gauss divergence theorem to the first integral
and convert it from a volume integral to an area integral
Cell π βΆ ββ« πππ
ππ₯ ππ₯ ππ΄
π΄π
+β«βπ
π΄π(π β πβ) πβ
Ξ©π
= 0
where π΄π is the boundary (faces) of cell π , which are just the two end points in 1D. ππ₯ is the π₯
component of the unit outward normal at the boundaries, same as the one we used in the SV
expression in FEM. In 1D, area integral is not really an integral, but the sum of the integrand evaluated
at the two end points of cell π.
Cell 1 Cell 2 Cell 3 Cell 4
x
1 2 3 4
16
Cell π βΆ β [(πππ
ππ₯ππ₯π΄π)
ππππ‘+ (ππ΄π
ππ
ππ₯ππ₯π΄π)
πππβπ‘] + β«
βπ
π΄π(π β πβ) πβ
Ξ©π
= 0
where βleftβ and βrightβ are the left and right end points (faces) of cell π. The volume integral over cell
π can be approximated as
β«βπ
π΄π(π β πβ) πβ
Ξ©π
β βπ
π΄π(ππ β πβ)π΄πΞπ₯ = βπ(ππ β πβ)Ξπ₯
which is obtained by considering the nodal value ππ (stored at the center of cell π) to be constant over
cell π , which has a volume of π΄πΞπ₯ . Also using ππ₯ππππ‘ = β1 and ππ₯πππβπ‘ = 1 , equation of cell π
becomes
Cell π βΆ β [(βπππ
ππ₯π΄π)
ππππ‘+ (π
ππ
ππ₯π΄π)
πππβπ‘] + βπ(ππ β πβ)Ξπ₯ = 0
This is an energy balance equation. It considers the balance of heat coming into the cell from its left
face, the heat going out of the cell from its right face and the convective heat going out of the cell to
the surroundings. This βphysical accountingβ character of FVM is what makes it natural and easy to
understand for engineers.
The main approximation in FVM is to approximate ππ
ππ₯ at the right and left faces of the cell. For an inner
cell (not located at a boundary), they can be approximated using the nodal values of ππ, ππ+1 and ππβ1
as follows
ππ
ππ₯|ππππ‘
β ππ β ππβ1Ξπ₯
, ππ
ππ₯|πππβπ‘
β ππ+1 β ππΞπ₯
which are second-order central approximations around the faces. Substitute these into the equation
of cell π.
Cell π βΆ β [βπππ β ππβ1Ξπ₯
π΄π + πππ+1 β ππΞπ₯
π΄π] + βπ(ππ β πβ)Ξπ₯ = 0
By putting the known values in and arranging we get
β4.3982ππβ1 + 16.6504ππ β 4.3982ππ+1 = 196.3495
Compared with the inner node equations obtained in Example 2.6, the right hand side value is the
same, but the coefficients of the unknowns are different. FVM and FEM discretizations are not identical
for this problem. The difference seems to be due to the discretization of the convective cooling term.
Note that FDM will give the same result as FVM, when the second derivative of the DE is approximated
in a second-order central way.
To complete the FVM discretization and obtain a solution, we need to work on the boundary cells,
which will not be done here.
Cell i
i-1 i i+1
Left Right
17
Example 2.10:
(Reference: Reddyβs book) Weβll perform an β -convergence study by solving the following pure
diffusion problem (Poisson equation)
βπ2π
ππ₯2= 2 , 0 < π₯ < 1 with π(0) = π(1) = 0
The exact solution is πππ₯ = π₯(1 β π₯).
Solutions with 2, 3 and 4 linear elements with constant element size for each case are shown below.
Nodal values are exact, even for the 2 element mesh. But inside the elements there are deviations
from the exact solution. To calculate how much these deviations contribute to the πΏ2 and energy norm
errors, letβs express the FE solutions as follows
For 2 elements βΆ ππππ = {β2(π₯/β)
β2(2 β π₯/β) for 0 β€ π₯ β€ β for β β€ π₯ β€ 2β
For 3 elements βΆ ππππ = {
2β2(π₯/β)
2β2(2 β π₯/β) + 2β2(π₯/β β 1)
2β2(3 β π₯/β)
for 0 β€ π₯ β€ β for β β€ π₯ β€ 2β for 2β β€ π₯ β€ 3β
18
For 4 elements βΆ ππππ =
{
3β
2(π₯/β)
3β2(2 β π₯/β) + 4β2(π₯/β β 1)
4β2(3 β π₯/β) + 3β2(π₯/β β 2)
3β2(4 β π₯/β)
for 0 β€ π₯ β€ β for β β€ π₯ β€ 2β for 2β β€ π₯ β€ 3βfor 3β β€ π₯ β€ 4β
where β = 1/2, 1/3 and 1/4 for 2, 3, and 4 element solutions, respectively. Knowing the exact
solution, we can calculate the integrals of the error norms and obtain the following results
β πΏ2 norm error Energy norm error
1/2 0.04564 0.2887
1/3 0.02028 0.1925
1/4 0.01141 0.1443
Following is the log-log plot of these values. Although not easy to see on the graph, slopes of the πΏ2
and energy norm error lines are 2 and 1, as discussed before.
Exercise: Repeat the above β-convergence study using quadratic elements and see if you can get the
rate of convergences predicted by the theory.
Slope of 1
Slope of 2