0% found this document useful (0 votes)
22 views61 pages

Lecture Notes Name-363 (FDM & Fem)

Uploaded by

Mahmud Alif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views61 pages

Lecture Notes Name-363 (FDM & Fem)

Uploaded by

Mahmud Alif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

NAME 363: Computational Fluid Dynamics (CFD)

Finite Difference Method (FDM)


Finite Element Method (FEM)

Prepared by
Dr. Md. Shahjada Tarafder

Department of Naval Architecture and Marine Engineering


Bangladesh University of Engineering & Technology
Dhaka-1000, Bangladesh
BUET NAME 363 – CFD (FDM & FEM)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 2


BUET NAME 363 – CFD (FDM & FEM)

Table of Contents

Chapter 1 Introduction 4

Chapter 2 Governing Equations of Fluid Flows 7

Chapter 3 Finite Difference Method 8


3.1 Introduction 9
3.2 Finite difference by Taylor series expansion 9
3.2.1 First order derivative 9
3.2.2 Second order derivative 11
3.3 Finite difference by polynomials 11
3.4 Finite difference by general approach 12
3.5 Finite difference approximation for mixed derivatives 13

Chapter 4 Interpolation 17

Chapter 5 Finite Element Method 34


5.1 Introduction 34
5.2 Variational operator 35
5.3 Functional 38
5.4 Euler-Lagrange Equation 42
5.5 Rayleigh-Ritz method: 44
5.6 Galerkin method 50
5.7 Finite Element Method 52

Chapter 6 Error! Bookmark not defined.

Finite volume method Error! Bookmark not defined.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 3


BUET NAME 363 – CFD (FDM & FEM)

Chapter 1
Introduction

1.1 Definition of CFD


(a) CFD is a science that with the help of digital computers produces quantitative predictions
of fluid flows based on the conservation laws (conservation of mass, momentum and
energy) of governing equation of fluid motion. These predictions normally occur under
those conditions defined in terms of flow geometry, the physical properties of a fluid and
the boundary and initial condition of a flow field. The prediction generally concerns sets
of valves of the flow variable such as velocity. Pressure or temperature at selected locations
in the domain and for selected times. It may also evaluate the overall behavior of the flow.
Such as the flow rate or the hydrodynamic force acting on an object in the flow. During the
past four decades, different types of numerical methods have been developed to simulate
the fluid flows involving a wide range of applications. The numerical methods include
• Finite difference method
• Finite element method
• Finite volume method and
• Spectral method
The CFD predictions are never completed exact. Because many sources of error are
involved in the predictions, one has to be very careful in interpreting the results produced
by CFD techniques. The most common sources of error are:
• Discretization error
• Input data error and
• Modeling error
Source: Fluid Mechanics by Kundu

(b) Fluid flows are governed by the partial differential equation or integral equation (PDE)
which is derived on the basis of the conservation laws of mass, momentum, and energy.
Computational Fluid Dynamics (CFD) is the art of replacing such PDE systems by a set
of algebraic equations which is be solved by using digital computers.
Source: Lecture note - Kuzmin

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 4


BUET NAME 363 – CFD (FDM & FEM)

(c) CFD is a branch of fluid mechanics that uses numerical analysis and data structures to
analyze and solve problems that involve fluid flows. Computers are used to perform the
calculations required to simulate the free-stream flow of the fluid, and the interaction of
the fluid (liquids and gases) with surfaces defined by boundary conditions. With high-
speed supercomputers, better solutions can be achieved, and are often required to solve the
largest and most complex problems.

Ongoing research yields software that improves the accuracy and speed of complex
simulation scenarios such as transonic or turbulent flows. Initial validation of such
software is typically performed using experimental apparatus such as wind tunnels. In
addition, previously performed analytical or empirical analysis of a particular problem can
be used for comparison. A final validation is often performed using full-scale testing, such
as flight tests.

CFD is applied to a wide range of research and engineering problems in many fields of
study and industries, including aerodynamics and aerospace analysis, weather simulation,
natural science and environmental engineering, industrial system design and
analysis, biological engineering, fluid flows and heat transfer,
and engine and combustion analysis.
Source: Wikipedia

1.2 Steps in CFD

1.2.1 Mathematical modeling of fluid flow:

1.2.2 Discretization method


This is a method of approximating the differential equations by a system of algebraic equations for the
variables at some sent of discrete locations in space and time. The most common discretization methods
are finite difference method, finite volume method, finite element method and the boundary element
method.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 5


BUET NAME 363 – CFD (FDM & FEM)

1.2.3 Numerical grid or mesh generation:


In a finite difference method, approximations for the derivatives at the grid points have to be selected. In a
finite volume method, one has to select the methods of approximating surface and volume integrals. In
finite element method, one has to choose the shape functions and weighting functions.

1.2.4 Solution method

1.2.5 Convergence criteria

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 6


BUET NAME 363 – CFD (FDM & FEM)

Chapter 2
Governing Equations of Fluid Flows

Fluid flow is caused by the action of externally applied forces like pressure differences, gravity, shear force,
rotation and surface tension. Surface force and body force. The properties of fluids include density,
viscosity, specific heat and surface tension. While all fluids behave similarly under action of forces, their
macroscopic properties differ considerably. The effects of viscosity are important only near walls, so that
the flow in the largest part to the domain can be considered as inviscid. Fluid obeying Newton’s law of
viscosity is called Newtonian fluid.

Many other phenomena affect fluid flow. These include temperature differences which lead to heat transfer
and density differences which give rise to buoyancy. They and differences in concentration of solutes may
affect flows significantly or even be the sole cause of the flow. Phase changes (boiling, condensation,
melting and freezing) when they always lead to important modifications for the flow and give rise to
multiphase flow. Variation of other properties such as viscosity, surface tension may also play important
role in determining the nature of the flow. The basic conservation principles and laws used to derive the
governing equations of fluid flow and the techniques for the numerical solution of the governing equations.
The flow within a certain spatial region is called a control volume and the method analysis is called the
control volume approach.

The non-conservative form of equations is often used in finite difference method. To obtain an approximate
solution numerical we have to use a discretization method which approximates the differential equations
by a system of algebraic equations which can be solved on a computer. The approximations are applied to
small domains in space and or time so the numerical solutions provide results at discrete locations in space
and time. Much as the accuracy of experimental data depends on the quality of the tools used, the accuracy
of numerical solutions is dependent on the quality of discretization used.

One dimensional fluid flow


In case of one-dimensional flow, we have the net mass flow the same at every cross-section that is
𝜌𝐴𝑢 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡
where  is the density, A is the cross-sectional area and u is the flow velocity. Differentiating Eq. () we
have
𝑑(𝜌𝐴𝑢)
=0
𝑑𝑥

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 7


BUET NAME 363 – CFD (FDM & FEM)

If the fluid is inviscid, there exists a potential function (x) such that
𝑑𝜙
𝑢=
𝑑𝑥
Hence Eq. () becomes
𝑑 𝑑𝜙
(𝜌𝐴 ) = 0
𝑑𝑥 𝑑𝑥

Conservation form

Equation of continuity 
+ div (  u ) = 0
t
x-momentum equation ( u) p
+ div (  uu ) = − + div (  grad u ) + S Mx
t x
y-momentum equation  (  v) p
+ div (  vu ) = − + div (  grad v) + S My
t x
z-momentum equation  (  w) p
+ div(  wu ) = − + div(  grad w) + S Mz
t z
Energy equation ( i)
+ div(  iu ) = − p div u + div (k grad T ) +  + Si
t

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 8


BUET NAME 363 – CFD (FDM & FEM)

Chapter 3
Finite Difference Method

3.1 Introduction
The derivatives of the dependent variables appearing in the governing partial differential equation of fluid
flows are replaced by algebraic finite difference approximations which change the differential equation into
an algebraic equation that can be solved by simple arithmetic.

The starting point is the conservation equation in differential form. The solution domain is covered by a
grid. At each grid point, the differential equation is approximated by replacing the partial derivatives by
approximations in terms of the nodal values of the functions. The result is a system of algebraic equations
per grid node in which the variable value at a certain number of nodes appear as unknowns. Taylor’s series
expansion or polynomial is used to obtain approximations to the first and second derivatives of the variables
with respect to the co-ordinates.

3.2 Finite difference by Taylor series expansion

3.2.1 First order derivative


Using Taylor’s series expansion, the function 𝑢(𝑥 + Δ𝑥) can be expressed as
Δ𝑥 𝜕𝑢 (Δ𝑥)2 𝜕2 𝑢 (Δ𝑥)3 𝜕3 𝑢
𝑢(𝑥 + Δ𝑥) = 𝑢(𝑥) + (
1! 𝜕𝑥
) + 2!
( 𝜕𝑥 2 ) + 3!
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.1)

(b)
(a)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 9


BUET NAME 363 – CFD (FDM & FEM)

Fig. 3.1 Geometric interpretation of difference formula

If the points are numbered as i and i+1 as shown in Fig. 2.1(b), Eq. (2.1) can be written as
𝜕𝑢 (Δ𝑥)2 𝜕2 𝑢 (Δ𝑥)3 𝜕3 𝑢
𝑢𝑖+1 = 𝑢𝑖 + Δ𝑥 (𝜕𝑥 ) + 2!
(𝜕𝑥 2 ) + 3!
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.2)
𝑖 𝑖 𝑖

Solving for 𝜕𝑢/𝜕𝑥, one obtains


𝜕𝑢 𝑢𝑖+1 −𝑢𝑖 Δ𝑥 𝜕2 𝑢 (Δ𝑥)2 𝜕3 𝑢
(𝜕𝑥 ) = Δ𝑥
− ( )
2 𝜕𝑥 2 𝑖
− 6
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.3)
𝑖 𝑖

The terms with factors of Δ𝑥 and its higher order can be written as 𝑂(Δ𝑥) and is referred to as the truncation
error and is defined as the difference between the exact value and its numerical approximations.
𝜕𝑢 𝑢𝑖+1 −𝑢𝑖
( ) = + 𝑂(Δ𝑥) (2.4)
𝜕𝑥 𝑖 Δ𝑥

This is known as forward difference formula as the derivative is approximated at point i using the forward
value 𝑢𝑖+1 at point 𝑖 + 1. Similarly, the function 𝑢(𝑥 − Δ𝑥) can be expressed as
Δ𝑥 𝜕𝑢 (Δ𝑥)2 𝜕 2 𝑢 (Δ𝑥)3 𝜕 3 𝑢
𝑢(𝑥 − Δ𝑥) = 𝑢(𝑥) − ( )+ ( 2) − ( 3) + ⋯ ⋯ ⋯
1! 𝜕𝑥 2! 𝜕𝑥 3! 𝜕𝑥
Writing in terms of node number yields
𝜕𝑢 (Δ𝑥)2 𝜕2 𝑢 (Δ𝑥)3 𝜕3 𝑢
𝑢𝑖−1 = 𝑢𝑖 − Δ𝑥 ( ) + ( 2) − ( 3) + ⋯⋯⋯ (2.5)
𝜕𝑥 𝑖 2! 𝜕𝑥 𝑖 3! 𝜕𝑥 𝑖

Solving for 𝜕𝑢/𝜕𝑥, one obtains


𝜕𝑢 𝑢𝑖 −𝑢𝑖−1 Δ𝑥 𝜕2 𝑢 (Δ𝑥)2 𝜕3 𝑢
(𝜕𝑥 ) = Δ𝑥
+ ( )
2 𝜕𝑥 2 𝑖
− 6
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.6)
𝑖 𝑖
𝑢𝑖 −𝑢𝑖−1
= Δ𝑥
+ 𝑂(Δ𝑥) (2.7)

This is known as backward difference formula as the derivative is evaluated at point i using the backward
value 𝑢𝑖−1 . Subtracting Eq. (2.5) from Eq. (2.2) one obtains
𝜕𝑢 (Δ𝑥)3 𝜕3 𝑢
𝑢𝑖+1 − 𝑢𝑖−1 = 2 Δ𝑥 (𝜕𝑥 ) + 2 3!
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.8)
𝑖 𝑖

Solving for 𝜕𝑢/𝜕𝑥, one obtains


𝜕𝑢 𝑢𝑖+1 −𝑢𝑖−1
(𝜕𝑥 ) = 2 Δ𝑥
+ 𝑂(Δ𝑥)2 (2.9)
𝑖

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 10


BUET NAME 363 – CFD (FDM & FEM)

This is known as central difference formula as the derivative is approximated at the central point i using the
forward functional value 𝑢𝑖+1 and the backward functional value 𝑢𝑖−1.

3.2.2 Second order derivative


Again, consider the Taylor series expansion
𝜕𝑢 (Δ𝑥)2 𝜕2 𝑢 (Δ𝑥)3 𝜕3 𝑢
𝑢𝑖+1 = 𝑢𝑖 + Δ𝑥 (𝜕𝑥 ) + 2!
(𝜕𝑥 2 ) + 3!
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.10)
𝑖 𝑖 𝑖
𝜕𝑢 (2 Δ𝑥)2 𝜕2 𝑢 (2 Δ𝑥)3 𝜕3 𝑢
𝑢𝑖+2 = 𝑢𝑖 + 2 Δ𝑥 (𝜕𝑥 ) + 2!
(𝜕𝑥 2 ) + 3!
(𝜕𝑥 3 ) + ⋯⋯⋯ (2.11)
𝑖 𝑖 𝑖

Multiplying Eq. (2.10) by 2 and then subtracting it from Eq. (2.11) we obtain
𝜕2 𝑢 𝜕3 𝑢
𝑢𝑖+2 − 2 𝑢𝑖+1 = −𝑢𝑖 + (Δ𝑥)2 ( ) + 2 (Δ𝑥)3 ( ) + ⋯⋯⋯ (2.12)
𝜕𝑥 2 𝑖 𝜕𝑥 3 𝑖

Solving for 𝜕 2 𝑢/𝜕𝑥 2


𝜕2 𝑢 𝑢𝑖+2 −2 𝑢𝑖+1 +𝑢𝑖
(𝜕𝑥 2 ) = (Δ𝑥)2
+ 𝑂(Δ𝑥) (2.13)
𝑖

This equation represents the forward difference approximation for the second derivative of order Δ𝑥 . A
similar approximation for the second derivative for backward difference approximation can be produced
by using the Taylor series expansions of 𝑢𝑖−1 𝑎𝑛𝑑𝑢𝑖−2 as
𝜕2 𝑢 𝑢𝑖 −2𝑢𝑖−1 +𝑢𝑖−2
( ) = + 𝑂(Δ𝑥) (2.14)
𝜕𝑥 2 𝑖 (Δ𝑥)2

Adding Eq. (2.5) and Eq. (2.2) one obtains


(Δ𝑥)2 𝜕2 𝑢 (Δ𝑥)4 𝜕4 𝑢
𝑢𝑖+1 + 𝑢𝑖−1 = 2𝑢𝑖 + 2 2!
(𝜕𝑥 2 ) +2 4!
(𝜕𝑥 4 ) + ⋯⋯⋯ (2.15)
𝑖 𝑖
𝜕2 𝑢
Solving for 𝜕𝑥 2
one obtains
𝜕2 𝑢 𝑢𝑖+1 −2𝑢𝑖 +𝑢𝑖−1
( ) = + 𝑂(Δ𝑥)2 (2.16)
𝜕𝑥 2 𝑖 (Δ𝑥)2

This is central difference formula for second derivative of order (Δ𝑥)2 .

3.3 Finite difference by polynomials


The functions are usually approximated by fitting a polynomial of equally spaced points as shown in Fig.
Now the equation for a second-degree polynomial is
𝑢 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 (2.17)
Applying Eq. (2.17) at node 𝑖, 𝑖 + 1 𝑎𝑛𝑑 𝑖 + 2 we obtain
𝑢𝑖 = 𝑎0 (2.18)
𝑢𝑖+1 = 𝑎0 + 𝑎1 ∆𝑥 + 𝑎2 (∆𝑥)2 (2.19)
2
𝑢𝑖+2 = 𝑎0 + 2 𝑎1 ∆𝑥 + 𝑎2 (2 ∆𝑥) (2.20)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 11


BUET NAME 363 – CFD (FDM & FEM)

Solving Eq. 2.18, Eq. 2.19 and Eq. 2.20 one obtains
𝑎0 = 𝑢𝑖 (2.21)
−𝑢𝑖+2 +4𝑢𝑖+1 −3𝑢𝑖
𝑎1 = 2 ∆x
(2.22)
𝑢𝑖+2 −2𝑢𝑖+1 +𝑢𝑖
𝑎2 = 2 (∆x)2
(2.23)

Differentiating with respect to x one obtains


𝜕𝑢
𝜕𝑥
= 𝑎1 + 2 𝑎2 𝑥 (2.24)
𝜕2 𝑢
𝜕𝑥 2
= 2 𝑎2 (2.25)

Now the first order derivative at 𝑥𝑖 = 0 can finally be expressed as


𝜕𝑢 −𝑢𝑖+2 +4𝑢𝑖+1 −3𝑢𝑖
= 𝑎1 = (2.26)
𝜕𝑥 2 ∆x

And the second derivative as


𝜕2 𝑢 𝑢𝑖+2 −2𝑢𝑖+1 +𝑢𝑖
𝜕𝑥 2
= (∆x)2
(2.27)

3.4 Finite difference by general approach


A first–order accurate finite difference approximation of the derivative at xi can be derived by considering
the value of u at three different points like xi, xi-1 and xi-2. The approximation is constructed as weighted
average of the values of 𝑢𝑖 , 𝑢𝑖−1 𝑎𝑛𝑑𝑢𝑖−2 such as
𝑎𝑢𝑖 +𝑏𝑢𝑖−1 +𝑐𝑢𝑖−2
(𝑢𝑥 )𝑖 =
∆𝑥
+ 𝑂(∆𝑥)2 (2.28)
1 1
𝑢𝑖−1 = 𝑢𝑖 − ∆𝑥(𝑢𝑥 )𝑖 + (∆𝑥 )2 (𝑢𝑥𝑥 )𝑖 − ( ∆𝑥 )3 (𝑢𝑥𝑥𝑥 )𝑖 + ⋯⋯⋯∞ (2.29)
2! 3!
1 1
𝑢𝑖−2 = 𝑢𝑖 − 2 ∆𝑥(𝑢𝑥 )𝑖 + 2! (2 ∆𝑥 )2 (𝑢𝑥𝑥 )𝑖 − 3! (2 ∆𝑥 )3 (𝑢𝑥𝑥𝑥 )𝑖 + ⋯ ⋯ ⋯ ∞(2.30)

