QuickerSim CFD Course Notes
QuickerSim CFD Course Notes
1.3 Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.2 Turbulence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Lecture 2 12
3 Lecture 3 17
1
3.5 1D FDM discretization and implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4 Lecture 4 24
5 Lecture 5 33
5.6 Finite Element Method: Intuitive introduction to the idea of Finite Element . . . . . . . . . . 39
6 Lecture 6 40
2
6.3 Reference elements and geometry transformation . . . . . . . . . . . . . . . . . . . . . . . . 43
7 Lecture 7 47
7.3.6 Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.5.1 Timestepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3
7.5.2 Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.5.3 Limiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4
1 Basic flow and heat transfer models
~q = −λ · ∇T (1.1)
where:
• ~q - heat flux
q = −D · ∇c (1.2)
where:
• q - heat
• ∇c - gradient of concentration
For convection, it means that you have some quantity like thermal energy or mechanical momentum, and it is
transported with moving fluid(1.3),
φ = ~u · ~n · e (1.3)
where:
• ~u - velocity
• e = ρ · cp · T -thermal energy
Equation (1.3) can be also written for momentum and than we get another equation (1.4)
~ = (~u · ~n) · (ρ~u)
φ (1.4)
5
We want to calculate how quickly particular quantity change inside of the volume From equations (1.1), (1.2)
and (1.4) we can construct a typical conservation law(1.8).
Z Z Z Z
∂
udΩ = − (~u · ~n) · udΓ + λ∇u · ~ndΓ + qv dΩ (1.5)
∂t Ω Γ Γ Ω
Where Γ = ∂Ω is boundary of some domain Ω. Using Gaussian theorem for scalar quantity (1.6) and vector
quantity (1.7). Z Z
p · ~ndΓ = ∇pdΩ (1.6)
Γ Ω
Z Z
~v · ~ndΓ = (∇ · ~v ) dΩ (1.7)
Γ Ω
Substituting equations (1.6) and (1.7) to the typical conservation law (1.8) give us:
Z Z Z Z
∂
udΩ = − ∇ (~v · u) · dΩ + ∇ (λ∇u) · dΩ + qv dΩ (1.8)
∂t Ω Ω Ω Ω
Transforming equation (1.8).
Z Z
∂u
+ ∇ (~v · u) dΩ = [∇(λ∇u) + qv ] dΩ (1.9)
Ω ∂t Ω
If domain Ω is chosen arbitrary than equation (1.9) will change into differential equation (skip integrals).
∂u
+ ∇ (~v · u) = ∇(λ · ∇u) + qv (1.10)
∂t
In equation (1.10) particular elements are:
∂u
• ∂t - time derivative
• ∇ (~v · u) - convection derivative
• ∇(λ∇u) - diffusion term
• qv - source term
Assuming that λ = const we get divergence of gradient which can be called Laplacian(∆).
∇(λ∇u) = λ∇ · (∇u) = λ∆u
When we are considering stationary flow without any source we get Advection-Diffusion equation (1.11).
~v · ∇u = λ∆u (1.11)
Considering 1-D case Advection-Diffusion equation (1.11) transform into:
∂u ∂2u
a
=λ 2
∂x ∂x
Often, when we are considering incompressible fluid we know that ∇~v = 0. This lead us to Laplace equation.
−λ∆u = 0 (1.12)
When we add source term on the right side of Laplace equation (1.12 )we will get Poisson equation.
−λ∆u = f (1.13)
6
1.2 Boundary conditions
u|boundary = w
−~n · ∇u|boundary = q
−~n · ∇u + cu = f
~q = −α(T − T∞ )
Mixed boundary condition is when in some place of boundary we set different type of boundary condition than
in other.
1.3 Flow
∂u
+ ∇ (~v · u) = ∇(λ · ∇u) + qv
∂t
When in typical conservation law (1.10) we replace u with density ρ and we skipped mass diffusion and mass
source term (not physical) we will get mass conservation law (continuity equation)
∂ρ
+ ∇ · (ρ~v ) = 0 (1.14)
∂t
After adding assumption that density is constant ρ = const (almost all liquids and gasses with Mach number
less than 0.3) we get:
∇ · ~v = 0 (1.15)
When in typical conservation law (1.10) we replace u with ρ~v we will get momentum conservation equation.
In which diffusion of momentum is cause by internal forces given by Stress-Strain Correlation (1.16).
1 ∂ui ∂uj
Ḋij = + (1.17)
2 ∂xj ∂xi
∂ρ~v
+ ∇ · (~v × ρ~v ) = −∇ · (pI) + ∇ · 2µḊ + f~0 (1.18)
∂t
7
where µ[P a · s] is dynamic viscosity.
ρv1 ρv1 v1 ρv1 v2 ρv1 v3
∇ · (~v × ρ~v ) = ∇ [v1 , v2 , v3 ] × ρv2 = ∇ ρv2 v1 ρv2 v2 ρv2 v3 =
ρv3 ρv3 v1 ρv3 v3 ρv3 v3
∂ ∂ ∂ ∂ ∂ ∂ (1.19)
= (ρv1 v1 ) + (ρv1 v2 ) + (ρv1 v3 ) + (ρv2 v1 ) + (ρv2 v2 ) + (ρv2 v3 )+
∂x1 ∂x2 ∂x3 ∂x1 ∂x2 ∂x3
∂ ∂ ∂
+ (ρv3 v1 ) + (ρv3 v2 ) + (ρv3 v3 )
∂x1 ∂x2 ∂x3
Let’s consider equation (1.19 for x-direction.
∂~v
ρ + ρ~v · ∇~v = −∇ · (pI) + ∇ · 2µḊ + ρF~0 (1.21)
∂t
Sometimes we use equation (1.21) in other form(1.22.)
∂~v 1
+ ~v · ∇~v = − ∇ · (pI) + ∇ · 2ν Ḋ + F~0 (1.22)
∂t ρ
where ν is kinematic viscosity.
µ m2
ν= (1.23)
ρ s
Finally we have 4 equation written bellow:
2
∂ 2 vx ∂ 2 vx
∂p
ρ ∂v
∂t
x
+ ρv x
∂vx
∂x + ρv y
∂vx
∂y + ρv z
∂vx
∂z = − ∂x + µ ∂ vx
2 + 2 + 2 + fx
∂v ∂vy ∂vz
x
∂v ∂v ∂v ∂v ∂ 2v ∂ 2v ∂ 2v
y y y y ∂p y y y
∂t + ρvx ∂x + ρvy ∂y + ρvz ∂z = − ∂y + µ ∂vx2 + ∂vy2 + ∂vz2 + fy
ρ
(1.24)
∂vy ∂v ∂v ∂v ∂p ∂2v ∂2v ∂2v
ρ ∂t + ρvx ∂xy + ρvy ∂yy + ρvz ∂zy = − ∂y + µ ∂v2y + ∂v2y + ∂v2y + fy
x y z
∂vx ∂vy
∂vz
∂x + ∂y + ∂z = 0
8
1.3.1 Channel and pipe flow
• velocity inlet, pressure outlet (numerically most most stable pair of boundary conditions)
Sometimes in order to accelerate flow, external force term can be used to introduce fluid acceleration in channel.
Friction losses can be calculate with using equation (1.26)
9
1.3.2 Turbulence
(
∂~v
∂t + (~v · ∇) ~v = − ρ1 ∇p + ν∆~v + f~
(1.31)
∇ · ~v = 0
In turbulence modelling we are using average velocity and pressure. Additionally to simulate turbulence we
add turbulent viscosity µT to physical one µ. So as to model turbulence viscosity we can use for example k − ω
model or any other.
∂~v 1
+ ~v · ∇ ~v = − ∇p + ∇ · 2(µ + µT )Ḋ + f~
(1.32)
∂t ρ
• µ - dynamic viscosity
• ∇p - pressure gradient
• q=Q
m
A s - instantaneous flux, discharge per unit area, superficial velocity
µ ρ ~q
∇p = − ~q − · q2 · (1.36)
K K2 ||~q||
ϕ = const (1.37)
∇ · ~v = 0 (1.38)
10
When we put Darcy’s law (1.33) into equation (1.35) and apply divergence for both side we get:
1K
∇~v = − · ∇ · (∇p) = 0 (1.39)
ϕµ
Permeability doesn’t need to be a scalar value. It can also be a tensor for materials which have different perme-
ability in different direction (i.e. wood - diagonal terms).
K11 K12 K13
K = K21 K22 K23 (1.40)
K31 K32 K33
In porous media flow there aren’t any significant numeric issues. For interface tracking we can use:
• PLIC
• level set function
~q = −λ∇T (1.41)
T = T (~x, t) (1.43)
− (λ∇T ) · ~n + C · T |Γ = f −→ q = α (T − T∞ ) (1.45)
11
2 Lecture 2
∂ρcp T
+ ∇ (~v · ρcp T ) = ∇(k · ∇ρcp T ) + qv (2.2)
∂t
λ
where k = ρcp .
In most cases the equation can be simplified, as ρ = const and cp = const, and solved for T. However, if those
values are not constant, one should follow the following scheme:
2. solve for eT
4. calculate cp = f2 (T )
Let’s assume we are given a coupled problem of a solid and a fluid. In such cases always remember to apply
boundary conditions to the boundaries of the domain, not between the solid and the fluid. The interaction
between those two bodies will be represented in the equations.
qr = σST 4 (2.3)
where = 5, 67 · 10−8 mW
2 K 4 is the Boltzmann constant.
This means that each body will radiate thermal energy in every direction. Now, let’s imagine the body radiates
on to the surface. The energy will either be absorbed or reflected or transmitted.
α+ρ+τ =1 (2.4)
12
2.3 Heat transfer in porous media
Let’s consider that fig.2.3 shows a section of a larger structure, for instance a radiator. Instead of calculating
heat transfer of the radiator, we want to simplify it by porous media. To do so, we need to calculate equivalent
coefficients.
Firstly, let’s calculate the porousity, which is given by the porous area to total area ratio. In our case ϕ = 14
24 .
Assume we apply Dirichlet boundary conditions equal to 1 on the right hand side and 0 on the right hand side
of the structure. Comparing real case with porous one we obtain
∂T 1
|Q̇| = λx · · S = λx · · 6 (2.5)
∂x 4
1
|Q̇| = 2 · λ · ·1 (2.6)
5
Hence
4
λx = λ (2.7)
15
Analogously, we can calculate λy coefficient, if we apply boundary conditions equal to 1 on the upside and 0
on the downside of the structure.
1
|Q̇| = λy · · 4 (2.8)
6
1
|Q̇| = 2 · λ · ·1 (2.9)
10
Hence
3
λy = λ (2.10)
30
13
In this case, fluid is treated as an external source. Therefore
∂T ∂T
−∇(λx + λy ) = αSv (Tf − Ts ) (2.12)
∂x ∂y
aA + bB ⇐⇒ cC + dD (2.13)
where substrats are on the left hand side and products on the right hand side.
14
For instance, advection-diffusion equation for evaporation
∂ρH2 O
+ ∇ (ρH2 O · ~v ) = ∇(D · ∇ρH2 O ) + sH2 O (2.18)
∂t
νT
Where, in the case of turbulent flows, D = DT + Sct .
Such equations are stiff, therefore have to be integrated by special functions (ode15s etc).
Discretisation splits into two different things: discretisation of space and time, and discretisation of equations.
1D:
2D:
Delaunay triangulation:
3D:
15
• Delaunay triangulation works for 3D cases and generates tetra mesh
• mesh can be created with either tetra or bricks or everything
• everithing can be consistently subdivided into tetra
The main idea of the discretization is to switch from infinite dimensional function space to a finite set of algebraic
equations, which are computable for a computer.
du un+1 − un
= −λu −→ = −λun (2.19)
dt ∆t
A scheme that is
• stable
• consistent
is also convergent!!!
It’s essential to properly set mesh size where gradients are supposedly high. Otherwise we can get some devia-
tions from the solution, for example while calculating heat flux or friction force.
16
3 Lecture 3
In numerical methods it is necessary to calculate approximate values of function derivatives using values of
functions in some arbitrary chosen points in space. In order to obtain the most accurate approximation one
assumes that derivative of the function can be calculated as linear combination of values of analysed function
in certain points in space and uses Taylor series expansion to derive the proper coefficients. The procedure of
deriving that formula is as follows:
• Discretize space into set of points: xi = x0 + ij=1 ∆xi . The simplest discretization pattern assumes
P
regular spacing ∀i ∆xi = h. This spacing will be used in all further equations.
• Choose finite subset of points which you want to use to create the approximation scheme (for example
{xi−1 , xi , xi+1 }).
by substituting Taylor series expansion into the equation written above. System of equations to solve is
obtained from comparison of the lowest order terms.
a + b + c = 0
−ha + hc = 0
1 2 1 2
2h a + 2h c = 1
The most frequently used approximations of derivatives obtained from that scheme:
17
• First derivative central scheme:
df fi+1 − fi−1
=
dx i 2h
• Second derivative scheme:
d2 f fi+1 − 2fi + fi−1
2 =
dx i h2
In order to test implemented numerical method rigorously one should create convergence plots. Convergence
plot presents the dependence between the discretization described by parameter h (it’s often the time step size
or spatial mesh spacing) and the error norm ε. The most often used norms are:
• L2 − norm: sZ
ε = ||u − ū||2 = |u − ū|2 dΩ
Ω
• Maximum norm:
ε = ||u − ū||max = max(|u − ū|)
where u and ū denote numerical solution and exact solution respectively. As it can be seen from the equations
above in order to create convergence plots one needs the exact solution of the problem. Therefore convergence
plots are based on data form numerical solutions of problems that have well known analytic solution.
18
The order of numerical method is the number p for which:
ε ≤ Chp
where C is a constant number. According to that definition it’s possible to read the order of numerical method
from logarithmic convergence plot:
The order of numerical method is the slope of the line on that plot.
A good practice after creating a new geometry and a new mesh is conducting the mesh sensitivity/independency
study. It is analysis of dependency between some calculated values in your solution (for example forces, strains,
fluxes etc.) and parameters characterizing created mesh (for example cell sizes, spacing etc.). For enough
refined mesh computed values should not differ to much, but when the mesh is too coarse it is possible to
observe change of calculated value.
19
Figure 4: Example dependency between calculated force and mesh spacing
Plots such as this one seen above give information about parameters of the mesh which should be used in
created model. If one obtains many different results using different meshes then he should refine the mesh until
he obtains similar values.
q = K∇T
d2 T d2 T
∇ · q = ∇ · (K∇T ) = k1 + k2 =0
dx2 dy 2
It’s possible to convert this equation to:
d2 T d2 T
+ =0
dξ 2 dη 2
by performing simple substitution:
x(ξ) = ξ
y(η) = αη
20
q
where ξ and η are new variables and α = kk12 is a scalar constant. Therefore it’s possible to solve that equation
using standard Laplace equation solver. It’s not necessary to implement new one which enables conductivity
matrix input. After solving Laplace equation results have to be scaled to obtain the solution of anisotropic heat
convection.
In order to find the solution of that problem the matrix formulation has to be implemented:
u 5
1 0 0 0 ··· 0 1
−ν2 2ν2 −ν2 u2 f2
h h h
0 ··· 0
0 −ν2 2ν2 −ν2 0 .. ..
h h h . .
.. = ..
0 . .. . .. . .. 0
. .
−ν −ν
2ν
0 ··· 2 2 2 un−1
fn−1
h h h
0 ··· ··· 0 1 −1 un 0
21
The nonsingular linear system of equations with tridiagonal matrix has been created. It can be solved by tridi-
agolanl matrix algorithm or iterative solvers such as Gauss-Saidel method.
In this paragraph the stability of the finite difference method will be analysed on the example of advection
equation:
∂u ∂u
=a
∂t ∂x
The following convention of the notation is adopted: unj denotes value of function from the advection equation
in the spatial node number i in the n-th time step. The simplest finite difference discretization of the advection
equation called the explicit Euler method is as follows:
un+1
j − unj unj+1 − unj−1
=a (3.1)
∆t 2h
That scheme can be illustrated by a stencil:
This numerical scheme and other possible finite difference schemes are consistent, because they are derived
form Taylor series expansions, however it is not guaranteed they are stable and convergent. In order to check
the stability of numerical schemes it is necessary to conduct von Neumann stability analysis. At first assume
that exists decomposition of numerical solution:
Njn denotes the exact analytical solution in the discretization node and the εnj is the numerical error. Plugging
the decomposition [3.2] into [3.4] leads to conclusion that the numerical error satisfies the same equation [3.4]:
εn+1
j − εnj εnj+1 − εnj−1
=a (3.3)
∆t 2h
The numerical scheme is stable if and only if the error decreases in each iteration. The numerical error can be
decomposed using the Fourier’s function decomposition:
εnj = E(t)eikxj
22
where xj denotes the x coordinate of the j-th node. Assuming uniformly spaced nodes there hold equalities:
xj+1 = xj + h, xj−1 = xj − h. After substituting that decomposition into [3.3] the relation between εn+1
j and
εnj is as follows:
εn+1
j a∆t ikh a∆t
=1+ (e − e−ikh ) = 1 + i sin (kh)
εnj 2h h
εn+1
The scheme is stable if and ony if || jεn || < 1. Because ||1 + i a∆t
h sin (kh)|| ≥ 1 the explicit Euler scheme
j
is unconditionally unstable. The next possible scheme of discretization of advection equation is Implicit Euler
method:
un+1
j − unj un+1
j+1 − uj−1
n+1
=a (3.4)
∆t 2h
which can be represented graphically as:
Using the same procedure it is possible to prove that by contrast to Explicit Euler scheme the Implicit Euler
scheme is unconditionally stable. However in Implicit Euler scheme it is necessary to solve system of linear
equations to calculate the solution in the next time step. The other discretization scheme is the upwind scheme.
Assuming that a < 0 the upwind scheme is given by:
un+1
j − unj unj − unj−1
=a
∆t h
and can be represented by a stencil:
23
In case of a > 0 the upwind scheme has to be modified:
un+1
j − unj unj+1 − unj
=a
∆t h
The procedure of von Neumann stability analysis gives the condition of stability of the upwind scheme. It’s
called the Courant-Friedrichs-Lewy condition:
a∆t
<1
h
Most of numerical schemes used to solve more complicated equations than the advection equation are condi-
tionally stable. Therefore it’s highly recomended to conduct von Neumann stability analysis of the implemented
numerical procedures to create discretization which satisfies received conditions.
4 Lecture 4
Note the approximation made when summing both Cauchy development to form the discretization. In order to
have a true equality, we should have:
We can imagine that the second order coefficient (∆x)2 and (∆t)2 will converge quickly to zero when decreas-
ing the time and space steps, so we will neglect them. By rearranging it, we got:
24
∂uni ∂un 1 ∂ 2 uni 1 ∂ 2 uni
+a i + ∆t 2 + a∆x 2
+O((∆x), (∆t)) = 0
|∂t {z ∂x} |2 {z∂t } |2 {z ∂x }
advection equation dynamical response diffusive term
We observe that the non-neglected terms produce space diffusion or a dynamical response. The dynamical
response will be observed by numerically-created oscillations.
If this problem is just a test problem, you can solve the equation below instead to neutralize the diffusion term.
∂u ∂2u
a =ν 2
∂x ∂x
In the upwind scheme, we’ll use the direction of the information (± x) to choose whether we’ll use the element
on the right hand side or on the left hand side (figure 8). The dircretization becomes:
25
Figure 9: Different solutions of the advection-diffusion equation.
a∆x
The use of the central scheme for this equation requires P e = ν ≤ 2. Otherwise, it will create wiggles,
depicted on the figure 10 below.
Figure 10: Wiggles created by the central scheme in red and the real solution in black.
Because this condition is very hard to be satisfied, we better us the upwind scheme. However, the upwind
scheme produces numerical diffusion as we saw previously.
Let’s see now how the matrix looks like. If a > 0, then:
26
ν a 2ν a 2ν
− ui+1 + + ui − + ui−1 = 0
(∆x)2 ∆x (∆x)2 ∆x (∆x)2
| {z } | {z } | {z }
B A A
u1 1
1 0 0 0 ··· 0
−A A u2 0
B 0 ··· 0
... ...
.. .. .. .. ..
0 . . . . .· .. = ..
..
.. .. .. ..
.
. . . . . 0 .
B .. ...
.
0 ··· 0 −A A
0 ··· 0 0 0 1 un 0
27
Figure 12: Matrice for the differencial equation.
−4 1 0 ··· 0 1 0 ··· ··· 0
1 −4 1 0 0 ···
0 1 0 0
with D =
0 1 −4 1 0 and I = 0 0
1 0 0.
0 0 1 −4 1 0 · · · 0 1 0
0 ··· 0 1 −4 0 ··· ··· 0 1
Let a cell-centered FVM mesh be. Let’s call Ωv the volume (or surface in 2D) of one cell of the mesh and Γv
its surface (or perimeter in 2D).
∂u
+ ∇ · (~v · u) = ∇ · (λ∇u) + f
Z Z ∂t Z Z
∂u
dΩ + ∇ · (~v · u) dΩ = ∇ · (λ∇u) dΩ + f dΩ
Ωv ∂t Ωv Ωv Ωv
R
Let be |V | = Ωv dΩ. Then
Z
∂u ∂
dΩ = ū |V |
Ωv ∂t ∂t
Z
f dΩ = f¯ |V |
Ωv
According to the Gaussian theorem, with (f ) the faces or segments constituting Γv and |Af | the surface or
length of the face or segment f , we can write:
28
Z I
∇ · (~v · u) dΩ = ~n · (~v · u) dΓ — the convective flux
Ωv Γv
X
= n~f · v~f · uf |Af |
(f )
Z I
∇ · (λ∇u) dΩ = ~n · (λ∇u) dΓ — the diffusive flux
Ωv Γv
X ∂u
= λf · |Af |
∂n f
(f )
1. Nodes (coordinates)
2. Cells (connectivity matrix): link the node to the cells they belong
3. Neighbours: creating a matrix with each row i listing the neighbours of the cell i
OR
1. Nodes (coordinates)
With infinite precision, the FVM is conservative: the fluxes from one cell always goes to other (neighbouring)
cells.
We already have the node coordinates. Let’s take as example the mesh shown in the figure 13.
29
Figure 13: Example of a hexahedron mesh.
Node id Cells id
1 1
2 1 2 3
3 3 5
4 2 3 4 5
5 1 2 4
6 4
7 5
8 5
Table 1: Caption
For instance, in row 3 and 4, the cells that share those points have the id 3 and 5; the cells number 3 and 5 are
neighbours. In the same way, we observe that the nodes 2 and 4 are shared by the cells 2 and 3, which mean
they are neighbours. It is interesting to note that the points which are part of one cell only are useless in this
process and we can already count them in the boundary.
Let us take an example of two cells which have different thermal conductivity. Cell 1 has a thermal conductivity
of λlow and cell 2 λhigh (figure 14).
30
Figure 14: Two cells made of two different materials.
Our aim is to define the thermal conductivity on the shared face. A first intuition could be to interpolate by
assigning an average value:
λlow + λhigh
λf ace =
2
But this does not reflect the reality. Take a look to the example in figure 15.
Let set λ1 = 1 and λ1 = 5. Because the FVM is conservative, the heat flux through the shared face (Qf ) must
be equal to the one in the cell 1 (Q1 ) and 2 (Q2 ); the temperature distribution respects this conservation law.
With the interpolation, we would have:
31
∆T1 −5
Q1 = −λ1 = −1 =5
∆x 1
∆T2 −1
Q2 = −λ2 = −5 =5
∆x 1
λ1 + λ2 ∆Tf
Qf = − = −3 × −3 = 9
2 ∆x
We have to find another formula for the thermal conductivity at the face. Back to the general case presented in
figure 14, we’ll find:
Tf − T1 Q1 ∆x
Q1 = −λlow |Af | ⇒ Tf − T1 =
∆x/2 2|Af |λlow
T2 − Tf Q2 ∆x
Q2 = −λhigh |Af | ⇒ T2 − Tf =
∆x/2 2|Af |λhigh
T2 − T1 Qf ∆x
Qf = −λf |Af | ⇒ T2 − T1 =
∆x |Af |λf
T2 − T1 = (T2 − Tf ) + (Tf − T1 )
Qf ∆x Q2 ∆x Q1 ∆x
⇒− =− −
|Af |λf 2|Af |λhigh 2|Af |λlow
1 1 1 1
⇒ = +
λf 2 λhigh λlow
If we verify this new formula on the example depicted on figure 15, we got:
1 1 1 1 3 5
= + = 0.6 = λf =
λf 2 λ2 λ1 5 3
∆Tf 5
Qf = −λf = − (0.5 − 3.5) = 5
∆x 3
We finally found an expression for the thermal conductivity on the face which satisfies the conservation law
Q1 = Q2 = Qf .
32
5 Lecture 5
We will use Advection-Diffusion equation with implicit and upwind scheme of discretization.
Z Z
~nf ~vf uf dΓ − ~nλ∇uf dΓ = 0 (5.1)
Γv Γv
After applying discretization, we get:
X X ∂u
~nf ~vf uf |Af | − λf |Af | = 0 (5.2)
∂n f
(f ) (f )
In order to apply implicit upwind scheme into equation (5.2) we need to make sure that.
X X X uN,f − ui
max(0, ~np~vp )ui |Af | + min(0, ~np~vp )uN,f |Af | − λf |Af | = 0 (5.3)
d~N,f
(f ) (f ) (f )
f
Where uN,f is the value from the neighboring cell on a certain face, and d~N,f is the distance to the neighboring
centroid.
max(0, ~np~vp ) + λ |Af | ui + min(0, ~np~vp ) − λ |Af | uN,f = 0
X X
~ ~ (5.4)
(f ) dN,f (f ) dN,f
33
5.2 Gradient calculation and reconstruction
di,N
• Gauss Procedure
• QUICK Scheme
34
5.3 Checkerboard pressure problem and staggered grid concept
div ~v = 0 (5.9)
In most cases, when discretizing pressure, we would store it at the same point as velocity. However, it would
cause a singularity in the problem which means an algorithm is wrongly defined.
Typically we would transfer the place of storing velocity creating a staggered grid.
35
Figure 21: Staggered Grid 2-D
∂ 2 vx ∂ 2 vx
∂vx ∂vx ∂vx 1 ∂p
+ vx + vy =− +ν + (5.10)
∂t ∂x ∂y ρ ∂x ∂x2 ∂y 2
M · vx + C · vx = −Sx · p − D · vx (5.11)
Where:
• C - convection matrix
36
• S - matrix applied to pressure
• D - diffusion matrix
M +C +D 0 Sx vx Fx
0 M + C + D Sy vy = Fy (5.12)
SxT SyT 0 p 0
Sx
B= (5.14)
Sy
C = BT (5.15)
Now formula (5.12) is written as:
A S u F
= (5.16)
C 0 p 0
(
Au + Bp = F
(5.17)
Cu = 0
We can use the first equation from (5.16) to analytically calculate what is u.
When we already have u we can plug it into the second equation from (5.16).
37
Let’s make an initial guess of pressure p∗ , and then we will calculate the initial guess of velocity u∗ . We will
constantly improve these guesses.
u∗ = A−1 (F − Bp∗ ) (5.22)
We will assume that the correct physical value is the sum of the initial guess and some correction marked with
the upper index 0 .
u = u∗ + u0 (5.23)
p = p∗ + p0 (5.24)
(
Au0 + Bp0 = 0
(5.25)
C(u∗ + u0 ) = 0
Now let’s introduce the most important approximation in the SIMPLE scheme. This approximation replaces
matrix A with matrix D where D = diag(A).
Physical interpretation of this approximation in the finite volume method is that it neglects some portion of
diffusion from neighboring cells.
u0 = −D −1 Bp0 (5.27)
u = u∗ + βu0 (5.31)
38
5.6 Finite Element Method: Intuitive introduction to the idea of Finite Element
4
X
u(x, y) = Ui Ni (x, y) (5.32)
i=1
~a · ∇u = ν∆u + f (5.33)
39
We will multiply the equation (5.33) by any arbitrary function v.
~a · ∇u · v = ν∆u · v + f · v (5.34)
Now, we will integrate the equation (5.34) over the whole domain.
Z Z Z
~a · ∇u · vdΩ = ν∆u · vdΩ + f · vdΩ (5.35)
Ω Ω Ω
v = const (5.36)
∇ · (∇u · v) = ∆u · v + ∇u · ∇v (5.37)
After applying the equation (5.37), we get:
Z Z Z
ν ∆u · vdΩ = ν ∇ · (∇u · v)dΩ − ν ∇u · ∇vdΩ (5.38)
Ω Ω Ω
Now we can put the formula (5.38) into the equation (5.35).
Z Z Z Z
~a∇u · vdΩ + ν ∇u · ∇vdΩ = f · vdΩ + ν ~n · ∇u · vdΓ (5.39)
Ω Ω Ω Γ
In the 1-D case, the equation (5.39) would look like this.
L L L
Z Z Z
∂u ∂u ∂v ∂u ∂u
a · vdx + ν · dx = f · vdx + ν ·v −ν ·v (5.40)
0 ∂x 0 ∂x ∂x 0 ∂x x=L ∂x x=0
The most important advantage of this formulation (5.39) - weak form, is that the second derivative in our
equation disappeared.is that the second derivative in our equation disappeared.
6 Lecture 6
For the sake of example we consider one-dimensional Poisson equation in weak form. The method of trans-
forming differential equations into the weak form was presented in the previous chapter.
Z Z
∂u ∂v ∂u x=L
dΩ = f v dΩ + v (6.1)
Ω ∂x ∂x Ω ∂x x=0
In order to derive finite elements method the solution domain has to be discretized into n elements and n + 1
nodes:
40
We assume that the x coordinate of the left boundary is xa = 0, the right x coordinate is xb = L and the sizes
of elements are all equal to ∆x = Ln . In the next step a set of test functions (also called shape functions) has to
be defined. The most common choice of test functions is defined as follows:
0 if x < (j − 1)∆x
x
∆x − (j − 1) if (j − 1)∆x ≤ x < j∆x
ϕj (x) = x (6.2)
− ∆x + (j + 1) if j∆x ≤ x < (j + 1)∆x
0 if x ≥ (j + 1)∆x
The plot of that shape function for node number j = 4 is presented below:
The other sets of test functions can be chosen, but they have to be the partition of unity. The numerical solution
is represented via nodal values uj and the test functions ϕj (x):
N
X
u(x) = uj ϕj (x)
j=1
41
The set of discretized equations is obtained by evaluating integrals in equation [6.1] with test functions plugged
as v into that equation and numerical solution plugged as u:
Z X N Z X N
∂ϕj ∂ϕi
uj dΩ = Fj ϕj ϕi dΩ (6.3)
Ω ∂x ∂x Ω
j=1 j=1
In the equation above Fj denotes the value of source term in j-th node. When test functions defined in [6.2]
are used the boundary term in the discretized equation cancels out. In most cases the values of Fj are known
explicitly. Thus the [6.3] is a system of linear equations where the uknowns are uj . In order to solve that problem
R ∂ϕ
the diffusion matrix with coefficients Dij = Ωi ∂xj ∂ϕ i
∂x dΩ has to be assembled. When local test functions are
used the only test functions which supports have nonzero measure intersection with the i-th element are test
function of the nodes adjacent to that element. Therefore the easiest way to assemble diffusion matrix is creating
the local matrices for each element separately and then assembling them into the global diffusion matrix. The
local matrices represent the components of the global diffusion matrix ensuing from integration of right hand
side of [6.3] over the i-th element: Z
∂ϕi ∂ϕi
d11 = dΩ
Ωi ∂x ∂x
Z
∂ϕi ∂ϕi+1
d12 = dΩ
Ωi ∂x ∂x
Z
∂ϕi+1 ∂ϕi+1
d22 = dΩ
Ωi ∂x ∂x
As it comes form the equations above the local diffusion matrices are symmetric.
After local diffusion matrices are created they have to be assembled into global diffusion matrix. In order to do
that elements of all local matrices have to be added to the initially all zero global matrix. Elements of i-th local
matrix are added to the global matrix following the scheme:
Dii = Dii + d11
Di,i+1 = Di,i+1 + d12
Di+1,i = Di+1,i + d21
Dii = Dii + d22
This scheme hold if the nodes and elements numbering scheme is consistent with this presented on figure 24.
42
Otherwise if the elements are not numbered ascendingly, but they belong to the set of indexes I = {i1 , ..., in }
for elements and J = {j1 , ..., jn+1 } for nodes, the local matrix for ik -th element are defined as:
Z
∂ϕjk ∂ϕjk
d11 = dΩ
Ωi ∂x ∂x
k
∂ϕjk ∂ϕjk+1
Z
d12 = dΩ
Ωik ∂x ∂x
∂ϕjk+1 ∂ϕjk+1
Z
d22 = dΩ
Ωik ∂x ∂x
Elements of ik -th local matrix have added to the global matrix following the scheme:
The derivation of FEM in previous two chapters was done using equaivalently spaced subdivisions of the do-
main. In general the subdivisions in 1D and the shapes of elements in 2D or 3D are not identical. Thus the
different shape functions have to be defined in each element. It’s not efficient to store data of different shape
functions in each element. Therefore the other idea is employed. The one reference element and it’s shape
functions are defined. Then the shape function in each element are calculated using the mapping from reference
element to real element from mesh. The equation defining that mapping is the same for all elements and it
depends on coordinates of element points. The general formula for that mapping is:
−
→ −
→
x =−
→
x(ξ ) (6.4)
−
→
where −→
x denotes the coordinates of the element form mesh and ξ denote the coordinates of reference element.
The mappings from the equations above are defined via coordinates of the nodes of elements {Xi , Yi , Zi } and
the shape functions of reference element.
X −
→
x= Xj ϕj ( ξ )
(j)
X −
→
y= Yj ϕj ( ξ )
(j)
X −
→
z= Zj ϕj ( ξ )
(j)
43
−
→
That transformation is easy to perform if reference coordinates ξ = (ξ, η, ζ) are known. However if it’s
necessary to calculate −→
x = (x, y, z) coordinates the set of equations has to be solved. In case of nonlinear
shape functions this system of equations is nonlinear. The derivatives of shape functions that occur for example
in diffusion matrix derivation are then calculated via chain rule:
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂x ∂ξ ∂x ∂η ∂x ∂ζ ∂x
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂y ∂ξ ∂y ∂η ∂y ∂ζ ∂y
∂ϕi ∂ϕi ∂ξ ∂ϕi ∂η ∂ϕi ∂ζ
= + +
∂z ∂ξ ∂z ∂η ∂z ∂ζ ∂z
In order to compute integrals from [6.3] after transformation of shape functions and their derivatives to coordi-
nates ξ, η, ζ of reference element also volume element has to be transformed. That transformation is multipli-
cation of volume element by Jacobian of transformation [6.4].
∂xi
dΩ = dx dy dz = det( ) dξ dη dζ
∂ξj
The general formula for weak form of Poisson equation in case of one dimensional transformation is:
Z N Z N
X ∂ϕj ∂ξ ∂ϕi ∂ξ ∂xi X ∂xi
uj ( )( ) det( ) dΩ = Fj ϕj ϕi det( ) dΩ
Ωref j=1 ∂ξ ∂x ∂ξ ∂x ∂ξj Ωref j=1 ∂ξj
The matrix coefficients in FEM are obtained via calculation of integrals of shape functions and their derivatives.
It’s clear that the accuracy of that method strongly depends on chosen numerical scheme for approximation of
integrals. The most accurate and computationally efficient algorithm is the Gaussian integration. It approxi-
mates the integral by:
Z b p
∼
X
f (x) dx = wi f (xi )
a i=1
where xi denote set of points in the interval a, b and (wi ) denote respective coefficients defined for that
interval. The gaussian quadratures are derived in a way that quadratures using p points should integrate with
infinite accuracy polynomials with degree up to 2p − 1. Therefore if shape functions are polynomialsgaussian
quadratures allow
to integrate
them with accuracy of computers finite arithmetic error. Each interval a, b can
be mapped into − 1, 1 . Thus it’s possible to evaluate any integral on that standard interval. The coefficients
44
wi for integral on standard interval can be found in engineering tables. Analogously surface and volumetric
gaussian quadratures are defined on standardized ploygons and polyhedra.
Z p
f (~x) dΩ ∼
X
= wi f (x~i )
Ω i=1
The finite elements method is the discretization of the weak form of partial differential equation problem. In
the Poisson equation is analysed. In two dimensions the weak form of that equation is:
Z Z Z
∇u · ∇v dΩ = f v dΩ + ν ∇u · ~nv dΓ (6.5)
Ω Ω Γ
where q is given function. After substitution of that boundary condition into [] the weak formulation of the
Poisson equation is: Z Z Z
∇u · ∇v dΩ = f v dΩ + qv dΓ
Ω Ω Γ
if the boundary integral is omitted it means that the zero Neumann condition is implemented (in case of q ≡ 0
that boundary integral is equal to zero). The general form of the discretized equation can be written as:
X
Dij uj = fi i = 1, ..., n (6.6)
j
R
where Dij denotes the diffusion matrix, uj denotes the nodal values of searched function and fi = Ω f ϕi dΩ
is the right hand side of discretized equation. The nonzero Neumann boundary condition is imposed by adding
to each element of right hand size vector fi the value of boundary integral:
Z
qϕi dΓ
ΓN
where ΓN denotes the subset of boundary Γ where Neumann boundary condition is imposed. Because the shape
functions are local the integration form expression above has to be done only on boundary surfaces (in 2D on
boundary sections) which are adjacent to the i-th node.
45
6.5.2 Dirichlet boundary conditions
The Dirichlet boundary condition imposes value of demanded function u in certain subsets of the domain. In
terms of discretized solution it means that values of the function u have to be fixed in some nodes. Thus the
values in the certain subset of m chosen nodes labeled with global indexes: K = {k1 , ..., km } are no longer the
unknowns. The modifications of diffusion matrix and right hand side vector from [6.6] that imply numerical
Dirichlet condition on nodes with indexes from K are as follows:
• Values in rows with numbers kl where l ∈ 1, ..., m and kl ∈ K = {k1 , ..., km } which are initially
Dkl ,j : j ∈ 1, ..., n have to be replaced with δkl ,j : j = 1, ..., n where δkl ,j denotes the Kronecker delta.
• Values in right hand side vector indexed with numbers kl where l ∈ 1, ..., m and kl ∈ K = {k1 , ..., km }
which are initially fkl : j ∈ 1, ..., n have to be replaced with imposed Dirichlet boundary condition values
ukl : l ∈ 1, ..., m : kl ∈ K = {k1 , ..., km }.
It’s worth noting that despite the modified diffusion matrix is no longer symmetric the Krylov subspace solvers
such as Conjugate Gradient Methods still converge to the desired solution.
In the equation above u∞ is the constant value and ΓR is the subset of the domain’s boundary on which the
Robin’s boundary condition is imposed. The implementation of Robin boundary condition is similar to imple-
mentation of Neumann boundary condition. The equation [6.5.1] can be transformed by substitution of [6.7]
into: Z Z Z Z
∇u · ∇v dΩ = f v dΩ − c uv dΓ + c u∞ v dΓ (6.8)
Ω Ω ΓR ΓR
Pn
The discretization of second term on the right hand side of the equation above using the u = i=1 ui ϕi and
v = ϕi can be expressed as:
Z X n
ϕi ϕj uj dΓ
ΓR j=1
it equals:
n
X
Mij uj
j=1
46
Therefore it means that numerical Robin boundary condition modifies diffusion matrix by adding to it the matrix
M.
Dmodif ied = D + M
The discretization of third term in the equation [6.8] is:
Z
hi = c u∞ ϕi dΓ
ΓR
The right hand side vector of equation [6.6] has to be modified as follows:
fmodif ied = f + h
7 Lecture 7
In reference elements Gaussian quadratures are defined, so it’s more convenient to integrate inside them.
A quad element extends from -1 to 1 in both xi and eta directions. The local numbering of nodes is counter-
clockwise, starting from the node in (-1, -1). The following shape functions are given for the reference quad
element:
1
ψ1 = (1 − ξ)(1 − η)
4
47
1
ψ2 = (1 + ξ)(1 − η)
4
1
ψ3 = (1 + ξ)(1 + η)
4
1
ψ4 = (1 − ξ)(1 + η)
4
A triangular element extends from 0 to 1 in both xi and eta directions. Similarly to quad element, the numbering
of local nodes is counterclockwise, starting from the node in (0, 0). The following shape functions are given for
the reference triangular element:
ψ1 = 1 − ξ − η
ψ2 = ξ
ψ3 = η
In order to develop higher order elements, additional shape functions associated with midnodes are added.
Previously calculated shape functions do not hold anymore, so new ones have to be derived. As linear functions
are no longer desired, we have to add components with η 2 , η · ξ, ξ 2 . The general form of a shape function is:
ψ = a + bξ + cη + dξ 2 + eξη + f η 2 (7.1)
48
Obviously, the coefficient a,b,c,d,e,f are the unknowns, and we have to find them in such a way, that for each
node, the shape function is 1 in the node and 0 in the other nodes. So what we come up with is a linear system
of equations, which should be solved for each node.
Let’s go back to the assembly of the global matrix for a diffusion problem in 2D and let’s see what happened
to the transformation of the geometry and the transformation of the gradient to the reference domain. What we
need to discretise is something like that
Z Z
∇u · ∇vdΩ = ∇u · ∇v|J|dΩref (7.3)
Ωe Ωref
P
Remind that u = (j) Uj ψj (ξ, η) The gradient of u:
h ∂u ∂u i h ∂u ∂ξ ∂u ∂η ∂u ∂ξ ∂u ∂η i
∇u = , = + , + (7.4)
∂x ∂y ∂ξ ∂x ∂η ∂x ∂ξ ∂y ∂η ∂y
Gradient of v can be calculated analogically. Now, what we have to calculate is ∇u∇v.
∂u ∂ξ ∂v ∂ξ ∂u ∂η ∂v ∂ξ
∇u · ∇v = · + · +
∂ξ ∂x ∂ξ ∂x ∂η ∂x ∂ξ ∂x
∂u ∂ξ ∂v ∂η ∂u ∂η ∂v ∂η
+ · + · +
∂ξ ∂x ∂η ∂x ∂η ∂x ∂η ∂x
∂u ∂ξ ∂v ∂ξ ∂u ∂η ∂v ∂ξ
+ · + · +
∂ξ ∂y ∂ξ ∂y ∂η ∂y ∂ξ ∂y
∂u ∂ξ ∂v ∂η ∂u ∂η ∂v ∂η
+ · + · =
∂ξ ∂y ∂η ∂y ∂η ∂y ∂η ∂y
(7.5)
∂u ∂v ∂ξ ∂ξ ∂ξ ∂ξ
= + +
∂ξ ∂ξ ∂x ∂x ∂y ∂y
∂u ∂v ∂ξ ∂η ∂ξ ∂η
+ + +
∂ξ ∂η ∂x ∂x ∂y ∂y
∂u ∂v ∂η ∂ξ ∂η ∂ξ
+ + +
∂η ∂ξ ∂x ∂x ∂y ∂y
∂u ∂v ∂η ∂η ∂η ∂η
+ +
∂η ∂η ∂x ∂x ∂y ∂y
Let’s substitute
∂ξ
= λ11
∂x
∂ξ
= λ12
∂y
49
∂η
= λ21
∂x
∂η
= λ22
∂y
λ11 λ12
The matrix is the Jacobi of the transformation from the physical space to the reference. In general
λ21 λ22
it’s not easy to compute, as there is a nonlinear relationship between the spaces. Jacobi matrix of the inverse
transformation is the inverse of the matrix of the origin transformation.
Working only with linear elements for solving Navier Stokes equation will always be unstable. The most
common solution for this issue is to define two different function spaces for the representation of velocity and
50
pressure. Many different pairs have been investigated in terms of their stability, and the most common one is
to have linear elements for pressure field and second order elements for velocity field (Q2P1, see fig. 30).
The condition, which tells whether a given pair will be stable, is called LBB condition or inf-sup condition.
In the upwind scheme in finite difference and finite volume methods, all information downstream the node
is neglected, and only the information upstream is considered. We want to do the same in FEM. The most
popular approach is to add some constant to the shape function upstream the node, and subtract the same value
downstream. Such test functions can be easily calculated.
ṽ = v + τ~a · ∇v (7.8)
Similarly to the FVM. the upwind scheme adds some diffusion, thus we want to keep the τ coefficient low, but
on the other hand high enough to keep the calculations stable.
51
Figure 31: SUPG method
Methods such that different shape and test functions are used are called Petrov-Galerkin methods (Streamline
Upwind Petrov Galerkin method is presented in the fig. 31).
If you want to implement 7.8 into 7.7 equation, additional terms are generated, so you should probably use
more gaussian quadrature points. The approach in which all v are replaced with ṽ is called Consistent SUPG.
However, replacing v only in the convective term also stabilises the equation.
∂~u 1
+ ~u · ∇~u = − ∇p + ν∆~u (7.9)
∂t ρ
In order to obtain the weak form we have to add v function.
Z Z Z Z
∂~u 1
· ~v + ~u · ∇~u · ~v = − ∇p · ~v + ν ∆~u · ~v (7.10)
Ω ∂t Ω ρ Ω Ω
The convective term is nonlinear. Nonlinear equations are typically solved by dividing them into a set of linear
subproblems. Assembling the matrix for Navier Stokes equation one has to assume some advection velocity,
usually it is the velocity from the previous iteration. Now the convection term looks like the following
Z
˜ · ~v
~u · ∇~u (7.12)
Ω
52
The first term will generate mass matrix in the following way
Z XZ
∂~u
· ~v = (ψj ψi )U~j (7.13)
Ω ∂t (j)Ω
In FEM, we want to transform the pressure term, because linear interpolation is used, which means that cal-
culating the gradient of pressure would yield constant gradient across the element. However, since we have
second order elements for velocity, we also work with second order test functions, so calculating the gradient
of v would give us a linear function. So the following thing is done
Z Z Z Z Z
1 1 1 1 1
∇p · ~v = ∇(p · ~v ) − p · ∇~v = ~n · p · v − p · ∇~v (7.14)
ρ Ω ρ Ω ρ Ω ρ Γ ρ Ω
So finally we obtain
Z Z Z Z Z Z
∂~u ˜
· ~v + ~u · ∇~u · ~v + ν ∇~u · ∇~v − p · ∇~v = − ~n · p · v + ν ~n · ∇~u · v (7.15)
Ω ∂t Ω Ω Ω Γ Γ
The scheme is always implicit, as the mass matrix is 3x3 with ψj ψi at every place. What has been come up
with is called matrix lumping, which means that all elements of the row are added to the main diagonal. Then,
one can use explicit formulas. Matrix lumping is used for some preconditioners.
Usually, we apply zero velocity at the walls, zero pressure at the outlet and some given velocity at the intlet.
For open boundary condition we apply
1
− p~n + ν∇ · ~u · ~n = p(t)~n (7.16)
ρ
Which is exactly the same as the last two terms of the equation 7.15. The right hand side is the average pressure
at the boundary, so if you want to implement outlet boundary condition, you don’t have to implement anything
at the rhs of 7.15.
53
7.3.5 Vector notation
M+D+C px ux
M+D+C py uy
p
7.3.6 Nonlinearity
Problem with potential field ∆u = 0 can easily be solved using Boundary Element Method. Let’s assume we
don’t have a prescribed domain and let’s write Laplace equation in polar coordinates for 2D.
∂2f 1 ∂f 1 ∂2f
∆u = + + (7.19)
∂r2 r ∂r r2 ∂θ2
Harmonic functions are basically functions that fulfull this equation everywhere. There are many such func-
tions. In 3D one can easily prove that Φ = 1r satisfies the Laplace equation. In 2D case Φ = ln |r| is a harmonic
function.
The idea of the Boundary Element Method is the following. Let’s assume we are given some geometry with
a hole inside and we are interested in solving the Laplace problem everywhere inside. First we need to intro-
duce space discretisation (see fig. 34), which in this case is introducing the boundary elements. Now we have
54
to associate some source functions, for example Φ = ln |r| in 2D. If you draw ’streamlines’ of such a func-
tion, it generates flux radially. It satisfies the Laplace equation because the flux is extremely high where the
circumference is extremely low, and the other way around.
It conserves well, with one singularity exactly at the center. That’s why we don’t want the center of those
functions inside our domain. So the Boundary Element Method assumes that the source function ought to be
located a bit away of the panels. The next step is to introduce control points, which can lay on the boundary.
Then we will have Φj (~r = Aj · ln |~r − r~js | assuming that j is the index of the panel. We can apply dirichlet
boundary conditions v. The solution will the be following.
X
u(~r) = Aj Φj (~r) (7.20)
(j)
55
The matrix generated in such a way will always be full, as you couple every boundary elements with all other
elements. The nice thing is that domain discretisation is not necessary, so you have massively fewer elements.
The simplest choice is to write the equation this way
X
Aj Φj (xi , yi ) = vi (7.21)
(j)
7.5.1 Timestepping
7.5.2 Linearization
One of the techniques is called Picard linearization and is based on using the term from the previous time step.
Another technique is Newton-Raphson method. It takes some approximate solution, then it uses Taylor expan-
sion f (x + h) = f (x) + h · f 0 (x). Now the idea is to move in the f 0 direction by h such that the result will be
0. So h = − ff0(x i)
(xi ) and the new xi+1 = xi + h. The method should converge really quickly, however, it may
also diverge.
In the case of vector functions, you have to solve ∇F~ (~x) · ~h = −F~ (~x), where ∇F~ (~x) is the Jacobi matrix.
~ = x~i + ~h.
Then xi+1
In CFD it is common to have some problematic source terms. For instance, you may want to solve such a
problem,
∆u = u5 (7.24)
56
where the source term is associated with the function and highly nonlinear. Some of the ideas about how to deal
with this issue
• underrelaxation
• linearize u5 = u4 · u and then the equation will be (∇ + u4 ) · u. Obviously, the u is some approximation,
for which we can use the solution from the previous time step, but this approach is far more stable than
having it on the right hand side. You can also use underrelaxation here.
• Newton-Raphson
The Newton-Raphson method will converge faster, but underrelaxation will have better convergence radius.
7.5.3 Limiters
Sometimes you deal with physical problems that you know that the solution must be within certain limits. One
of the naive ways is, for instance, if the solution should not be below 0, let’s assign 0 or 1e-10. The main
drawback of that is that it’s not conservative.
Another option is to apply flux limiters, so that everything that comes out of the calculations is within the limits.
Some heat transfer theory and practice will be discussed hereafter. The radiation however will not be described.
Conduction:
~q = −λ∇T
−
→
λ = λ(T, X
|{z} )
if anisotropic
with ~q the heat flux in [W ], λ the thermal conductivity in [W.m−1 .K −1 ] and T the temperature in [K]. It is
interesting to have some reference value in mind for the thermal conductivity since it varies a lot between the
materials (figure 35) and as a function of temperature (36).
57
Figure 35: Thermal conductivity as a function of materials
58
• Dirichlet: TBC = V alue
∂T
• Neumann: ∂X BC
= V alue
∂T
= α(T − T∞ ), with α the thermal conductivity of the interface in [W.m−1 .K −1 ] and
• Robin: λ ∂X BC
Tinf ty the reference temperature
Convection:
q = α(Tw − T∞ )
α = α(ρf , cp,f , νf , λf , Re, Tf , ...)
with α the convective heat transfer coefficient [W.m−1 .K −1 ], Tw the temperature of the wall, ρf the density
of the fluid [kg.m−3 ], cp,f its specific heat capacity [J.kg −1 .K −1 ], νf its kinematic viscosity [m2 .s−1 ], λf its
thermal diffusivity [m2 .s−1 ], Re the Reynolds number of the fluid flow [∅].
• Reynolds: Re = u.L
ν with u the velocity [m.s−1 ], L the reference length [m]
[convection] αf .L
• Nusselt: N u = [conduction] =
λf , with αf the convective heat transfer coefficient of the fluid [W.m−1 .K −1 ]
and λf its conductivity [W.m−2 .K −1 ]
• Prandtl: P r = νa , with a = λ
ρ.cp the thermal diffusivity [m2 .s−1]
[advection] u.L
• Peclet: P e = [dif f usion] = Re.P r = α
• Rayleigh: Ra = Re.P r
[buoyancy] g.L3 .β(Tinf ty −Tw ) 1
• Grashof: Gr = [viscosity] = ν2
, with β = Tf
α .L
• Biot: Bi = λf s , with αf the convective heat transfer coefficient of the fluid and λs the thermal conduc-
tivity of the solid (figure 37)
59
Figure 37: Temperature distribution (in green) as a function of the Biot number
We can do an analogy between heat transfer and electricity which will help us to calculate approximate solutions
and heat coefficients.
Let us take a few examples to show the power of this point of view.
60
Figure 38: Two bodies in parallel in which the conserved heat flux q goes through can be compared to two
resistors in parallel in which a conserved intensity I goes through.
Figure 39: Two bodies in series in which the conserved heat flux q goes through can be compared to two resistors
in series in which a conserved intensity I goes through.
61
1 P 1 P 1
In the parallel case (figure 38), we have Rtot = i Ri = i δ . In the series case (figure 40), we’ve got
λi .Ai
Rtot = i Ri = i λi δ.Ai .
P P
Figure 40: Example of the analogy between the heat transfer and the electric current.
In this example, we consider a battery cell, surrounded by air, mounted on a cooling plate where a cooling
fluid flows in. There are two ways the heat can go from the cell (we consider the temperature of the cell being
stored in its center): the first one from the cell to the fluid through the cooling plate and two interfaces and the
second one from the cell to the surrounding air through one interface. Hereafter the scheme of the case and the
equivalent electrical circuit (figure 41).
62
Figure 41: Example of the analogy between the heat transfer and the electric current: a battery.
where:
• R1 = Rc2 + Rair is the equivalent resistance for the heat transfer from cell to air
• R2 = Rc1 + Rc−cp + Rcp + Rf is the equivalent resistance for the heat transfer from cell to cooling fluid
63
Parameter Value
A 2.10−3 m2
Xcp 0.02 m
Xc 0.05 m
λc 10 W.m−1 .K −1
λair 5 W.m−1 .K −1
λc−cp
αc−cp αc = 1050−4 = 5.105 W.m−2 .K −1
αcp 5.103 W.m−2 .K −1
We can now calculate the equivalent resistance for each heat transfer.
Xc 1
R1 = + = 41.67 K.W −1
λc .3A αair .3A
Xc 1 Xcp 1
R2 = + + + = 2.651 K.W −1
λc .A αc−cp .A λcp .A αf .A
1 1 1 R1 .R2
= + ⇒ RF U LL = = 2.492 K.W −1
RF U LL R1 R2 R1 + R2
RzRED = min{R1 , R2 } = 2.651 K.W −1
The resistance R1 being equal to 41.67 means that, in order to have a heat transfer of 1 W , we need to have
a temperature difference Tc − Tf equal to 41.67 K. The resistance RF U LL is resistance considering the two
resistance R1 and R2 being in parallel and considering a unique heat flux QF U LL from the cell to the outside.
Question: Can we simplify our model by omitting one heat transfer? Here, can neglect the cell-air transfer and
what would be the error?
R1
≈ 16
R2
The result of the previous fraction gives us the information that the resistance to the heat transfer between cell
and air is 16 times higher than the on to the heat transfer between cell and cooling fluid with a same temperature
difference. In other words, if Tf = T air, only 1 Watt would be transferred from the cell to the air while
there would be 16 Watts from the cell to the cooling fluid. The cooling fluid being even colder than the air,
we can choose not considering the heat transfer from cell to air which leads to adiabatic cell walls. With this
1
assumption, the error would therefore be = 16 × 100 = 6.25%.
64
8.4 How to calculate the thermal conductivity at the interface?
Let us take the example of a fluid flowing through a pipe and consider the heat transfer between both (figure
42). The values are the following (table 8.4):
Parameter Value
L 10 m
d 30.10−3 m
ṁ 0.5 kg.s−1
Tw 90 ◦ C
Tf,inlet 60 ◦ C
with Tf the temperature of the fluid near the wall. Now, to calculate the thermal conductivity at the interface,
we will loop over 3 steps:
3. Find the proper correlation: table in a book which corresponds to our case, Re, ...
0.25
ν¯f = 0.021.Re0.8 .P r 0.43 . P rf .L = 201.08, with L a constant depending on Ld . Here, L ≈ 1.
f f P rw
N¯u .λ
ᾱ = f f
d = 4497.5 W.m−1 .K −1
This ᾱ means that, each square meter, for 1 Kelvin temperature difference between wall and fluid, there
will be 4497.5 Watts transferred from the wall to the fluid. But we have to keep in mind that the heat
capacity of the water is almost this value too, which means it has to receive this amount of energy to be
heated up by only one Celsius degree.
65
To calculate the average temperature of the stream, the following method can be used:
A hot fluid is flowing inside this quencher of diameter d. Heat is transferring to the outside through the walls
of width δ (figure 43).
66
Parameter Value
uf 10 m/s
d 3m
δ 2.10−3 m
Tf −20 ◦ C
TR 90 ◦ C
Tw 0.5(Tf + TR ) = 35 ◦ C
λw 550 W.m−2 .K −1
We’ll proceed to two steps to calculate the thermal conductivity at the wall.
If we now take the steal wall thickness into account, the thermal conductivity of the wall becomes:
αmodif = 1 +1 δ = 20.78 W.m−1 .K −1
ᾱ λw
In this case, ᾱ ≈ αmodif . In our model, we could therefor neglect the thickness of the wall.
A hot cylindrical battery cell of radius r and height L is cooled down by the surrounding air; the thermal
conductivity at the wall is the unknown α (figures 44 and 45).
67
Figure 44: Heat exchange between a cylindrical battery cell and the air outside.
Figure 45: Definition of some temperature: Tw the temperature of the solid wall, Tf the temperature of the fluid
close to the wall, Tinf = T∞ the reference temperature of the fluid.
Parameter Value
L 0.05 m
Circ 2πr = 0.02 m
T∞ 20 ◦ C
Tw ? ◦C
1 ◦
Tf 2 (Tw − T∞ ) =? C
68
Same as previously, we’ll proceed to two steps to calculate the thermal conductivity at the wall.
1. First, we give an initial value for the thermal conductivity of the wall: αinit = 5 W.m−2 .K −1
Q ◦
Q = 1.47 W = α.S.∆T ⇒ ∆T = αinit .S = 20 C
∆T = Tw − T∞ = 20◦ C ⇒ Tf = 12 (2T∞ + 20) = 30◦ C, Tw = 40◦ C
69