You are on page 1of 12

1/5/2014

5-Jan-14

Computational Fluid Dynamics

Review of FDM

j+1
ui,j
j

Based on Taylors series:


ui 1, j ui , j

O(x)
x i , j
x
ui , j ui 1, j
u

O(x)
x i , j
x
ui 1, j ui 1, j
u

O(x 2 )
x i , j
2x

j -1

i -1

i+1

- Forward difference
- Backward difference
- Central difference

ui 1, j 2ui , j ui 1, j
2u
- Central difference (2nd

O(x 2 )
2
2
order)
x i , j
x

Above approximations can be substituted for


differentials in the PDE.

5-Jan-14

Computational Fluid Dynamics

16

Scalar fields
A scalar field is a function in which the scalar property
(e.g. Temperature) can be expressed in terms of x
and y.
For example the following are scalar fields

T ( x, y ) x 2 y 2

U ( x, y) xe

x2 y 2

0.5

-0.5
1

0
-1 -2

1/5/2014

5-Jan-14

Computational Fluid Dynamics

17

Vector fields
A vector field is a vector quantity which is a function of
position. An example is the velocity of a fluid.
Consider the following two vectors over the following
domains.
5

-5
-5

-5
-5

v = [x,y]

v = [-y,x]

Computational Fluid Dynamics


5-Jan-14

18

Divergence of a vector field


The divergence of a vector field v is defined by:

v1 v2
Div(v) .v
,
.v

x
y
x y
Example:
Consider flow of water in a pipe.
(2)
(1)
If the velocity is the same at (1) and (2) then divergence is
zero.
In physical terms the divergence measures the extent to
which a vector field behaves like a source or a sink.

1/5/2014

5-Jan-14

Computational Fluid Dynamics

19

Divergence of vector field


Exercise
what is the divergence of:
v x, y
v [ y, x]

Solution:
v x, y .v

( y ) ( x) 0 0 0
x
y

.v

(3 x 2 3 y 2 ) (6 xy ) 6 x 6 x 0
x
y

Computational Fluid Dynamics


5-Jan-14

( x) ( y ) 1 1 2
x
y

v [ y, x] .v
v 3 x 2 3 y 2 ,6 xy

v 3 x 2 3 y 2 ,6 xy

20

Gradient of a scalar field


The gradient of a scalar field is a vector field
defined by:
T T
Grad(T ) T
,

x y

The result is a vector field which points in the


direction of maximum change of T for every
point it is calculated.

1/5/2014

5-Jan-14

Computational Fluid Dynamics

21

Gradient of a scalar field


Example
T ( x, y ) x 2 y 2

T [2 x,2 y ]

T T
Grad(T ) T
,

x
y

11

0.50.5

00

-0.5
-0.5

-1-1
-1.5-1

-1

-0.5 -0.5

00

0.50.5

5-Jan-14

Computational Fluid Dynamics

1 1.5

22

Fluid flow
Fluid flows (air, water, etc) that are incompressible,
non-viscous, and do not rotate to form vortices can be
represented by the Laplace Equation, where:

0
2

or

2
2

0
x 2
y 2

Here (x,y) defines a scalar field known as the


velocity potential. This is related to flow velocity v by:

v
,

x

Therefore we could solve either for v, the velocity


components, or for , the velocity potential.

1/5/2014

5-Jan-14

Computational Fluid Dynamics

23

Example
Consider the following function for velocity potential

( x, y ) x3 3xy 2
Derivatives are:

6 xy
y

3x 2 3 y 2
x

2
6x
x 2

2
6 x
y 2

Therefore velocity potential satisfies Laplace


Equation
2
2

0
x 2 y 2

5-Jan-14

Computational Fluid Dynamics

Example

24

( x, y ) x3 3xy 2

Velocity 3x 2 3 y 2 ,6 xy

1.5
1
0.5
0
-0.5
-1
-1.5
-1.5

-1

-0.5

0.5

1.5

1/5/2014

5-Jan-14

Computational Fluid Dynamics

26

Divergence theorem
A

Consider an area of fluid A


enclosed by the surface S

u u
v u ,
x y

Consider a velocity field

The divergence theorem states

.v dA v. dS
But

.u 2u so

2u 2u
A x 2 y 2 dA

x n

( x)

u
n( y ) dS
y

5-Jan-14

Computational Fluid Dynamics

27

Divergence theorem
2u 2u
A x 2 y 2 dA

x n

( x)

u
n( y ) dS
y

So the divergence theorem relates what is


happening in the interior of a domain to what
is happening on the boundary
A
S

1/5/2014

5-Jan-14

Computational Fluid Dynamics

28

The Finite Volume Method (FVM)