Substituting Eq. (2.4.2) and (2.4.3) in Eq. (2.4.1) we obtain


1 1
(𝑢𝑥 )𝑖 ∆𝑥 = 𝑎𝑢𝑖 + 𝑏 [𝑢𝑖 − ∆𝑥(𝑢𝑥 )𝑖 + (∆𝑥)2 (𝑢𝑥𝑥 )𝑖 − (∆𝑥)3 (𝑢𝑥𝑥𝑥 )𝑖 + ⋯ ⋯ ⋯ ∞]
2! 3!
1 1
+ 𝑐 [𝑢𝑖 − 2 ∆𝑥(𝑢𝑥 )𝑖 + (2 ∆𝑥 )2 (𝑢𝑥𝑥 )𝑖 − (2 ∆𝑥 )3 (𝑢𝑥𝑥𝑥 )𝑖 + ⋯ ⋯ ⋯ ∞]
2! 3!
(∆𝑥)2
= (𝑎 + 𝑏 + 𝑐)𝑢𝑖 − (2𝑐 + 𝑏)∆𝑥(𝑢𝑥 )𝑖 + (4𝑐 + 𝑏)(𝑢𝑥𝑥 )𝑖 + ⋯ ⋯ ⋯ ∞
2
Taking the coefficients of similar terms from both sides of above equation we obtain
𝑎+𝑏+𝑐 =0
2𝑐 + 𝑏 = −1
4𝑐 + 𝑏 = 0

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 12


BUET NAME 363 – CFD (FDM & FEM)

After solving we get


3 1
𝑎 = 2; 𝑏 = −2 and 𝑐 = 2

Therefore, from Eq. (2.4.1)


3 1
𝑢
2 𝑖
− 2𝑢𝑖−1 + 𝑢
2 𝑖−2
(𝑢𝑥 )𝑖 = + 𝑂(∆𝑥)2
∆𝑥
3 𝑢𝑖 − 4𝑢𝑖−1 + 𝑢𝑖−2
= + 𝑂(∆𝑥)2
2 ∆𝑥
Similarly, a second–order central finite difference approximation of the derivative at xi can be derived as
𝜕2𝑢 𝑢𝑖+1 − 2𝑢𝑖 + 𝑢𝑖−1
( 2 ) = + 𝑂(Δ𝑥)2
𝜕𝑥 𝑖 (Δ𝑥)2

3.5 Finite difference approximation for mixed derivatives


The approximation of mixed partial derivatives will be performed by Taylor series expansion first and
second by the use of approximation of partial derivatives derived earlier.

3.5.1 Mixed derivative by Taylor Series Expansion


The Taylor series expansion for a function 𝑢(𝑥 + ∆𝑥, 𝑦 + ∆𝑦) of two variables x and y can be expressed as
𝜕𝑢 𝜕𝑢 (∆𝑥)2 𝜕2 𝑢 ∆𝑥∆𝑦 𝜕2 𝑢
𝑢(𝑥 + ∆𝑥, 𝑦 + ∆𝑦) = 𝑢(𝑥, 𝑦) + ∆𝑥 𝜕𝑥 + ∆𝑦 𝜕𝑦 + 2! 𝜕𝑥 2
+2 2! 𝜕𝑥𝜕𝑦

(∆𝑦)2 𝜕2 𝑢
+ 2! 𝜕𝑦 2
+ 𝑂[(∆𝑥)3 , (∆𝑦)3 ] (2.31)

Using indices i and j to represent a grid point at x and y plane one obtains
(∆𝑥)2 ∆𝑥∆𝑦
𝑢𝑖+1,𝑗+1 = 𝑢𝑖,𝑗 + ∆𝑥(𝑢𝑥 )𝑖,𝑗 + ∆𝑦(𝑢𝑦 )𝑖,𝑗 + 2!
(𝑢𝑥𝑥 )𝑖,𝑗 + 2
2!
(𝑢𝑥𝑦 )𝑖,𝑗
(∆𝑦)2
+ 2!
(𝑢𝑦𝑦 )𝑖,𝑗 + 𝑂[(∆𝑥)3 , (∆𝑦)3 ] (2.32)

Similarly, the expressions of 𝑢𝑖−1,𝑗−1 , 𝑢𝑖+1,𝑗−1 and 𝑢𝑖−1,𝑗+1 can be written as


(∆𝑥)2 ∆𝑥∆𝑦
𝑢𝑖−1,𝑗−1 = 𝑢𝑖,𝑗 − ∆𝑥(𝑢𝑥 )𝑖,𝑗 − ∆𝑦(𝑢𝑦 ) + (𝑢𝑥𝑥 )𝑖,𝑗 + 2 (𝑢𝑥𝑦 )𝑖,𝑗
𝑖,𝑗 2! 2!

(∆𝑦)2
+ 2!
(𝑢𝑦𝑦 )𝑖,𝑗 + 𝑂[(∆𝑥)3 , (∆𝑦)3 ] (2.33)
(∆𝑥)2 ∆𝑥∆𝑦
𝑢𝑖+1,𝑗−1 = 𝑢𝑖,𝑗 + ∆𝑥(𝑢𝑥 )𝑖,𝑗 − ∆𝑦(𝑢𝑦 )𝑖,𝑗 + 2!
(𝑢𝑥𝑥 )𝑖,𝑗 − 2
2!
(𝑢𝑥𝑦 )𝑖,𝑗
(∆𝑦)2
+ 2!
(𝑢𝑦𝑦 )𝑖,𝑗 + 𝑂[(∆𝑥)3 , (∆𝑦)3 ] (2.34)
(∆𝑥)2 ∆𝑥∆𝑦
𝑢𝑖−1,𝑗+1 = 𝑢𝑖,𝑗 − ∆𝑥(𝑢𝑥 )𝑖,𝑗 + ∆𝑦(𝑢𝑦 )𝑖,𝑗 + 2!
(𝑢𝑥𝑥 )𝑖,𝑗 − 2
2!
(𝑢𝑥𝑦 )𝑖,𝑗
(∆𝑦)2
+ (𝑢𝑦𝑦 )𝑖,𝑗 + 𝑂[(∆𝑥)3 , (∆𝑦)3 ] (2.35)
2!

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 13


BUET NAME 363 – CFD (FDM & FEM)

Combining Eq. (2.5.2) to (2.5.5) we get


𝜕2𝑢 𝑢𝑖+1,𝑗+1 − 𝑢𝑖+1,𝑗−1 − 𝑢𝑖−1,𝑗+1 + 𝑢𝑖−1,𝑗−1
= + 𝑂[(∆𝑥)2 , (∆𝑦)2 ]
𝜕𝑥𝜕𝑦 4 ∆𝑥∆𝑦

3.5.2 Mixed derivative by the use of approximation of partial derivatives


The first order central difference approximation from Eq. (2.2.9) as
𝜕𝑢 𝑢𝑗+1 −𝑢𝑗−1
𝜕𝑦
= 2 Δy
+ 𝑂(Δy)2 (2.36)

Now for a mixed partial derivative


𝜕2 𝑢 𝜕 𝑢𝑗+1 −𝑢𝑗−1 1 𝜕𝑢 1 𝜕𝑢
𝜕𝑥𝜕𝑦
= 𝜕𝑥 [ 2 Δy
+ 𝑂(Δy)2 ] = [ ]
2 Δy 𝜕𝑥 𝑗+1
− 2 Δy [𝜕𝑥 ] + 𝑂(Δy)2 (2.37)
𝑗−1
𝜕𝑢
Substituting a central differencing scheme of 𝜕𝑥
of order (x)2we have
𝜕2 𝑢 1 𝑢𝑖+1,𝑗+1 −𝑢𝑖−1,𝑗+1 𝑢𝑖+1,𝑗−1 −𝑢𝑖−1,𝑗−1
𝜕𝑥𝜕𝑦
= 2 Δy [ 2 Δx
− 2 Δx
] + 𝑂[(Δx)2 , (Δy)2 ] (2.38)

Thus
𝜕2 𝑢 𝑢𝑖+1,𝑗+1 −𝑢𝑖−1,𝑗+1 −𝑢𝑖+1,𝑗−1 +𝑢𝑖−1,𝑗−1
𝜕𝑥𝜕𝑦
=[ 4 ΔxΔy
] + 𝑂[(Δx)2 , (Δy)2 ] (2.39)

Example 3.1 Derive the discretized form of Laplace equation in a region of xy-plane as shown in Fig.
𝜕2 𝑢 𝜕2 𝑢
+ =0 (2.40)
𝜕𝑥 2 𝜕𝑦 2

Using second-order central difference scheme at point (𝑥𝑖 , 𝑦𝑖 ), we obtain


𝑢𝑖+1,𝑗 −2𝑢𝑖,𝑗 +𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 −2𝑢𝑖,𝑗 +𝑢𝑖,𝑗−1
(Δ𝑥)2
+ (Δy)2
=0 (2.41)

If we assumeΔ𝑥 = Δ𝑦, we get


𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 = 0 (2.42)
Eq. contains four neighboring points around the central points (𝑥𝑖 , 𝑦𝑖 ) and is known as the five-point
difference formula for Laplace equation. Rearranging Eq. () we obtain
1
𝑢𝑖,𝑗 = 4 (𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 ) (2.43)

We can observe from above equation that the function value at the grid point is the average of the values at
the four adjoining points. To evaluate numerically the solution of Laplace’s equation at the grid points we
can apply Eq. () at the grid points where 𝑢𝑖,𝑗 is unknown, thus obtaining a system of linear equations. The
system of linear equations may be solved using either direct methods or iterative methods.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 14


BUET NAME 363 – CFD (FDM & FEM)

Ex. 3.2 The steady state two-dimensional heat flow in a metal plate is given by
𝜕2 𝑇 𝜕2 𝑇
𝜕𝑥 2
+ 𝜕𝑦2 = 0 (2.44)

Find the temperatures T1, T2, T3 and T4 using the boundary conditions as shown in Fig. below:

The discretized form of Eq. (2.44) can be written as


1
𝑇𝑖,𝑗 = (𝑇𝑖+1,𝑗 + 𝑇𝑖−1,𝑗 + 𝑇𝑖,𝑗+1 + 𝑇𝑖,𝑗−1 ) (2.45)
4

Applying Eq. (2.45) at node 1, 2, 3, and 4 we obtain


Node 1: 4 𝑇1 = 0 + 100 + 𝑇2 + 𝑇3
4 𝑇1 − 𝑇2 − 𝑇3 + 0 ∙ 𝑇4 = 100 (2.46)

Node 2: 4 𝑇2 = 𝑇1 + 100 + 200 + 𝑇4


𝑇1 − 4𝑇2 + 0 ∙ 𝑇3 + 𝑇4 = −300 (2.47)

Node 3: 4 𝑇3 = 0 + 𝑇1 + 𝑇4 + 50
𝑇1 + 0 ∙ 𝑇2 − 4𝑇3 + 𝑇4 = −50 (2.48)

Node 4: 4 𝑇4 = 𝑇3 + 𝑇2 + 200 + 100


0 ∙ 𝑇1 + 𝑇2 + 𝑇3 − 4𝑇4 = −300 (2.49)
Eq. (2.46) to (2.49) can be written into a matrix form as
4 −1 −1 0 𝑇1 100
1 −4 0 1 𝑇2 −300
[ ][ ] = [ ] (2.50)
1 0 −4 1 𝑇3 −50
0 1 1 −4 𝑇4 −300
Solving Eq. (2.50) we obtain
T1 = 70.82 T2 = 122.91
T3 = 60.42 T4 = 120.82

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 15


BUET NAME 363 – CFD (FDM & FEM)

Ex. 3.3 Using finite difference method solve the Poisson equation ∇2 𝑢 = 2𝑥 2 𝑦 2 over the square domain 0
≤ x ≤3 and 0 ≤ y ≤3 with u = 0 on the boundary. The domain is to be divided into squares of unit sizes.
∇2 𝑢 = 2𝑥 2 𝑦 2 (2.51)
𝜕2𝑢 𝜕2𝑢
+ = 2𝑥 2 𝑦 2
𝜕𝑥 2 𝜕𝑦 2
𝑢𝑖+1,𝑗 −2𝑢𝑖,𝑗 +𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 −2𝑢𝑖,𝑗 +𝑢𝑖,𝑗−1
(Δ𝑥)2
+ (Δy)2
= 2𝑥 2 𝑦 2 (2.52)

If we assumeΔ𝑥 = Δ𝑦, we get


𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 − 4𝑢𝑖,𝑗 = 2𝑥 2 𝑦 2 (Δ𝑥)2 (2.53)
Applying Eq. (2.53) at each grid points, we get
Node 1: 0 + 0 + 𝑢2 + 𝑢3 − 4 𝑢1 = 2 (1)2 (2)2 (1)2
−4 𝑢1 + 𝑢2 + 𝑢3 = 8 (2.54)
Node 2: 0 + 0 + 𝑢1 + 𝑢4 − 4 𝑢2 = 2 (2)2 (2)2 (1)2
𝑢1 − 4 𝑢2 + 𝑢4 = 32 (2.55)
Node 3: 0 + 0 + 𝑢1 + 𝑢4 − 4 𝑢3 = 2 (1)2 (1)2 (1)2
𝑢1 − 4 𝑢3 + 𝑢4 = 2 (2.56)
2 2 2
Node 4: 0 + 0 + 𝑢2 + 𝑢3 − 4 𝑢4 = 2 (2) (1) (1)
𝑢2 + 𝑢3 − 4 𝑢4 = 8 (2.57)
Eq. (2.54) to (2.57) can be written into a matrix form as
4 −1 −1 0 𝑢1 8
1 −4 0 1 𝑢2 32
[ ][ ] = [ ] (2.50)
1 0 −4 1 𝑢3 2
0 1 1 −4 𝑢4 8
Solving Eq. (2.50) we get
22 43
𝑢1 = − 𝑢2 = −
4 4
13 22
𝑢3 = − 4
𝑢4 = − 4

Problems
Derive a forward difference approximation of order (∆𝑥) with the use of second order polynomial.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 16


BUET NAME 363 – CFD (FDM & FEM)

Chapter 4
Interpolation

4.1 Introduction
The basic idea of the finite element method is to seek a piecewise approximate solution by dividing the
region of interest into small regions called elements. The functions used to represent the behavior of the
solution within an element are called the interpolation functions.

The choice of the finite element shown in Fig. 3.1 depends on the geometry of the global domain. A one-
dimensional domain is discretized by line elements where linear elements are restricted to straight sides and
quadratic and higher-order elements can have curved surfaces. Two-dimensional domain is subdivided into
triangular, rectangular and quadrilateral elements. The most common types of three-dimensional elements
are the tetrahedron and the hexahedron. The finite element interpolations are characterized by the shape of
the finite element and order of approximations.

Fig. 3.1 Types of finite element

In a one-dimensional domain, discretization into an array of elements is not difficult to grasp—small


element size is generally needed where variables change rapidly. In two-dimensional regions, generation
of an acceptable mesh becomes more troublesome; several meshes may need to be made before a suitable
mesh is created that yields reasonable results. In a three-dimensional domain, the mesh is not only more
cumbersome to make, but also difficult to visualize—many trial meshes may be required if the problem
domain is complex.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 17


BUET NAME 363 – CFD (FDM & FEM)

4.2 One-dimensional interpolation


Global co-ordinate system: Referring to Fig. 3.2, the polynomial expressions of variable u to be
approximated for one-dimensional element can be written as
𝑢 = 𝛼0 + 𝛼1 𝑥 + 𝛼2 𝑥 2 + ⋯ ⋯ ⋯ + 𝛼𝑛 𝑥 𝑛 (3.1)
= ∑𝑛𝑖=0 𝛼𝑖 𝑥 𝑖

Fig. 3.2 Linear interpolation in global co-ordinate system

For a linear variation we have


𝑢 = 𝛼0 + 𝛼1 𝑥 (3.2)
Applying Eq. (3.1) at node 1 and 2 we obtain
Node 1: 𝑢 = 𝑢1 at 𝑥 = 𝑥1
𝑢1 = 𝛼0 + 𝛼1 𝑥1 (3.3)
Node 2: 𝑢 = 𝑢2 at 𝑥 = 𝑥2
𝑢2 = 𝑎0 + 𝛼1 𝑥2 (3.4)
Solving Eq. (3.3) and (3.4) we get
𝑢1 𝑥2 −𝑢2 𝑥1
𝛼0 = 𝑥2 −𝑥1
𝑢2 −𝑢1
𝛼1 = 𝑥2 −𝑥1

Substituting the values of 𝛼0 and𝛼1 in Eq. (3.2) we obtain


𝑢 = 𝛼0 + 𝛼1 𝑥
𝑢1 𝑥2 −𝑢2 𝑥1 𝑢 −𝑢
= 𝑥2 −𝑥1
+ 𝑥2 −𝑥 1 𝑥
2 1
𝑥2 −𝑥 𝑥−𝑥1
= 𝑢
𝑥2 −𝑥1 1
+ 𝑢
𝑥2 −𝑥1 2
(3.5)

= N1 𝑢1 + N2 𝑢2

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 18


BUET NAME 363 – CFD (FDM & FEM)

𝑥2 −𝑥 𝑥−𝑥1
Where N1 = and N2 =
𝑥2 −𝑥1 𝑥2 −𝑥1

