Finite Volume Method An Introduction Praveen. C CTFD Division National Aerospace Laboratories Bangalore 560 037 email: praveen@cfdlab.net April 7, 2006 Praveen. C (CTFD, NAL) FVM CMMACS 1 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 2 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 3 / 65
Divergence theorem In Cartesian coordinates, q = (u, v, w) q = u x + v y + w z Divergence theorem dv n V q dv = V V q ˆn ds Praveen. C (CTFD, NAL) FVM CMMACS 4 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 5 / 65
Conservation laws Basic laws of physics are conservation laws: mass, momentum, energy, charge Control volume n Streamlines Rate of change of φ in V = -(net flux across V ) φ dv = F ˆn ds t V V Praveen. C (CTFD, NAL) FVM CMMACS 6 / 65
Conservation laws If F is differentiable, use divergence theorem φ dv = t F dv or V [ ] φ t + F V dv = 0, V φ t + F = 0 In Cartesian coordinates, F = (f, g, h) φ t + f x + g y + h z = 0 for every control volume V Praveen. C (CTFD, NAL) FVM CMMACS 7 / 65
Differential and integral form Differential form φ t + F = 0 (conserved quantity) + divergence(flux) = 0 t Integral form φ dv = F ˆn ds t V V Praveen. C (CTFD, NAL) FVM CMMACS 8 / 65
Mass conservation equation φ = ρ, F = ρ q F ˆn ds = amount of mass flowing across ds per unit time ρ dv + ρ q ˆn ds = 0 t V V Using divergence theorem ρ dv + t or V V V [ ] ρ t + (ρ q) (ρ q) ds = 0 dv = 0 Praveen. C (CTFD, NAL) FVM CMMACS 9 / 65
Mass conservation equation Differential form ρ t + (ρ q) = 0 In Cartesian coordinates, q = (u, v, w) ρ t + x (ρu) + y (ρv) + z (ρw) = 0 Non-conservative form ρ t + u ρ x + v ρ y + w ρ ( u z + ρ x + v y + w ) = 0 z or in vector notation ρ t + q ρ + ρ q = 0 Praveen. C (CTFD, NAL) FVM CMMACS 10 / 65
Navier-Stokes equations Mass: Momentum: Energy: ρ t + (ρ q) = 0 t (ρ q) + (ρ q q) + p E t + (E + p) q = τ = ( q τ) + Q Praveen. C (CTFD, NAL) FVM CMMACS 11 / 65
Convection and diffusion Mass: Momentum: Energy: ρ t + (ρ q) = 0 t (ρ q) + (ρ q q) + p E t + (E + p) q = τ = ( q τ) + Q Praveen. C (CTFD, NAL) FVM CMMACS 12 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 13 / 65
Convection-diffusion equation Convection-diffusion equation u t + a u x = µ 2 u x 2 a,µ are constants, µ > 0 Conservation law form u t + f x f f c f d = 0 = f c + f d = au = µ u x Praveen. C (CTFD, NAL) FVM CMMACS 14 / 65
Convection equation Scalar convection equation u t + a u x = 0 Exact solution u(x, t + t) = u(x a t, t) Wave-like solution: convected at speed a Wave moves in a particular direction Solution can be discontinuous Hyperbolic equation Praveen. C (CTFD, NAL) FVM CMMACS 15 / 65
Scalar convection equation a > 0 t Praveen. C (CTFD, NAL) FVM CMMACS 16 / 65
Scalar convection equation a > 0 a t t t+ t Praveen. C (CTFD, NAL) FVM CMMACS 17 / 65
Convection equation Scalar convection equation u t + a u x = 0 Exact solution u(x, t + t) = u(x a t, t) Wave-like solution: convected at speed a Wave moves in a particular direction Solution can be discontinuous Hyperbolic equation Praveen. C (CTFD, NAL) FVM CMMACS 18 / 65
Diffusion equation Scalar diffusion equation u t = µ 2 u x 2 Solution u(x, t) e µk 2t f(x; k) Solution is smooth and decays with time Elliptic equation Praveen. C (CTFD, NAL) FVM CMMACS 19 / 65
Diffusion equation: Initial condition t Praveen. C (CTFD, NAL) FVM CMMACS 20 / 65
Diffusion equation t t+ t Praveen. C (CTFD, NAL) FVM CMMACS 21 / 65
Diffusion equation Scalar diffusion equation u t = µ 2 u x 2 Solution u(x, t) e µk 2t f(x; k) Solution is smooth and decays with time Elliptic equation Praveen. C (CTFD, NAL) FVM CMMACS 22 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 23 / 65
FVM in 1-D: Conservation law 1-D conservation law Initial condition u t + f(u) = 0, a < x < b, t > 0 x u(x, 0) = g(x) Boundary conditions at x = a and/or x = b Praveen. C (CTFD, NAL) FVM CMMACS 24 / 65
FVM in 1-D: Grid Divide computational domain into N cells a = x 1/2, x 1+1/2, x 2+1/2,..., x N 1/2, x N+1/2 = b h i i=1 i i=n x=a i 1/2 i+1/2 x=b Cell number i Cell size (width) C i = [x i 1/2, x i+1/2 ] h i = x i+1/2 x i 1/2 Praveen. C (CTFD, NAL) FVM CMMACS 25 / 65
FVM in 1-D Conservation law applied to cell C i xi+1/2 ( u t + f ) x x i 1/2 dx = 0 C i Cell-average value Integral form i 3/2 i 1/2 h i+1/2 i+3/2 i u i (t) = 1 xi+1/2 u(x, t) dx h i x i 1/2 h i du i dt + f(x i+1/2, t) f(x i 1/2, t) = 0 Praveen. C (CTFD, NAL) FVM CMMACS 26 / 65
FVM in 1-D i=1 i 1 i i+1 i=n x=a i 1/2 i+1/2 x=b Cell-average value is dicontinuous at the interface What is the flux? Numerical flux function f(x i+1/2, t) F i+1/2 = F(u i, u i+1 ) Praveen. C (CTFD, NAL) FVM CMMACS 27 / 65
FVM in 1-D Finite volume update equation (ODE) h i du i dt + F i+1/2 F i 1/2 = 0, i = 1,..., N Telescopic collapse of fluxes N ( ) du i h i + F dt i+1/2 F i 1/2 = 0 i=1 d dt N h i u i + F N+1/2 F 1/2 = 0 i=1 Rate of change of total u = -(Net flux across the domain) h i i=1 i i=n x=a i 1/2 i+1/2 x=b Praveen. C (CTFD, NAL) FVM CMMACS 28 / 65
Time integration At time t = 0 set the initial condition u o i := u i (0) = 1 xi+1/2 g(x) dx h i x i 1/2 Choose a time step t (stability and accuracy) or M Break time (0, T) into M intervals t = T M, tn = n t, n = 0, 1, 2,...,M For n = 0, 1, 2,...,M, compute u n i = u i (t n ) u(x i, t n ) u n+1 i = u n i t h i (F n i+1/2 F n i 1/2 ) Praveen. C (CTFD, NAL) FVM CMMACS 29 / 65
Numerical Flux Function Take average of the left and right cells U i+1 U i Central difference scheme du i dt i+1/2 F i+1/2 = 1 2 [f(u i) + f(u i+1 )] + f i+1 f i 1 h i = 0 Suitable for elliptic equations (diffusion phenomena) Unstable for hyperbolic equations (convection phenomena) Praveen. C (CTFD, NAL) FVM CMMACS 30 / 65
Convection equation: Centered flux Convection equation, a = constant u t + a u x = 0, Centered flux, F i+1/2 = (au i + au i+1 )/2 f(u) = au du i dt + a u i+1 u i 1 h i = 0 U i+1 U i i+1/2 Praveen. C (CTFD, NAL) FVM CMMACS 31 / 65
Convection equation: Upwind flux Upwind flux U i+1 U i or F i+1/2 = F i+1/2 = a + a 2 i+1/2 { au i, if a > 0 au i+1, if a < 0 u i + a a u i+1 2 Praveen. C (CTFD, NAL) FVM CMMACS 32 / 65
Convection equation: Upwind flux Upwind scheme or du i dt du i dt du i dt + a u i u i 1 h i = 0, if a > 0 + a u i+1 u i h i = 0, if a < 0 + a + a u i u i 1 2 h i + a a u i+1 u i = 0 2 h i Praveen. C (CTFD, NAL) FVM CMMACS 33 / 65
Diffusion equation Diffusion equation u t + f x = 0, f = µ u x No directional dependence; use centered formula On uniform grid F i+1/2 = µ u i+1 u i x i+1 x i du i dt = µ u i+1 2u i + u i 1 h 2 Praveen. C (CTFD, NAL) FVM CMMACS 34 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 35 / 65
Choice of numerical parameters What scheme to use? What should be the grid size h? What should be the time step t? Praveen. C (CTFD, NAL) FVM CMMACS 36 / 65
Stability: Convection equation Take a > 0 CFL number Centered flux Upwind flux Solution at t = 1 λ = a t h u n+1 i = u n i λ 2 un i+1 + λ 2 un i 1 u n+1 i = (1 λ)u n i + λu n i 1 Praveen. C (CTFD, NAL) FVM CMMACS 37 / 65
Convection equation: Initial condition 1 Initial condition 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 Praveen. C (CTFD, NAL) FVM CMMACS 38 / 65
Convection equation: Centered scheme, λ = 0.8 8e+10 6e+10 Exact solution At t=1 4e+10 2e+10 0-2e+10-4e+10-6e+10-8e+10 0 0.2 0.4 0.6 0.8 1 Praveen. C (CTFD, NAL) FVM CMMACS 39 / 65
Convection equation: Upwind scheme, λ = 0.8 1 Exact solution At t=1 0.8 0.6 0.4 0.2 0 0 0.2 0.4 0.6 0.8 1 Praveen. C (CTFD, NAL) FVM CMMACS 40 / 65
Convection equation: Upwind scheme, λ = 1.1 40000 30000 Exact solution At t=1 20000 10000 0-10000 -20000-30000 -40000 0 0.2 0.4 0.6 0.8 1 Praveen. C (CTFD, NAL) FVM CMMACS 41 / 65
Stability: Convection equation Centered flux: Unstable Upwind flux: conditionally stable λ 1 or t h a Praveen. C (CTFD, NAL) FVM CMMACS 42 / 65
Stability: Diffusion equation Central scheme Stability parameter Update equation u n+1 i u n i t = µ un i+1 2un i + u n i 1 h 2 ν = µ t h 2 u n+1 i = νu n i+1 + (1 2ν)un i + νu n i 1 Stability condition ν 1 2 or t h2 2µ Praveen. C (CTFD, NAL) FVM CMMACS 43 / 65
Stability: Convection-diffusion equation Convection-diffusion equation u t + f x = 0, f = au µ u x Upwind scheme for convective term; central scheme for diffusive term F i+1/2 = a + a 2 u i + a a u i+1 µ u i+1 u i 2 x i+1 x i Update equation u n+1 i = + + ( a + t + µ t ) h h ( 2 1 a t µ t h h ( 2 a t h + µ t h 2 u n i 1 ) u n i ) u n i+1 Praveen. C (CTFD, NAL) FVM CMMACS 44 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 45 / 65
Non-linear conservation law Inviscid Burgers equation Finite difference scheme u t + u u x = 0 du i dt + u i + u i u i u i 1 2 h + u i u i u i+1 u i 2 h = 0 Gives wrong results Not conservative; cannot be put in FV form h du i dt + F i+1/2 F i 1/2 = 0 Praveen. C (CTFD, NAL) FVM CMMACS 46 / 65
Non-linear conservation law Conservation law u t + ( ) u 2 = 0 or x 2 Upwind finite volume scheme u t + f x = 0, u2 f(u) = 2 with h du i dt + F i+1/2 F i 1/2 = 0 { 1 F i+1/2 = 2 u2 i if u i+1/2 0 1 2 u2 i+1 if u i+1/2 < 0 Approximate interface value, for example u i+1/2 = 1 2 (u i + u i+1 ) Praveen. C (CTFD, NAL) FVM CMMACS 47 / 65
Transonic flow over NACA0012 5 Praveen. C (CTFD, NAL) FVM CMMACS 48 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 49 / 65
Computational domain (Josy) Praveen. C (CTFD, NAL) FVM CMMACS 50 / 65
Grids and finite volumes Praveen. C (CTFD, NAL) FVM CMMACS 51 / 65
Structured grid Praveen. C (CTFD, NAL) FVM CMMACS 52 / 65
Unstructured grid Praveen. C (CTFD, NAL) FVM CMMACS 53 / 65
Unstructured hybrid grid Praveen. C (CTFD, NAL) FVM CMMACS 54 / 65
Unstructured hybrid grid Praveen. C (CTFD, NAL) FVM CMMACS 55 / 65
Cartesian grid Saras (Josy) Praveen. C (CTFD, NAL) FVM CMMACS 56 / 65
Block-structured grid Fighter aircraft (Nair) Praveen. C (CTFD, NAL) FVM CMMACS 57 / 65
Cell-centered and vertex-centered Praveen. C (CTFD, NAL) FVM CMMACS 58 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 59 / 65
FVM in 2-D Conservation law Integral form A i du i dt u t + f x + g y = 0 + (fn x + gn y ) ds = 0 C i C i C i Praveen. C (CTFD, NAL) FVM CMMACS 60 / 65
FVM in 2-D Approximate flux across the cell face nij C j C i F ij S ij (fn x + gn y ) ds Finite volume approximation A i du i dt + j N(i) F ij S ij = 0 Praveen. C (CTFD, NAL) FVM CMMACS 61 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 62 / 65
Summary Integral form of conservation law Satisfies conservation of mass, momentum, energy, etc. Can capture discontinuities like shocks Can be applied on any type of grid Useful for complex geometry Praveen. C (CTFD, NAL) FVM CMMACS 63 / 65
Outline 1 Divergence theorem 2 Conservation laws 3 Convection-diffusion equation 4 FVM in 1-D 5 Stability of numerical scheme 6 Non-linear conservation law 7 Grids and finite volumes 8 FVM in 2-D 9 Summary 10 Further reading Praveen. C (CTFD, NAL) FVM CMMACS 64 / 65
For further reading I Blazek J., Computational Fluid Dynamics: Principles and Applications, Elsevier, 2004. Hirsch Ch., Numerical Computation of Internal and External Flows, Vol. 1 and 2, Wiley. LeVeque R. J., Finite Volume Methods for Hyperbolic Equations, Cambridge University Press, 2002. Wesseling P., Principles of Computational Fluid Dynamics, Springer, 2001. Ferziger J. H. and Peric M., Computational methods for fluid dynamics, 3 rd edition, Springer, 2003. http://www.cfd-online.com/wiki Praveen. C (CTFD, NAL) FVM CMMACS 65 / 65