Based on small control volumes, each
enclosing a grid node
By approximating the flow on the surface of
each control volume we can calculate a
solution for the dependent variable at the grid
node
Use the divergence theorem to relate flow on
the surface of the control volume to the
interior

5-Jan-14

Computational Fluid Dynamics

29

Grid generation
First generate the grid by placing nodes across a
domain and constructing control volumes around
them.
Example:
Consider following 1-dimensional domain between A
and B.
W

B
Control Volumes

Nodes

Control volume faces (boundaries) are placed


midway between adjacent nodes.

1/5/2014

5-Jan-14

Computational Fluid Dynamics

30

Grid generation
W

B
Control Volumes

Nodes

For boundary nodes it is common practice to ensure


that the boundary lies on a control volume face.
Compass notation is usually used. E.g. central control
volume is (P) and its east and west neighbours are
(E) and (W). The east & west faces of control volume
(P) are (e) & (w) respectively.

5-Jan-14

Computational Fluid Dynamics

31

Grid generation 2D
Similar to 1D, the boundaries are on the
control volume surfaces.

Control Volumes Control Volumes


Nodes placed at centre of control volumes
[dotted lines represent control volumes, solid lines represent node
adjacencies/data dependencies.]

1/5/2014

5-Jan-14

Computational Fluid Dynamics

FVM 1D

32

Consider the following one-dimensional Poisson equation.

2u
g 0
x 2

Assume that all control volumes have equal width h.


Integrate equation over a control volume of width x = h and
cross-sectional area A = 1.

x x dx gdx 0
A

Then, using the divergence theorem:

u
u


gh 0
x e x w

2u 2u
A x 2 y 2 dA
u

x n

( x)

u
n( y ) dS
y

5-Jan-14

Computational Fluid Dynamics

FVM 1D

33

Discretization in 1D
2u
g 0
x 2

u
u


gh 0

w
e

The dependent variable, u, is approximated


at the nodal points (P) by the discretised
variable U.
The gradient of u at the East/West faces must
be approximated.

10

1/5/2014

5-Jan-14

Computational Fluid Dynamics

34

FVM 1D: Discretization in 1D


U is assumed to be linear between the nodes.
Consider the face at (e) and approximate derivative
here using central difference.
P

0.5h

u
U U P

h
x e

So the derivatives at faces (e) and (w) can be


represented by:
u
U U P

h
x e

U UW
u

P
h
x w

5-Jan-14

Computational Fluid Dynamics

35

FVM 1D: Discretized equations


Combining the previous terms..
2u
g 0
x 2

u
u


gh 0

w
e

U U P U P UW
E
gh 0

h
h

Alternately APU P AEU E AW U W S


Where

AE AW 1 h ,

AP AE AW , S gh

Here UP, is the dependent variable at P and UE, UW are the East
and West neighbours. AP, AE & AW are the respective coefficients.
We write it in this standard form because it applies even when the
control volumes do not have equal width.

11

1/5/2014

5-Jan-14

Computational Fluid Dynamics

38

Boundary condition
If the boundary condition is Dirichlet then we have U given at the
boundary. Let this be UB.

UB
A

The value of u is given at the boundary face (w). Therefore as we


wish to obtain the gradient at this face we can use the forward or
backward difference formula. Therefore:

APU P AEU E S

u
u

gh 0

w
e

AE

U P U B

0.5h

U E U P

1
,
h

S gh

AP AE
2U B
h

5-Jan-14

Computational Fluid Dynamics

Example

2
h

39
1

U(0)

x/2

U(0.02)

Consider the following 1D elliptic equation:


2u
1,000,000 0
x 2
over the domain 0 < x < 0.02, with cross sectional area of unity
and boundary conditions u(0) = 100 and u(0.02) = 200.
0.5

Using the finite volume method show that the discretised


equations for the variable, UP, at an internal node can be
written in terms of its east and west neighbours, UE and
UW respectively, such that:
APUP = AEUE + AWUW + S
where AP, AE and AW are the coefficients and S is a source term.

Using the above mesh (x = 0.004), calculate U3 if


U2 = 218 and U4 = 258.

13

1/5/2014

5-Jan-14

Computational Fluid Dynamics

Solution

40

Integrate the equation over the control


volume
u u
u
x x dx Qdx x e x w Qh 0
Approximate the derivatives using central
differences u U E U P
U UW
u

P
x e

To give

x w

U U P U P UW
E
Qh 0

h
h

APU P AEU E AW U W S

Rearranging

AE AW

1
,
h

AP AE AW , S Qh

5-Jan-14

Computational Fluid Dynamics

Solution

41

Solving at nodes:

Taking h = 0.004, Q = 2,000,000, U2 = 218,


U4 = 258 and
1
U3

(258 218 32) 254

The full solution is U1 = 150, U2 = 218, U3 =


254, U4 = 258, U5 = 230.

14

You might also like