1 at x = 𝑥1 1 at x = 𝑥2
Note that N1 = { and N2 = {
0 at x = 𝑥2 0 at x = 𝑥1
The terms 𝑁1 and 𝑁2 are called the interpolation function (also known as trial function, shape function and
base function). The property of the shape function is given by
𝑥 −𝑥 𝑥−𝑥1
∑2𝑖=1 Ni = 2 + =1 (3.6)
𝑥 −𝑥 𝑥 2 1 2 −𝑥1

Local co-ordinate system: Let the origin of the co-ordinate system placed at node of the element so that
x1 = 0 and defining ℎ = 𝑥2 − 𝑥1 = 𝑥2 as shown in Fig. 3.3, we get from Eq. (3.5)
𝑥 𝑥
u = (1 − ℎ) 𝑢1 + ℎ 𝑢2 (3.7)

Natural or non-dimensional co-ordinate system: The co-ordinate system where the interpolation
functions are derived in terms of non-dimensional spatial variables is called a natural co-ordinate system.
(a) Origin is at node 1
u = (1 − 𝜉) 𝑢1 + 𝜉 𝑢2

(b) Origin at the centre of the element


𝑥
Letting 𝜉 = 𝑙
the polynomial expansion for a variable u in non-dimensional co-ordinate system can be

written as
𝑢 = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜉 2 + ⋯ ⋯ ⋯ + 𝛼𝑛 𝜉 𝑛 (3.8)
= 𝛼0 + 𝛼1 𝜉 for linear variation
Let ℎ = 2𝑙 and  = 0 at the centre of the element as shown Fig. 3.4, we obtain from Eq. (3.8)

u= 0 1
U u u = u(x)

u1 u2
h

x/h
1 2 x
0 1
1 2
x2
Fig. 3.3 Origin is at node 1
Fig. 3.4 Origin is at the centre of the element

Node 1: 𝑢 = 𝑢1 𝑤𝑖𝑡ℎ 𝜉 = −1

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 19


BUET NAME 363 – CFD (FDM & FEM)

𝑢1 = 𝛼0 − 𝛼1 (3.9)
Node 2: 𝑢 = 𝑢2 𝑤𝑖𝑡ℎ 𝜉 = +1
𝑢2 = 𝛼0 + 𝛼1 (3.10)
Solving Eq. (3.9) and Eq. (3.10) we get
1
𝛼0 = (𝑢1 +𝑢2 )
2
1
𝛼1 = (𝑢2 −𝑢1 )
2
Substituting the values of 𝛼0 and 𝛼1 in Eq. (3.8) we get
1 1
𝑢 = (1 − 𝜉)𝑢1 + (1 + 𝜉)𝑢2
2 2
= N1 𝑢1 + N2 𝑢2 (3.11)
where
1
N1 = (1 − 𝜉)
2
1 } (3.12)
N2 = (1 + 𝜉)
2
1 1
N1 + 𝑁2 = (1 − 𝜉) + (1 + 𝜉) = 1
2 2

Quadratic variation: Referring to Fig. 3.5, the polynomial approximation n for a variable u in non-
dimensional co-ordinate system can be written as
2

u= 0 1 2

h=2l

x/l
1 2 3
-1 0 1
1 2 3

Fig. 3.5 Quadratic interpolation in natural coordinate system

𝑢 = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜉 2 (3.13)
Node 1: 𝑢 = 𝑢1 𝑤𝑖𝑡ℎ 𝜉 = −1
𝑢1 = 𝛼0 − 𝛼1 + 𝛼2 (3.14)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 20


BUET NAME 363 – CFD (FDM & FEM)

Node 2: 𝑢 = 𝑢2 𝑤𝑖𝑡ℎ 𝜉 = 0
𝑢2 = 𝛼0 (3.15)
Node 3: 𝑢 = 𝑢3 𝑤𝑖𝑡ℎ 𝜉 = +1
𝑢3 = 𝛼0 + 𝛼1 + 𝛼2 (3.16)
Solving Eq. (3.14), (3.15) and (3.16) we get
𝛼0 = 𝑢2
1
𝛼1 = (𝑢3 − 𝑢1 )
2
1
𝛼2 = (𝑢1 + 𝑢3 ) − 𝑢2
2
Substituting the values of α0 , α1 and α2 in Eq. (3.13) and then rearranging we get
𝑢 = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜉 2
1 1
𝑢 = 𝑢2 + 2 (𝑢3 − 𝑢1 ) 𝜉 + [2 (𝑢1 + 𝑢3 ) − 𝑢2 ]𝜉 2
1 1 1
𝑢 = 𝜉(𝜉 − 1) 𝑢1 + (1 − 𝜉 2 )𝑢2 + 𝜉(1 + 𝜉) 𝑢3
2 2 2
= N1 𝑢1 + N2 𝑢2 + N3 𝑢3 (3.17)
Where the interpolation functions are
1
N1 = 𝜉(𝜉 − 1)
2
N2 = (1 − 𝜉 2 ) (3.18)
1
𝑁3 = 2
𝜉(1 + 𝜉)}

Lagrange Interpolation: The Lagrange interpolation function LN is of the form


𝑛
𝑥 − 𝑥𝑀
𝑁𝑁 = 𝐿𝑁 = ∏
𝑥𝑁 − 𝑥𝑀
𝑀=1 𝑀≠𝑁
(𝑥−𝑥1 )(𝑥−𝑥2 )⋯⋯(𝑥−𝑥𝑁−1 )(𝑥−𝑥𝑁+1 )⋯⋯(𝑥−𝑥𝑛 )
= (𝑥𝑁 −𝑥1 )(𝑥𝑁 −𝑥2 )⋯⋯(𝑥𝑁 −𝑥𝑁−1 )(𝑥𝑁 −𝑥𝑁+1 )(𝑥𝑁 −𝑥𝑀 )
(3.19)

The element is divided into equal length segments with m and n equal to order of approximations and the
number of nodes in an element respectively. Let us consider a first order approximation of a dependent
variable u such as Eq. (3.5)
u = L1 𝑢1 + L2 𝑢2 (3.20)
Where L1 and L2 from Eq. (3.19) as
𝑥−𝑥2
L1 = 𝑥
1 −𝑥2
𝑥−𝑥1 } (3.21)
L2 = 𝑥2 −𝑥1

Placing the origin of the co-ordinate system is at node 1 so that x1= 0 and defining x2 = h, we have
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 21
BUET NAME 363 – CFD (FDM & FEM)

𝑥−ℎ 𝑥
L1 = =1−
−ℎ ℎ
𝑥
L2 =

𝑥
If 𝜉 = , the interpolation function in natural co-ordinate system can be written as

𝜉−𝜉𝑀
𝐿𝑁 = ∏𝑛𝑀=1 𝑀≠𝑁 𝜉 (3.22)
𝑁 −𝜉𝑀

Where
𝜉−𝜉2
L1 = 𝜉 = (1 − 𝜉); (3.23)
1 −𝜉2

𝜉−𝜉1
L2 = 𝜉 =𝜉 (3.24)
2 −𝜉1

Quadratic approximation: n = 3
(𝜉−𝜉2 )(𝜉−𝜉3 )
L1 = (𝜉 ; (3.25)
1 −𝜉2 )(𝜉1 −𝜉3 )

(𝜉−𝜉1 )(𝜉−𝜉3 )
L2 = (𝜉 ; (3.26)
2 −𝜉1 )(𝜉2 −𝜉3 )

(𝜉−𝜉1 )(𝜉−𝜉2 )
L3 = (𝜉 (3.27)
3 −𝜉1 )(𝜉3 −𝜉2 )

u= 0 1 2

h=2l

x/l
1 2 3

0 1/2 1
1 2 3

Fig. 3.6 Origin is taken at Node 1

If the origin is taken at node 1 of the element as shown in Fig. 1 we have


1
𝜉1 = 0, 𝜉2 = 𝑎𝑛𝑑 𝜉3 = 1
2
Now from Eq. (3.25-3.27)
1
L1 = 2 (ξ − ) (ξ − 1); (3.28)
2

L2 = −4ξ(ξ − 1); (3.29)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 22


BUET NAME 363 – CFD (FDM & FEM)

1
L3 = 2ξ (ξ − ) (3.30)
2

If the origin is taken at node 2 of the element as shown in Fig. 1 we have


𝜉1 = −1, 𝜉2 = 0 𝑎𝑛𝑑 𝜉3 = 1
Now from Eq. (3.25-3.27)
1
L1 = ξ(ξ − 1); (3.31)
2

L2 = (1 − ξ2 ); (3.32)
1
L3 = 2 ξ(ξ + 1) (3.33)

4.3 Two-dimensional interpolation


4.3.1 Global Co-ordinate Triangular element
Assume an interpolation function for the variation of u as
𝑢 = 𝛼0 + 𝛼1 𝑥 + 𝛼2 𝑦 (3.34)
𝛼0
= [1 𝑥 𝑦] [𝛼1 ]
𝛼2
= [1 𝑥 𝑦][𝛼] (3.35)

The boundary conditions in terms of nodal point values of u are


Node 1: 𝑢 = 𝑢1 𝑎𝑡 𝑥 = 𝑥1 ; 𝑦 = 𝑦1
Node 2: 𝑢 = 𝑢2 𝑎𝑡 𝑥 = 𝑥2 ; 𝑦 = 𝑦2
Node 3: 𝑢 = 𝑢3 𝑎𝑡 𝑥 = 𝑥3 ; 𝑦 = 𝑦3

Applying the boundary conditions in Eq. (3.34) we get


𝑢1 = 𝛼0 + 𝛼1 𝑥1 + 𝛼2 𝑦1
𝑢2 = 𝛼0 + 𝛼1 𝑥2 + 𝛼2 𝑦2
𝑢3 = 𝛼0 + 𝛼1 𝑥3 + 𝛼2 𝑦3

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 23


BUET NAME 363 – CFD (FDM & FEM)

Fig. 3.7 Triangular element

The above equation can be written into a matrix form as


𝑢1 1 𝑥1 𝑦1 𝛼0
[𝑢2 ] = [1 𝑥2 𝑦2 ] [𝛼1 ]
𝑢3 1 𝑥3 𝑦3 𝛼2
[𝑢] = [𝐷][𝛼]
Multiplying both sides by [𝐷]−1 yields
[𝛼] = [𝐷]−1 [𝑢]
From Eq. (3.35)
𝑢 = [1 𝑥 𝑦][𝐷]−1 [𝑢] (3.36)
Now consider the matrix
1 𝑥1 𝑦1
[𝐷] = [1 𝑥2 𝑦2 ]
1 𝑥3 𝑦3
The inverse of the matrix [𝐷] is obtained as

𝐴𝑑𝑗𝐷 1 𝐴11 𝐴12 𝐴13 𝑇


[𝐷]−1 = = [𝐴 𝐴22 𝐴23 ]
|𝐷| |𝐷| 𝐴21 𝐴32 𝐴33
31

where
𝐴11 = (𝑥2 𝑦3 − 𝑥3 𝑦2 ) 𝐴12 = (𝑦2 − 𝑦3 ) 𝐴13 = (𝑥3 − 𝑥2 )
𝐴21 = (𝑥3 𝑦1 − 𝑥1 𝑦3 ) 𝐴22 = (𝑦3 − 𝑦1 ) 𝐴23 = (𝑥1 − 𝑥3 )
𝐴31 = (𝑥1 𝑦2 − 𝑥2 𝑦1 ) 𝐴32 = (𝑦1 − 𝑦2 ) 𝐴33 = (𝑥2 − 𝑥1 )

The area of the triangular element is


1 𝑥1 𝑦1
1 1
Δ = 2 [1 𝑥2 𝑦2 ] = |𝐷| and
2
1 𝑥3 𝑦3

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 24


BUET NAME 363 – CFD (FDM & FEM)

1 𝐴11 𝐴21 𝐴31


[𝐷]−1 = [𝐴12 𝐴22 𝐴32 ]
2Δ 𝐴 𝐴23 𝐴33
13

Now from Eq. (3.36)


𝑢 = [1 𝑥 𝑦][𝐷]−1 [𝑢]
𝑥 𝑦 − 𝑥3 𝑦2 𝑥3 𝑦1 − 𝑥1 𝑦3 𝑥2 𝑦1 − 𝑥1 𝑦2 𝑢1
1 2 3
𝑢 = [1 𝑥 𝑦] [ 𝑦2 −𝑦3 𝑦3 − 𝑦1 𝑦1 −𝑦2 ] [𝑢2 ]
2Δ 𝑥3 − 𝑥2 𝑥1 − 𝑥3 𝑥2 − 𝑥1 𝑢3
1
u =2Δ [(𝑥2 𝑦3 − 𝑥3 𝑦2 ) + 𝑥(𝑦2 −𝑦3 ) + 𝑦(𝑥3 − 𝑥2 )]𝑢1 +
1
[(𝑥 𝑦 − 𝑥1 𝑦3 ) + 𝑥(𝑦3 − 𝑦1 ) + 𝑦(𝑥1 − 𝑥3 )]𝑢2 +
2Δ 3 1
1
[𝑥 𝑦 − 𝑥1 𝑦2 ) + 𝑥(𝑦1 −𝑦2 ) + 𝑦(𝑥2 − 𝑥1 )]𝑢3
2Δ 2 1
u = 𝑁1 𝑢1 + 𝑁2 𝑢2 + 𝑁3 𝑢3
where
1
𝑁1 (𝑥, 𝑦) = [(𝑥 𝑦 − 𝑥3 𝑦2 ) + 𝑥(𝑦2 −𝑦3 ) + 𝑦(𝑥3 − 𝑥2 )]
2Δ 2 3
1
𝑁2 (𝑥, 𝑦) = [(𝑥 𝑦 − 𝑥1 𝑦3 ) + 𝑥(𝑦3 − 𝑦1 ) + 𝑦(𝑥1 − 𝑥3 )]
2Δ 3 1
1
𝑁3 (𝑥, 𝑦) = [(𝑥 𝑦 − 𝑥2 𝑦1 ) + 𝑥(𝑦1 − 𝑦2 ) + 𝑦(𝑥2 − 𝑥1 )]
2Δ 1 2 }
Defining
𝑎1 = 𝑥2 𝑦3 − 𝑥3 𝑦2 𝑏1 = 𝑦2 −𝑦3 𝑐1 = 𝑥3 − 𝑥2
𝑎2 = 𝑥3 𝑦1 − 𝑥1 𝑦3 𝑏2 = 𝑦3 − 𝑦1 𝑐2 = 𝑥1 − 𝑥3
𝑎3 = 𝑥1 𝑦2 − 𝑥2 𝑦1 𝑏3 = 𝑦1 −𝑦2 𝑐3 = 𝑥2 − 𝑥1

the shape functions can be expressed as


1
𝑁1 = [𝑎 + 𝑏1 𝑥 + 𝑐1 𝑦]
2Δ 1
1
𝑁2 = [𝑎 + 𝑏2 𝑥 + 𝑐2 𝑦]
2Δ 2
1
𝑁3 = [𝑎 + 𝑏3 𝑥 + 𝑐3 𝑦]
2Δ 3
Moreover, From Eq. () the shape function can also be written into a matrix form as

1 1 𝑥 𝑦 Δ
𝑁1 = |1 𝑥2 𝑦2 | = 1
2Δ 1 𝑥3 𝑦3 Δ

1 𝑥 𝑦
1 Δ
𝑁2 = 2Δ |1 𝑥3 𝑦3 | = 2
Δ
1 𝑥1 𝑦1
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 25
BUET NAME 363 – CFD (FDM & FEM)

1 𝑥 𝑦
1 Δ3
𝑁3 = |1 𝑥1 𝑦1 | =
2Δ 1 𝑥2 𝑦2 Δ

Where Δ1 , Δ2 and Δ3 are the areas of PCB, PAC and PAB which are opposite to nodes 1, 2 and 3
respectively.

4.3.2 Natural Co-ordinate Triangular element


Let us consider a triangle with the natural co-ordinate 𝐿𝑁 whose values are zero along the sides and one on
the vertices with a linear variation in between ash shown in Fig. 3.10.

Fig. 3.8 Natural co-ordinate triangular element

The co-ordinates are defined as


𝐴1
𝐿1 =
𝐴
𝐴2
𝐿2 =
𝐴
𝐴3
𝐿3 = }
𝐴
Where 𝐴1 , 𝐴2 and 𝐴3 are the partial areas defined by joining point P in the triangle with the corner nodes.
Now the total area A is
𝐴1 + 𝐴2 + 𝐴3 = 𝐴 (𝐿1 + 𝐿2 + 𝐿3 )
𝐴1 + 𝐴2 + 𝐴3 = 𝐴
𝐿1 + 𝐿2 + 𝐿3 = 1

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 26


BUET NAME 363 – CFD (FDM & FEM)

The global co-ordinate (x, y) are related the natural co-ordinate through the expressions:
𝑥 = 𝐿1 𝑥1 + 𝐿2 𝑥2 + 𝐿3 𝑥3
𝑦 = 𝐿1 𝑦1 + 𝐿2 𝑦2 + 𝐿3 𝑦3
Now
1 = 𝐿1 + 𝐿2 + 𝐿3
𝑥 = 𝐿1 𝑥1 + 𝐿2 𝑥2 + 𝐿3 𝑥3
𝑦 = 𝐿1 𝑦1 + 𝐿2 𝑦2 + 𝐿3 𝑦3

1 1 1 1 𝐿1
[𝑥 ] = [𝑥1 𝑥2 𝑥3 ] [𝐿2 ]
𝑦 𝑦1 𝑦2 𝑦3 𝐿3

1 1 1 −1 1 1 1 1 −1 1 1 1 𝐿1
[𝑥1 𝑥2 𝑥3 ] [𝑥 ] = [𝑥1 𝑥2 𝑥3 ] [𝑥1 𝑥2 𝑥3 ] [𝐿2 ]
𝑦1 𝑦2 𝑦3 𝑦 𝑦1 𝑦2 𝑦3 𝑦1 𝑦2 𝑦3 𝐿3

1 1 1 −1 1 𝐿1
[𝑥1 𝑥2 𝑥3 ] [𝑥 ] = [𝐿2 ]
𝑦1 𝑦2 𝑦3 𝑦 𝐿3

After solving the matrix, we get


