FMIA F. Moukalled L. Mangani M. Darwish An Advanced Introduction with OpenFOAM and Matlab This textbook explores both the theoretical oundation o the Finite Volume Method (FVM) and its applications in omputational Fluid Dynamics (FD). Readers will discover a thorough explanation o the FVM numerics and algorithms used in the simulation o incompressible and compressible luid lows, along with a detailed examination o the components needed or the development o a collocated unstructured pressure-based FD solver. Two particular FD codes are explored. The irst is ufvm, a three-dimensional unstructured pressure-based inite volume academic FD code, implemented within Matlab. The second is OpenFOAM, an open source ramework used in the development o a range o FD programs or the simulation o industrial scale low problems. Moukalled Mangani Darwish Fluid Mechanics and Its Applications 113 Series Editor: A. Thess The Finite Volume Method in omputational Fluid Dynamics With over 220 igures, numerous examples and more than one hundred exercises on FVM numerics, programming, and applications, this textbook is suitable or use in an introductory course on the FVM, in an advanced course on FD algorithms, and as a reerence or FD programmers and researchers. Fluid Mechanics and Its Applications F. Moukalled L. Mangani M. Darwish The Finite Volume Method in omputational Fluid Dynamics The Finite Volume Method in omputational Fluid Dynamics An Advanced Introduction with OpenFOAM and Matlab Engineering ISBN 978-3-319-16873-9 9 783319 168739 omputing the Gradient hapter 09
Gradient in artesian Grids
omputing the Gradient ( δ x) w ( δ x) e φ x e = φ E φ x E x NW N NE = φ E φ δ x e ( δ y) n S n W S w S e E ( Δy) φ x = φ e φ w x e x w = φ E + φ 2 Δx φ + φ W 2 y ( δ y) s SW S ( Δx) S s SE = φ E φ W 2Δx φ x φ y = φ E φ W 2Δx = φ N φ S 2Δy x
Gauss Gradient ( δ x) w ( δ x) e φ dω =! φ ds Ω Ω ( δ y) n NW N S n NE φ Ω =! Ω φ = 1 Ω φ ds φ dω = 1 Ω Ω! Ω φ ds y ( δ y) s W SW S w S ( Δx) S s S e E SE ( Δy) φ = 1 Ω ~ φ S x
omputing the Gradient ( δ x) w ( δ x) e φ = 1 Ω ~ φ S ( δ y) n NW N S n NE 1. ompute ace values over all aces φ = φ N λ + φ 2. Loop over aces and assemble the discrete integral ( 1 λ ) y ( δ y) s W SW S w S ( Δx) S s S e E SE ( Δy) φ S 3. Divide the complete integrals at the center o the cells by the volume x
Gradient in Unstructured Grids
Unstructured Grids y φ dω =! φ ds Ω Ω F 5 F 6 φ Ω = Ω φ = 1 Ω φ dω φ dω = 1 Ω Ω! Ω φ ds S 1 F 1 n 1 1 n 2 1 n 6 6 5 3 2 n3 4 n 4 n 5 F 4 φ = 1 Ω ~ φ S F 2 F 3 x
Gradients at ell Faces F φ = φ N λ + φ ( 1 λ ) φ e F stencil F φ = φ ( φ e dc )e dc + φ φ D d D e dc φ e F stencil
Interpolated Gradient ( φ) F ( φ) ( φ) ( ( φ) e )e F F φ φ F e F e F ( φ) d F ( φ) e F n S d F F ( φ) F ( φ) ( φ) F φ e F stencil
Improved Gauss Gradient
Non-onjunctionality y Non-onjunctional ontrol Volume Dierence between and results in a decrease o the order o accuracy r F F r r S r e z r r r r F S F x y x y onjunctional ontrol Volume r F F r S e z r r F S F r r y x x
Nodal oints F 1 n 1 F 3 F 2 φ V = nv(v ) n=1 nv(v ) n=1 φ n r V r n 1 r V r n n 2 F 4 φ = 1 Ω nb =1 φ S φ = 1 nb φ + φ V 1 V 2 Ω 2 =1 S
Midpoint Rule S S F e F e φ = 1 Ω " φ ' φ = φ ' + ( φ) r r ' ' ( ) φ 1 Ω " φ φ = φ ' + correction = α φ + φ φ = φ ' + correction ( ) = φ ' + ( φ) ' r r ' { ( ) ( r r )} + ( 1 α ) φ N + ( φ) N r r N ( ) r r ( )( φ) N r r N = φ ' + α φ ( ) + 1 α { ( )} ( )
Other Interpolations
Least Square Gradient
Least Square Error φ F φ = ( φ) ( r F r ) distance 1 neighbours distance 2 neighbours 2 ( ) ( r Fk r ) ( φ Fk φ ) k =1..NB(){ } G = φ φ = x k =1..NB() φ + y Δφ k 2 Δφ k = φ Fk φ = ( r Fk r ) i = ( r Fk r ) j G φ x G φ y = 0 = 0
Least Square Gradient φ φ φ 2 x + y + Δz k z Δφ k = 0 φ φ φ 2 x + y + Δz k z Δφ k = 0 φ φ φ 2 Δz k x + y + Δz k z Δφ k = 0 Δz k Δz k Δz k Δz k Δz k Δz k ( φ ) x ( φ ) y ( φ ) z = Δφ k Δφ k Δz k Δφ k
Least Square Gradient φ x and φ x y = = Δφ k Δφ k Δφ k Δφ k w F = 1 r F r 2
Distance 2 Neighbours
Gradient Interpolation
Exercises
1 1 12 13 11 1 2 3 5 1 10 1/3 6 7 4 8 9 0 0.5 1
2 1 2 1 4 3 (0,0)