1
𝐿1 = [(𝑥 𝑦 − 𝑥3 𝑦2 ) + 𝑥(𝑦2 −𝑦3 ) + 𝑦(𝑥3 − 𝑥2 )]
2Δ 2 3
1
𝐿2 = [(𝑥 𝑦 − 𝑥1 𝑦3 ) + 𝑥(𝑦3 − 𝑦1 ) + 𝑦(𝑥1 − 𝑥3 )]
2Δ 3 1
1
𝐿3 = [(𝑥 𝑦 − 𝑥1 𝑦2 ) + 𝑥(𝑦1 − 𝑦2 ) + 𝑦(𝑥2 − 𝑥1 )]
2Δ 2 1 }

So the interesting result is obtained as

𝐿1 = 𝑁1
𝐿2 = 𝑁2 }
𝐿3 = 𝑁3

For quadratic approximation we may write


𝑥 = 𝑎1 𝐿1 + 𝑎2 𝐿2 + 𝑎3 𝐿3 + 𝑎4 𝐿1 𝐿2 + 𝑎5 𝐿2 𝐿3 + 𝑎6 𝐿3 𝐿1 (3.34)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 27


BUET NAME 363 – CFD (FDM & FEM)

Fig. 3.9 Natural co-ordinate triangular element Fig. 3.10 Natural co-ordinate triangular element
with quadratic variation with cubic variation

Referring to Fig. 3.11 with three additional nodes installed at mid-sides of the triangle, we may write at
each corner and mid-side node
𝑥1 = 𝑎1 𝑥2 = 𝑎2 𝑥3 = 𝑎3
1 1 1 1 1 1 1 1 1
𝑥4 = 𝑎1 + 𝑎2 + 𝑎4 𝑥5 = 𝑎2 + 𝑎3 + 𝑎5 𝑥6 = 𝑎1 + 𝑎3 + 𝑎6
2 2 4 2 2 4 2 2 4

Solving for the constant and substituting into Eq. (3.34) we obtain
𝑁1 = (2𝐿1 − 1)𝐿1 𝑁2 = (2𝐿2 − 1)𝐿2 𝑁3 = (2𝐿3 − 1)𝐿3
𝑁4 = 4𝐿1 𝐿2 𝑁5 = 4𝐿2 𝐿3 𝑁6 = 4𝐿3 𝐿1

4.3.3 Integration of Functions of Natural Co-ordinates


The integration of the interpolation functions constructed for various degrees of approximation over the
domain can be expressed as

∬ 𝑓(𝑁) 𝑑𝑥 𝑑𝑦 = ∬ 𝑓(𝑥, 𝑦) 𝑑𝑥 𝑑𝑦

If the functions 𝑓(𝑥, 𝑦) are of higher order, the explicit integration becomes extremely cumbersome. Let
us consider an integral

𝐼 = ∬ 𝑥 𝑝 𝑦 𝑞 𝑑𝑥 𝑑𝑦

The limit of this integral must be calculated from the slope of each side of the triangle oriented from the
reference Cartesian coordinates. The final form of the integral consists of the sum of the integrals performed

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 28


BUET NAME 363 – CFD (FDM & FEM)

along all three sides of the triangle. With the origin of the Cartesian co-ordinates at the centroid the
following results are obtained:

Fig. 3.11 Triangle oriented from the reference Cartesian coordinates

𝑛=1 𝐼 = ∬ 𝑥 𝑑𝑥 𝑑𝑦 = ∬ 𝑦 𝑑𝑥 𝑑𝑦 = 0
𝐴 𝑝 𝑞 𝑝 𝑞 𝑝 𝑞
𝑛=2 𝐼= (𝑥 𝑦 + 𝑥2 𝑦2 + 𝑥3 𝑦3
12 1 1
𝐴 𝑝 𝑞 𝑝 𝑞 𝑝 𝑞
𝑛=3 𝐼 = 30 (𝑥1 𝑦1 + 𝑥2 𝑦2 + 𝑥3 𝑦3
𝐴 𝑝 𝑞 𝑝 𝑞 𝑝 𝑞
𝑛=4 𝐼 = 60 (𝑥1 𝑦1 + 𝑥2 𝑦2 + 𝑥3 𝑦3
2𝐴 𝑝 𝑞 𝑝 𝑞 𝑝 𝑞
𝑛=4 𝐼 = 105 (𝑥1 𝑦1 + 𝑥2 𝑦2 + 𝑥3 𝑦3

For one-dimensional element with two co-ordinates L1 and L2 takes the form

𝑚! 𝑛!
𝐼 = ∫ 𝐿𝑚 𝑛
1 𝐿2 𝑑𝐴 = 𝐿
(𝑚 + 𝑛 + 1)!
𝐴

The integration of the interpolation function over the two-dimensional triangular element with co-ordinate
L1, L2 and L3can be represented as

∫ 𝑓(𝑁) 𝑑𝐴 = ∫ 𝑓(𝐿𝑁 ) 𝑑𝐴
𝐴 𝐴

𝑝 𝑚! 𝑛! 𝑝!
𝐼 = ∫ 𝐿𝑚 𝑛
1 𝐿2 𝐿3 𝑑𝐴 = 2𝐴
(𝑚 + 𝑛 + 𝑝 + 2)!
𝐴

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 29


BUET NAME 363 – CFD (FDM & FEM)

4.3.4 Rectangular Element


The interpolation function for a four-node bilinear rectangular element in global co-ordinate system is given
by
𝑢 = 𝛼0 + 𝛼1 𝑥 + 𝛼2 𝑦 + 𝛼3 𝑥𝑦
and the nodal values of the element are
𝑢 = 𝑢1 𝑎𝑡 𝑥 = −𝑏, 𝑦 = −𝑎
𝑢 = 𝑢2 𝑎𝑡 𝑥 = 𝑏, 𝑦 = −𝑎
𝑢 = 𝑢3 𝑎𝑡 𝑥 = 𝑏, 𝑦= 𝑎
𝑢 = 𝑢4 𝑎𝑡 𝑥 = −𝑏, 𝑦= 𝑎

Fig. 3.12 Rectangular element

Applying these boundary conditions in to Eq. () we


𝑢1 + 𝑢2 + 𝑢3 + 𝑢4
𝛼0 =
4
𝑢1 − 𝑢2 − 𝑢3 + 𝑢4
𝛼1 =
4
𝑢1 + 𝑢2 − 𝑢3 − 𝑢4
𝛼2 =
4
𝑢1 − 𝑢2 + 𝑢3 − 𝑢4
𝛼3 =
4
Substituting the values of 𝛼0 , 𝛼1 , 𝛼2 𝑎𝑛𝑑 𝛼3 in Eq. () and then rearranging we get
𝑢 = 𝑁1 𝑢1 + 𝑁2 𝑢2 + 𝑁3 𝑢3 + 𝑁4 𝑢4
Where the shape function are given as
1
𝑁1 = (𝑏 − 𝑥)(𝑎 − 𝑦)
4𝑎𝑏
1
𝑁2 = (𝑏 + 𝑥)(𝑎 − 𝑦)
4𝑎𝑏
1
𝑁3 = (𝑏 + 𝑥)(𝑎 + 𝑦)
4𝑎𝑏
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 30
BUET NAME 363 – CFD (FDM & FEM)

1
𝑁4 = (𝑏 − 𝑥)(𝑎 − 𝑦)
4𝑎𝑏
𝑥 𝑦
The shape functions can also be expressed in terms of length ratio 𝜉 = and 𝜂 = , we obtain
𝑏 𝑎
1
𝑁1 = (1 − 𝜉)(1 − 𝜂) with −1 < 𝜉 ≤ 1 𝑎𝑛𝑑 − 1 < 𝜂 ≤ 1
4
1
𝑁2 = 4 (1 + 𝜉)(1 − 𝜂) with −1 < 𝜉 ≤ 1 𝑎𝑛𝑑 − 1 < 𝜂 ≤ 1
1
𝑁3 = 4 (1 + 𝜉)(1 + 𝜂) with −1 < 𝜉 ≤ 1 𝑎𝑛𝑑 − 1 < 𝜂 ≤ 1
1
𝑁4 = 4 (1 − 𝜉)(1 − 𝜂) with −1 < 𝜉 ≤ 1 𝑎𝑛𝑑 − 1 < 𝜂 ≤ 1

4.3.5 Quadrilateral Isoperimetric Element


In Isoperimetric elements the interpolation functions which are used to define the geometry of element are
also used to describe the variation of the dependent variable within the element. The isoperimetric co-
ordinates (𝜉, 𝜂) islocated at the centroid of the element and its nodal values (𝜉𝑖 , 𝜂𝑖 ) varies from 0 to ±1.
The relationship between Cartesian co-ordinate p(x, y) and isoperimetric co-ordinate 𝑠(𝜉, 𝜂)can be
expressed as
𝑥
𝑦} = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜂 + 𝛼3 𝜉𝜂

Fig. 3.13 Quadrilateral element

The variation of the variable u over the element may also be written as
𝑢 = 𝛼0 + 𝛼1 𝜉 + 𝛼2 𝜂 + 𝛼3 𝜉𝜂

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 31


BUET NAME 363 – CFD (FDM & FEM)

𝛼0
𝛼
= [1 𝜉 𝜂 𝜉𝜂] [𝛼1 ]
2
𝛼3
= [1 𝜉 𝜂 𝜉𝜂][𝛼]
Applying the boundary conditions in terms of nodal values we obtain
Node 1: 𝑢1 = 𝛼0 − 𝛼1 − 𝛼2 + 𝛼3
Node 2: 𝑢2 = 𝛼0 + 𝛼1 − 𝛼2 − 𝛼3
Node 3: 𝑢3 = 𝛼0 + 𝛼1 + 𝛼2 + 𝛼3
Node 4: 𝑢4 = 𝛼0 − 𝛼1 + 𝛼2 − 𝛼3
The above equations can be written into a matrix form as
𝑢1 1−1 −1 1 𝛼0
𝑢2 𝛼
[𝑢 ] = [1 1 −1 −1 ] [𝛼1 ]
3 1 1 1 1 2
𝑢4 1 −1 1 −1 𝛼3
[𝑢] = [𝐷][𝛼]
[𝑎] = [𝐷]−1 [𝑢]
1 1 1 1
1
[𝐷]−1 = [−1 1 1 −1 ]
4 −1 −1 1 1
1 −1 1 −1
𝑢 = [1 𝜉 𝜂 𝜉𝜂][𝐷]−1 [𝑢]
1 1 1 1 𝑢1
1 −1 1 1 −1 𝑢2
= [1 𝜉 𝜂 𝜉𝜂] [ ][ ]
4 −1 −1 1 1 𝑢3
1 −1 1 −1 𝑢4
1
= [(1 − 𝜉 − 𝜂 + 𝜉𝜂)𝑢1 + (1 + 𝜉 − 𝜂 − 𝜉𝜂)𝑢2 +(1 + 𝜉 + 𝜂 + 𝜉𝜂)𝑢3 + (1 − 𝜉 + 𝜂 − 𝜉𝜂)𝑢4 ]
4
1
= [(1 − 𝜉)(1 − 𝜂)𝑢1 + (1 + 𝜉)(1 − 𝜂)𝑢2 +(1 + 𝜉)(1 + 𝜂)𝑢3 + (1 − 𝜉)(1 + 𝜂)𝑢4 ]
4
= 𝑁1 𝑢1 + 𝑁2 𝑢2 + 𝑁3 𝑢3 + 𝑁4 𝑢4
Now the shape functions for quadrilateral element are
1 1
𝑁1 = 4 (1 − 𝜉)(1 − 𝜂) 𝑁2 = 4 (1 + 𝜉)(1 − 𝜂)
1 1
𝑁3 = 4 (1 + 𝜉)(1 + 𝜂) 𝑁4 = 4 (1 − 𝜉)(1 + 𝜂)

In general, the shape functions can be written as


1
𝑁𝑖 = (1 + 𝜉𝑖 𝜉)(1 + 𝜂𝑖 𝜂); 𝑖 = 1, 2, 3,4
4
Writing Eq. (1) in terms of nodal values we shall get similar expression of Eq. ()

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 32


BUET NAME 363 – CFD (FDM & FEM)

𝑥 = 𝑁1 𝑥1 + 𝑁2 𝑥2 + 𝑁3 𝑥3 + 𝑁4 𝑥4 = ∑ 𝑁𝑖 𝑥𝑖
𝑖=1
4

𝑦 = 𝑁1 𝑦1 + 𝑁2 𝑦2 + 𝑁3 𝑦3 + 𝑁4 𝑦4 = ∑ 𝑁𝑖 𝑦𝑖
𝑖=1

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 33


BUET NAME 363 – CFD (FDM & FEM)

Chapter 5
Finite Element Method
5.1 Introduction
In finite element method, the fluid domain under consideration in divided into finite number of sub-domain
known as elements. A simple function assumed for the variation of each dependent variable inside each
element. The summation of variation of the dependent variable in each element used to describe the whole
flow field. If u is assumed to vary linearly inside an element, we can define a second derivative for it. Since
most fluid problems include second derivative, the following techniques is designed to over this problem.
The partial differential equation is multiplied by an unknown function and then the whole equation can be
integrated over the domain which it applies. Finally, the terms that need to have the order of their derivatives
reduced are integrated by parts. This is known as producing a variation formulation.

The governing equations are multiplied by a weight function before they are integrated over the entire
domain. The solution is approximated by a linear shape function within each in a way that guarantees
continuity of the solution across element boundaries. Such a function can be constructed from its values the
corners of the element.

This approximation is then substituted into the weighted integral of the conservations law and the equations
to be solved are derived by requiring the derivative of the integral with respect to each nodal value to be
zero. This corresponds to selecting the best solution with the set of the allowed functions.

Calculus of variations, branch of mathematics concerned with the problem of finding a function for which
the value of a certain integral is either the largest or the smallest possible. Many problems of this kind are
easy to state, but their solutions commonly involve difficult procedures of the
differential calculus and differential equations.

The calculus of variations is a field of mathematical analysis that uses variations, which are small changes
in functions and functionals, to find maxima and minima of functionals: mappings from a set
of functions to the real numbers. Functionals are often expressed as definite integrals involving functions
and their derivatives. Functions that maximize or minimize functionals may be found using the Euler–
Lagrange equation of the calculus of variations.

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 34


BUET NAME 363 – CFD (FDM & FEM)

Fig. 4.1

5.2 Variational operator


Let us consider a function 𝐹(𝑥, 𝑢, 𝑢′ ) and the variation of u for a constant value of  is denoted by 𝛿𝑢 = 𝜖 𝜂
of which  is a function of 𝜂(𝑥). Now the change in value of the function 𝐹(𝑥, 𝑢, 𝑢′ ) at a fixed-point x is
Δ𝐹 = 𝐹(𝑥, 𝑢 + 𝜖 𝜂, 𝑢′ + 𝜖 𝜂 ′ ) − 𝐹(𝑥, 𝑢, 𝑢′ ) (4.1)
′)
Using Taylor’s series expansion, the function 𝐹(𝑥, 𝑢, 𝑢 can be expanded as
𝜕𝐹 𝜕𝐹 1 𝜕2𝐹 𝜕2𝐹
Δ𝐹 = 𝐹(𝑥, 𝑢, 𝑢′ ) + ( 𝜀 𝜂 + ′ 𝜀 𝜂 ′ ) + (𝜀𝜂)2 2 + (𝜀𝜂 𝜀𝜂 ′ )
𝜕𝑢 𝜕𝑢 2 𝜕𝑢 𝜕𝑢 𝜕𝑢𝑦 ′
1 𝜕2𝐹
+ (𝜀𝜂 ′ )2 ′ 2 + ⋯ ⋯ − 𝐹(𝑥, 𝑢, 𝑢′ )
2 𝜕𝑢
𝜕𝐹 𝜕𝐹 1 𝜕2𝐹 𝜕2𝐹 1 𝜕2𝐹
= 𝜀 𝜂 + ′ 𝜀 𝜂 ′ + (𝜀𝜂)2 2 + (𝜀𝜂 𝜀𝜂 ′ ) + (𝜀𝜂 ′ )2
+⋯
𝜕𝑢 𝜕𝑢 2 𝜕𝑢 𝜕𝑢 𝜕𝑢′ 2 𝜕𝑢′ 2
𝜕𝐹 𝜕𝐹
= 𝜀 𝜂+ 𝜀 𝜂 ′ + 𝜖 𝑅1 (𝜀) in which lim 𝑅1 (𝜀) = 0
𝜕𝑢 𝜕𝑢′ 𝜖→0

The first variation of F is defined by


𝐹(𝑥, 𝑢 + 𝜖 𝜂, 𝑢′ + 𝜖 𝜂 ′ ) − 𝐹(𝑥, 𝑢, 𝑢′ ) Δ𝐹
𝛿𝐹 = 𝜖 [lim ] = 𝜖 lim
𝜖→0 𝜀 𝜖→0 𝜀
𝜕𝐹 𝜕𝐹 𝜕𝐹 𝜕𝐹
𝛿𝐹 = 𝜖 ( 𝜂 + ′ 𝜂′ ) = 𝜖𝜂 + ′ 𝜖𝜂 ′
𝜕𝑢 𝜕𝑢 𝜕𝑢 𝜕𝑢
𝜕𝐹 𝜕𝐹
𝛿𝐹 = 𝜕𝑢 𝛿𝑢 + 𝜕𝑢′ 𝛿𝑢′ (4.2)

The total differential of 𝐹(𝑥, 𝑢, 𝑢′ ) isobtained as


𝜕𝐹 𝜕𝐹 𝜕𝐹
𝑑𝐹 = 𝜕𝑥 𝑑𝑥 + 𝜕𝑢 𝑑𝑢 + 𝜕𝑢′ 𝑑𝑢′ (4.3)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 35


BUET NAME 363 – CFD (FDM & FEM)

Since x is fixed varied during the variation from u to 𝑢 + 𝛿𝑢, 𝑑𝑥 = 0. Now from Eq. (4.3)
𝜕𝐹 𝜕𝐹
𝑑𝐹 = 𝑑𝑢 + ′ 𝑑𝑢′
𝜕𝑢 𝜕𝑢
= 𝛿𝐹
The operator  acts as differential operation with respect to dependent variables and the laws of variation
of sums, products, ratios and powers are completely analogous to the corresponding laws of differentiation
as follows:
(a) 𝛿(𝐹1 ± 𝐹2 ) = 𝛿𝐹1 ± 𝛿𝐹2
(b) 𝛿(𝐹1 ∙ 𝐹2 ) = 𝐹2 𝛿𝐹1 + 𝐹1 𝛿𝐹2
𝐹 𝐹2 𝛿𝐹1 −𝐹1 𝛿𝐹2
(c) 𝛿 ( 1 ) =
𝐹2 𝐹22

(d) 𝛿(𝐹1𝑛 ) = 𝑛(𝐹1 )𝑛−1 𝛿𝐹1

𝑑 𝑑𝑢
(e) (𝛿𝑢) = 𝛿( )
𝑑𝑥 𝑑𝑥

Proof
𝑑 𝑑 𝑑𝜂
(𝛿𝑢) = (𝜖𝜂) = 𝜖
𝑑𝑥 𝑑𝑥 𝑑𝑥
𝑑𝑢 𝑑 𝑑𝑢 𝑑𝜂
𝛿( ) = (𝑢 + 𝜖𝜂) − =𝜖
𝑑𝑥 𝑑𝑥 𝑑𝑥 𝑑𝑥
𝑑 𝑑𝑢
(𝛿𝑢) = 𝛿 ( )
𝑑𝑥 𝑑𝑥

𝑏 𝑏
(f) 𝛿 ∫𝑎 𝑢(𝑥)𝑑𝑥 = ∫𝑎 𝛿𝑢𝑑𝑥
Proof
𝑏 𝑏 𝑏 𝑏 𝑏 𝑏
𝛿 ∫𝑎 𝑢(𝑥)𝑑𝑥 = ∫𝑎 (𝑢 + 𝜖𝜂) 𝑑𝑥 − ∫𝑎 𝑢 𝑑𝑥 = ∫𝑎 𝑢𝑑𝑥 + ∫𝑎 𝜖𝜂𝑑𝑥 − ∫𝑎 𝑢 𝑑𝑥
𝑏

= ∫ 𝜖𝜂𝑑𝑥
𝑎
𝑏 𝑏

∫ 𝛿𝑢𝑑𝑥 = ∫ 𝜖𝜂𝑑𝑥
𝑎 𝑎
𝑏 𝑏

𝛿 ∫ 𝑢(𝑥)𝑑𝑥 = ∫ 𝛿𝑢𝑑𝑥
𝑎 𝑎

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 36


BUET NAME 363 – CFD (FDM & FEM)

𝑏 𝑏 𝑏
(g) 𝛿 ∫𝑎 𝑥 𝑢(𝑥)𝑑𝑥 = ∫𝑎 𝑥 (𝑢 + 𝜖𝜂)𝑑𝑥 − ∫𝑎 𝑥𝑢𝑑𝑥
𝑏 𝑏 𝑏 𝑏
= ∫𝑎 𝑥 𝑢 𝑑𝑥 + ∫𝑎 𝑥 𝜖𝜂𝑑𝑥 − ∫𝑎 𝑥 𝑢 𝑑𝑥 = ∫𝑎 𝑥 𝜖𝜂𝑑𝑥
𝑏 𝑏

𝛿 ∫ 𝑥 𝑢 (𝑥)𝑑𝑥 = ∫ 𝑥 𝛿𝑢𝑑𝑥
𝑎 𝑎

(h) 𝑔𝑟𝑎𝑑(𝛿𝐹) = 𝛿(𝑔𝑟𝑎𝑑𝐹)


𝜕 𝜕
∇(𝛿𝐹) = 𝑖 (𝛿𝐹) + 𝑗 (𝛿𝐹)
𝜕𝑥 𝜕𝑦
𝜕𝐹 𝜕𝐹
=𝑖𝛿( )+𝑗𝛿( )
𝜕𝑥 𝜕𝑦
𝜕𝐹 𝜕𝐹
= 𝛿 [𝑖 (𝜕𝑥 ) + 𝑗 (𝜕𝑦)]

= 𝛿(∇𝐹)

1
(i) 𝑔𝑟𝑎𝑑(𝛿𝐹) ∙ 𝑔𝑟𝑎𝑑𝐹 = 2 𝛿|𝑔𝑟𝑎𝑑𝐹|2
𝜕 𝜕 𝜕𝐹 𝜕𝐹
∇(𝛿𝐹) ∙ ∇𝐹 = [𝑖 𝜕𝑥 𝛿𝐹 + 𝑗 𝜕𝑦 𝛿𝐹] ∙ [𝑖 𝜕𝑥 + 𝑗 𝜕𝑦]
𝜕𝐹 𝜕𝐹 𝜕𝐹 𝜕𝐹
= [𝑖𝛿 (𝜕𝑥 ) + 𝑗𝛿 (𝜕𝑦)] ∙ [𝑖 𝜕𝑥 + 𝑗 𝜕𝑦]
𝜕𝐹 𝜕𝐹 𝜕𝐹 𝜕𝐹
=𝛿( ) +𝛿( )
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦

𝜕𝐹 𝜕𝐹
Applying the formula 𝛿𝐹 = 𝛿𝑢 + 𝛿𝑢′
𝜕𝑢 𝜕𝑢′
𝜕 𝜕𝐹 𝜕 𝜕𝐹 𝜕𝐹 𝜕 𝜕𝐹 𝜕 𝜕𝐹 𝜕𝐹
∇(𝛿𝐹) ∙ ∇𝐹 = [𝜕𝑥 (𝜕𝑥 ) 𝛿𝑥 + 𝜕𝑦 (𝜕𝑥 ) 𝛿𝑦] 𝜕𝑥 + [𝜕𝑥 (𝜕𝑦) 𝛿𝑥 + 𝜕𝑦 (𝜕𝑦) 𝛿𝑦] 𝜕𝑦
𝜕𝐹 𝜕 𝜕𝐹 𝜕𝐹 𝜕 𝜕𝐹 𝜕𝐹 𝜕 𝜕𝐹 𝜕𝐹 𝜕 𝜕𝐹
= [𝜕𝑥 𝜕𝑥 (𝜕𝑥 ) + 𝜕𝑦 𝜕𝑥 (𝜕𝑦)] 𝛿𝑥 + [𝜕𝑥 𝜕𝑦 (𝜕𝑥 ) + 𝜕𝑦 𝜕𝑦 (𝜕𝑦)] 𝛿𝑦

1 𝜕 𝜕𝐹 2 𝜕𝐹 2 1 𝜕 𝜕𝐹 2 𝜕𝐹 2
= [( ) + ( ) ] 𝛿𝑥 + [( ) + (𝜕𝑦) ] 𝛿𝑦
2 𝜕𝑥 𝜕𝑥 𝜕𝑦 2 𝜕𝑦 𝜕𝑥
𝜕𝐹 𝜕𝐹
Applying the formula 𝛿𝐹 = 𝜕𝑢 𝛿𝑢 + 𝜕𝑢′ 𝛿𝑢′
1 𝜕𝐹 2 𝜕𝐹 2
= 2
𝛿 [( 𝜕𝑥
) + (𝜕𝑦) ]
1
= 𝛿|∇ 𝐹|2
2

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 37


BUET NAME 363 – CFD (FDM & FEM)

5.3 Functional
The definite integral of the form
𝑏 𝑑𝑢
𝐼(𝑢) = ∫𝑎 𝐹(𝑥, 𝑢, 𝑢́ ) 𝑑𝑥, 𝑢 = 𝑢(𝑥), 𝑢́ = 𝑑𝑥
𝑑𝑢
is called a functional in which the integrand 𝐹(𝑥, 𝑢, 𝑢́ ) is a function of the argument x, u and 𝑑𝑥
.

Mathematically, a functional is an operator mapping u into a scalar 𝐼(𝑢)and the functions 𝑢 = 𝑢(𝑥) maps
u with respect to x. The integrand 𝐹(𝑥, 𝑢, 𝑢́ ) is a function of functions of u(x).

(a) A functional 𝐼(𝑢) is said to be linear in u if and only if it satisfies the following relation.

𝑙(𝛼𝑢 + 𝛽𝑣) = 𝛼 𝑙(𝑢) + 𝛽 𝑙(𝑣)

for any scalars  and  and dependent variables u and v. An example for a linear functional is
𝐿
dv
𝐼(𝑣) = ∫ 𝑣 𝑓 𝑑𝑥 + 𝐿 𝑀0
0 dx

where f = f(x) and M0 are known quantities.

(b) A functional 𝐵(𝑢, 𝑣) is said to be bilinear if it is linear in each of its arguments u and v.

𝐵(𝛼𝑢1 + 𝛽𝑢2 , 𝑣) = 𝛼 𝐵(𝛼𝑢1 , 𝑣) + 𝛽 𝐵(𝑢2 , 𝑣) Linearity in the first argument

𝐵(𝑢, 𝛼𝑣1 + 𝛽𝑣2 , ) = 𝛼 𝐵(𝑢, 𝑣1 ) + 𝛽 𝐵(𝑢, 𝑣2 ) Linearity in the second argument

𝑤ℎ𝑒𝑟𝑒 𝑢, 𝑢1 , 𝑢2 , 𝑣, 𝑣1 𝑎𝑛𝑑 𝑣2 are dependent variables.

(c) A bilinear functional is said to be symmetric its u and v if 𝐵(𝑢, 𝑣) = 𝐵(𝑣, 𝑢). An example of a
symmetric functional is as follows:
𝑏 du dv
𝐼(𝑢, 𝑣) = ∫𝑎 𝐸𝐴 dx dx
𝑑𝑥

Example 5.1 Determine the functional of the following boundary value problem
d2 u
dx2
= 𝑓(𝑥) with 𝑢(𝑎) = 𝑢(𝑏) = 0

Solution:
𝑏 𝑏 𝑏 𝑏
𝛿 ∫ 𝑓(𝑥) 𝑢 𝑑𝑥 = ∫ 𝑓(𝑥) 𝛿𝑢 𝑑𝑥 𝑆𝑖𝑛𝑐𝑒 𝛿 ∫ 𝑥 𝑢(𝑥) 𝑑𝑥 = ∫ 𝑥 𝛿𝑢 𝑑𝑥
𝑎 𝑎 𝑎 𝑎
𝑏
= ∫ 𝑓(𝑥) 𝛿𝑢 𝑑𝑥
𝑎

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 38


BUET NAME 363 – CFD (FDM & FEM)

𝑏
d2 u
=∫ 𝛿𝑢 𝑑𝑥
𝑎 dx 2
du 𝑏 𝑏 du d
= [𝛿𝑢 dx ] − ∫𝑎 (𝛿𝑢) 𝑑𝑥
𝑎 dx dx
𝑏 du du
= − ∫𝑎 dx 𝛿 (dx ) 𝑑𝑥

1 𝑏 du 2
= − ∫ 𝛿 ( ) 𝑑𝑥
2 𝑎 dx
𝑏
1 du 2
= −𝛿 ∫ ( ) 𝑑𝑥
𝑎 2 dx
𝑏
1 du 2
𝛿 ∫ [𝑓(𝑥) 𝑢 + ( ) ] 𝑑𝑥 = 0
𝑎 2 dx
Now the functional defined by the minimum value of the integral can be obtained as
b
1 du 2
𝐼(𝑢) = ∫ [ ( ) + u(x)𝑓(𝑥)] 𝑑𝑥
2 dx
a

Example 5.2 Determine the functional of the following boundary value problem
∇2 u = −𝑓(𝑥, 𝑦) with u = 0 on the boundary C of the region S.
Solution:
Method 1:

𝛿 ∬ 𝑓 𝑢 𝑑𝑥 𝑑𝑦 = ∬ 𝑓 𝛿𝑢 𝑑𝑥 𝑑𝑦
𝑆 𝑆

Substituting the values of f in right hand side of above equation we obtain

𝛿 ∬ 𝑓𝑢 𝑑𝑥 𝑑𝑦 = − ∬ ∇2 u 𝛿𝑢 𝑑𝑥 𝑑𝑦
𝑆 𝑆

Vector identity: 𝛁 ∙ (𝑭 𝛁𝑮) = 𝛁𝑭 ∙ 𝛁𝑮 + 𝑭 𝛁 𝟐 𝐆


Replacing F by u and G by u, we get ∇ ∙ (𝛿𝑢∇u) = ∇𝛿𝑢 ∙ ∇u + 𝛿𝑢∇2 u and hence

𝛿 ∬ 𝑓𝑢 𝑑𝑥 𝑑𝑦 = ∬ ∇𝛿𝑢 ∙ ∇u 𝑑𝑥 𝑑𝑦 − ∬ ∇ ∙ (𝛿𝑢∇u) 𝑑𝑥 𝑑𝑦
𝑆 𝑆 𝑆
1
Applying Gauss divergence theorem and ∇(𝛿𝐹) ∙ ∇ 𝐹 = = 2
𝛿|∇ 𝐹|2 we have

1
𝛿 ∬ 𝑓 𝑢 𝑑𝑥 𝑑𝑦 = ∬ δ|∇u|2 dx dy − ∫ 𝛿𝑢(∇u ∙ n) dS
2 𝐶
𝑆 𝑆

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 39


BUET NAME 363 – CFD (FDM & FEM)

1
𝛿 ∬𝑆 𝑓 𝑢 𝑑𝑥 𝑑𝑦 = δ ∬𝑆 |∇u|2 dx dy
2

1 ∂u 2 ∂u 2
δ ∬ [ {( ) + ( ) } − 𝑓𝑢] dx dy = 0
2 ∂x ∂y
𝑆

So, the required functional is

1 ∂u 2 ∂u 2
𝐼(𝑢) = ∬ [ {( ) + ( ) } − 𝑓𝑢] dx dy
2 ∂x ∂y
𝑆

Method 2:
Let us consider a function v(x, y) that satisfies the boundary condition 𝑣 = 0 𝑜𝑛 𝐶.
∇2 u = −𝑓(𝑥, 𝑦)
Multiplying both sides by v(𝑥, 𝑦) and then integrating we obtain

∬ 𝑣 ∇2 u dx dy = − ∬ 𝑣 𝑓𝑑𝑥 𝑑𝑦
S S

Using the vector identity ∇ ∙ (𝐹 ∇𝐺) = ∇𝐹 ∙ ∇𝐺 + 𝐹 ∇2 G and letting 𝐹 = 𝑣 and 𝐺 = 𝑢, we get

∬ ∇v ∙ ∇u 𝑑𝑥 𝑑𝑦 − ∬ ∇ ∙ (𝑣∇u) 𝑑𝑥 𝑑𝑦 = ∬ 𝑣 𝑓𝑑𝑥 𝑑𝑦
S S S

Applying Gauss-divergence theorem in the second integral of above equation we get

∂v ∂u ∂v ∂u
∬( + ) dx dy − ∫ 𝑣(∇u ∙ n)𝑑𝑠 = ∬ 𝑣 𝑓𝑑𝑥 𝑑𝑦
∂x ∂x ∂y ∂y C
S S

Where n is the unit normal vector on the arc and the terms inside the first bracket of Eq. () are bilinear and
setting 𝑣 = 𝑢 in the bilinear terms and then multiplying by ½ we get the functional as

1 ∂u 2 ∂u 2
I(u) = ∬ [ {( ) + ( ) } − u 𝑓] dx dy
2 ∂x ∂y
S

Boundary value problems with associated functionals


No.
(a) d2 u
dx2
= 𝑓(𝑥)with 𝑢(𝑎) = 𝑢(𝑏) = 0
b
1 du 2
𝐼(𝑢) = ∫ [ ( ) + u(x)𝑓(𝑥)] 𝑑𝑥
2 dx
a

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 40


BUET NAME 363 – CFD (FDM & FEM)

𝐼(𝑢) = ∫ 𝑢(2𝑓 − 𝑢′′ )𝑑𝑥


a

(b) d2 u 𝑑𝑢
dx2
+ 𝑘𝑢 = 𝑓(𝑥) with 𝑢(0) = 0, |
𝑑𝑥 𝑥=1
=1
b
1 du 2
𝐼(𝑢) = ∫ [( ) − k u2 + 2 u x 2 ] 𝑑𝑥 − 𝑢(1)
2 dx
a
2
(c) ∇ u = 0 with u = 0 on the boundary C of R

1 ∂u 2 ∂u 2
I(u) = ∬ [ {( ) + ( ) }] dx dy
2 ∂x ∂y
S
2
(d) ∇ u = −𝑓(𝑥, 𝑦) with u = 0 on the boundary C of R

1 ∂u 2 ∂u 2
I(u) = ∬ [ {( ) + ( ) } − u 𝑓] dx dy
2 ∂x ∂y
S
4
(e) 𝑑 𝑢 𝑑2 𝑢
𝐸𝐼 + 𝑘𝑢 = 𝑓(𝑥) 𝑤𝑖𝑡ℎ 𝑢 = = 0 𝑎𝑡 𝑥 = 0, 1
𝑑𝑥 4 𝑑𝑥 2
2
1 𝑑2𝑢
I(u) = ∬ [( 2 ) + 𝑘𝑢2 − 2𝑢𝑓] dx
2 𝑑𝑥
S

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 41


BUET NAME 363 – CFD (FDM & FEM)

5.4 Euler-Lagrange Equation


Consider a functional I such that
𝑏
𝑑𝑢
𝐼 = ∫ 𝐹 (𝑥, 𝑢, ) 𝑑𝑥
𝑑𝑥
𝑎

The relation between u and x is not known and the problem consists of finding the relation so that I become
either a maximum or a minimum. The necessary condition for extremum of the function is
𝑑𝐼
| =0
𝑑𝜀 𝜀=0

Let 𝑢 = 𝜂(𝑥) be any function with continuous second derivative which vanishes at the end points of the
interval (𝑥0 , 𝑥1 ) and 𝑢 = 𝑢0 (𝑥) + 𝜀 𝜂(𝑥) represents a family of curves passing through(𝑥0 , 𝑢0 )and
(𝑥1 , 𝑢1 ). Now from Eq. () one obtains
𝑏

𝐼 = ∫ 𝐹(𝑥, 𝑢0 + 𝜀 𝜂, 𝑢0′ + 𝜀 𝜂 ′ ) 𝑑𝑥
𝑎

The Taylor’s series expansion for a multivariable function 𝐹(𝑥, 𝑢0 + 𝜀 𝜂, 𝑢0′ + 𝜀 𝜂 ′ )about a point
(𝑥0 , 𝑢0 , 𝑢0′ ) can be expressed as
𝜕𝐹 𝜕𝐹 1 𝜕2 𝐹 𝜕2 𝐹 1 𝜕2 𝐹
𝐹(𝑥, 𝑢, 𝑢′ ) = 𝐹(𝑥, 𝑢0 , 𝑢0′ ) + [ 𝜀 𝜂+ 𝜀 𝜂 ′ ] + (𝜀𝜂)2 +(𝜀𝜂 𝜀𝜂 ′ ) + (𝜀𝜂 ′ )2 2 + ⋯⋯
𝜕𝑢0 𝜕𝑢0′ 2 𝜕𝑢02 𝜕𝑢0 𝜕𝑢0′ 2 𝜕𝑢0′

Integrating Eq. () between a and b and taking the derivative with respect to , we obtain
𝑏
𝑑𝐼 𝜕𝐹 𝜕𝐹 𝜕2𝐹 𝜕2𝐹 𝜕2𝐹
= ∫ [0 + ( 𝜂 + ′ 𝜂 ′ ) + (𝜀𝜂 2 + 2𝜀 𝜂𝜂 ′ + 𝜀𝜂 ′
2 ) + ⋯ ⋯ ] 𝑑𝑥
𝑑𝜀 𝑎 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0′ 𝜕𝑢0′

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 42


BUET NAME 363 – CFD (FDM & FEM)

Applying the condition for extremum, we get


𝑏
𝜕𝐹 𝜕𝐹 𝜕2𝐹 𝜕2𝐹 𝜕2𝐹
∫ [( 𝜂 + ′ 𝜂 ′ ) + {𝜀𝜂 2 + 2𝜀 𝜂𝜂 ′ + 𝜀𝜂 ′
2 } + ⋯ ⋯ ] 𝑑𝑥 = 0
𝑎 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0 𝜕𝑢0′ 𝜕𝑢0′
The terms within the first bracket is called the first variation of I and is written as
𝑏
𝜕𝐹 𝜕𝐹
𝛿𝐼 = ∫ ( 𝜂 + ′ 𝜂 ′ ) 𝑑𝑥 = 0
𝑎 𝜕𝑢0 𝜕𝑢0
And the second variation of I is
𝑏
𝜕2𝐹 𝜕2𝐹 𝜕2𝐹
𝛿 2 𝐼 = ∫ (𝜀𝜂 + 2𝜀 𝜂𝜂 ′
+ 𝜀𝜂 ′
2 ) 𝑑𝑥 = 0
𝑎 𝜕𝑢02 𝜕𝑢0 𝜕𝑢0′ 𝜕𝑢0′
As 𝜀 = 0, 𝑢0 + 𝜀 𝜂 = 𝑢 and Eq. () can finally be written as
𝑏
𝜕𝐹 𝜕𝐹
∫ ( 𝜂 + ′ 𝜂 ′ ) 𝑑𝑥 = 0
𝑎 𝜕𝑢 𝜕𝑢
𝑏
𝑏
𝜕𝐹 𝜕𝐹 𝑑 𝜕𝐹
∫ 𝜂 𝑑𝑥 + ′ 𝜂|𝑏𝑎 − ∫ ( ′ ) 𝜂 𝑑𝑥 = 0
𝑎 𝜕𝑢 𝜕𝑢 𝑑𝑥 𝜕𝑢
𝑎
𝑏
𝜕𝐹 𝑑 𝜕𝐹 𝜕𝐹 𝜕𝐹
∫ [ − ( ′ )] 𝜂 𝑑𝑥 + ′ 𝜂(𝑏) − ′ 𝜂(𝑎) = 0
𝑎 𝜕𝑢 𝑑𝑥 𝜕𝑢 𝜕𝑢 𝜕𝑢
As the value of  is zero on the boundary x = a and x = b, we obtain
𝑏
𝜕𝐹 𝑑 𝜕𝐹
∫ [ − ( )] 𝜂 𝑑𝑥 = 0
𝑎 𝜕𝑢 𝑑𝑥 𝜕𝑢′
𝜕𝐹 𝑑 𝜕𝐹
− ( )
𝜕𝑢 𝑑𝑥 𝜕𝑢′

Similar operations when performed on the integral


𝑏

𝐼 = ∫ 𝐹(𝑥, 𝑢, 𝑢′ , 𝑢′′ ⋯ ⋯ 𝑢𝑛 )𝑑𝑥


𝑎

yield the Euler-Lagrange of the form


𝜕𝐹 𝑑 𝜕𝐹 𝑑2 𝜕𝐹 𝜕𝐹
− ( ′ ) + 2 ( ′′ ) − ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ + (−1)𝑛 𝑛 = 0
𝜕𝑢 𝑑𝑥 𝜕𝑢 𝑑𝑥 𝜕𝑢 𝜕𝑢
The equation can also be generalized to the problems of minimizing double integral over the region R as

𝜕𝑢 𝜕𝑢
𝐼(𝑢) = ∫ 𝐹 (𝑥, 𝑦, 𝑢, , ) 𝑑𝑥𝑑𝑦
𝜕𝑥 𝜕𝑦
𝑅

The Euler-Lagrange equation corresponding to Eq. () may be derived as

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 43


BUET NAME 363 – CFD (FDM & FEM)

𝜕𝐹 𝜕 𝜕𝐹 𝜕 𝜕𝐹
− [ 𝜕𝑢 ] − [ 𝜕𝑢 ] = 0
𝜕𝑢 𝜕𝑥 𝜕 ( ) 𝜕𝑦 𝜕 ( )
𝜕𝑥 𝜕𝑥

Example 5.3 Find out the Euler Lagrange equation that extremizes the following functional
1 𝑏
du 2 𝑑𝑢
𝐼(𝑢) = ∫ [( ) + u2 + 2 u x] 𝑑𝑥 = ∫ 𝐹 (𝑥, 𝑢, ) 𝑑𝑥
dx 𝑑𝑥
0 𝑎

𝑑𝑢 du 2
Now 𝐹 (𝑥, 𝑢, 𝑑𝑥 ) = (dx ) + u2 + 2 u x

𝐹(𝑥, 𝑢, 𝑢′) = (𝑢′)2 + u2 + 2 u x


𝜕𝐹
= 2𝑢 + 2𝑥
𝜕𝑢
𝜕𝐹
= 2𝑢′
𝜕𝑢′
The extremization of the functional 𝐼(𝑢) requires to satisfy the condition below:
𝜕𝐹 𝑑 𝜕𝐹
− ( )=0
𝜕𝑢 𝑑𝑥 𝜕𝑢′
𝑑 du
2𝑢 + 2𝑥 − (2 ) = 0
𝑑𝑥 dx
𝑑 du
( )=𝑢+𝑥
𝑑𝑥 dx

5.5 Rayleigh-Ritz method:


The Rayleigh-Ritz method begins with finding a functional based on the branch of mathematics of calculus
of variations. A minimization of such a functional provides the solution of the differential equations.
Actually, the calculus of variations determines the particular function u(x) which extremizes the functional.
𝜕2 𝑢 𝜕2 𝑢
Consider the poisons equation ( + ) = −𝑓(𝑥, 𝑦) with u = 0 on the boundary condition of the square
𝜕𝑥 2 𝜕𝑦 2

(0 < 𝑥 ≤ 1, 0 < 𝑦 ≤ 1). The functional of the Poisons equation is given by

𝜕𝑢 2 𝜕𝑢 2
𝐼(𝑢) = ∬ {( ) + ( ) − 2𝑢𝑓} 𝑑𝑥𝑑𝑦
𝜕𝑥 𝜕𝑦

Let the exact solution 𝑢 be approximated by


𝑢 ≈ ∑𝑛𝑖=0 𝛼𝑖 𝜙𝑖 .
Now from the equation of the functional we have

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 44


BUET NAME 363 – CFD (FDM & FEM)

2 2
𝜕𝜙𝑖 𝜕𝜙𝑖
𝐼(𝑢) = ∬ {(∑ 𝛼𝑖 ) + (∑ 𝛼𝑖 ) − 2 ∑ 𝛼𝑖 𝜙𝑖 𝑓} 𝑑𝑥𝑑𝑦
𝜕𝑥 𝜕𝑦

𝜕𝜙 2 𝜕𝜙 2 𝜕𝜙 𝜕𝜙𝑗 𝜕𝜙𝑖 𝜕𝜙𝑗


= ∬ ∑ 𝛼𝑖2 {( 𝜕𝑥𝑖) + ( 𝜕𝑦𝑖) } 𝑑𝑥𝑑𝑦 + 2 ∬ ∑𝑗≠𝑖 𝛼𝑖 𝛼𝑗 ( 𝜕𝑥𝑖 𝜕𝑥
+ 𝜕𝑦 𝜕𝑦
) 𝑑𝑥 𝑑𝑦

−2 ∬ ∑ 𝛼𝑖 𝜙𝑖 𝑓 𝑑𝑥 𝑑𝑦

𝜕𝐼
= 2𝐴𝑖𝑖 𝛼𝑖 + 2 ∑ 𝐴𝑖𝑗 𝛼𝑗 − 2 ℎ𝑖
𝜕𝛼𝑖
𝑗≠𝑖

Where

𝜕𝜙𝑖 𝜕𝜙𝑗 𝜕𝜙𝑖 𝜕𝜙𝑗


𝐴𝑖𝑗 = ∬ ( + ) 𝑑𝑥 𝑑𝑦
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦

And

ℎ𝑖 = ∬ 𝜙𝑖 𝑓 𝑑𝑥 𝑑𝑦

Now the variation parameters are to be chosen such that 𝐼(𝛼𝑖 ) is a minimum. Thus
𝜕𝐼
=0
𝜕𝛼𝑖

2𝐴𝑖𝑖 𝛼𝑖 + 2 ∑ 𝐴𝑖𝑗 𝛼𝑗 − 2 ℎ𝑖 = 0
𝑗≠𝑖
𝑛

∑ 𝐴𝑖𝑗 𝛼𝑗 = ℎ𝑖
𝑗=0

The above equation is a system of linear algebraic equations for the unknown parameters 𝛼𝑗 which has a
unique solution.

Example 5.4 Solve the following problem by Rayleigh-Ritz method


𝑑2 𝑢
+𝑢+𝑥 =0
𝑑𝑥
subject to 𝑢(𝑥) = 0 𝑎𝑡 𝑥 = 0, 1
Solution:
The functional I(u) is given by

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 45


BUET NAME 363 – CFD (FDM & FEM)

1
1 du 2
𝐼(𝑢) = ∫ [− ( ) + u2 + 2 u x] 𝑑𝑥
2 dx
0

Let the solution be approximated by


𝑢(𝑥) ≈ 𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥)
where 𝛼1 and 𝛼2 are the constants and the approximate solution 𝑢(𝑥) satisfies the boundary conditions.
Now from above equation
𝑑𝑢 2
( ) ≈ [𝛼1 (1 − 2𝑥) + 𝛼2 (2𝑥 − 3𝑥 2 )]2
𝑑𝑥
≈ 𝛼12 (1 − 4𝑥 + 4𝑥 2 ) + 𝛼22 (4𝑥 2 − 12𝑥 3 + 9𝑥 4 ) + 2 𝛼1 𝛼2 (2𝑥 − 7𝑥 2 + 6𝑥 3 )
1 1
du 2 1
∫ ( ) 𝑑𝑥 = ∫ 𝛼12 (1 − 4𝑥 + 4𝑥 2 ) 𝑑𝑥 + ∫ 𝛼22 (4𝑥 2 − 12𝑥 3 + 9𝑥 4 ) 𝑑𝑥
dx 0
0 0
1
+ ∫ 2 𝛼1 𝛼2 (2𝑥 − 7𝑥 2 + 6𝑥 3 ) 𝑑𝑥
0
1 1 1 1
du 2 𝑥2 𝑥3 𝑥3 𝑥4 𝑥5 𝑥2 𝑥3 𝑥4
∫( ) 𝑑𝑥 = 𝛼12 [𝑥 − 4 + 4 ] + 𝛼22 [4 − 12 + 9 ] + 2 𝛼1 𝛼2 [2 − 7 + 6 ]
dx 2 3 0 3 4 5 0 2 3 4 0
0
1 1

∫ u 𝑑𝑥 = ∫[𝛼12 (𝑥 2 − 2𝑥 3 + 𝑥 4 ) + 2 𝛼1 𝛼2 (𝑥 3 − 2𝑥 4 + 𝑥 5 ) + 𝛼22 (𝑥 4 − 2𝑥 5 + 𝑥 6 ) ] 𝑑𝑥
2

0 0
1 1 1 1
𝑥3 𝑥4 𝑥5 𝑥4 𝑥5 𝑥6 𝑥5 𝑥6 𝑥7
2
∫ u 𝑑𝑥 = 𝛼12 [ 2
− 2 + ] + 2 𝛼1 𝛼2 [ − 2 + ] + 𝛼2 [ − 2 + ]
3 4 5 0 4 5 6 0 5 6 7 0
0
1 1

∫ u x 𝑑𝑥 = ∫[𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥)] x 𝑑𝑥


0 0
1 1 1
𝑥3 𝑥4 𝑥4 𝑥5
∫ u x 𝑑𝑥 = 𝛼1 [ − ] + 𝛼2 [ − ]
3 4 0 4 5 0
0

Eq. () can be written as


1 1 1 1 1 1 1 1 1 1 1 1 1 1
𝐼(𝑢) ≈ − 𝛼12 [1 − 4 + 4 ] − 𝛼22 [4 − 12 + 9 ] − 𝛼1 𝛼2 [2 − 7 + 6 ] + 𝛼12 [ − 2 + ]
2 2 3 2 3 4 5 2 3 4 2 3 4 5
1 1 1 1 1 1 1 1 1 1 1
+ 𝛼1 𝛼2 [ − 2 + ] + 𝛼22 [ − 2 + ] + 𝛼1 [ − ] + 𝛼2 [ − ]
4 5 6 2 5 6 7 3 4 4 5
9 13 2 126 1 1
≈ − 𝛼12 − 𝛼2 − 𝛼1 𝛼2 + 𝛼1 + 𝛼2
60 210 840 12 20
Using the conditions for the extremization of I, we obtain
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 46
BUET NAME 363 – CFD (FDM & FEM)

𝜕𝐼 3 3 1
= − 𝛼1 − 𝛼2 + = 0
𝜕𝛼1 5 10 6
𝜕𝐼 3 26 1
= − 𝛼1 − 𝛼2 + =0
𝜕𝛼2 10 105 10
Solving these two equations we get
1988 7
𝛼1 = 10332 = 0.1924 and 𝛼2 = 41 = 0.1707

Thus, the approximate solution becomes

𝑢(𝑥) ≈ 0.1924 𝑥(1 − 𝑥) + 0.1707𝑥 2 (1 − 𝑥)

The exact solution can be obtained as

𝑠𝑖𝑛𝑥
𝑢= −𝑥
𝑠𝑖𝑛1

Example 5.5 Solve the boundary value problem by Rayleigh-Ritz method


𝑑2 𝑢
𝑑𝑥
+𝑥 = 0 with 𝑢(𝑥) = 0 𝑎𝑡 𝑥 = 0, 1

Solution:
The functional of the problem is given by
1
d2 u
𝐼(𝑢) = − ∫ u [2x + ] 𝑑𝑥
dx 2
0

Let the solution be approximated by the equation as


𝑛

𝑢(𝑥) ≈ ∑ 𝛼𝑖 𝜙𝑖 (𝑥) = 𝛼1 𝜙1 (𝑥) + 𝛼2 𝜙2 (𝑥) = 𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥)


𝑖=1

Substituting Eq. () in Eq. () we obtain


1 𝑛 𝑛
d2 𝜙𝑗
𝐼(𝑢) ≈ − ∫ ∑ 𝛼𝑖 𝜙𝑖 [2x + ∑ 𝛼𝑗 ] 𝑑𝑥
dx 2
0 𝑖=1 𝑗=1

1 𝑛 1 𝑛 𝑛
d2 𝜙𝑗
≈ − [2 ∫ ∑ 𝛼𝑖 𝑥 𝜙𝑖 𝑑𝑥 + ∫ ∑ ∑ 𝛼𝑖 𝛼𝑗 𝜙𝑖 𝑑𝑥]
dx 2
0 𝑖=1 0 𝑖=1 𝑗=1

Defining
1

𝑝𝑖 = ∫ 𝑥 𝜙𝑖 𝑑𝑥
0

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 47


BUET NAME 363 – CFD (FDM & FEM)

1 d2 𝜙𝑗 𝑑𝜙𝑗 1 1 𝑑𝜙𝑖 𝑑𝜙𝑗 1 𝑑𝜙𝑖 𝑑𝜙𝑗


𝑞𝑖𝑗 = ∫0 𝜙𝑖 dx2
𝑑𝑥 = [𝜙𝑖 𝑑𝑥 0
] − ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥 = − ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥

we can write the above equation as


𝑛 𝑛 𝑛

𝐼(𝑢) ≈ − [2 ∑ 𝛼𝑖 𝑝𝑖 + ∑ ∑ 𝛼𝑖 𝛼𝑗 𝑞𝑖𝑗 ]
𝑖=1 𝑖=1 𝑗=1

Applying the condition of extremization we get


𝑑𝐼
𝑑𝛼𝑖
≈ 2 𝑝𝑖 + 2 𝛼𝑗 𝑞𝑖𝑗 = 0

𝑖 = 1: 𝑝1 + 𝛼1 𝑞11 + 𝛼2 𝑞12 = 0
𝑖 = 2: 𝑝2 + 𝛼1 𝑞21 + 𝛼2 𝑞22 = 0
Let 𝑢(𝑥) ≈ 𝛼1 𝜙1 (𝑥) + 𝛼2 𝜙2 (𝑥) with 𝜙1 (𝑥) = 𝑥(1 − 𝑥) and 𝜙2 (𝑥) = 𝑥 2 (1 − 𝑥)
𝜙1′ (𝑥) ≈ (1 − 2𝑥) and 𝜙2′ (𝑥) ≈ (2𝑥 − 3𝑥 2 )
Now
1 1
1
𝑝1 = ∫ 𝑥 𝜙1 𝑑𝑥 = ∫ 𝑥 2 (1 − 𝑥) 𝑑𝑥 =
12
0 0
1 1
1
𝑝2 = ∫ 𝑥 𝜙2 𝑑𝑥 = ∫ 𝑥 3 (1 − 𝑥) 𝑑𝑥 =
20
0 0
1 1
𝑑𝜙1 2 1
𝑞11 = −∫( ) 𝑑𝑥 = ∫(1 − 2𝑥)2 = −
𝑑𝑥 3
0 0
1 1
𝑑𝜙2 2 2
𝑞22 = −∫( ) 𝑑𝑥 = − ∫(2𝑥 − 3𝑥 2 )2 𝑑𝑥 = −
𝑑𝑥 15
0 0
1
1
𝑞12 = 𝑞21 = − ∫(1 − 2𝑥) (2𝑥 − 3𝑥 2 ) 𝑑𝑥 = −
6
0

Now from Eq. () and () we obtain


1 1 1
𝑖 = 1: − 𝛼1 − 𝛼2 = 0
12 3 6
1 1 2
𝑖 = 2: − 𝛼1 − 𝛼2 = 0
20 6 15
1
Solving above two equations we get 𝛼1 = 𝛼2 = 6

Now the approximate solution is obtained as


𝑢(𝑥) ≈ 𝛼1 𝜙1 (𝑥) + 𝛼2 𝜙2 (𝑥)

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 48


BUET NAME 363 – CFD (FDM & FEM)

1 1
≈ 𝑥(1 − 𝑥) + 𝑥 2 (1 − 𝑥)
6 6
1
≈ 𝑥(1 − 𝑥 2 )
6

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 49


BUET NAME 363 – CFD (FDM & FEM)

5.6 Galerkin method


The idea of weighted residual method is to multiply the residual by a weighting function and force the
integral of the weighted expression to zero. Consider the problem
d2 u
dx2
= 𝑓(𝑥) with 𝑢(𝑎) = 𝑢(𝑏) = 0

Let the solution is approximated by an interpolation function 𝑢(𝑥) ≈ ∑∞


𝑛=1 αi Ni (x). The substitution of 𝑢

into the differential equation gives the residual R(x) as


d2 u
𝑅(𝑥) = − 𝑓(𝑥)
dx 2
Taking a weight function N(x), we have
𝑏
∫ 𝑅(𝑥) 𝑁(𝑥) 𝑑𝑥 = 0
𝑎

Choosing different weighting functions and replacing each of them in Eq. (), we can generate a system of
linear equations in the unknown parameters αi that will determine an approximation of 𝜙 in form of finite
series given in Eq. (). The type of weighting function chosen depends on the type of weighted residual
technique selected. In the Galerkin method, the weights are set equal to the shape functions 𝑁𝑖 (𝑥).

Example 5.6
𝑑2 𝑢
+𝑢+𝑥 =0 with 𝑢(𝑥) = 0 𝑎𝑡 𝑥 = 0, 1
𝑑𝑥

Let us consider an approximate solution given by 𝑢(𝑥) ≈ 𝛼1 𝑁1 (𝑥) + 𝛼2 𝑁2 (𝑥). The interpolation functions
N1(x) and N2(x) are defined by
𝑁1 (𝑥) = 𝑥(1 − 𝑥) and
𝑁2 (𝑥) = 𝑥 2 (1 − 𝑥) in such a way that satisfies the boundary conditions,
𝑁1 (x) = 𝑁2 (𝑥) = 0 𝑎𝑡 𝑥 = 0, 1.
Now the approximate solution and the residual R(x) are respectively written as
𝑢 = 𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥) = 𝛼1 𝑁1 + 𝛼2 𝑁2
𝑑2 𝑢
𝑅(𝑥) = +𝑢+𝑥
𝑑𝑥
Setting the integrals of the product of the Residual and the weighted functions 𝑁1 (𝑥) and 𝑁2 (𝑥) gives
1
∫ 𝑅(𝑥) 𝑁1 (𝑥) = 0
0
1
∫ 𝑅(𝑥) 𝑁2 (𝑥) = 0
0

Now from Eq. () we obtain

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 50


BUET NAME 363 – CFD (FDM & FEM)

1
𝑑2 𝑢
∫ [ + 𝑢 + 𝑥] 𝑁1 (𝑥) = 0
0 𝑑𝑥2

𝑑𝑢 1 1
𝑑𝑢 𝑑𝑁1 (𝑥) 1 1
[𝑁1 (𝑥) ] − ∫ 𝑑𝑥 + ∫ 𝑢 𝑁1 (𝑥) 𝑑𝑥 + ∫ 𝑁1 (𝑥) 𝑥 𝑑𝑥 = 0
𝑑𝑥 0 0 𝑑𝑥 𝑑𝑥 0 0

Applying the boundary conditions, we have


1 1 1
𝑑𝑢 𝑑𝑁1 (𝑥)
∫ 𝑑𝑥 − ∫ 𝑢 𝑁1 (𝑥) 𝑑𝑥 − ∫ 𝑁1 (𝑥) 𝑥 𝑑𝑥 = 0
0 𝑑𝑥 𝑑𝑥 0 0
1
∫ [𝛼1 (1 − 2𝑥) + 𝛼2 (2𝑥 − 3𝑥 2 )](1 − 2𝑥)𝑑𝑥
0
1 1
− ∫ [𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥)] 𝑥(1 − 𝑥) 𝑑𝑥 − ∫ 𝑥(1 − 𝑥) 𝑥 𝑑𝑥 = 0
0 0
1
𝛼1 ∫ [(1 − 2𝑥)2 − 𝑥 2 (1 − 𝑥)2 ]𝑑𝑥
0
1 1
+ 𝛼2 ∫0 [(2𝑥 − 3𝑥 2 )(1 − 2𝑥) − 𝑥 3 (1 − 𝑥)2 ]𝑑𝑥 − ∫0 𝑥 2 (1 − 𝑥) 𝑑𝑥 = 0
3 3 1
𝛼1 + 𝛼2 =
10 20 12
Similarly, from Eq. ()
1 1 1
𝑑𝑢 𝑑𝑁2 (𝑥)
∫ 𝑑𝑥 − ∫ 𝑢 𝑁2 (𝑥) 𝑑𝑥 − ∫ 𝑁2 (𝑥) 𝑥 𝑑𝑥 = 0
0 𝑑𝑥 𝑑𝑥 0 0
1
∫ [𝛼1 (1 − 2𝑥) + 𝛼2 (2𝑥 − 3𝑥 2 )](2𝑥 − 3𝑥 2 )𝑑𝑥
0
1 1
− ∫ [𝛼1 𝑥(1 − 𝑥) + 𝛼2 𝑥 2 (1 − 𝑥)] 𝑥 2 (1 − 𝑥) 𝑑𝑥 − ∫ 𝑥 2 (1 − 𝑥) 𝑥 𝑑𝑥 = 0
0 0
1
𝛼1 ∫ [(1 − 2𝑥)(2𝑥 − 3𝑥 2 ) − 𝑥 3 (1 − 𝑥)2 ]𝑑𝑥
0
1 1
+ 𝛼2 ∫ [(2𝑥 − 3𝑥 2 )2 − 𝑥 4 (1 − 𝑥)2 ] 𝑑𝑥 − ∫ 𝑥 3 (1 − 𝑥) 𝑑𝑥 = 0
0 0
3 13 1
𝛼1 + 𝛼2 =
20 105 20
Solving Eq. () and () we obtain
71 7
𝛼1 = 369 and 𝛼2 = 41

So, the approximate solution is


71 7
𝑢≈ 𝑥(1 − 𝑥) + 𝑥 2 (1 − 𝑥)
369 41

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 51


BUET NAME 363 – CFD (FDM & FEM)

5.7 Finite Element Method


Consider the following boundary value problem
𝑑2 𝑢 𝑑𝑢
𝑑𝑥 2
= −𝑓(𝑥) with 𝑢(𝑥) = 0 𝑎𝑡 𝑥 = 0 𝑎𝑛𝑑 𝑑𝑥
= 0 𝑎𝑡 𝑥 = 1

Multiplying both sides by the shape function N(x) and then integrating over the element we get
𝑥𝑖+1 𝑥𝑖+1
𝑑2 𝑢
∫ 𝑁(𝑥) 2 𝑑𝑥 = − ∫ 𝑁(𝑥) 𝑓(𝑥) 𝑑𝑥
𝑑𝑥
𝑥𝑖 𝑥𝑖
𝑥𝑖+1 𝑥𝑖+1
𝑑𝑢 𝑥𝑖+1 𝑑𝑁(𝑥) 𝑑𝑢
[𝑁(𝑥) ] −∫ 𝑑𝑥 = − ∫ 𝑁(𝑥) 𝑓(𝑥) 𝑑𝑥
𝑑𝑥 𝑥𝑖 𝑑𝑥 𝑑𝑥
𝑥𝑖 𝑥𝑖

Simplifying the above equation yields


𝑥𝑖+1 𝑥𝑖+1
𝑑𝑁(𝑥) 𝑑𝑢 𝑑𝑢 𝑑𝑢
∫ 𝑑𝑥 = ∫ 𝑁(𝑥) 𝑓(𝑥) 𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ]
𝑑𝑥 𝑑𝑥 𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖
𝑥𝑖 𝑥𝑖

Let the solution over the i-th element be approximated by


𝑛
(𝑖)
𝑢(𝑥) ≈ ∑ 𝑁𝑗 (𝑥) 𝑢𝑗
𝑗=1

in which 𝑁𝑗 are the shape functions and j represents the number of nodes over the element. Substituting Eq.
() into Eq. () we obtain
𝑛 𝑥𝑖+1 𝑥𝑖+1
(𝑖) 𝑑𝑁𝑖 (𝑥) 𝑑𝑁𝑗 (𝑥) 𝑑𝑢 (𝑖) 𝑑𝑢 (𝑖)
∑ 𝑢𝑗 ∫ 𝑑𝑥 = ∫ 𝑁𝑖 (𝑥) 𝑓(𝑥)𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ]
𝑑𝑥 𝑑𝑥 𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖
𝑗=1 𝑥𝑖 𝑥𝑖

(𝑖 = 1, 2, 3 ⋯ ⋯ 𝑛)
Eq. () for the i-th element can be finally written into a matrix form as
𝑛
(𝑖) (𝑖) (𝑖)
∑ 𝐾𝑖𝑗 𝑢𝑗 = 𝐹𝑖
𝑗=1
(𝑖) (𝑖)
Where 𝐾𝑖𝑗 and 𝐹𝑖 are called the stiffness matrix and force vector respective and are given by
𝑥𝑖+1
(𝑖) 𝑑𝑁𝑖 (𝑥) 𝑑𝑁𝑗 (𝑥)
𝐾𝑖𝑗 = ∫ 𝑑𝑥
𝑑𝑥 𝑑𝑥
𝑥𝑖

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 52


BUET NAME 363 – CFD (FDM & FEM)

𝑥𝑖+1
(𝑖) 𝑑𝑢 (𝑖) 𝑑𝑢 (𝑖)
𝐹𝑖 = ∫ 𝑁𝑖 (𝑥) 𝑓(𝑥)𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ]
𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖
𝑥𝑖

Eq. () is a system of linear algebraic equations and can be solved by Cramer’s rule or L-U decomposition
(𝑖)
method for the value of 𝑢𝑗 .

𝑑2 𝑢 𝑑𝑢
Example 5.7 Solve the boundary value problem 𝑑𝑥 2 = −2 with 𝑢(𝑥) = 0 𝑎𝑡 𝑥 = 0 𝑎𝑛𝑑 𝑑𝑥
= 0 𝑎𝑡 𝑥 = 1

by finite element method and then compare the numerical result with the analytical one.

Solution:
Let the solution over 𝑖-th element be approximated by
𝑛
(𝑖)
𝑢(𝑥) ≈ ∑ 𝑁𝑗 (𝑥) 𝑢𝑗
𝑗=1

And the discretized form of the above differential equation can be expressed as
𝑛
(𝑖) (𝑖) (𝑖)
∑ 𝐾𝑖𝑗 𝑢𝑗 = 𝐹𝑖
𝑗=1

where (i) denotes the element number, i is the node number over the element and
𝑥𝑖+1
(𝑖) 𝑑𝑁𝑖 (𝑥) 𝑑𝑁𝑗 (𝑥)
𝐾𝑖𝑗 = ∫ 𝑑𝑥
𝑑𝑥 𝑑𝑥
𝑥𝑖
𝑥𝑖+1
(𝑖) 𝑑𝑢 (𝑖) 𝑑𝑢 (𝑖)
𝐹𝑖 = ∫ 𝑁𝑖 (𝑥) 𝑓(𝑥)𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ]
𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖
𝑥𝑖

If the region of interest [0, 1] is divided into two equal intervals as shown in Fig the shape functions at node
𝑖 and 𝑖 + 1can be obtained as
1
𝑥 −𝑥 𝑥−𝑥𝑖 −𝑥 𝑥−0
Ni (x) = 𝑥 𝑖+1−𝑥 ; Ni+1 (x) = 𝑥 N1 (x) = 21 ; N2 (x) = 1
𝑖+1 𝑖 𝑖+1 −𝑥𝑖 −0 −0
2 2

Now the derivatives of the shape functions are


dNi 1 dNi+1 1
dx
= −𝑥 =𝑥
𝑖+1 −𝑥𝑖 dx 𝑖+1 −𝑥𝑖

Application of Eq. () at node (1) and (2) for element 1 gives


(1) (1) (1) (1)
𝐾11 𝐾12 𝑢1 𝐹
[ (1) (1)
][ (1)
] = [ 1(1) ]
𝐾21 𝐾22 𝑢2 𝐹2

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 53


BUET NAME 363 – CFD (FDM & FEM)

Where
(1) 1/2 𝑑𝑁1 𝑑𝑁1 (1) 1/2 𝑑𝑁1 𝑑𝑁2
𝐾11 = ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥 𝐾12 = ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥
(1) 1/2 𝑑𝑁2 𝑑𝑁1 (1) 1/2 𝑑𝑁2 𝑑𝑁2
𝐾21 = ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥 𝐾22 = ∫0 𝑑𝑥 𝑑𝑥
𝑑𝑥

Similarly, for element 2 we have


(2) (2) (2) (2)
𝐾11 𝐾12 𝑢1 𝐹
[ (2) (2) ] [ (2) ] = [ 1(2) ]
𝐾21 𝐾22 𝑢2 𝐹2
Where
(2) 1 𝑑𝑁1 𝑑𝑁1 (2) 1 𝑑𝑁1 𝑑𝑁2
𝐾11 = ∫1/2 𝑑𝑥 𝑑𝑥
𝑑𝑥 𝐾12 = ∫1/2 𝑑𝑥 𝑑𝑥
𝑑𝑥
(2) 1 𝑑𝑁2 𝑑𝑁1 (2) 1 𝑑𝑁2 𝑑𝑁2
𝐾21 = ∫1/2 𝑑𝑥 𝐾22 = ∫1/2 𝑑𝑥
𝑑𝑥 𝑑𝑥 𝑑𝑥 𝑑𝑥

(𝒊) (𝒊)
(i) Calculation of 𝑲𝒊𝒋 and 𝑭𝒊 for Element 1:
(1) (1)
𝐾11 = 2 𝐾12 = −2,
(1) (1)
𝐾21 = −2, 𝐾22 = 2
And the force vectors at nodes 1and 2 are
𝑥𝑖+1
(1) 𝑑𝑢 (1) 𝑑𝑢 (1) 1 𝑑𝑢 (1)
𝐹1 = −2 ∫ 𝑁1 𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ] = − [𝑁(𝑥) ]
𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖 2 𝑑𝑥 𝑥𝑖
𝑥𝑖

[𝑠𝑖𝑛𝑐𝑒 𝑁𝑖 = 1, 𝑁𝑖+1 = 0]
𝑥𝑖+1
(1) 𝑑𝑢 (1) 𝑑𝑢 (1) 1 𝑑𝑢 (1)
𝐹2 = −2 ∫ 𝑁2 𝑑𝑥 + [𝑁(𝑥) ] − [𝑁(𝑥) ] = + [𝑁(𝑥) ]
𝑑𝑥 𝑥𝑖+1 𝑑𝑥 𝑥𝑖 2 𝑑𝑥 𝑥𝑖+1
𝑥𝑖

[𝑠𝑖𝑛𝑐𝑒 𝑁𝑖 = 0, 𝑁𝑖+1 = 1]
Now the matrix for element 1 can be expressed as
1 𝑑𝑢 (1)
(1) − |
2 −2 𝑢1 2 𝑑𝑥 1
[ ] [ (1) ] =
−2 2 𝑢
2
1 𝑑𝑢 (1)
+ |
[2 𝑑𝑥 2 ]

(𝒊) (𝒊)
(ii) Calculation of 𝑲𝒊𝒋 and 𝑭𝒊 for Element 2:
(2) (2)
𝐾11 = 2, 𝐾12 = −2,
(2) (2)
𝐾21 = −2, 𝐾22 = 2
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 54
BUET NAME 363 – CFD (FDM & FEM)

(2) 1 𝑑𝑢 (2) 1 𝑑𝑢
𝐹1 = −[ ] , 𝐹2 = +[ ]
2 𝑑𝑥 𝑥𝑖 2 𝑑𝑥 𝑥𝑖+1

Now the matrix for element 2


1 𝑑𝑢 (2)
(2) − |
2 −2 𝑢1 2 𝑑𝑥 1
[ ] [ (2) ] =
−2 2 𝑢
2
1 𝑑𝑢 (2)
+ |
[2 𝑑𝑥 2 ]
The element 1 and 2 are connected at the node 2 in a way that the global solutions
can be mathematically expressed as
(1) (1) (2) (2)
𝑢1 = 𝑢1 , 𝑢2 = 𝑢2 = 𝑢1 , 𝑢2 = 𝑢3
Now the global finite element model is
(1)
1 𝑑𝑢
− |
2 𝑑𝑥 1
2 −2 0 𝑢1
1 𝑑𝑢 (1) 1 𝑑𝑢 (2)
[−2 2 + 2 −2] [𝑢2 ] = + | + − |
0 −2 2 𝑢3 2 𝑑𝑥 2 2 𝑑𝑥 1
1 𝑑𝑢 (2)
+ |
[ 2 𝑑𝑥 2 ]
𝑑𝑢 (1) 𝑑𝑢 (2) 𝑑𝑢 (2)
The terms 𝑑𝑥 | and 𝑑𝑥 | will cancel each other and the term 𝑑𝑥 | is zero for the boundary condition. The
2 1 2

solution from the boundary condition gives 𝑢1 = 0 and the global matrix can finally be written as
1
4 −2 𝑢2
[ ] [𝑢 ] = [1]
−2 2 3
2
Now the solution of the matrix system is
3
𝑢2 = 4, 𝑢3 = 1

The approximate solution throughout the interval [0, 1]is finally obtained as

2 (1) (1) 1
𝑁1 (𝑥)𝑢1 + 𝑁2 (𝑥)𝑢2 0<𝑥≤
𝑢(𝑥) ≈ ∑ 𝑁𝑗 (𝑥) 𝑢𝑗 = { 2
(2) (2) 1
𝑗=1 𝑁1 (𝑥)𝑢1 + 𝑁2 (𝑥)𝑢2 <𝑥≤ 1
2
3 1
𝑥 0<𝑥≤
={ 2 2
𝑥+1 1
<𝑥≤ 1
2 2

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 55


BUET NAME 363 – CFD (FDM & FEM)

𝜕2 𝑢 𝜕2 𝑢
Example 5.8 Solve the poisons equation by the finite element method (𝜕𝑥 2 + 𝜕𝑦2 ) = −𝑓(𝑥, 𝑦)
with u = 0 on the boundary condition of the square (0 < 𝑥 ≤ 1, 0 < 𝑦 ≤ 1)

Solution:
∇2 𝑢 = −𝑓(𝑥, 𝑦)
Multiplying both sides of the equation by the shape function−𝑁(𝑥, 𝑦) and integrating, we obtain

− ∬ 𝑁(𝑥, 𝑦) ∇2 𝑢 𝑑𝑥 𝑑𝑦 = ∬ 𝑁(𝑥, 𝑦) 𝑓(𝑥, 𝑦)𝑑𝑥 𝑑𝑦

From the vector identity ∇ ∙ (𝑁 ∇𝑢) = ∇N ∙ ∇𝑢 + 𝑁 ∇2 𝑢we get

∬ ∇N. ∇u 𝑑𝑥 𝑑𝑦 − ∬ ∇ ∙ (𝑁 ∇𝑢) 𝑑𝑥 𝑑𝑦 = ∬ 𝑁 𝑓(𝑥, 𝑦) 𝑑𝑥 𝑑𝑦

Using Gauss-divergence theorem in the second integral we obtain

𝜕𝑢 𝜕𝑁 𝜕𝑢 𝜕𝑁
∬( + ) 𝑑𝑥 𝑑𝑦 − ∫ (𝑁 ∇u) ∙ 𝑛 𝑑𝑠 = ∬ 𝑁 𝑓(𝑥, 𝑦)𝑑𝑠
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
Ω 𝐶 Ω

𝜕𝑢 𝜕𝑁 𝜕𝑢 𝜕𝑁
∬( + ) 𝑑𝑥 𝑑𝑦 = ∫ 𝑞𝑛 𝑁 𝑑𝑠 + ∬ 𝑁𝑓 𝑑𝑥 𝑑𝑦
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
Ω 𝐶 Ω
𝜕𝑢 𝜕𝑢
Where 𝑞𝑛 = ∇u ∙ 𝑛 = 𝑛 + 𝑛𝑦 and n is the unit normal vector on the boundary C and dS is the arc
𝜕𝑥 𝑥 𝜕𝑦

length of an infinitesimal element along the boundary. Let the solution 𝑢 be approximated as
𝑛
(𝑖)
𝑢 ≈ ∑ 𝑁𝑗 𝑢𝑗
𝑗=1

in which 𝑁𝑗 are the the shape functions and j represents the number of nodes over the element. Eq. () for i-
th element can be expressed as
Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 56
BUET NAME 363 – CFD (FDM & FEM)

𝑛
𝜕𝑁𝑖 𝜕𝑁𝑗 𝜕𝑁𝑖 𝜕𝑁𝑗 (𝑖)
∑∬( + ) 𝑢 𝑑𝑥 𝑑𝑦 = ∬ 𝑓 𝑁𝑖 𝑑𝑥 𝑑𝑦 + ∫ 𝑞𝑛 𝑁𝑖 𝑑𝑆
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦 𝑗
𝑗=1 Ω Ω 𝐶

Eq. () can be written as


𝑛
(𝑖) (𝑖) (𝑖)
∑ 𝐾𝑖𝑗 𝑢𝑗 = 𝐹𝑖
𝑗=1
(𝑖) (𝑖)
Where𝐾𝑖𝑗 and 𝐹𝑖 are called the stiffness matrix and force vector respectively and are given by

(𝑖) 𝜕𝑁𝑖 𝜕𝑁𝑗 𝜕𝑁𝑖 𝜕𝑁𝑗


𝐾𝑖𝑗 = ∬ ( + ) 𝑑𝑥 𝑑𝑦
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
Ω

(𝑖)
𝐹𝑖 = ∬ 𝑓 𝑁𝑖 𝑑𝑥 𝑑𝑦 + ∫ 𝑞𝑛 𝑁𝑖 𝑑𝑠
Ω 𝐶

We apply Eq. () at each of three nodes of element 1 and write these equations into a matrix form as
(1) (1) (1) (1) (1)
𝑘11 𝑘12 𝑘13 𝑢1 𝐹1
(1) (1) (1) (1) (1)
𝑘21 𝑘22 𝑘23 [𝑢2 ] = [𝐹2 ]
(1) (1) (1) (1) (1)
[𝑘31 𝑘32 𝑘33 ] 𝑢3 𝐹3
Where
(1) 𝜕𝑁1 𝜕𝑁1 𝜕𝑁1 𝜕𝑁1 (1) (1) 𝜕𝑁1 𝜕𝑁2 𝜕𝑁1 𝜕𝑁2
𝑘11 = ∬Ω ( + ) 𝑑𝑥 𝑑𝑦; 𝑘12 = 𝑘21 = ∬Ω ( + ) 𝑑𝑥 𝑑𝑦
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦 𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦

(1) (1) 𝜕𝑁 𝜕𝑁3 𝜕𝑁1 𝜕𝑁3 (1) 𝜕𝑁 2 𝜕𝑁 2


𝑘13 = 𝑘31 = ∬Ω ( 𝜕𝑥1 𝜕𝑥
+ 𝜕𝑦 𝜕𝑦
) 𝑑𝑥 𝑑𝑦; 𝑘22 = ∬Ω [( 𝜕𝑥2 ) + ( 𝜕𝑦2 ) ] 𝑑𝑥 𝑑𝑦

(1) (1) 𝜕𝑁 𝜕𝑁3 𝜕𝑁2 𝜕𝑁3 (1) 𝜕𝑁 2 𝜕𝑁 2


𝑘23 = 𝑘32 = ∬Ω ( 𝜕𝑥2 𝜕𝑥
+ 𝜕𝑦 𝜕𝑦
) 𝑑𝑥 𝑑𝑦; 𝑘33 = ∬Ω ( 𝜕𝑥3 ) + ( 𝜕𝑦3 ) 𝑑𝑥 𝑑𝑦

𝜕2 𝑢 𝜕2 𝑢
Now solution for (𝜕𝑥 2 + 𝜕𝑦 2 ) = −2 with u = 0 on the boundary of the square (0 < 𝑥 ≤ 1, 0 < 𝑦 ≤ 1)
(𝒊) (𝒊)
(i) Calculation of 𝑲𝒊𝒋 and 𝑭𝒊 for Element 1:

Area of the triangular element 1 is


1 𝑥1 𝑦1 1 0 0
1 1 1
∆= |1 𝑥2 𝑦2 | = |1 1/2 0 |=
2 2 8
1 𝑥3 𝑦3 1 1/2 1/2
And the corresponding shape functions for this element are
1 𝑥 𝑦
∆1 1 1 𝑥 𝑦
𝑁1 = = |1 𝑥2 𝑦2 | = 4 |1 1/2 0 | = (1 − 2𝑥)
∆ 2∆ 1 𝑥 𝑦3 1 1/2 1/2
3

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 57


BUET NAME 363 – CFD (FDM & FEM)

1 𝑥 𝑦 1 𝑥 𝑦
∆2 1
𝑁2 = = |1 𝑥3 𝑦3 | = 4 |1 1/2 1/2| = 2(𝑥 − 𝑦)
∆ 2∆ 1 𝑥 𝑦1
1 1 0 0
1 𝑥 𝑦 1 𝑥 𝑦
∆3 1
𝑁3 = = |1 𝑥1 𝑦1 | = 4 |1 0 0| = 2𝑦
∆ 2∆ 1 𝑥 𝑦2 1 1/2 0
2

The components of the stiffness for element 1 can be obtained as


1 1
𝐾11 = ∬Ω 4 𝑑𝑥 𝑑𝑦 = 𝐾12 = 𝐾21 = − ∬Ω 4 𝑑𝑥 𝑑𝑦 = − 𝐾13 = 𝐾31 = 0
2 2
1 1
𝐾22 = 1 𝐾23 = 𝐾32 = − 𝐾33 =
2 2

The force vectors at node 1 for element 1 is

𝐹1 = 2 ∬𝑆 𝑁1 𝑑𝑥 𝑑𝑦 + ∬𝑆 𝑁1 𝑞𝑛 𝑑𝑆 = 2 ∬𝑆 𝐿11 𝐿02 𝐿03 𝑑𝑥 𝑑𝑦 + ∬𝑆 𝐿1 𝑞𝑛 𝑑𝑆


1! 0! 0!
= 2 (1+0+0+2)! 2𝐴 + ∬𝑆 𝐿1 𝑞𝑛 𝑑𝑆
1! 0! 0! (1)
= 2 (1+0+0+2)! 2𝐴 + 𝑙1
1 (1)
= 12 + 𝑙1

Similarly, the force vectors at node 2 and 3are


1 (1)
𝐹2 = 2 ∬Ω 𝑁2 𝑑𝑥 𝑑𝑦 + ∫ 𝑁2 𝑞𝑛 𝑑𝑠 = 12 + 𝑙2
1 (1)
𝐹3 = 2 ∬Ω 𝑁3 𝑑𝑥 𝑑𝑦 + ∫ 𝑁3 𝑞𝑛 𝑑𝑠 = 12 + 𝑙3
(1) (1) (1)
Where 𝑙1 = ∬𝑆 𝑁1 𝑞𝑛 𝑑𝑆; 𝑙2 = ∬𝑆 𝑁2 𝑞𝑛 𝑑𝑆 and 𝑙3 = ∬𝑆 𝑁3 𝑞𝑛 𝑑𝑆.

Now the matrix for element 1 can finally be written as


1 1 1 (1)
− 0 (1) + 𝑙1
2 2 𝑢1 12
1 1 1
1 − [𝑢2(1) ] = (1)
+ 𝑙2
2 2 (1)
12
1 1 𝑢3 1 (1)
[0 −
2 2] [12 + 𝑙3 ]

Matrix solution:
Let the global solutions be 𝑢1 , 𝑢2 , 𝑢3 , 𝑢4 , 𝑢5 𝑎𝑛𝑑 𝑢6 at the respective six vertices. Now the matrix with
respect to global co-ordinate system can be written as

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 58


BUET NAME 363 – CFD (FDM & FEM)

Matrix for Element 1:

1 1 
2 − 0 0 0 0
2 1  l1(1) 
   u1 
1   1   (1) 
0 0  u2 
1
1 − 0    l2 
2 2 
   u3  1 1  l3 
(1)

0 0  u  = 12 0  +  0 
0 1 1
− 0
 2 2  4    
0 0 0 0 
0 0  u5  0  0 
       
0 0 0 0 0 0  u6  0   0 
0 0 0 
 0 0 0

Matrix for Element 2:

0 0 0 0 0
0
 
0 1
0 −
1
0 0   u1  0  0 
 2 2  u  1   (2) 
0 0 0 0 0 0   2   l1 
  u3  1 0   0 
0 − 1   =  + 
0  u4  12 1  l2(2) 
1
 0 1 −
2 2
  u5  1  l3(2) 
0 0 0
1 1
0  u     
 2 2   6  0   0 
0 0 0 
 0 0 0

Matrix for Element 04

0 0 0 0 0 0
0 0   u 
 0 0 0 0
1 0  0 
 1 1    1   
0 0 0 − 0  u2    0
 2 2  u3  1 0  l1 
(4)

0 0 0 0 0 0  = +
   
  u4  12 1   0 
1 1 1  l2(4) 
0 0 − 0 1 −  u5 
 2 2      (4 ) 
 
 u 
 0  l3 
1 1 6
0 0 0 0 − 
 2 2

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 59


BUET NAME 363 – CFD (FDM & FEM)

Matrix for element 3:

0 0 0 0 0 0
 
0 1

1
0 0 0   u1  1   0 
 2 2 
 u  1   (3) 
 1 1   2   l3 
0 − 1 0 − 0  u3  1 1  l2(3) 
 2 2  u  = 12 0  +  0 
0 0 0 1 0 0  4     
 
 u5  0  l1(3) 
0 0 −
1
0
1 
0  u     
 2 2   6  0   0 
0 0 0 
 0 0 0

Assembling the element matrices, we obtain the global matrix as

 1 −1 0 0 0 0   u1  1  l1(1) 
 (3) 
 −1
 4 −2 −1 0 0  u2  3 
   l (1)
2 + l1
(2)
+ l3 
 0 −2 4 0 −2 
0  u3  1 3 l3 + l2 + l1
(1) (3) (4) 

   =  + 
 0 −1 0 2 −1 0  u4  12 1  l2(2) 
 0 0 −2 −1 4 −1 u5   
3 l3 + l1 + l2 
(2) (3) (4 )

       
 0 0 0 0 −1 1  u6  1  l3(4) 
From the boundary conditions we have 𝑢1 = 𝑢2 = 𝑢4 = 𝑢5 = 𝑢6 = 0. Now Eq. () gives
1 (1) (2) (3)
−2 𝑢3 = + 𝑙2 + 𝑙1 + 𝑙3
4
1 (1) (3) (4)
2 𝑢3 = 4 + 𝑙3 + 𝑙2 + 𝑙1
1 (2) (3) (4)
−2 𝑢3 = + 𝑙3 + 𝑙1 + 𝑙2
4
From Eq. () we obtain
1 1 (1) (3) (4)
𝑢3 = + [𝑙 + 𝑙2 + 𝑙1 ]
8 2 3
(1) (1)
But 𝑙3 = ∫𝐶123 𝑞𝑛 2𝑦 𝑑𝑠
0.5 0.5 0
(1) (1) (1)
=∫ [𝑞𝑛 2𝑦] 𝑑𝑥 + ∫ [𝑞𝑛 2𝑦] 𝑑𝑥 + ∫ [𝑞𝑛 2𝑦] 𝑑𝑥 = 0
𝑦=0 𝑥=0.5 𝑦=𝑥
0 0 0.5
(3) (4)
Similarly, 𝑙2 = 𝑙1 = 0
1
So, the final solution is 𝑢3 = 8

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 60


BUET NAME 363 – CFD (FDM & FEM)

Alternate derivation for stiffness matrix:


The stiffness matrix can also be derived as:

(𝑖) 𝜕𝑁𝑖 𝜕𝑁𝑗 𝜕𝑁𝑖 𝜕𝑁𝑗


𝐾𝑖𝑗 = ∬ ( + ) 𝑑𝑥 𝑑𝑦
𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑦
Ω

The shape functions for a linear triangular element at node 1, 2 and 3 are as follows:
1
𝑁1 (𝑥, 𝑦) = [𝑎 + 𝑏1 𝑥 + 𝑐1 𝑦]
2Δ 1
1
𝑁2 (𝑥, 𝑦) = [𝑎 + 𝑏2 𝑥 + 𝑐2 𝑦]
2Δ 2
1
𝑁3 (𝑥, 𝑦) = [𝑎 + 𝑏3 𝑥 + 𝑐3 𝑦]
2Δ 3
(𝑖)
𝐾𝑖𝑗 is symmetric and all terms under the integral are constant. Differentiating the shape functions with
respect to x and y we have from Eq. () as

(𝑖) 𝐾
𝐾𝑖𝑗 = ∬(𝑏𝑖 𝑏𝑗 + 𝑐𝑖 𝑐𝑗 ) 𝑑𝐴
4𝐴2
Ω

𝐾 𝑏1 𝑏1 + 𝑐1 𝑐1 𝑏1 𝑏2 + 𝑐1 𝑐2 𝑏1 𝑏3 + 𝑐1 𝑐3
= [𝑏2 𝑏1 + 𝑐2 𝑐1 𝑏2 𝑏2 + 𝑐2 𝑐2 𝑏2 𝑏3 + 𝑐2 𝑐3 ]
4𝐴2
𝑏3 𝑏1 + 𝑐3 𝑐1 𝑏3 𝑏2 + 𝑐3 𝑐2 𝑏3 𝑏3 + 𝑐3 𝑐3

And the co-efficient values of the shape functions of a linear triangular element are

i 𝑎𝑖 𝑏𝑖 𝑐𝑖
1 𝑥2 𝑦3 − 𝑥3 𝑦2 𝑦2 −𝑦3 𝑥3 − 𝑥2
2 𝑥3 𝑦1 − 𝑥1 𝑦3 𝑦3 − 𝑦1 𝑥1 − 𝑥3
3 𝑥2 𝑦1 − 𝑥1 𝑦2 𝑦1 −𝑦2 𝑥2 − 𝑥1

Prepared by Dr. Md. Shahjada Tarafder February 2023 Page 61

You might also like